fix(ec2): prevent deduplication of init command args#30821
fix(ec2): prevent deduplication of init command args#30821mergify[bot] merged 13 commits intoaws:mainfrom
Conversation
aws-cdk-automation
left a comment
There was a problem hiding this comment.
The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.
A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.
✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.
scanlonp
left a comment
There was a problem hiding this comment.
Looking good with a couple small comments:
- Let's switch the logic flow. It will be easier to understand with the specific cases handled first.
- Do we have any current unit tests that test for de-duplication on non-command uses of the deep merge? If yes then we are all set. If not, we should probably put that case in to verify that this change stays scoped to the individual function we are targeting.
From what it seems like, this specific |
scanlonp
left a comment
There was a problem hiding this comment.
My comments are addressed. I am good with the PR. Going to wait for a second review for approval.
| const config = new ec2.InitConfig([ | ||
| ec2.InitSource.fromUrl('/tmp/foo', 'https://amazon.com/foo.zip'), | ||
| ec2.InitSource.fromUrl('/tmp/foo', 'https://amazon.com/foo.zip'), | ||
| ec2.InitSource.fromUrl('/tmp/foo', 'https://amazon.com/foo.zip'), |
There was a problem hiding this comment.
can you make this:
ec2.InitSource.fromUrl('/tmp/foo', 'https://amazon.com/foo.zip'),
ec2.InitSource.fromUrl('/tmp/foo', 'https://amazon.com/foo.zip'),
ec2.InitSource.fromUrl('/tmp/foo', 'https://amazon.com/bar.zip'),
ec2.InitSource.fromUrl('/tmp/foo', 'https://amazon.com/bar.zip'),
ec2.InitSource.fromUrl('/tmp/bar', 'https://amazon.com/bar.zip'),
ec2.InitSource.fromUrl('/tmp/bar', 'https://amazon.com/bar.zip'),
ec2.InitSource.fromUrl('/tmp/bar', 'https://amazon.com/foobar.zip'),
ec2.InitSource.fromUrl('/tmp/bar', 'https://amazon.com/foobar.zip'),
or something like this so we can see whether the dedeup logic applies to both the first parameter and the second, or if it's just the second?
There was a problem hiding this comment.
Good catch, will include some more dedup test values.
|
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 #26221
Reason for this change
Previously, using
ec2.InitCommand.argvCommand()would remove some duplicate strings in the input array. This produces an incorrect command in the template, leading to unexpected behaviour.Description of changes
An additional line was added to the
deepMergefunction that is called in theInitConfig.bindForType()method, which checks the key of the input array, preventing it from becoming a set (removing duplicates) if it is a list of commands.Description of how you validated changes
A unit test was added to generate an
AWS::CloudFormation::Initresource identical to the one reproduced in the issue. The test was run and failed before the changes were made, and following the changes incfn-init.ts, the test passed.Checklist
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license