AWS CloudFormation and Interactive inputs

Girish V P
Tensult Blogs
Published in
3 min readAug 10, 2018

This Blog has moved from Medium to blogs.tensult.com. All the latest content will be available there. Subscribe to our newsletter to stay updated.

AWS CloudFormation allows providing required resources in your cloud environment using the set of commands stored in the Cloud Formation templates. It stores the infrastructure as code and can be reused by changing or without changing it. This document focus on how user interactive inputs are fulfilled by Cloud Formation Templates. Normally, an Interactive program input can be text box, drop-down list, selection boxes with multiple inputs, a restricted set of values, etc. For newly created objects, say S3 bucket, it makes sense a text box which the user inputs the name of a new S3 bucket. A drop down list is recommended for an EC2 .pem key since you can attach only one key with one instance. But for a Security group case is different, multiple security groups can be attached to a single EC2 instance. So we prefer a selection box with multiple values. When you want to restrict user’s selection to t2.micro or t2.small when cloud formation triggers action, it is a subset of values you may have to consider.

I have written below a template which prompts following user controls for the inputs when a Cloud Formation stack is executed out of it.

  • A text box to input the name of S3 bucket to be created.
  • List box asking for names (multiple)of security groups.
  • Drop down list which selects an existing EC2 .pem key.
  • Subset of EC2 instance types.

Configuration

  1. The Code is written in such a way that Resources like S3Bucket and EC2Machine are calling the Parameters like Security Group, KeyName etc within the Template. This file is stored locally and has to be uploaded when Cloud Formation stack is created. I have created a file with name cf-ec2–7.txt.

2) See the screenshot with the breakup of the above code with some references.

3) You have to create a new stack from the Cloud Formation service of AWS web console.

4) Up load, the file you have created to S3 bucket as prompted below

5) When you click Next you can see it prompts for user input based on code you have written above.

6) Go ahead with the creation and execution of the stack. Now you test and make sure that all resources are created based on your inputs from Cloud Formation console.

Conclusion

AWS CloudFormation can automate the provisioning of the resources in the cloud environment using Cloud Formation templates. We have created here a template that prompts for the user input like text boxes, dropdown list, etc.

--

--