Lono CloudFormation Framework Introduction Part 2: EC2, EIP, and Previews
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:
- param diff preview
- code diff preview
- 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
Thanks for reading this far. If you found this article useful, I'd really appreciate it if you share this article so others can find it too! Thanks 😁 Also follow me on Twitter.
Got questions? Check out BoltOps.
You might also like
More tools:
-
Kubes
Kubes: Kubernetes Deployment Tool
Kubes is a Kubernetes Deployment Tool. It builds the docker image, creates the Kubernetes YAML, and runs kubectl apply. It automates the deployment process and saves you precious finger-typing energy.
-
Jets
Jets: The Ruby Serverless Framework
Ruby on Jets allows you to create and deploy serverless services with ease, and to seamlessly glue AWS services together with the most beautiful dynamic language: Ruby. It includes everything you need to build an API and deploy it to AWS Lambda. Jets leverages the power of Ruby to make serverless joyful for everyone.
-
Lono
Lono: The CloudFormation Framework
Building infrastructure-as-code is challenging. Lono makes it much easier and fun. It includes everything you need to manage and deploy infrastructure-as-code.