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",
  InstanceId: ref("Instance")
)
output("IpAddress")

Additionally, we’ll also change the InstanceType from t3.micro to t3.small:

configs/demo/params/development.txt:

InstanceType=t3.small

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 three types of previews:

  1. param diff preview
  2. code diff preview
  3. CloudFormation changeset preview

The lono preview diff compares previously used CloudFormation parameters to the ones about to be deployed. This is helpful to see if you changed things like InstanceType.

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 last type of lono preview leverages the AWS CloudFormation changeset feature. It tells us how resources will change: created, modified, or deleted.

The previews helps to tell you why CloudFormation changeset has detected a change.

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.

Lono Introduction Series