In the previous article Running Terraform with Cloudify Part 1 we have covered how to create a blueprint for a dedicated Terraform template.
What You’ll learn
In this article we will create a generic blueprint. The blueprint receives the inputs Terraform version, the URL/Git path, variables and environment variables.
You can always adjust the blueprints to your need. For example if you are using private repo (one of the examples from Part1), you can add user and password inputs.
You’ll need to have the following setup on you development machine.
Git — To work with our tutorial examples
Python 3.7 — To run Cloudify CLI (cfy)
Docker — To run Cloudify Manager container
AWS access key id and secret access key with permissions to create and delete EC2 instances. You can follow the AWS documentation on how to get those in the link
What is Cloudify?
Cloudify is an orchestration tool that can do many things.
In our current example I’ll walk you step by with the best practices on what is required to spin an EC2 instance.
We will create a simple blueprint file that describes how EC2 instance should be created and upload it to Cloudify Manager.
To spin an EC2 instance we will created and install a deployment. As part of it Cloudify Manager will connect to AWS and create an EC2 instance as described in the blueprint.
Cloudify Installation: Running locally Cloudify Manager is very easy. You’ll need to install locally on your machine docker and run on it Cloudify Manager Community edition container.
To run Cloudify Manager Community edition simply run the following command. You might wait some time until the application is fully up and running
sudo docker run --name cfy_manager_local -d --restart unless-stopped -v /sys/fs/cgroup:/sys/fs/cgroup:ro --tmpfs /run --tmpfs /run/lock --security-opt seccomp:unconfined --cap-add SYS_ADMIN -p 80:80 -p 8000:8000 cloudifyplatform/community-cloudify-manager-aio:latest
Congratulations now you can browse to
http://localhost and login with default user and password
Cloudify CLI installation
You have two ways to work with Cloudify Manager. You can work either with UI or CLI. In this article we will work CLI.
To install Cloudify CLI run the following command:
pip install cloudify==6.1.0
Before we start we need to install AWS and Utilities Plugin
To simplify let’s upload all supported plugins
cfy plugins bundle-upload
Let’s first walk through what we is the blueprint objective.
The blueprint receives the Terraform version. The Terraform binary URL will be calculated based on it.
The Terraform also requires variables and environment variables that should be filled during the deployment creation.
Now when we are aware of what the blueprint does let’s deep dive.
There are 5 inputs:
terraform_version— The terraform version to be used. The default version is 0.13.0 but other version can be provided as well.
module_location— The URL to
.gitrepository, the input doesn’t have a default value and it’s marked as required. Therefor it must be provided when running the blueprint.
terraform_template_location— if the terraform template to be executed is in the root directory use the default value, In case it’s in a directory provide the relative path to it.
variables— is a key, value dictionary, the expected key is the variable name and the value is the value to be passed
environment_variables— same as the variables but for the environment variables
Terraform node type
The Terraform binary path is calculated based on the selected version. It’s concatination
_linux_amd64.zip e.g if you use the default value
0.13.0 the URL will be
The rest of the inputs,
variable , and
environment_variables will be injected directly
let’s checkout the example and run it.
git clone email@example.com:cloudify-community/cloudify-tutorial.git
The directory contains two files.
blueprint.yaml is the file we have described above.
inputs.yaml is the file that contains the values for the blueprint‘s inputs.
inputs.yaml have the following structure
If you haven’t set up secrets for your AWS account yet run the following command:
cfy secrets create YOUR_ACCESS_KEY_ID aws_access_key_id
cfy secrets create YOUR_AWS_SECRET_ACCESS_KEY aws_secret_access_key
Now we are ready to apply the changes
cfy apply -i inputs.yaml