In the last article, we launched a security group and instance. In this post, we’ll add an Elastic IP address and associate it with the instance. Add the following code:

blueprints/demo/app/templates/ec2.rb:

resource("IpAddress", "AWS::EC2::EIP",
  instance_id: ref("Instance")
)
output("IpAddress")

To deploy the changes, use lono cfn deploy.

lono cfn deploy demo

Note: Source Code for this tutorial is available at: tongueroo/lono-cloudformation-examples

Previews

The first thing you’ll notice about deploying new changes is that lono prompts you with a preview of the changes. Interestingly, Lono provides two types of previews: 1) lono code diff and 2) CloudFormation changeset.

The lono code diff is what it sounds like: it’s a diff of the currently deployed template vs. the template about to be deployed. The code diff helps confirm that code changes are what you expect.

The second type of lono preview leverages the AWS CloudFormation changeset feature. It tells us how resources will change: created, modified, or deleted.

Update

After confirming yes to the changes, lono rolls them out. You’ll see something like this.

Here’s the CloudFormation Console Resources for the deployed stack.

And the stack outputs. The EIP has been added.

For good measure, we’ll also check via the EC2 Console.

Summary

In this post, we added an EIP to an EC2 instance. In doing this task, we learn how to update a CloudFormation stack and how lono provides helpful previews of what will change. Lono combines the create and update commands to a unified lono cfn deploy command. Overall there’s a lot more power to lono. This was just a quick introduction to updating a stack. In the next post, we’ll cover how to customize the templates with lono configs.

Prebuilt CloudFormation Templates

You may be interested in BoltOps Pro blueprints. Blueprints are essentially CloudFormation templates packaged up in a convenient and reusable way. The BoltOps Pro subscription gives you access to all the blueprints in the BoltOps Pro GitHub organization. Just configure, deploy, and run.

Also, if there is a blueprint you would like to see in the future. Please feel free to send us your suggestions: Pro Blueprint Suggestion.

Posts in This Series