Skip to content
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

(CodePipeline-Actions): Event created from ECR-Action does not use the default value the ECR-Action is using #13818

Closed
Kruspe opened this issue Mar 26, 2021 · 10 comments · Fixed by #13822 or #17270
Assignees
Labels
@aws-cdk/aws-codepipeline-actions bug This issue is a bug. effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p1

Comments

@Kruspe
Copy link
Contributor

Kruspe commented Mar 26, 2021

When creating an ECR Action, CDK creates an CloudWatch event. I was expecting it to only listen on PutImage events for the latest tag since that is the default value provided by the docs and.

Instead the event listens on every tag.

Reproduction Steps

new EcrSourceAction({
      actionName: 'Image',
      repository,
      output: imageArtifact,
      variablesNamespace: 'ImageVariables',
    });

Creates an event that triggers for all PutImages regardless of the tag.

What did you expect to happen?

new EcrSourceAction({
      actionName: 'Image',
      repository,
      output: imageArtifact,
      variablesNamespace: 'ImageVariables',
      imageTag: 'latest',
    });

The event created by this check only the latest tag but I only inserted the tag that is provided by default.

What actually happened?

The CW event listens for all PutImage calls regardless of the tag.

Environment

  • CDK CLI Version : 1.95.1 (build ed2bbe6)
  • Framework Version: 1.95.1
  • Node.js Version: 15.12.0
  • OS : BigSur 11.2.3
  • Language (Version): TypeScript (3.8.3)

Other

If the described behaviour is the desired one I can create a PR for it. :)

This is 🐛 Bug Report

@Kruspe Kruspe added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Mar 26, 2021
@skinny85
Copy link
Contributor

Hey @Kruspe ,

thanks for opening the issue. I wonder if this could be related to #10901?

Thanks,
Adam

@skinny85 skinny85 added the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Mar 26, 2021
@Kruspe
Copy link
Contributor Author

Kruspe commented Mar 26, 2021

Hey @skinny85,

This seems to be unrelated. It might be connected but on my end the event does trigger an execution but simply not as I would expect it.

The event created by CDK is missing the tag information and thus triggers an execution for every new tag created through PutImage. Since the default value is latest I would expect the event to also only trigger an execution when an image with the latest tag is pushed.

Max

@skinny85
Copy link
Contributor

skinny85 commented Mar 26, 2021

Yep @Kruspe, I think you're right.

I suspect the problem is here:

We send the props.imageTag to the API that creates the Event, but we don't default it to 'latest' there, which is why it triggers for every push.

Let me work on a quick fix for this.

In the meantime, you should be able to work around this by explicitly passing latest as the imageTag property when creating the EcrSourceAction, like you posted.

Thanks,
Adam

skinny85 added a commit to skinny85/aws-cdk that referenced this issue Mar 26, 2021
…y tag

The EcrSourceAction was incorrectly being triggered on a push of every tag if the `imageTag`
property was not provided, instead of defaulting to 'latest',
like its documentation suggested.

Correct the error by passing 'latest' to the created CloudWatch Event if `imageTag` was not set.

Fixes aws#13818
@skinny85 skinny85 added effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p1 and removed needs-triage This issue or PR still needs to be triaged. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Mar 26, 2021
@Kruspe
Copy link
Contributor Author

Kruspe commented Mar 27, 2021

Sounds good.
Let me know if you need me to do anything on this :)

Max

@mergify mergify bot closed this as completed in #13822 Apr 2, 2021
mergify bot pushed a commit that referenced this issue Apr 2, 2021
…y tag (#13822)

The EcrSourceAction was incorrectly being triggered on a push of every tag if the `imageTag`
property was not provided, instead of defaulting to 'latest',
like its documentation suggested.

Correct the error by passing 'latest' to the created CloudWatch Event if `imageTag` was not set.

Fixes #13818

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@github-actions
Copy link

github-actions bot commented Apr 2, 2021

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

hollanddd pushed a commit to hollanddd/aws-cdk that referenced this issue Aug 26, 2021
…y tag (aws#13822)

The EcrSourceAction was incorrectly being triggered on a push of every tag if the `imageTag`
property was not provided, instead of defaulting to 'latest',
like its documentation suggested.

Correct the error by passing 'latest' to the created CloudWatch Event if `imageTag` was not set.

Fixes aws#13818

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
@sparten11740
Copy link
Contributor

@skinny85 imo the way to fix this would've been to change the docs - or at least to provide an alternative to trigger on all tags as part of the fix if latest is actually the desired default.

Defaulting imageTag to latest when not specified prevents us to watch changes on all tags because it's no longer possible to pass through undefined as imageTag to the underlying onCloudTrailImagePushed function. In our case that was desired behaviour

@skinny85
Copy link
Contributor

Good call @sparten11740, I haven't thought of that.

What do you think about allowing '' (empty string) passed as the tag to mean "watch for all tags"?

@sparten11740
Copy link
Contributor

@skinny85 that sounds reasonable

@skinny85
Copy link
Contributor

@sparten11740 any chance you would be willing top open us a PR adding this feature? It should be relatively straightforward. Check out our "Contributing guide" for some info on how to get started with CDK development.

@sparten11740
Copy link
Contributor

@skinny85 only today found the time to work on this, opened a PR with a proposed solution

mergify bot pushed a commit that referenced this issue Nov 25, 2021
…ion (#17270)

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*
beezly pushed a commit to beezly/aws-cdk that referenced this issue Nov 29, 2021
…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*
TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this issue Feb 21, 2022
…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*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codepipeline-actions bug This issue is a bug. effort/small Small work item – less than a day of effort in-progress This issue is being actively worked on. p1
Projects
None yet
3 participants