terraform-aws-ecr icon indicating copy to clipboard operation
terraform-aws-ecr copied to clipboard

add optional policy allowing push access

Open kpankonen opened this issue 2 years ago • 11 comments

what

  • adds the ability to give push-only access to the repository

why

  • full access was more than we wanted in our situation (CI pushing images to the repo) so we added a principals_push_access to give push-only access.

references

  • policy is based on this AWS doc

kpankonen avatar Jun 02 '22 18:06 kpankonen

https://github.com/cloudposse/terraform-aws-ecr/issues/96

ngoyal16 avatar Jun 10 '22 07:06 ngoyal16

/test all

nitrocode avatar Jun 10 '22 13:06 nitrocode

Thanks for the contribution. I'm just trying to get a second set of eyes on this to make sure it's what we want in this module.

nitrocode avatar Jun 10 '22 13:06 nitrocode

Use distinct function for override policy document

ngoyal16 avatar Jun 10 '22 14:06 ngoyal16

Either we should move lambda condition to independent or add in push policy as welll

I prefer it should be independent

ngoyal16 avatar Jun 10 '22 14:06 ngoyal16

Use distinct function for override policy document

I'm not sure I follow. Where do you think there should be a distinct function?

kpankonen avatar Jun 16 '22 13:06 kpankonen

Use distinct function for override policy document

I'm not sure I follow. Where do you think there should be a distinct function?

Main.tf line no 250

ngoyal16 avatar Jun 16 '22 13:06 ngoyal16

Use distinct function for override policy document

I'm not sure I follow. Where do you think there should be a distinct function?

Main.tf line no 250

Maybe I'm missing something but I think that would require restructuring the module so that the all (push, readonly, full)actions are combined/distinct before they get used in a policy document. That would also mean losing the sid on the different policy blocks. That would make it harder to understand the policy when looking at it from the AWS side.

Or I'm looking at the wrong thing...

kpankonen avatar Jun 16 '22 13:06 kpankonen

i see the bridgecrew code analysis is failing but i'm not able to see the output of the job

kpankonen avatar Jun 30 '22 15:06 kpankonen

/test all

nitrocode avatar Jul 06 '22 15:07 nitrocode

@kpankonen currently lambda access is granted using dynamic statements in each group and it may be problematic if someone want to create and ECR with just lambda access as resource policy. then policy might be missing because we are checking if the system has push or pull or full variables then only create not based on lambda too. We should have independent staement for lambda access policy.

ngoyal16 avatar Aug 27 '22 03:08 ngoyal16

@aknysh @nitrocode is there anything else i can do to help get this merged?

kpankonen avatar Nov 13 '22 15:11 kpankonen

/test all

aknysh avatar Nov 14 '22 03:11 aknysh

/rebuild-readme

aknysh avatar Nov 14 '22 03:11 aknysh

/test all

aknysh avatar Nov 14 '22 03:11 aknysh

@kpankonen currently lambda access is granted using dynamic statements in each group and it may be problematic if someone want to create and ECR with just lambda access as resource policy. then policy might be missing because we are checking if the system has push or pull or full variables then only create not based on lambda too. We should have independent statement for lambda access policy.

@kpankonen @ngoyal16 I agree with this. Lambda permissions are already in the 2 existing policies, and it should be separated into its own policy. We'll not do it in this PR, but @kpankonen please update your new push-access policy to include the lambda principals as @ngoyal16 mentioned to make all 3 policies symmetrical and allow Lambdas to push. Otherwise, the PR looks good to me, thanks

aknysh avatar Nov 14 '22 04:11 aknysh

@tovbinm there is an small change needs to be done

ngoyal16 avatar Dec 06 '22 01:12 ngoyal16

The PR has been updated to add the Lambda access policy

kpankonen avatar Dec 06 '22 02:12 kpankonen

are any additional changes needed?

kpankonen avatar Apr 05 '23 18:04 kpankonen

/test all

Gowiem avatar Apr 05 '23 19:04 Gowiem

@kpankonen Apologies, but can you fix the out of date README? Do the following:

make init
make github/init
make readme

and commit the changes (if any)

Gowiem avatar Apr 05 '23 19:04 Gowiem

@kpankonen Apologies, but can you fix the out of date README? Do the following:

make init
make github/init
make readme

and commit the changes (if any)

done!

kpankonen avatar Apr 05 '23 20:04 kpankonen

/test all

joe-niland avatar Apr 05 '23 21:04 joe-niland

anything else needed?

kpankonen avatar Apr 13 '23 20:04 kpankonen

Argh @kpankonen -- we're doing you wrong here with multiple of us trying to move it forward, but then dropping the ball (we get drowned in a sea of GH notification emails as part of being on the maintainer team, so that is our excuse 😅 ).

Can you please address the conflicts or try rebasing again? Once this is ready to go, ping me here or better yet in the SweetOps slack and I will be sure to get this over the line for you. Thanks for the work and patience!

Gowiem avatar May 18 '23 20:05 Gowiem

/terratest

Gowiem avatar May 18 '23 22:05 Gowiem

@Gowiem updated

kpankonen avatar May 18 '23 23:05 kpankonen

/terratest

Gowiem avatar May 18 '23 23:05 Gowiem

@aknysh I believe we need your approval to move this forward.

FYI, I am going to do a fast follow on this PR today or tomorrow to break out the principals_lambda policies into their own policy doc so they don't need to be included with each of these full vs read vs write docs.

Gowiem avatar May 18 '23 23:05 Gowiem