-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(ec2): prevent deduplication of init command args #30821
Conversation
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 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.
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.
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 |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, will include some more dedup test values.
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 approve of the 👻
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
deepMerge
function 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::Init
resource 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