Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

490
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda