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

499
Vistas
AWS CDK accessing a resource in a parent stack from a nested stack

I am trying to pass an Arn for a resource created in a parent stack to be used in a nested stack. The aws-cdk documentation states that:

When a resource from a parent stack is referenced by a nested stack, a CloudFormation parameter will automatically be added to the nested stack and assigned from the parent

However, trying to reference a resource created in a parent stack results in Circular dependency between resources: error.

What would be the best way to pass a reference for a resource from a parent stack to a nested one?

object TestTemplateApp extends App {


  class MainStack(parent: Construct)
    extends Stack(parent, "Main") {

    //some other resources
    val firstNestedStack = new FirstNestedStack(this)

  }


  class FirstNestedStack(parent: Construct)
    extends NestedStack(parent, "Batch") {


    //some other resources

    val s3Bucket = Bucket.Builder
      .create(this, "id")
      .bucketName(("example"))
      .build()

    val BucketArn = s3Bucket.getBucketArn

    val secondNested = new SecondNestedStack(this, BucketArn)
  }

  class SecondNestedStack(parent: Construct, bucketArn: String) extends NestedStack(parent, "second") {

    //some other resources

    val secondS3Bucket = Bucket.Builder
      .create(this, s" S3WorkspaceBucket")
      .bucketName(s"$bucketArn example") // assume we want to use the ARN of the s3 bucket from the parent in the bucket in the nested stack
      .build()
  }

  val cdkApp = CDKApp.Builder.create().outdir("/tmp/test_template").build()
  val mainStack = new MainStack(cdkApp)
  cdkApp.synth()

}
over 4 years ago · Santiago Trujillo
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