diff --git a/action.yml b/action.yml index 4615689fb..150ac72a5 100644 --- a/action.yml +++ b/action.yml @@ -58,6 +58,9 @@ inputs: run-task-started-by: description: "A name to use for the startedBy tag when running a task outside of a service. Will default to 'GitHub-Actions'." required: false + run-task-assign-public-ip: + description: "A boolean indicating whether to assign a public IP to the task." + required: false wait-for-task-stopped: description: 'Whether to wait for the task to stop when running it outside of a service. Will default to not wait.' required: false diff --git a/dist/index.js b/dist/index.js index 3596c7d90..cf7889536 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36,6 +36,7 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) { const launchType = core.getInput('run-task-launch-type', { required: false }) || 'FARGATE'; const subnetIds = core.getInput('run-task-subnets', { required: false }) || ''; const securityGroupIds = core.getInput('run-task-security-groups', { required: false }) || ''; + const assignPublicIp = core.getInput('run-task-assign-public-ip', { required: false }) || ''; const containerOverrides = JSON.parse(core.getInput('run-task-container-overrides', { required: false }) || '[]'); let awsvpcConfiguration = {} @@ -47,6 +48,10 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) { awsvpcConfiguration["securityGroups"] = securityGroupIds.split(',') } + if (assignPublicIp != "") { + awsvpcConfiguration["assignPublicIp"] = assignPublicIp ? "ENABLED" : "DISABLED" + } + const runTaskResponse = await ecs.runTask({ startedBy: startedBy, cluster: clusterName, diff --git a/index.js b/index.js index 3bc791f7e..a7be523ec 100644 --- a/index.js +++ b/index.js @@ -30,6 +30,7 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) { const launchType = core.getInput('run-task-launch-type', { required: false }) || 'FARGATE'; const subnetIds = core.getInput('run-task-subnets', { required: false }) || ''; const securityGroupIds = core.getInput('run-task-security-groups', { required: false }) || ''; + const assignPublicIp = core.getInput('run-task-assign-public-ip', { required: false }) || ''; const containerOverrides = JSON.parse(core.getInput('run-task-container-overrides', { required: false }) || '[]'); let awsvpcConfiguration = {} @@ -41,6 +42,10 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes) { awsvpcConfiguration["securityGroups"] = securityGroupIds.split(',') } + if (assignPublicIp != "") { + awsvpcConfiguration["assignPublicIp"] = assignPublicIp ? "ENABLED" : "DISABLED" + } + const runTaskResponse = await ecs.runTask({ startedBy: startedBy, cluster: clusterName,