-
Notifications
You must be signed in to change notification settings - Fork 260
feat: Add support for 'VolumeConfigurations' property on both UpdateService and RunTask API call #721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add support for 'VolumeConfigurations' property on both UpdateService and RunTask API call #721
Changes from all commits
47333c8
41cb704
cc490ca
18081f9
60308e8
88cc3e2
0f33b03
d83db92
cabe278
f0981f6
63285fe
0f3d04b
3b1c0ed
07f78f1
0ed20b3
62d2ebc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,8 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSMa | |
const assignPublicIP = core.getInput('run-task-assign-public-IP', { required: false }) || 'DISABLED'; | ||
const tags = JSON.parse(core.getInput('run-task-tags', { required: false }) || '[]'); | ||
const capacityProviderStrategy = JSON.parse(core.getInput('run-task-capacity-provider-strategy', { required: false }) || '[]'); | ||
const runTaskManagedEBSVolumeName = core.getInput('run-task-managed-ebs-volume-name', { required: false }) || ''; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have we thought about auto populating this property for customers from the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, That is a good point. I think it would be possible to auto-populate the volume name from task-definition if, the task-definition contains a volume with Backward-compatibility wise - it should be fine, because:
Pros of this auto-population I think would be:
Cons might be:
|
||
const runTaskManagedEBSVolume = core.getInput('run-task-managed-ebs-volume', { required: false }) || '{}'; | ||
|
||
let awsvpcConfiguration = {} | ||
|
||
|
@@ -47,6 +49,20 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSMa | |
if(assignPublicIP != "" && (subnetIds != "" || securityGroupIds != "")){ | ||
awsvpcConfiguration["assignPublicIp"] = assignPublicIP | ||
} | ||
let volumeConfigurations = []; | ||
let taskManagedEBSVolumeObject; | ||
|
||
if (runTaskManagedEBSVolumeName != '') { | ||
if (runTaskManagedEBSVolume != '{}') { | ||
taskManagedEBSVolumeObject = convertToManagedEbsVolumeObject(runTaskManagedEBSVolume); | ||
volumeConfigurations = [{ | ||
name: runTaskManagedEBSVolumeName, | ||
managedEBSVolume: taskManagedEBSVolumeObject | ||
}]; | ||
} else { | ||
core.warning(`run-task-managed-ebs-volume-name provided without run-task-managed-ebs-volume value. VolumeConfigurations property will not be included in the RunTask API call`); | ||
} | ||
} | ||
|
||
const runTaskResponse = await ecs.runTask({ | ||
startedBy: startedBy, | ||
|
@@ -59,7 +75,8 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSMa | |
launchType: capacityProviderStrategy.length === 0 ? launchType : null, | ||
networkConfiguration: Object.keys(awsvpcConfiguration).length === 0 ? null : { awsvpcConfiguration: awsvpcConfiguration }, | ||
enableECSManagedTags: enableECSManagedTags, | ||
tags: tags | ||
tags: tags, | ||
volumeConfigurations: volumeConfigurations | ||
}); | ||
|
||
core.debug(`Run task response ${JSON.stringify(runTaskResponse)}`) | ||
|
@@ -86,6 +103,47 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSMa | |
} | ||
} | ||
|
||
function convertToManagedEbsVolumeObject(managedEbsVolume) { | ||
managedEbsVolumeObject = {} | ||
const ebsVolumeObject = JSON.parse(managedEbsVolume); | ||
if ('roleArn' in ebsVolumeObject){ // required property | ||
managedEbsVolumeObject.roleArn = ebsVolumeObject.roleArn; | ||
core.debug(`Found RoleArn ${ebsVolumeObject['roleArn']}`); | ||
} else { | ||
throw new Error('managed-ebs-volume must provide "role-arn" to associate with the EBS volume') | ||
} | ||
|
||
if ('encrypted' in ebsVolumeObject) { | ||
managedEbsVolumeObject.encrypted = ebsVolumeObject.encrypted; | ||
} | ||
if ('filesystemType' in ebsVolumeObject) { | ||
managedEbsVolumeObject.filesystemType = ebsVolumeObject.filesystemType; | ||
} | ||
if ('iops' in ebsVolumeObject) { | ||
managedEbsVolumeObject.iops = ebsVolumeObject.iops; | ||
} | ||
if ('kmsKeyId' in ebsVolumeObject) { | ||
managedEbsVolumeObject.kmsKeyId = ebsVolumeObject.kmsKeyId; | ||
} | ||
if ('sizeInGiB' in ebsVolumeObject) { | ||
managedEbsVolumeObject.sizeInGiB = ebsVolumeObject.sizeInGiB; | ||
} | ||
if ('snapshotId' in ebsVolumeObject) { | ||
managedEbsVolumeObject.snapshotId = ebsVolumeObject.snapshotId; | ||
} | ||
if ('tagSpecifications' in ebsVolumeObject) { | ||
managedEbsVolumeObject.tagSpecifications = ebsVolumeObject.tagSpecifications; | ||
} | ||
if (('throughput' in ebsVolumeObject) && (('volumeType' in ebsVolumeObject) && (ebsVolumeObject.volumeType == 'gp3'))){ | ||
managedEbsVolumeObject.throughput = ebsVolumeObject.throughput; | ||
} | ||
if ('volumeType' in ebsVolumeObject) { | ||
managedEbsVolumeObject.volumeType = ebsVolumeObject.volumeType; | ||
} | ||
core.debug(`Created managedEbsVolumeObject: ${JSON.stringify(managedEbsVolumeObject)}`); | ||
return managedEbsVolumeObject; | ||
} | ||
|
||
// Poll tasks until they enter a stopped state | ||
async function waitForTasksStopped(ecs, clusterName, taskArns, waitForMinutes) { | ||
if (waitForMinutes > MAX_WAIT_MINUTES) { | ||
|
@@ -136,13 +194,32 @@ async function tasksExitCode(ecs, clusterName, taskArns) { | |
async function updateEcsService(ecs, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment, desiredCount, enableECSManagedTags, propagateTags) { | ||
core.debug('Updating the service'); | ||
|
||
const serviceManagedEBSVolumeName = core.getInput('service-managed-ebs-volume-name', { required: false }) || ''; | ||
const serviceManagedEBSVolume = core.getInput('service-managed-ebs-volume', { required: false }) || '{}'; | ||
|
||
let volumeConfigurations = []; | ||
let serviceManagedEbsVolumeObject; | ||
|
||
if (serviceManagedEBSVolumeName != '') { | ||
if (serviceManagedEBSVolume != '{}') { | ||
serviceManagedEbsVolumeObject = convertToManagedEbsVolumeObject(serviceManagedEBSVolume); | ||
volumeConfigurations = [{ | ||
name: serviceManagedEBSVolumeName, | ||
managedEBSVolume: serviceManagedEbsVolumeObject | ||
}]; | ||
} else { | ||
core.warning('service-managed-ebs-volume-name provided without service-managed-ebs-volume value. VolumeConfigurations property will not be included in the UpdateService API call'); | ||
} | ||
} | ||
|
||
let params = { | ||
cluster: clusterName, | ||
service: service, | ||
taskDefinition: taskDefArn, | ||
forceNewDeployment: forceNewDeployment, | ||
enableECSManagedTags: enableECSManagedTags, | ||
propagateTags: propagateTags | ||
propagateTags: propagateTags, | ||
volumeConfigurations: volumeConfigurations | ||
}; | ||
|
||
// Add the desiredCount property only if it is defined and a number. | ||
|
Uh oh!
There was an error while loading. Please reload this page.