-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
(aws-s3): bucket policy fails to create when bucket:arn is not yet available #28659
Comments
Unfortunately I can't reproduce this for a few attemps export class Demo extends DemoStack {
constructor(scope: Construct, id: string, props: StackProps) {
super(scope, id, props);
new s3.Bucket(this, 'test', {
removalPolicy: RemovalPolicy.DESTROY,
autoDeleteObjects: true
})
}
} app.ts for (let i=0; i<30; i++) {
new Demo(app, `demo${i}stack`, { env });
} And I deploy with npx cdk deploy --all --require-approval never --concurrency 30 I didn't see any error after a few attempts. Can you try it again? |
This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled. |
Working on replicating again. I'm at a loss for a method to recreate it deterministically - it appears to be triggered by the S3 Create Bucket being a bit slow. I'm going to try to set up a test that just keeps repeating the stress test indefinitely, hoping to catch the slower S3 behavior when it occurs. |
I am facing the exact issue as well. It seems that cloudformation tries to create the bucket policy before the bucket creation is complete. Its inconsistent but saw it a few times in the last 2-3 weeks. |
I am also facing a similar issue. Seems to be happen intermittently and started becoming an issue just before Christmas. Note the buckets (and stacks they are in) haven't been changed for a few months, so seems like a fairly new problem. |
Talking to some coworkers, our theory is that the issue is not CDK per se - that a change in CloudFormation led to CloudFormation ceasing to recognize the dependency of the policy on the bucket from the context of the template (I'm running my tests using the generated template rather than the CDK program to confirm this). If this is the case, then the issue is not necessarily within the CDK - but an update to the S3 Bucket construct to explicitly set the dependency would smooth over the CFN issue. |
i am having the same issue with just creating a bucket with an access policy as well. const logBucket = new Bucket(
this,
${config.kitName}-alb-logs-bucket,
{
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
removalPolicy:RemovalPolicy.DESTROY,
autoDeleteObjects: true
}
) Unable to retrieve Arn attribute for AWS::S3::Bucket, with error message Bucket not found |
This is confirmed to be a CloudFormation issue. The word from AWS is: Due to a recent change in internal workflow of CloudFormation, our development teams have identified an issue that can cause this error intermittently. They are currently working on deploying a fix for the same. So it seems that there's no change to CDK needed, that for the moment we just retry after a failure and it clear up entirely - hopefully soon. |
I am seeing this issue myself quite frequently. I am using the CDK BucketDeployment, which automatically generates a parallel construct containing a lambda function, IAM role and policy. It is the policy that is trying to reference the arn of the bucket with Fn::GetAtt in the synthesized output. biffgaut, can you reference where you found the AWS issue being reported? Thanks. |
That message was from an internal ticket here at AWS - there isn't any further info available at the moment. I have not seen this issue referenced online anywhere but here, which is shocking to me as it has occurred on several workloads managed by our team so I would assume the impact is bigger than the few people monitoring this issue. |
As an FYI this has happened ~60 times in the last 60 days so @biffgaut you're not alone here. We are also running into this issue with lambda function roles, I suspect it's not* isolated to bucket policies. |
I opened a support ticket with the AWS cloudformation team. |
I am also facing the same problem. It is really annoying as it is hampering deployments. |
I am also experiencing the same issue. |
Work Around the Issue for now:
Option 2:
|
Happening again yall... |
Hi so if you're running into this issue running a static site out of an s3 bucket via cloudfront you can split the code into 2 stacks for a more reliable CI/CD process. Bucket Stack:
Distro Stack (with domain stuff):
Also, pay me. |
Is there any update to this? I am attempting to deploy a bucket and a stackset and the stackset fails because the bucket policy does not finish deploying, despite the policy not being built until after the bucket. |
Describe the bug
A dependency issue between S3 Buckets and Bucket Policies in the L2 Bucket class allows the Policy to access the arn of the bucket before it is available, causing the creation of the Bucket Policy to fail. Being a dependency issue, this is an intermittent issue and works correctly the vast majority of the time. When it fails, simply relaunching the stack usually works.
Expected Behavior
The L2 Bucket construct should launch successfully every time.
Current Behavior
testPolicy9D625504
CREATE_FAILED
Unable to retrieve Arn attribute for AWS::S3::Bucket, with error message Bucket not found
Reproduction Steps
I created a simple CDK app with this code:
I then set up a bash script that launched it 40 times, essentially simultaneously:
On 1 of the 30 I saw the error I reference above.
Possible Solution
If I am interpreting the behavior correctly, it seems that adding a Dependency on the Bucket to the BucketPolicy in the L2 Construct would prevent the Policy from trying to access the bucket before it is ready. Perhaps here?
aws-cdk/packages/aws-cdk-lib/aws-s3/lib/bucket.ts
Line 651 in 3318a38
Additional Information/Context
We've seen it in several of our constructs (and newer versions of the CDK than what I cite below for the test above). Someone also mentioned they have seen it in aws-codepipline.
CDK CLI Version
2.108.0
Framework Version
2.108.0
Node.js Version
20.9.0
OS
MacOS Ventura 13.6.3
Language
TypeScript
Language Version
Typescript 5.2.2
Other information
Versions cited are for the test I cited, but it's been seen in other versions as well.
The text was updated successfully, but these errors were encountered: