Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

806
Vistas
AWS CDK Error: bucket policy already exists on bucket

I am trying to create a lambda and a DynamoDB using CDK in java. When I try to do 'CDK Deploy' I face following error:

11:20:30 AM | CREATE_FAILED        | AWS::S3::BucketPolicy | StagingBucketPolicy
The bucket policy already exists on bucket xyz-cdk-toolkit-stagingbucket-1hpv60vcdqk7s.

CDK Version: 1.48.0
over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

This error occurs directly from CloudFormation, and as it says, the bucket you are adding the policy to, already has an existing one. CloudFormation does not allow for replacement/modification of bucket policies that were created outside of its control.

This is a security measure preventing you by accidentally changing existing policies.

If you want to control the bucket policy with CDK (or CloudFormation) you have to recreate it in CDK, delete the original one, and create using the CDK.

over 4 years ago · Santiago Trujillo Denunciar

0

As I mentioned in comment above in response to @Marcin's reply, this blog helped me solve the problem. Following are the steps I followed:

  1. Copied the cloud formation yaml snippet to a file named s3-bucket.yml provided in the blog.
  2. Used aws cli command to first create this bucket: aws cloudformation deploy --template-file resources/s3-bucket.yml --stack-name my-bucket-stack1
  3. Fired this CDK command to deploy my stack: cdk deploy --toolkit-stack-name my-bucket-stack1

These steps created my stack.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda