AWS Cloud Formation-Create, Edit, and deploy
AWS Cloud Formation (CF) is a service that allows Enterprises to manage their infrastructure as code. The CF templates are easy to read in both JSON, or the recently supported YAML data serialization language.
You can use your favorite JSON editor to create, and edit templates, and then upload them to your AWS CF Service to use in creating a stack.
Vi, Notepad++, Sublime, Atom, are some of the well known JSON editors, but if you need more than that, such as the ability to validate JSON syntax, as well as deploy your stack from the editor, then I would recommend Eclipse Java EE IDE with AWS toolkit.
Please follow these steps to get your IDE installed and configured:
1- Download Eclipse: Eclipse Neon 64 bit download
2- Choose the Eclipse Java EE IDE
3- Create your workspace, this is the directory where your projects are going to be saved.
4- Launch the Eclipse Marketplace, search for AWS, then install the AWS toolkit for Eclipse 2.0
5- Configure connection to your AWS account , by adding your IAM user Access key and secret access key:
You can retrieve the account keys from your IAM console by click in the account name, and click on “create access key” under the “Security Credentials “tab.
6- Your Eclipse for Java with AWS toolkit should be setup, and connected to your AWS account. You should be able to see any EC2 instances, EBS volumes, S3 buckets, and other resources you have configured.
But make sure you have the correct region selected first.
7- Click on Cloud Formation under the Java “src” folder, and you will see stacks that you have created.
Double click on your stack to open it.
If your stack doesn’t open the first time, close eclipse, reopen it, then try to launch your stack again.
If you have worked with Eclipse before, you would know about these quirks, and that every now and then, you will have to change your workspace.
8- Tips from Amazon AWS site:
- Only files that end in .template can be launched from the Eclipse IDE. If your file ends with another extension, such as .json, you will need to rename it first with a .template extension to use this feature.
- Right click on template editor, and click validate
- Your template will be validated for JSON correctness only; it will not be validated for CloudFormation correctness. A stack template validated in this way can still fail to launch or update.
9- If you don’t have any CF stacks created, you can create one by clicking on “New AWS Java Project”. (Click on the Amazon Icon on the tool bar to get the menu)
Choose AWS CF sample
9- Alternatively, you can start your template using CF builder in your AWS CF console, save it as a “.template” file, and drag and drop it under your cloud formation menu in Eclipse.
Once you create your stack with the CF designer in the AWS console, save it to your local storage, and then load it into your eclipse in order to add parameters to your resources, finalize it, and run it.
Eclipse is by no means perfect, since I think that the JSON validation is not good enough, and that it should also validate CF syntax. I am also trying to figure out, curly braces highlighting, so I know where is the closing brace without having to count. I checked the project’s GitHub repository, and someone has already put in a feature request for that.
I think it will just get better from here, I am impressed with what the AWS toolkit has to offer, and looking forward to learning more.
In the next blog, I will write about creating a CF template to deploy a stack from Eclipse.