-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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(codepipeline): cannot trigger on all tags anymore in EcrSourceAction #17270
Conversation
…to EcrSourceAction The EcrSourceAction could previously be used to trigger on changes to all tags of an image. As part of the fix #13818, the imageTag was defaulted to latest if not provided. Therefore it was no longer possible to call the underlying onCloudTrailImagePushed function with an undefined imageTag to watch changes on all tags. Reintroduce triggering on all tags by passing an empty string as the imageTag. Fixes #13818
packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts
Outdated
Show resolved
Hide resolved
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.
@sparten11740 thank you for the contribution, but I have to say, I'm having second thoughts on whether this change even makes sense 😜.
The CodePipeline documentation states:
ImageTag
Required: NoThe tag used for the image.
Note
If a value forImageTag
is not specified, the value defaults tolatest
.
If that is true, then specifying ''
here would trigger on a push to every tag, yes. But the image downloaded would always be for the 'latest'
tag anyway! If that's the case, what's the point of triggering a deploy for a different tag, if it won't be used anyway, and 'latest'
will be used (so basically, a no-op deployment)?
Can you elaborate on your usecase a little bit?
packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts
Outdated
Show resolved
Hide resolved
You’re assuming that From my understanding the There are two minor disadvantages with this approach. First, looking at the container definition in the ECS console to find out what’s deployed, we’d always have to go to ECR first to see what image is actually hiding behind the image url (whereas if we used the e.g. commit hash or something else meaningful as dynamic tag this wouldn’t be the case). Second, creating a container image from a digest just feels a little clumsy. Of course this works and is not a big deal, but I’d much rather not be forced to use the |
I mostly understand, but I have a few follow-up questions 🙂. So, the ECR source Action produces a file with a bunch of metadata about the image. Among them is Second question. If we make the CloudWatch event react to every tag, like we do in this PR, does this mean that the metadata produced by the ECR source Action will be for whatever image was pushed that caused that Event to fire? So, even if the Third question: you wrote:
Can you explain how are you achieving this? Thanks, |
That's correct. I would like to use tag but can't because it needs to be the same for all invocations.
If we do it like in this PR, this would be the case but only if we provide Regarding your third question: The const containerImage = ContainerImage.fromDockerImageAsset({
repository,
imageUri: repository.repositoryUriForDigest(imageDigest),
assetHash: imageDigest,
node: repository.node,
}); If tag could be used, this would shrink to: ContainerImage.fromEcrRepository(repository, imageTag); I hope this could make it a little clearer. |
OK, thanks for the answers. I feel like this is all a little bit fragile - from relying on the undocumented behavior of the ECR CodePipeline source Action with regards to ignoring the tag, and just including whatever metadata of the image was just pushed, to the way you implement a I don't have any more philosophical objections to this PR. Let me do another round of reviews. |
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.
Looks good @sparten11740, just a few minor changes!
packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-codepipeline-actions/test/integ.pipeline-ecr-source-all-tags.ts
Outdated
Show resolved
Hide resolved
packages/@aws-cdk/aws-codepipeline-actions/lib/ecr/source-action.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Adam Ruka <adamruka85@gmail.com>
Pull request has been modified.
Co-authored-by: Adam Ruka <adamruka85@gmail.com>
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.
Awesome, thanks so much for the contribution @sparten11740!
One last tiny comment before we merge this in.
packages/@aws-cdk/aws-codepipeline-actions/test/ecr/ecr-source-action.test.ts
Show resolved
Hide resolved
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 the contribution @sparten11740!
Thank you for contributing! Your pull request will be updated from master 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 master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
…ion (aws#17270) The EcrSourceAction could previously be used to trigger on changes to all tags of an image. As part of the fix aws#13818, the imageTag was defaulted to latest if not provided. Therefore it was no longer possible to call the underlying onCloudTrailImagePushed function with an undefined imageTag to watch changes on all tags. Reintroduce triggering on all tags by passing an empty string as the imageTag. Fixes aws#13818 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
…ion (aws#17270) The EcrSourceAction could previously be used to trigger on changes to all tags of an image. As part of the fix aws#13818, the imageTag was defaulted to latest if not provided. Therefore it was no longer possible to call the underlying onCloudTrailImagePushed function with an undefined imageTag to watch changes on all tags. Reintroduce triggering on all tags by passing an empty string as the imageTag. Fixes aws#13818 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
As reported in #20594, this change does not actually work as advertised. I looked at the ECR Source Action source code and will always substitute in the value |
The EcrSourceAction could previously be used to trigger on changes to all tags of an image. As part of the fix #13818, the imageTag was defaulted to latest if not provided. Therefore it was no longer possible to call the underlying onCloudTrailImagePushed function with an undefined imageTag to watch changes on all tags.
Reintroduce triggering on all tags by passing an empty string as the imageTag.
Fixes #13818
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license