- 新しい順
- 投票が多い順
- コメントが多い順
Yes, it is possible to create a CDK stack that deploys to an AWS account that has an existing S3 bucket with the same name, without rewriting or deleting and re-creating the bucket.
One way to do this would be to use the aws-cdk-lib library's S3 class and pass in the name of the existing S3 bucket as a parameter. This will allow you to create a new stack that references the existing bucket without modifying or deleting it.
Another way is to use the CfnBucket class to import the existing S3 bucket into your CDK stack. This class allows you to import existing resources into your stack, and you can then add event notifications to it via the stack.
It is important to note that the permissions on the bucket should be appropriate to allow the CDK stack to access the bucket.
It would be the best approach to first export the current configuration of the bucket using the AWS CLI aws s3api get-bucket-configuration command and then import it as a CloudFormation resource in the CDK stack. This would ensure that all the current configuration is maintained and only new resources are added via the CDK stack.
関連するコンテンツ
- AWS公式更新しました 1年前