Skip to content
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

Merged
merged 16 commits into from
Jan 30, 2025

Conversation

amazreech
Copy link
Contributor

*Issue #, if available: n/A

Description of changes:

This PR enhances the amazon-ecs-deploy-task-definition GitHub Action to support Amazon ECS Managed EBS Volumes for both RunTask and UpdateService operations. The changes include:

  1. Introduced new input parameters:
    • run-task-managed-ebs-volume-name
    • run-task-managed-ebs-volume
    • service-managed-ebs-volume-name
    • service-managed-ebs-volume
  2. Added support for VolumeConfiguration property during runTask api call if the run-task-managed-ebs-volume-name
    and run-task-managed-ebs-volume parameters have been set.
  3. Added support for VolumeConfiguration property during updateService api call if the service-managed-ebs-volume-name and service-managed-ebs-volume parameters have been set.

Usage:

To use VolumeConfigurations property in runTask and UpdateService update your task definition to support an ECS volume that is configured at launch, and update your workflow file to look like below:

For RunTask:

workflow.yaml
....
- uses: aws-actions/amazon-ecs-deploy-task-definition@v1
  with:
    task-definition: .aws/task-definition-run-task.json
          cluster: ${{ env.ECS_CLUSTER }}
          run-task: true
          run-task-launch-type: EC2
          run-task-managed-ebs-volume-name: "ebs1"
          run-task-managed-ebs-volume: '{"sizeInGiB": 30, "volumeType": "gp3", "encrypted": true, "roleArn":"<>"}'

For UpdateService:

workflow.yaml
...
- name: Deploy ECS task definition to ECS Service
        uses: aws-actions/amazon-ecs-deploy-task-definition@v1
        with:
          task-definition: .aws/task-definition.json
          service: ${{ env.ECS_SERVICE }}
          cluster: ${{ env.ECS_CLUSTER }}
          run-task-managed-ebs-volume-name: "ebs1"
          run-task-managed-ebs-volume: '{"sizeInGiB": 30, "volumeType": "gp3", "encrypted": true, "roleArn":"<>"}'

Task Definition Example:

{
    "volumes": [
        {
            "name": "ebs1",
            "configuredAtLaunch": true
        }
    ]
}

Testing:
Manually Tested below use cases:

  • Updating a Service to use a EBSVolumeConfiguration
  • Updating a Service using EBSVolumeConfiguration to modify the existing configuration
  • Updating a TaskDefinition and Service to no longer a EBSVolumeConfiguration
  • RunTask api call to run a task with EBSVolume configured

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@amazreech amazreech changed the title Add support for 'VolumeConfigurations` property on both UpdateService and RunTask API call feat: Add support for 'VolumeConfigurations` property on both UpdateService and RunTask API call Jan 29, 2025
@amazreech amazreech changed the title feat: Add support for 'VolumeConfigurations` property on both UpdateService and RunTask API call feat: Add support for 'VolumeConfigurations' property on both UpdateService and RunTask API call Jan 29, 2025
@@ -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 }) || '';
Copy link
Contributor

@kg-aws kg-aws Jan 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we thought about auto populating this property for customers from the task-definition.json file provided in the input? Also, would auto-populate break any existing customers or in other words would it be backwards compatible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 configuredAtLaunch set to true. We could parse the Volume property from a pre-existingTaskDefinitionContents variable.

Backward-compatibility wise - it should be fine, because:

  1. Task definition MUST have a volume with configuredAtLaunch: true - in-order to configure a volume property with ECS
  2. This volume MUST match the name used in VolumeConfigurations

Pros of this auto-population I think would be:

  • less configuration on user side
  • can't break the volume name matching (since it uses exact name from task definition)

Cons might be:

  • a bit of a magic/implicit behavior, but can be called-out in the README

dist/index.js Show resolved Hide resolved
…y will be ignored if service or task managed-ebs-volume-name property is not provided
Copy link
Contributor

@kg-aws kg-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Copy link
Contributor

@kg-aws kg-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@amazreech amazreech merged commit 0bad458 into aws-actions:master Jan 30, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants