-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
Describe the bug
We recently filed an issue about how CodePipeline was failing due to the generation of extremely large IAM policy documents:
Our issue was closed and it was suggested that this PR might fix it:
This tracking issue was closed via that PR:
We have since upgraded our CDK version to 2.19.0
and set @aws-cdk/aws-iam:minimizePolicies
to true
.
This did seem to decrease the size of some IAM policies, but we are still hitting the same failure.
Expected Behavior
Expected #19114 to reduce generated IAM policy sizes so that our pipeline would deploy.
Current Behavior
Pipeline still fails to deploy with Maximum policy size of 10240 bytes exceeded for role xxx
.
See attachment for example of the offending IAM policy. The policy contains three statements, and the third one is the offending one. It is granting AssumeRole
to all of the roles for all of the actions in all of the accounts that this pipeline is trying to deploy to.
See attachment for example (sanitized) policy.
pipelineofpipelinesstackcoreinfrastructurepipeline03AEF9CA.template.JUST_OFFENDING_POLICY.sanitized.json.gz
There are 97 resources in that statement, they look like this:
{
"Fn::GetAtt": [
"pipelinecoreinfrastructureDeployProdcelluseast1produseast1synthCodePipelineActionRole8A60FDE1",
"Arn"
]
},
and this:
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::111111111111:role/core-infrastructure-pipelhangesactionroleb355ae8d7595154ac81b"
]
]
},
Reproduction Steps
Create a CodePipeline that creates additional Pipelines. In one of those additional pipelines, create a large number of actions that target multiple AWS accounts.
It would take some non-trivial effort for me to extract a concise reproducer from our current (private) code, but pending the responses to the questions above about whether this is still expected behavior, how to override the Role, etc., I am willing to try to put one together!
Possible Solution
It's not clear to me whether this behavior is still expected after the fix in #19114 was released.
We are looking for guidance on:
- Whether this is still a known issue in CDK
- Whether it is expected that additional fixes will be merged to address this
Also, there seem to be a ton of other tickets related to this, and in several of them it is hinted that users with advanced use cases like ours may need to opt out of this automatic policy generation, and override the Role with one that we manage ourselves (which might use wildcards or multiple policy attachments, etc.). If that is the current prescription, it would be wonderful if there were some official docs or examples that illustrated how to do this; I haven't really seen anything so far that gives me a concrete idea of how to even attempt it.
Additional Information/Context
No response
CDK CLI Version
2.19.0
Framework Version
2.19.0
Node.js Version
v16.5.0
OS
Amazon Linux 2
Language
Typescript
Language Version
TypeScript 4.4.2
Other information
No response