-
Notifications
You must be signed in to change notification settings - Fork 247
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
CloudFrontToS3 error when providing existing s3 bucket #1114
Comments
Thanks, we'll take a look. |
I just found a clue, the problem only seems to be present when the s3 bucket is created in a CDK stack different from the cloudfrontToS3 stack |
How is the external bucket shared with the stack containing the aws-cloudfront-s3 construct? |
it is shared via a parameter in the cloufront stack constructor :
|
I'm attempting to replicate your situation in my own client with the following 3 source files: first-stack.ts
second-stack.ts
issue1114-stack.ts
The result is circular reference error when I deploy the top stack because the generated CFN template for Issue1114Stack creates dependencies between the two stacks:
Am I missing something about your deployment? Are you taking some additional action to avoid this situation? Thanks |
I do not use NestedStack but Stack : app.ts
s3 stack
cloudfrontToS3 stack
Thanks, |
I created a one file app with as much of your code as I could (I had to make up IEnvironmentConfig). When I try to launch it I still get a circular dependency between stacks when the aws-cloudfront-s3 constructs references the RegionalDomainName of the bucket passed in. Can you figure out what is different about your code from the code below that enables you to avoid the circular reference error?
|
Came looking for solution to the circular dependency problem. |
We were so focused on the original issue and the circular reference preventing us from replicating it that we didn't think to dive deep on the circular reference itself. We'll take a look and see if we can learn more about it. Thanks. |
The issue isn't actually within the construct, as the code below sees the same behavior. With a little trial and error and template review, the issue seems to be granting the OAI permission to read the S3 bucket. This updates the BucketPolicy in the DeployBucketStack to grant access to a canonical user in the CloudFrontStack, creating the dependency of the deploy stack on the cloudfront stack. Setting up the S3 bucket at the origin then attempts to create the reverse dependency and the CDK objects. It's interesting that it's the CDK code that catches the circular reference and refuses to generate a template - I'm more familiar with CloudFormation enforcing circular reference problems. In other situations the CDK has used custom resources to break circular dependencies like this - you could try to open an issue on their Github repo. FWIW - I removed the grantRead call and still saw the error, apparently the S3Origin code will execute grantRead anyway.
|
When providing an existingBucketObj to the CloudFrontToS3 construct, I get an error :
Reproduction Steps
Error Log
Environment
Other
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: