cloudsoft.io

Saving and composing with the Library

This tutorial will walk you through creating a fairly simple reusable component, and configure some of the commonly-used items. This component is called a blueprint and will be saved to the local library catalog so we can re-use it.

A reusable AutoScaling Group component

We’re going to define an auto-scaling group of EC2 instances which will run a simple web server. The server is going to be set up using user data to display a welcome page. In a later tutorial, we’ll reuse this group and add an Elastic Load Balancer to access it.

On the home page of Visual Composer, click on the button “Open CloudFormation Composer with a blank canvas”. It opens the composer and shows a canvas containing a single item captioned “New Application”. Start by dragging an “AWS AutoScaling Group” from the palette onto the “New Application”.

Tip: if you use the filters, which are accessed by clicking on the cog icon on the left of the search box, this becomes easy to find; alternatively type into the palette's search box "AutoScalingGroup".

A panel will appear on the right of the canvas to show the properties of the newly added AutoScaling Group.

Tip: click on the entity in the canvas to view and edit its properties.

This “AWS AutoScaling Group” has all the properties of that CloudFormation resource. If you’re familiar with CloudFormation, you can add a Launch Configuration (from the palette) and refer to it.

However, in this tutorial we will use a simplified way to set the Launch Configuration: we will use the extra configuration option, named “Member spec”, to define that the Auto-Scaling Group will provision EC2 instances when scaling. We will do all of this within the Auto-Scaling Group’s configuration.

Tip: to see all of the properties, change the Configuration section's filter to 'All'.

Setting an ASG spec

We’re going to configure the “Member spec” to be an EC2 instance. Under the covers, the AWS::AutoScaling::LaunchConfiguration and AWS:EC2:Instance configuration are very similar. Therefore the graphical composer allows you to define the “members” of the group as EC2 instances. When we generate the CloudFormation template, it will produce the multiple resources required, including the Launch Configuration.

Initially the member spec field will show “(no spec set)”. Click on that text to open a new palette where you can search for the item to be used as the spec. <div class="alert alert-info"> Tip: Hovering over the “i” circle on a palette item will show more information on it.) Find and select an “EC2 Instance”. </div>

Editing the EC2 Instance

Configuring an EC2 Instance

The EC2 Instance is now selected in the canvas and you can edit its properties. Set the following values:

  • Image ID: ami-467ca739 (the Amazon Linux AMI) is a good choice in us-east-1, but you can use any AMI you like; type Amazon Linux and a suggested AMI should show up in the dropdown.
  • Instance Type: t3.micro is suggested for this demo.
  • Security Groups: select an existing security group that allows access from items in the security group to port 8080; it can allow wider access but that is the minimal required. This will secure the instances so later only the load-balancer can access it. You may need to create this security group from the AWS console - ensure you create it in the same VPC as where the VMs will be. (It can be created as part of this CloudFormation template but to keep things simple we are skipping this.)
  • User Data (plain text): this provides a way that a script can be run on the server when it boots. It will be encoded correctly for CloudFormation (i.e. the lines joined, and Base64 encoded). There is also the option to provide Base64 content. This option is not shown by default: to show it, click the filter icon at the top of the configuration properties and select ‘all’. This composer also allows supplying JSON/YAML values as described under Tips. For this demo, enter the following, which creates a very simple web site:

    #!/bin/bash -xe
    mkdir site ; cd site
    echo Hello world. > index.html
    nohup python -m SimpleHTTPServer 8080 &
    

    Edit the message if you wish.

Your EC2 Instance configuration is now complete.

Configuring an AutoScaling Group

Now click on the AutoScaling Group to configure its other settings:

  • Min Size: 2 (increase this so we have more redundancy)
  • Max Size: 4 (a value for this is always required; we’re not expecting much traffic here though!)
  • Desired Capacity: 3 (or leave blank to use “Min Size”)
  • VPC Zone Identifiers (Subnet IDs): choose at least two subnets in the same VPC, ideally corresponding to different availabililty zones, as this is where the ASG will create its instances

ASG Configuration

Saving

Now you’re done configuring this resource, you can save it to the local library catalog. Click the “Save to Library” button at the bottom right of the page. A pop up window appears, prompting you to enter metadata which will be kept in the local library for using this blueprint later. Enter the following:

  • Blueprint display name: Tutorial: AutoScaling Bundle.
  • Blueprint description: You can leave this blank for the tutorial. In general, this field is used to explain what the blueprint does and when to use it.
  • Version: 1.0. If you change and and again save the blueprint, it will require you to increase the version number. Alternatively, include the suffix “SNAPSHOT”, such as 0.1.0-SNAPSHOT, to be able to overwrite an existing version.

You do not need to edit any of the “Advanced” options, but for reference they are:

  • Bundle ID: The blueprint is saved in the local library as a ZIP (in fact an OSGi bundle) with an ID to access it. Items created in this composer will only have one item, so the ZIP is automatically created and the ID is inferred from the blueprint display name. Because this uses Cloudsoft AMP, however, a folder on the filesystem can be ZIPped up and installed, containing many blueprints and bundled with script and properties files used in these blueprints.

  • Blueprint symbolic name: The blueprint has an ID within the bundle, which is used to reference this blueprint in other blueprints. As here there is only one item, the symbolic name is inferred.

  • Blueprint type: There are three options, with the default, “Application entity”, being the most common. The (i) icon will give more information on the other options.

  • Blueprint icon URL: Provide the URL to an image if you want your item to have an icon. For example: https://upload.wikimedia.org/wikipedia/commons/thumb/5/53/Server-multiple.svg/848px-Server-multiple.svg.png

Once the name and version are set, and any other fields you want to change, click “Save” to make your blueprint available on the palette and in the local library catalog.

ASG Save

Saving blueprints makes them available as reusable building blocks when composing new blueprints. This decreases duplication, and also makes blueprint authoring more manageable by splitting it up into bite-sized pieces. These pieces can also be maintained and updated independently. It also allows best practices to be captured in the saved blueprints, so that other blueprints can re-use it with the guarantee that these best practices are being followed every time.

After you save, click to create a new blueprint, and proceed to the next tutorial.