Resource

The resource method maps to the CloudFormation Template Anatomy Resources section.

Example Snippets

# short form
resource("Instance", "AWS::EC2::Instance",
  instance_type: ref("InstanceType"),
  image_id: ref("ImageId"),
)

# medium form
resource("SecurityGroup",
  type: "AWS::EC2::SecurityGroup",
  properties: {
    group_description: "demo security group"
  }
)

# long form
resource("SnsTopic" => {
  type: "AWS::SNS::Topic",
  properties: {
    description: "my topic desc",
    display_name: "my topic name",
  }
})

Example Outputs

Resources:
  Instance:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType:
        Ref: InstanceType
      ImageId:
        Ref: ImageId
  SecurityGroup:
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: demo security group
  SnsTopic:
    Type: AWS::SNS::Topic
    Properties:
      Description: my topic desc
      DisplayName: my topic name

Back to DSL List Docs.

Pro tip: Use the <- and -> arrow keys to move back and forward.

Edit this page

See a typo or an error? You can improve this page. This website is available on GitHub and contributions are encouraged and welcomed. We love pull requests from you!