-
Notifications
You must be signed in to change notification settings - Fork 4.3k
feat(codepipeline-actions): native Amazon EC2 deployment support #33604
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
Conversation
...ages/@aws-cdk-testing/framework-integ/test/aws-codepipeline-actions/test/assets/artifact.zip
Outdated
Show resolved
Hide resolved
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #33604 +/- ##
=======================================
Coverage 83.98% 83.98%
=======================================
Files 120 120
Lines 6976 6976
Branches 1178 1178
=======================================
Hits 5859 5859
Misses 1005 1005
Partials 112 112
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
| /** | ||
| * Max number of instances. | ||
| * | ||
| * Valid range: from 1 to number of your instances |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /** | ||
| * Max percentage of instances. | ||
| * | ||
| * Valid range: from 1 to 99 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've succeeded to deploy with maxBatch: '100%'. The note of the AWS console seems inaccurate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated max allowed percentage to 100%.
| TargetDirectory: this.props.targetDirectory, | ||
| MaxBatch: this.props.maxBatch?.value, | ||
| MaxError: this.props.maxError?.value, | ||
| TargetGroupNameList: this.props.targetGroups?.length ? this.props.targetGroups.map((tg) => tg.targetGroupName).join(',') : undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (!Token.isUnresolved(percentage) && !(percentage >= 1 && percentage <= 99 && Number.isInteger(percentage))) { | ||
| throw new UnscopedValidationError(`percentage must be a positive integer between 1 and 99. got ${percentage}`); | ||
| } | ||
| return { value: `${Tokenization.stringifyNumber(percentage)}%` }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/aws-cdk-lib/aws-codepipeline-actions/lib/ec2/deploy-action.ts
Outdated
Show resolved
Hide resolved
|
snapshot change is caused by #33742 |
|
AWS CodePipeline now supports Deploy Spec file |
kumvprat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments on the PR
...-cdk-testing/framework-integ/test/aws-codepipeline-actions/test/integ.pipeline-ec2-deploy.ts
Outdated
Show resolved
Hide resolved
packages/aws-cdk-lib/aws-codepipeline-actions/lib/ec2/deploy-action.ts
Outdated
Show resolved
Hide resolved
| 'ec2:DescribeInstances', | ||
| 'elasticloadbalancing:DescribeTargetGroupAttributes', | ||
| 'elasticloadbalancing:DescribeTargetGroups', | ||
| 'elasticloadbalancing:DescribeTargetHealth', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ssm:CancelCommand may need to be scoped down, similar to ssm:SendCommand, assuming it can cancel the post/pre-scripts running on the specific instance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmmm, looks like ssm:CancelCommand has been added as part of the deploy spec support...
I'll reflect it anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I misunderstood your comment.
These policy statements are described in Amazon EC2 action reference.
The ssm:CancelCommand has no related resource types and resources field must be [*].
See https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanager.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for investigating this
We could add this link : https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanager.html and for the related elasticloadbalancing to the PR description/README
Would be nice for users to know about IAM actions
packages/aws-cdk-lib/aws-codepipeline-actions/lib/ec2/deploy-action.ts
Outdated
Show resolved
Hide resolved
kumvprat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall the PR looks good, except for a few remaining changes.
Is there a specific reason for clubbing the deploy spec support in this PR ?
Releasing it as a follow-up PR would also work
| integ.assertions | ||
| .awsApiCall('codepipeline', 'GetPipelineExecution', { pipelineName: ssmPipeline.pipelineName, pipelineExecutionId: ssmPipelineExecutionId }) | ||
| .waitForAssertions({ interval: cdk.Duration.seconds(30) }) | ||
| .expect(ExpectedResult.objectLike({ pipelineExecution: { status: 'Succeeded' } })); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not add the same checks for SSM_MANAGED_NODES and EC2 one ?
Is there some difference between the usages of the two instance types ? If so maybe we need to update the README example to reflect this
These checks seem to be missing from SSM_MANAGED_NODE types :
waitPipelieneSuccess.next(
integ.assertions
.httpApiCall(http://${alb.loadBalancerDnsName}/LB/index.html)
.expect(ExpectedResult.objectLike({ status: 200 })),
);
instances.NoLB.forEach((instance) => waitPipelieneSuccess.next(
integ.assertions
.httpApiCall(http://${instance.instancePublicDnsName}/NoLB/index.html)
.expect(ExpectedResult.objectLike({ status: 200 })),
));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know, SSM_MANAGED_NODES are on-premise instances outside of AWS.
These instances cannot be created in integ test.
(please correct me if wrong.)
The EC2 deploy action will succeed if no instances match.
So I only verify whether the pipeline succeeds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that SSM_MANAGED_NODE matches EC2 instances.
I've made separate 2 integ tests with EC2 and SSM_MANAGED_NODE.
| 'ec2:DescribeInstances', | ||
| 'elasticloadbalancing:DescribeTargetGroupAttributes', | ||
| 'elasticloadbalancing:DescribeTargetGroups', | ||
| 'elasticloadbalancing:DescribeTargetHealth', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for investigating this
We could add this link : https://docs.aws.amazon.com/service-authorization/latest/reference/list_awssystemsmanager.html and for the related elasticloadbalancing to the PR description/README
Would be nice for users to know about IAM actions
DeploySpec support will introduce the "choice" which deployment style are used. I'll drop deploySpec support in this PR if needed. |
|
I could not succeed to deploy with deployspec.yml currently. |
|
@kumvprat I've pushed updates and marked as ready.
I've added refs in PR description and code comments. |
kumvprat
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
|
Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
|
Comments on closed issues and PRs are hard for our team to see. |




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
Ec2DeployActionaction class and corresponding helpers.Ec2InstanceType- specify instance type: EC2 or SSM_MANAGED_NODEEc2DeploySpecification- choose deploy specification: inline or DeploySpec (not yet included)Ec2MaxInstances- specify maxBatch and maxError configurationUsage
Describe any new or updated permissions being added
Ec2DeployActionadds 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, ELBv2, SSM
Description of how you validated changes
Unit tests and an integ test.
The integ test also asserts pipeline execution.
Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license