question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

aws-codepipeline: cross region support creates huge inline policy document for the pipeline role

See original GitHub issue

We have a code pipeline setup with cross region support. The pipeline creates replication buckets in cross regions and pipeline internally adds permissions for these s3 buckets in the pipeline role here.

Something like this for each cross region:

{
            "Action": [
                "s3:GetObject*",
                "s3:GetBucket*",
                "s3:List*",
                "s3:DeleteObject*",
                "s3:PutObject*",
               "s3:Abort*"
            ],
            "Resource": [
                "arn:aws:s3:::<replicationbucket>",
                "arn:aws:s3:::<replicationbucket>/*"
            ],
            "Effect": "Allow"
        },

Since an addAction is called for each region, we add a new policy statement every time with the same permissions, which is causing the pipeline role inline policy to exceed the iam policy size limit causing below error.

Maximum policy size of 10240 bytes exceeded for role <pipelinerole>

Similar issue is seen for the sts:AssumeRole permissions added here.

Reproduction Steps

Create a codepipeline with multiple stages and ~ 15 regions.

What did you expect to happen?

The role that pipeline created should be reduced / compacted. Since there are many duplicate actions for each resource, we can have a single policy statement with all resources.

We were adding new stages and regions in our pipeline when we observed this.

What actually happened?

Got this error when deploying the stack.

Maximum policy size of 10240 bytes exceeded for role <pipelinerole>

Environment

  • CDK CLI Version : 1.23, I think the latest version has this bug too.
  • Framework Version: 1.23
  • Node.js Version: 12.x
  • OS : MacOS
  • Language (Version): TypeScript (3.8.3)

This is 🐛 Bug Report

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:11
  • Comments:22 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
moltarcommented, Sep 30, 2021

This is a real blocker!

The whole idea of infra-as-code is that it can be scaled and generated.

But this becomes an impediment and an antithesis to infra-as-code.

We were testing on a small set of stages to make sure it all worked. When we added other stages, everything crumbled and the pipeline is now broken.

2reactions
bilalqcommented, Dec 7, 2021

Could the CodePipeline construct run an aspect on itself to do the optimization on its end? It seems there’s reluctance to make sweeping IAM optimization changes based on comments in #14713, but this is a real show-stopper for production usage of CDK.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Identity and access management for AWS CodePipeline
Manage the CodePipeline service role. The CodePipeline service role is configured with one or more policies that control access to the AWS resources...
Read more >
Add a cross-Region action in CodePipeline
Describes how to use the console, AWS CLI, or AWS CloudFormation to create a cross-Region action for use in a pipeline.
Read more >
Using AWS CodePipeline to Perform Multi-Region Deployments
Now that AWS CodePipeline supports cross-region actions, you can deploy your application across multiple regions from a single pipeline.
Read more >
Quotas in AWS CodePipeline
CodePipeline has quotas for the number of pipelines, stages, actions, and webhooks that an AWS account can have in each AWS Region. These...
Read more >
Integrations with CodePipeline action types
You can configure CodePipeline to use a versioned Amazon S3 bucket as the ... The GitHub version 1 action is managed with OAuth...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found