@@ -39,6 +39,8 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSMa
39
39
const assignPublicIP = core.getInput('run-task-assign-public-IP', { required: false }) || 'DISABLED';
40
40
const tags = JSON.parse(core.getInput('run-task-tags', { required: false }) || '[]');
41
41
const capacityProviderStrategy = JSON.parse(core.getInput('run-task-capacity-provider-strategy', { required: false }) || '[]');
42
+ const runTaskManagedEBSVolumeName = core.getInput('run-task-managed-ebs-volume-name', { required: false }) || '';
43
+ const runTaskManagedEBSVolume = core.getInput('run-task-managed-ebs-volume', { required: false }) || '{}';
42
44
43
45
let awsvpcConfiguration = {}
44
46
@@ -53,6 +55,20 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSMa
53
55
if(assignPublicIP != "" && (subnetIds != "" || securityGroupIds != "")){
54
56
awsvpcConfiguration["assignPublicIp"] = assignPublicIP
55
57
}
58
+ let volumeConfigurations = [];
59
+ let taskManagedEBSVolumeObject;
60
+
61
+ if (runTaskManagedEBSVolumeName != '') {
62
+ if (runTaskManagedEBSVolume != '{}') {
63
+ taskManagedEBSVolumeObject = convertToManagedEbsVolumeObject(runTaskManagedEBSVolume);
64
+ volumeConfigurations = [{
65
+ name: runTaskManagedEBSVolumeName,
66
+ managedEBSVolume: taskManagedEBSVolumeObject
67
+ }];
68
+ } else {
69
+ 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`);
70
+ }
71
+ }
56
72
57
73
const runTaskResponse = await ecs.runTask({
58
74
startedBy: startedBy,
@@ -65,7 +81,8 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSMa
65
81
launchType: capacityProviderStrategy.length === 0 ? launchType : null,
66
82
networkConfiguration: Object.keys(awsvpcConfiguration).length === 0 ? null : { awsvpcConfiguration: awsvpcConfiguration },
67
83
enableECSManagedTags: enableECSManagedTags,
68
- tags: tags
84
+ tags: tags,
85
+ volumeConfigurations: volumeConfigurations
69
86
});
70
87
71
88
core.debug(`Run task response ${JSON.stringify(runTaskResponse)}`)
@@ -92,6 +109,47 @@ async function runTask(ecs, clusterName, taskDefArn, waitForMinutes, enableECSMa
92
109
}
93
110
}
94
111
112
+ function convertToManagedEbsVolumeObject(managedEbsVolume) {
113
+ managedEbsVolumeObject = {}
114
+ const ebsVolumeObject = JSON.parse(managedEbsVolume);
115
+ if ('roleArn' in ebsVolumeObject){ // required property
116
+ managedEbsVolumeObject.roleArn = ebsVolumeObject.roleArn;
117
+ core.debug(`Found RoleArn ${ebsVolumeObject['roleArn']}`);
118
+ } else {
119
+ throw new Error('managed-ebs-volume must provide "role-arn" to associate with the EBS volume')
120
+ }
121
+
122
+ if ('encrypted' in ebsVolumeObject) {
123
+ managedEbsVolumeObject.encrypted = ebsVolumeObject.encrypted;
124
+ }
125
+ if ('filesystemType' in ebsVolumeObject) {
126
+ managedEbsVolumeObject.filesystemType = ebsVolumeObject.filesystemType;
127
+ }
128
+ if ('iops' in ebsVolumeObject) {
129
+ managedEbsVolumeObject.iops = ebsVolumeObject.iops;
130
+ }
131
+ if ('kmsKeyId' in ebsVolumeObject) {
132
+ managedEbsVolumeObject.kmsKeyId = ebsVolumeObject.kmsKeyId;
133
+ }
134
+ if ('sizeInGiB' in ebsVolumeObject) {
135
+ managedEbsVolumeObject.sizeInGiB = ebsVolumeObject.sizeInGiB;
136
+ }
137
+ if ('snapshotId' in ebsVolumeObject) {
138
+ managedEbsVolumeObject.snapshotId = ebsVolumeObject.snapshotId;
139
+ }
140
+ if ('tagSpecifications' in ebsVolumeObject) {
141
+ managedEbsVolumeObject.tagSpecifications = ebsVolumeObject.tagSpecifications;
142
+ }
143
+ if (('throughput' in ebsVolumeObject) && (('volumeType' in ebsVolumeObject) && (ebsVolumeObject.volumeType == 'gp3'))){
144
+ managedEbsVolumeObject.throughput = ebsVolumeObject.throughput;
145
+ }
146
+ if ('volumeType' in ebsVolumeObject) {
147
+ managedEbsVolumeObject.volumeType = ebsVolumeObject.volumeType;
148
+ }
149
+ core.debug(`Created managedEbsVolumeObject: ${JSON.stringify(managedEbsVolumeObject)}`);
150
+ return managedEbsVolumeObject;
151
+ }
152
+
95
153
// Poll tasks until they enter a stopped state
96
154
async function waitForTasksStopped(ecs, clusterName, taskArns, waitForMinutes) {
97
155
if (waitForMinutes > MAX_WAIT_MINUTES) {
@@ -142,13 +200,32 @@ async function tasksExitCode(ecs, clusterName, taskArns) {
142
200
async function updateEcsService(ecs, clusterName, service, taskDefArn, waitForService, waitForMinutes, forceNewDeployment, desiredCount, enableECSManagedTags, propagateTags) {
143
201
core.debug('Updating the service');
144
202
203
+ const serviceManagedEBSVolumeName = core.getInput('service-managed-ebs-volume-name', { required: false }) || '';
204
+ const serviceManagedEBSVolume = core.getInput('service-managed-ebs-volume', { required: false }) || '{}';
205
+
206
+ let volumeConfigurations = [];
207
+ let serviceManagedEbsVolumeObject;
208
+
209
+ if (serviceManagedEBSVolumeName != '') {
210
+ if (serviceManagedEBSVolume != '{}') {
211
+ serviceManagedEbsVolumeObject = convertToManagedEbsVolumeObject(serviceManagedEBSVolume);
212
+ volumeConfigurations = [{
213
+ name: serviceManagedEBSVolumeName,
214
+ managedEBSVolume: serviceManagedEbsVolumeObject
215
+ }];
216
+ } else {
217
+ 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');
218
+ }
219
+ }
220
+
145
221
let params = {
146
222
cluster: clusterName,
147
223
service: service,
148
224
taskDefinition: taskDefArn,
149
225
forceNewDeployment: forceNewDeployment,
150
226
enableECSManagedTags: enableECSManagedTags,
151
- propagateTags: propagateTags
227
+ propagateTags: propagateTags,
228
+ volumeConfigurations: volumeConfigurations
152
229
};
153
230
154
231
// Add the desiredCount property only if it is defined and a number.
@@ -409,7 +486,11 @@ async function run() {
409
486
if (enableECSManagedTagsInput !== '') {
410
487
enableECSManagedTags = enableECSManagedTagsInput.toLowerCase() === 'true';
411
488
}
412
- let propagateTags = core.getInput('propagate-tags', { required: false }) || '';
489
+ const propagateTagsInput = core.getInput('propagate-tags', { required: false }) || '';
490
+ let propagateTags = null;
491
+ if (propagateTagsInput !== '') {
492
+ propagateTags = propagateTagsInput;
493
+ }
413
494
414
495
// Register the task definition
415
496
core.debug('Registering the task definition');
@@ -457,11 +538,6 @@ async function run() {
457
538
if (serviceResponse.status != 'ACTIVE') {
458
539
throw new Error(`Service is ${serviceResponse.status}`);
459
540
}
460
- // set propagateTags to the current value if no input provided
461
- if (describeResponse.services[0].propagateTags != null && propagateTags === '') {
462
- propagateTags = describeResponse.services[0].propagateTags;
463
- core.debug(`Current service 'propagateTags' value '${describeResponse.services[0].propagateTags}' will be set to service`);
464
- }
465
541
466
542
if (!serviceResponse.deploymentController || !serviceResponse.deploymentController.type || serviceResponse.deploymentController.type === 'ECS') {
467
543
// Service uses the 'ECS' deployment controller, so we can call UpdateService
0 commit comments