Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

489
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!