Bird
Raised Fist0
AWScloud~20 mins

Nested stacks for modularity in AWS - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Nested Stack Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Architecture
intermediate
2:00remaining
Understanding Nested Stack References

You have a main AWS CloudFormation stack that includes a nested stack for a VPC configuration. Which of the following correctly references the nested stack resource in the main template?

AWS
Resources:
  VPCStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: https://s3.amazonaws.com/examplebucket/vpc-template.yaml
      Parameters:
        VpcCIDR: 10.0.0.0/16
A
61/0.0.0.01 :RDICcpV    
:sretemaraP  
lmay.etalpmet-cpv/tekcubelpmaxe/moc.swanozama.3s//:sptth :LRUetalpmeT  
:seitreporP
kcatS::noitamroFduolC::SWA :epyT
B
Type: AWS::EC2::VPC
Properties:
  CidrBlock: 10.0.0.0/16
C
Type: AWS::CloudFormation::Stack
Properties:
  TemplateBody: |
    Resources:
      VPC:
        Type: AWS::EC2::VPC
        Properties:
          CidrBlock: 10.0.0.0/16
D
Type: AWS::CloudFormation::Stack
Properties:
  TemplateURL: https://s3.amazonaws.com/examplebucket/vpc-template.yaml
  Parameters:
    VpcCIDR: 10.0.0.0/16
Attempts:
2 left
💡 Hint

Look for the correct way to specify the nested stack's template location and parameters.

❓ service_behavior
intermediate
1:30remaining
Behavior of Parameter Passing in Nested Stacks

When you pass parameters from a parent stack to a nested stack, what happens if the nested stack template expects a parameter that the parent stack does not provide?

AThe nested stack deployment fails with a missing parameter error.
BThe nested stack uses a default value for the missing parameter automatically.
CThe parent stack ignores the missing parameter and continues deployment.
DThe nested stack creates the parameter with a null value.
Attempts:
2 left
💡 Hint

Think about required parameters and deployment validation.

❓ security
advanced
2:00remaining
Security Best Practices for Nested Stack Templates

You want to secure your nested stack templates stored in Amazon S3. Which approach best protects the templates from unauthorized access while allowing CloudFormation to deploy them?

AMake the S3 bucket public and restrict access using bucket policies.
BUse S3 bucket policies to allow access only from CloudFormation service principal and encrypt templates with SSE-S3.
CStore templates in a private bucket without any policies and rely on IAM roles for access.
DUse pre-signed URLs with long expiration times for template URLs.
Attempts:
2 left
💡 Hint

Consider least privilege and encryption.

❓ Configuration
advanced
1:30remaining
Troubleshooting Nested Stack Rollback Behavior

You deploy a parent stack with nested stacks. One nested stack fails during creation. What is the default behavior of CloudFormation regarding the parent and other nested stacks?

ACloudFormation rolls back the entire parent stack and all nested stacks created so far.
BCloudFormation deletes only the failed nested stack and keeps the rest.
CCloudFormation continues creating other nested stacks and leaves the failed one in rollback state.
DCloudFormation pauses deployment and waits for manual intervention.
Attempts:
2 left
💡 Hint

Think about atomic deployment and rollback.

🧠 Conceptual
expert
2:00remaining
Advantages of Using Nested Stacks for Large Infrastructure

Which of the following is NOT a primary advantage of using nested stacks in AWS CloudFormation for modular infrastructure design?

AImproved template readability and maintainability by breaking large templates into smaller ones.
BReuse of common infrastructure components across multiple stacks.
CAutomatic scaling of resources within nested stacks without manual intervention.
DSimplified updates by isolating changes to specific nested stacks.
Attempts:
2 left
💡 Hint

Consider what nested stacks manage versus what AWS services handle automatically.

Practice

(1/5)
1. What is the main benefit of using nested stacks in AWS CloudFormation?
easy
A. They replace the need for IAM roles.
B. They automatically increase server CPU capacity.
C. They break large templates into smaller, reusable parts.
D. They encrypt all data stored in S3 buckets.

Solution

  1. Step 1: Understand the purpose of nested stacks

    Nested stacks allow splitting a big CloudFormation template into smaller templates for easier management.
  2. Step 2: Compare options with this purpose

    Only They break large templates into smaller, reusable parts. describes breaking large templates into reusable parts, which matches nested stacks' main benefit.
  3. Final Answer:

    They break large templates into smaller, reusable parts. -> Option C
  4. Quick Check:

    Nested stacks = modular templates [OK]
Hint: Think modular: nested stacks split big templates [OK]
Common Mistakes:
  • Confusing nested stacks with scaling features
  • Assuming nested stacks handle encryption automatically
  • Mixing nested stacks with IAM role functions
2. Which syntax correctly defines a nested stack resource in a CloudFormation template?
easy
A. "Type": "AWS::Lambda::Function", "Properties": {"Handler": "index.handler"}
B. "Type": "AWS::S3::Bucket", "Properties": {"BucketName": "nested-stack"}
C. "Type": "AWS::EC2::Instance", "Properties": {"ImageId": "ami-123456"}
D. "Type": "AWS::CloudFormation::Stack", "Properties": {"TemplateURL": "https://s3.amazonaws.com/mybucket/mystack.yaml"}

Solution

  1. Step 1: Identify nested stack resource type

    The resource type for nested stacks is AWS::CloudFormation::Stack.
  2. Step 2: Check the properties for nested stack

    Nested stacks require a TemplateURL property pointing to the child template location.
  3. Final Answer:

    "Type": "AWS::CloudFormation::Stack", "Properties": {"TemplateURL": "https://s3.amazonaws.com/mybucket/mystack.yaml"} -> Option D
  4. Quick Check:

    Nested stack resource = AWS::CloudFormation::Stack [OK]
Hint: Nested stack resource type is AWS::CloudFormation::Stack [OK]
Common Mistakes:
  • Using S3 bucket or EC2 instance types for nested stacks
  • Omitting TemplateURL property
  • Confusing Lambda function syntax with nested stacks
3. Given a parent stack that passes a parameter VpcId to a nested stack, what will happen if the nested stack template does NOT declare VpcId as a parameter?
medium
A. The nested stack deployment will fail with a parameter validation error.
B. The nested stack will ignore the parameter and deploy successfully.
C. The parent stack will automatically create the missing parameter.
D. The nested stack will use a default VPC ID automatically.

Solution

  1. Step 1: Understand parameter passing in nested stacks

    Parameters passed from parent to nested stack must be declared in the nested stack template.
  2. Step 2: Consequence of missing parameter declaration

    If the nested stack does not declare the parameter, CloudFormation cannot map the value, causing deployment failure.
  3. Final Answer:

    The nested stack deployment will fail with a parameter validation error. -> Option A
  4. Quick Check:

    Missing nested stack parameter = deployment error [OK]
Hint: Nested stack must declare all passed parameters [OK]
Common Mistakes:
  • Assuming parameters are optional in nested stacks
  • Thinking parent stack auto-creates missing parameters
  • Believing nested stacks use default values without declaration
4. You have a nested stack that fails to update because the child stack template URL is incorrect. What is the best way to fix this error?
medium
A. Delete the parent stack and recreate it from scratch.
B. Update the parent stack template to use the correct TemplateURL for the nested stack.
C. Change the nested stack resource type to AWS::S3::Bucket.
D. Remove the nested stack resource from the parent template.

Solution

  1. Step 1: Identify cause of failure

    The error is due to an incorrect TemplateURL in the parent stack referencing the nested stack template.
  2. Step 2: Correct the TemplateURL

    Fixing the TemplateURL in the parent stack template ensures CloudFormation can find and deploy the nested stack correctly.
  3. Final Answer:

    Update the parent stack template to use the correct TemplateURL for the nested stack. -> Option B
  4. Quick Check:

    Fix TemplateURL in parent stack to fix nested stack update [OK]
Hint: Fix TemplateURL in parent template to fix nested stack errors [OK]
Common Mistakes:
  • Deleting entire parent stack unnecessarily
  • Changing resource type incorrectly
  • Removing nested stack resource instead of fixing URL
5. You want to create a modular infrastructure with nested stacks where a VPC stack outputs a VpcId and a subnet stack needs this VpcId as input. How should you connect these stacks to ensure modularity and correct parameter passing?
hard
A. Use Outputs in the VPC stack and pass them as Parameters to the subnet nested stack in the parent template.
B. Hardcode the VPC ID in the subnet stack template directly.
C. Deploy the subnet stack separately without any parameters.
D. Merge both VPC and subnet resources into a single large template.

Solution

  1. Step 1: Use Outputs to share data from VPC stack

    The VPC nested stack should declare an Output for VpcId to share it externally.
  2. Step 2: Pass Output as Parameter to subnet stack

    The parent stack template passes the VPC stack's VpcId Output as a Parameter to the subnet nested stack, maintaining modularity.
  3. Final Answer:

    Use Outputs in the VPC stack and pass them as Parameters to the subnet nested stack in the parent template. -> Option A
  4. Quick Check:

    Outputs to Parameters connect nested stacks modularly [OK]
Hint: Connect stacks via Outputs and Parameters in parent template [OK]
Common Mistakes:
  • Hardcoding values breaking modularity
  • Deploying stacks separately without parameter passing
  • Combining all resources in one big template losing modularity
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard