cloudsoft.io

Composing your First Template

Objectives

In this tutorial we will show you how to compose your first CloudFormation template. We will start with an extremely simple template, with a single EC2 instance.

Pre-requisites

This tutorial assumes you have a running instance, and have successfully logged into the instance from your browser.

Instructions

From the home page, click on Open CloudFormation Composer with blank canvas:

CFN Export - home page

The CFN Composer has 4 main parts:

  • The canvas: this is where is displayed the graphical representation of the CloudFormation template you are creating.
  • The palette: that is the box on the left containing AWS resources that can be dragged onto the canvas.
  • The editor: appears on the right when an item is selected. It allows the currently selected item to be edited.
  • The toolbar: this is the bar at the top which contains different composition modes and actions which can be taken with the template.

CFN Composer - palette

Choose from the palette your desired type of resource. To see the full list click the “Clear filters” button. (To view all the filters click the cog icon at the left of the search field). Browse through the catalog, or search for your chosen resource type.

Tip: 'search' will look for any resource mentioning the given text, including in its description. The most specific search term to use is the resource type, such as 'aws::ec2::instance'.

To add a resource either drag it onto the canvas or click it and select “Add to application”. When the item in the canvas is selected, the editor will appear and show the resource’s configuration.

CFN Composer - resource config

Click on a given configuration option to enter a value for that property on the resource.

Tip: the default list shows mandatory configuration, those options that have been set, and commonly used options. To change what is listed, click on the 'Filter configuration' icon at the top of the configuration section (e.g. to tick 'All').

Fill in all the desired configuration.

CFN Composer - resource populated config

Click the ‘Generate CloudFormation’ button to generate the CloudFormation template (which will save it to a local file).

For example, the graphical template shown above will generate:

---
AWSTemplateFormatVersion: "2010-09-09"
Description: "Application CloudFormation exported from Cloudsoft AMP"
Parameters: {}
Mappings: {}
Resources:
  AWSEC2Instance:
    Type: "AWS::EC2::Instance"
    Properties:
      ImageId: "ami-050a9a424ea2b9bef"
      InstanceType: "t3.small"
      SubnetId: "subnet-32eaa857"
      SecurityGroups:
      - "sg-08a4a56af8924486f"
      KeyName: "tutorial-example-keypair"
      Tags:
      - Key: "Name"
        Value: "Tutorial Example VM"
Outputs: {}
Tip: if there is an error, such as missing mandatory configuration, this will show as a red circle around the resource in the palette, and red against the invalid configuration (e.g. saying 'CidrBlock is required'). Some other errors may only be detected when the 'Export CFN' button is clicked, in which case a notification message will appear, explaining the problem.