Skip to content

Commit 9d39db7

Browse files
authored
feat(codepipeline-actions): native Amazon EC2 deployment support (#33604)
### Issue # (if applicable) Closes #33584. ### Reason for this change AWS CodePipeline introduces a new action to deploy to Amazon Elastic Compute Cloud (EC2). https://aws.amazon.com/about-aws/whats-new/2025/02/aws-codepipeline-native-ec2-deployment-support/ ### Description of changes Added the `Ec2DeployAction` action class and corresponding helpers. - `Ec2InstanceType` - specify instance type: EC2 or SSM_MANAGED_NODE - `Ec2DeploySpecification` - choose deploy specification: inline or DeploySpec (not yet included) - `Ec2MaxInstances` - specify maxBatch and maxError configuration #### Usage ```ts new cpactions.Ec2DeployAction({ actionName: 'EC2', input: buildOutput, // specify instance type instanceType: cpactions.Ec2InstanceType.EC2, // REQUIRED // specify tag key and value, not ec2.IInstance instanceTagKey: 'Target', // REQUIRED instanceTagValue: 'DeployTarget', // deploy specifications deploySpecifications: cpactions.Ec2DeploySpecifications.inline({ targetDirectory: '/home/ec2-user/deploy', // REQUIRED preScript: 'hooks/pre-script', postScript: 'hooks/post-script', // REQUIRED }), // the action will detach and attach instances from/to target groups targetGroups: [myTargetGroup], // the number or percentage of instances that can deploy in parallel maxBatch: cpactions.Ec2MaxInstances.target(2), maxError: cpactions.Ec2MaxInstances.percent(50), }); ``` ### Describe any new or updated permissions being added `Ec2DeployAction` adds permissions based on CodePipeline documentation: https://docs.aws.amazon.com/codepipeline/latest/userguide/action-reference-EC2Deploy.html#action-reference-EC2Deploy-permissions-action For details of actions, resource, and condition keys, see the Service Authorization Reference: [EC2](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonec2.html), [ELBv2](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awselasticloadbalancingv2.html), [SSM](https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanager.html) ### Description of how you validated changes Unit tests and an integ test. The integ test also asserts pipeline execution. ### Checklist - [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md) ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 29e0ccf commit 9d39db7

File tree

39 files changed

+73926
-1
lines changed

39 files changed

+73926
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
deployed index
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
true

packages/@aws-cdk-testing/framework-integ/test/aws-codepipeline-actions/test/integ.pipeline-ec2-deploy-ssm-managed.js.snapshot/asset.44e9c4d7a5d3fd2d677e1a7e416b2b56f6b0104bd5eff9cac5557b4c65a9dc61/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-codepipeline-actions/test/integ.pipeline-ec2-deploy-ssm-managed.js.snapshot/asset.93e64a8bca22f133010f6b56b48971e7b52020dc565d94d95683e48ad4396ce0/index.html

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-codepipeline-actions/test/integ.pipeline-ec2-deploy-ssm-managed.js.snapshot/asset.93e64a8bca22f133010f6b56b48971e7b52020dc565d94d95683e48ad4396ce0/scripts/post-deploy.sh

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-codepipeline-actions/test/integ.pipeline-ec2-deploy-ssm-managed.js.snapshot/asset.93e64a8bca22f133010f6b56b48971e7b52020dc565d94d95683e48ad4396ce0/scripts/pre-deploy.sh

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)