-
Notifications
You must be signed in to change notification settings - Fork 4k
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
S3 encryption cross-stack permission causes cyclic reference #3732
Comments
I'm actually not sure - @robwettach, can you try upgrading to 1.9.0 and see if that helps? Thanks, |
Doesn't look like it, no. I copied my "minimal sample code" into new 1.8.0 and 1.9.0 applications and I'm getting the same error still. |
I have the same issue in 1.13.1. Currently the only way is not to use CMK on buckets (which is a show stopper for us). @skinny85 can you please update? The issue can be easily reproduced from the snippet provided by @robwettach so you do not have to guess. |
Hi Elad, Is there any update on that? Same thing happens in 1.19.0. Thanks |
Hey @Artmobile. Can you create a bucket access policy (with iam.Policy) from the bucket stack and then reference it from the other stacks that have constructs that need access? This is a workaround but hopefully can satisfy your use-case in the interim. |
Unless I'm mistaken, it looks like Adam's commit (#3694) covers this case. From the commit message:
Thanks to this code snippet, as long as class S3ConsumerStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props: S3ConsumerStackProps) {
super(scope, id, props);
const accessRole = new iam.Role(this, "Access", {
assumedBy: new iam.ServicePrincipal("ecs-tasks.amazonaws.com")
});
this.addDependency(cdk.Stack.of(props.bucket));
props.bucket.grantRead(accessRole);
}
} |
@petermeansrock your suggestion worked. Thank you! |
Seems like this was resolved in #3694 |
I'm submitting a ...
What is the current behavior?
When attempting to grant read/write access to an encrypted S3 bucket exported from a separate stack, I'm receiving a "cyclic reference" error.
Minimal sample code:
Error output:
What is the expected behavior (or behavior of feature suggested)?
Granting access to a bucket from a separate stack should not cause a cyclic reference. I believe what's happening is that CDK is trying to modify the KMS key's Resource Policy to reference the Role's ARN. Is there any way to do that in the context of the consumer stack, or avoid that all together? In particular, I think this code is what's causing the cyclic reference, so even if I supplied my own KMS key to the S3 bucket it would probably have a similar effect if I simply called
grantEncryptDecrypt
from the consumer stack. Previously in CloudFormation I would simply export the KMS Key ARN and grant my IAM Role access without modifying the Key's Resource Policy. Is there any way to get that behavior by default in CDK?What is the motivation / use case for changing the behavior or adding this feature?
Environment
The text was updated successfully, but these errors were encountered: