Commit 9d39db7
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- packages
- @aws-cdk-testing/framework-integ/test/aws-codepipeline-actions/test
- ec2-deploy-artifacts/inline
- scripts
- integ.pipeline-ec2-deploy-ssm-managed.js.snapshot
- asset.44e9c4d7a5d3fd2d677e1a7e416b2b56f6b0104bd5eff9cac5557b4c65a9dc61
- asset.93e64a8bca22f133010f6b56b48971e7b52020dc565d94d95683e48ad4396ce0
- scripts
- asset.97484721f29e34bf38d7a459804dd2d2a8dea6f8c27d7531e215bf4274fbc895.bundle
- asset.9a1fcb4a7ecba81ad70e9d3fb241f6794497da945dae5f25924e4dd002b65f2d
- integ.pipeline-ec2-deploy.js.snapshot
- asset.44e9c4d7a5d3fd2d677e1a7e416b2b56f6b0104bd5eff9cac5557b4c65a9dc61
- asset.93e64a8bca22f133010f6b56b48971e7b52020dc565d94d95683e48ad4396ce0
- scripts
- asset.97484721f29e34bf38d7a459804dd2d2a8dea6f8c27d7531e215bf4274fbc895.bundle
- asset.9a1fcb4a7ecba81ad70e9d3fb241f6794497da945dae5f25924e4dd002b65f2d
- aws-cdk-lib/aws-codepipeline-actions
- lib
- ec2
- test/ec2
39 files changed
+73926
-1
lines changedLines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Lines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments