Course contentsShow
← Cloud and Infrastructure
Lesson 849 of 2,98916. AWS CloudFormationFree lesson

Resource Declaration Syntax

Learn how to declare AWS resources in templates with Type, Properties, and logical IDs.

Resource Declaration Syntax

What you'll learn: How to properly declare AWS resources in CloudFormation templates using Type, Properties, and logical IDs.

The Core Structure

Every AWS resource you create in CloudFormation follows a consistent syntax pattern. Think of it like filling out a form: you need to give your resource a name (logical ID), specify what kind of resource it is (Type), and provide the details about how to configure it (Properties).

The Three Essential Components

Logical ID

This is the unique name you choose to identify the resource within your template. It's like a nickname you'll use to reference this resource elsewhere. For example: MyWebServer or AppDatabase.

Type

This declares what AWS service and resource you're creating. It always follows the pattern AWS::Service::Resource. For example:

  • AWS::EC2::Instance for an EC2 instance
  • AWS::S3::Bucket for an S3 bucket
  • AWS::RDS::DBInstance for a database

Properties

These are the specific configuration settings for your resource—like instance size, bucket name, or database engine. Each resource type has its own set of available properties.

Basic Syntax Example

Resources:
  MyLogicalID:
    Type: AWS::S3::Bucket
    Properties:
      BucketName: my-unique-bucket-name

In this example:

  • MyLogicalID is the logical ID
  • AWS::S3::Bucket is the Type
  • BucketName is a Property of the bucket

All resource declarations go under the Resources: section of your template.

Key Takeaway: Every CloudFormation resource requires a logical ID (your custom name), a Type (the AWS resource type), and Properties (configuration details)—this three-part structure is the foundation of infrastructure-as-code with CloudFormation.