-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
New Resource: aws_ecr_repository_policy_statement #985
Conversation
13f5764
to
6755049
Compare
6755049
to
3429a95
Compare
Hi @greenboxal Sorry for taking this long to get back to you. Hope I understood the use-case well 😄 THanks! |
You can only apply one policy per repository. A lot of times you want to deploy the same application in different infrastructures, using the same repository. Maybe for creating a staging -> production pipeline. Let's say you have a module called If I want to use the same repository, I can't create the repo inside the module, otherwise I would end up with two different repositories. I need to create a policy for each The first approach that come to my head is: create one policy for each module instance and attach them to the repo. But then you have a issue here: ECR repos can only have one policy. This resources solves this, in the same way that |
|
||
if policy.Statements == nil { | ||
policy.Statements = make([]*ecrPolicyStatement, 0) | ||
} |
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.
@greenboxal Do you think you could take some time to create a data source called aws_iam_policy_document
which would have a source_policy document, that would allow to merge your policy into the source one?
Your use case seems totally valid and it would be a great addition to have it! 👍
I am just wondering that maybe we could make this part reusable so that we can handle this case in several situations. What do you think? :)
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 believe this will be helped/solved in a more generic sense with #2890 |
As noted above, this was solved more generically with the |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
This resource allows to manage ECR policy statements as single resources, allowing to spread them across several modules. This is useful as a ECR repository can have only one policy document.
It was implemented in the same way that aws_security_group_rule works: It locks the resource mutex and applies the diff (add, remove or change the statement) over the policy document and applies it on the repository.