Bird
Raised Fist0
AWScloud~20 mins

Template structure (JSON/YAML) in AWS - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Cloud Template Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Identify the main sections of an AWS CloudFormation template

Which of the following lists correctly shows the main sections of a valid AWS CloudFormation template in JSON or YAML?

AParameters, Resources, Outputs, Mappings, Conditions, Transform, Metadata
BResources, Variables, Functions, Outputs, Conditions
CParameters, Resources, Scripts, Outputs, Policies
DResources, Outputs, Variables, Templates, Conditions
Attempts:
2 left
💡 Hint

Think about the sections that define inputs, resources, and outputs in a CloudFormation template.

❓ Configuration
intermediate
1:30remaining
Determine the number of resources defined in this CloudFormation snippet

Given the following JSON snippet of a CloudFormation template, how many AWS resources are defined?

{
  "Resources": {
    "MyBucket": {
      "Type": "AWS::S3::Bucket"
    },
    "MyQueue": {
      "Type": "AWS::SQS::Queue"
    },
    "MyTopic": {
      "Type": "AWS::SNS::Topic"
    }
  }
}
A3
B2
C1
D4
Attempts:
2 left
💡 Hint

Count the top-level keys inside the Resources section.

❓ Architecture
advanced
2:30remaining
Choose the correct YAML template structure for conditional resource creation

Which YAML snippet correctly uses a condition to create an AWS resource only if a parameter value is 'true'?

A
Parameters:
  CreateBucket:
    Type: String
    AllowedValues: [true, false]
Conditions:
  ShouldCreateBucket: !Equals [!Ref CreateBucket, true]
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Condition: ShouldCreateBucket
B
Parameters:
  CreateBucket:
    Type: Boolean
Conditions:
  ShouldCreateBucket: !Equals [!Ref CreateBucket, 'true']
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Condition: ShouldCreateBucket
C
Parameters:
  CreateBucket:
    Type: String
    AllowedValues: [yes, no]
Conditions:
  ShouldCreateBucket: !Equals [!Ref CreateBucket, 'true']
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Condition: ShouldCreateBucket
D
Parameters:
  CreateBucket:
    Type: String
    AllowedValues: [true, false]
Conditions:
  ShouldCreateBucket: !Equals [!Ref CreateBucket, 'true']
Resources:
  MyBucket:
    Type: AWS::S3::Bucket
    Condition: ShouldCreateBucket
Attempts:
2 left
💡 Hint

Check the parameter type, allowed values, and how the condition compares the parameter value.

❓ security
advanced
2:00remaining
Identify the security risk in this CloudFormation template snippet

Review the following JSON snippet. What is the main security risk?

{
  "Resources": {
    "MyBucket": {
      "Type": "AWS::S3::Bucket",
      "Properties": {
        "BucketName": "my-public-bucket",
        "AccessControl": "PublicRead"
      }
    }
  }
}
AThe bucket name is not unique, causing deployment failure
BThe AccessControl property is missing, so the bucket is private by default
CThe bucket is publicly readable, exposing data to anyone on the internet
DThe bucket does not have versioning enabled, risking data loss
Attempts:
2 left
💡 Hint

Consider what 'PublicRead' means for an S3 bucket's accessibility.

❓ service_behavior
expert
3:00remaining
Predict the output of a CloudFormation stack update with a changed resource property

Given a CloudFormation template with an AWS::EC2::Instance resource, if you update the template to change the instance type from 't2.micro' to 't3.micro' and then update the stack, what will happen?

ACloudFormation updates the instance type in place without replacement or downtime
BCloudFormation replaces the instance with a new one of type 't3.micro', causing downtime
CCloudFormation fails the update because instance type cannot be changed
DCloudFormation creates a second instance of type 't3.micro' alongside the original
Attempts:
2 left
💡 Hint

Consider how CloudFormation handles changes to properties that require resource replacement.

Practice

(1/5)
1. What is the main purpose of a cloud template written in JSON or YAML?
easy
A. To manually configure cloud resources one by one
B. To write application code for cloud functions
C. To monitor cloud resource usage in real-time
D. To describe and set up cloud resources automatically

Solution

  1. Step 1: Understand what a cloud template does

    A cloud template is a file that describes cloud resources and how to create them automatically.
  2. Step 2: Compare options with this purpose

    Only To describe and set up cloud resources automatically matches this description; others describe different tasks.
  3. Final Answer:

    To describe and set up cloud resources automatically -> Option D
  4. Quick Check:

    Cloud templates automate resource setup = D [OK]
Hint: Templates automate resource setup, not manual or monitoring tasks [OK]
Common Mistakes:
  • Confusing templates with monitoring tools
  • Thinking templates are for writing application code
  • Assuming templates require manual resource setup
2. Which of the following is the correct top-level section name in an AWS CloudFormation JSON template?
easy
A. Resources
B. Scripts
C. Functions
D. Commands

Solution

  1. Step 1: Recall AWS CloudFormation template structure

    The main sections include Parameters, Resources, Outputs, etc. 'Resources' defines the cloud resources.
  2. Step 2: Identify valid section names

    Only 'Resources' is a valid top-level section; others are not used in CloudFormation templates.
  3. Final Answer:

    Resources -> Option A
  4. Quick Check:

    Resources section defines cloud resources = C [OK]
Hint: Remember: Resources section always defines cloud items [OK]
Common Mistakes:
  • Using non-existent sections like Scripts or Commands
  • Confusing function code with template sections
  • Mixing up template sections with programming terms
3. Given this snippet of a CloudFormation JSON template:
{
  "Resources": {
    "MyBucket": {
      "Type": "AWS::S3::Bucket"
    }
  }
}

What resource will this template create?
medium
A. An EC2 virtual server
B. An S3 storage bucket
C. A Lambda function
D. A VPC network

Solution

  1. Step 1: Read the resource type in the template

    The resource type is "AWS::S3::Bucket", which means an S3 storage bucket.
  2. Step 2: Match resource type to options

    Only An S3 storage bucket matches the S3 bucket resource type.
  3. Final Answer:

    An S3 storage bucket -> Option B
  4. Quick Check:

    "AWS::S3::Bucket" means S3 bucket = B [OK]
Hint: Look for "Type" value to identify resource created [OK]
Common Mistakes:
  • Confusing S3 bucket with EC2 or Lambda
  • Ignoring the resource type string
  • Assuming resource names define type
4. You wrote this YAML snippet for a CloudFormation template but it fails to deploy:
Resources:
  MyInstance:
    Type: AWS::EC2::Instance
    Properties:
      ImageId: ami-12345678
      InstanceType: t2.micro
      SecurityGroups: my-security-group

What is the likely error?
medium
A. InstanceType is invalid for EC2
B. ImageId must be a number, not a string
C. SecurityGroups should be a list, not a single string
D. Resources section name is misspelled

Solution

  1. Step 1: Check the SecurityGroups property format

    SecurityGroups expects a list of strings, but here it is a single string.
  2. Step 2: Validate other properties

    ImageId is a string (correct), InstanceType is valid, Resources is spelled correctly.
  3. Final Answer:

    SecurityGroups should be a list, not a single string -> Option C
  4. Quick Check:

    SecurityGroups needs list format = A [OK]
Hint: Lists must be in brackets or dash format in YAML [OK]
Common Mistakes:
  • Using string instead of list for SecurityGroups
  • Assuming ImageId is numeric
  • Misspelling Resources section
5. You want to create a reusable CloudFormation template that accepts a bucket name as input and outputs the bucket ARN. Which two sections must you include in your JSON template?
hard
A. Parameters and Outputs
B. Resources and Scripts
C. Functions and Parameters
D. Outputs and Commands

Solution

  1. Step 1: Identify input and output sections needed

    To accept input like bucket name, use Parameters. To show output like ARN, use Outputs.
  2. Step 2: Confirm other sections are invalid

    Scripts, Functions, Commands are not valid top-level sections in CloudFormation templates.
  3. Final Answer:

    Parameters and Outputs -> Option A
  4. Quick Check:

    Input = Parameters, Output = Outputs [OK]
Hint: Parameters take inputs; Outputs show results [OK]
Common Mistakes:
  • Using non-existent sections like Scripts or Commands
  • Confusing Resources with input/output sections
  • Forgetting to include Outputs for results
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