Deploying a Terraform Module in 5 Minutes
The latest 6.4 release of Cloudify makes it easier than ever to upload your existing Terraform modules into Cloudify. This article will walk you through the simple deployment of an AWS EC2 instance using this improved user experience. You will learn how Cloudify can take existing Terraform and automatically turn it into repeatable, self-service environments for your users.
What You’ll Learn
In the first article of this series, you will learn how to deploy an AWS EC2 instance using Cloudify to run an existing Terraform module. This will be the first article in a multi-part series that will walk you through a concrete journey toward cloud maturity. You will learn to model a simple web application, scale that application using Day 2 operations, and deploy your application using Infrastructure as Code. Each article in this series will cover one step in the journey, so stay tuned!

Prerequisites
You will need a working Cloudify Manager. Please see our documentation for information about installing your Manager.
What Is Cloudify?
Cloudify is a platform that enables you to repeatedly deploy your environments in a self-service way. Cloudify is capable of orchestrating many systems so that you can bring all of your DevOps tools together to deploy full-featured environments.
Let’s start
This article will show you how to deploy a simple Terraform module that provisions a single EC2 instance running Ubuntu 20.04 into a default VPC. All of the source code can be found on GitHub.
If you have worked with Terraform before, this basic module will likely be familiar to you. The main.tf deploys two resources in AWS: a security group to permit SSH and HTTP access, and an EC2 instance. The module also contains input variables and outputs to provide the user with the instance ID and IP address once Terraform has successfully run.
In the rest of this article, you are going to deploy this simple example using Cloudify.
Uploading to Cloudify
If this is your first time logging into a Cloudify Manager, then you will be prompted to configure a cloud provider. Be sure to follow the prompts to add an AWS Access Key ID and AWS Secret Access Key to your Cloudify manager. These credentials will be used by Terraform to authenticate with AWS.

For more information about Cloudify’s built-in secrets store, check out the documentation.
Once your cloud provider secrets have been successfully configured, it’s time to deploy your first Terraform module. Navigate to the Blueprints page, and select Upload > Upload from Terraform module.

The first step in uploading your module is to provide some basic information. Specify a Blueprint name and a Terraform version. Cloudify will automatically download and use the version of Terraform that you specify, making it easy to deploy modules with different version requirements.
The next step is to specify a URL to a zip archive containing the Terraform module. GitHub makes this easy by providing a zip download for every repository. You can find the zip file URL for a repository by opening the repository’s GitHub page and selecting Code > Download ZIP.
In this case, you can specify the URL to the zip file in Cloudify’s example repository: https://github.com/acritelli/cfy-blog-instance/archive/refs/heads/main.zip

Next, you can specify the variables used by Terraform. Cloudify will automatically detect the variables for you, and you can further customize them in three ways:
- As an input, which prompts the user when they create a deployment
- As a secret, which automatically pulls the value from Cloudify’s internal secret store
- As a static input, which statically defines a value for the variable
In this example, there are several variables that we want to accept user input for. The user should be able to input an instance_type, instance_name, region, and ssh_keypair. The credentials used by Terraform (aws_access_key and aws_secret_key) will come from the secret store. These are the credentials that you configured when you first logged into your Cloudify Manager.

The final step is to configure any Terraform outputs. Like variables, Cloudify will also automatically detect any outputs in your Terraform module. There are two types of outputs in Cloudify: outputs and capabilities. A capability allows you to expose an aspect of a deployment in a way that can be consumed by other deployments. This allows you to build entire environments out of reusable components. A complete discussion of outputs and capabilities is beyond the scope of this article, but we will set the Output type to Capability for this series.

Once you have defined all of your variables and outputs, simply click Create and Cloudify will handle the rest.
Creating a Deployment
At this point, Cloudify has automatically created a blueprint that you can use to create repeatable deployments. The next step is to create a deployment to see firsthand how this works.
Click on the rocket icon next to your newly created blueprint:

You will be prompted with the deployment creation form. Many of these fields will look very familiar: they are the inputs to your Terraform module! Simply provide a Deployment name and fill in all of the appropriate inputs. When you’re done, click Install and then Execute on the next page.

Cloudify will now begin taking all of the necessary steps to turn your blueprint into a fully deployed environment. This includes installing the correct version of Terraform, downloading your Terraform module, and then executing the necessary Terraform workflows (e.g., terraform apply).
The deployment information page provides all of the relevant details on a single screen. You can see the Execution Task Graph, which displays the exact series and order of steps that Cloudify takes to convert the declarative blueprint into an actual deployment. If anything goes wrong, you can take a look at the Deployment Events/Logs to troubleshoot and resolve any issues.

Once the deployment is done installing, you can find all of the information that you need on the Deployment Info page. This page has a variety of important information about your deployment, but the most important information for our purposes is the Deployment Outputs/ Capabilities section. This should also look familiar: it displays the Terraform outputs that you defined earlier!
At this point, you can try to log into your EC2 instance using the “ubuntu” user and the SSH keypair name that you specified during deployment. Once you have that working, feel free to create another deployment from the same blueprint to see how Cloudify makes it easy to deploy repeatable environments, with just the click of a button.

Cleaning Up
You have seen how easy it is to create repeatable deployments with Cloudify. However, Cloudify is far from just a deployment tool. It provides full lifecycle management of complex environments.This includes deployment, Day 2 Operations (such as scaling), and decommissioning. A future article in this series will cover Day 2 Operations, but for now you need to clean up the resources that you have deployed into AWS.
Open up the page for your deployment, and select Deployment actions > Uninstall. The uninstall process will start, and you will see an Execution Task Graph that shows the status of each step, just like with the installation process. Once again, if anything goes wrong, Cloudify has the logs and information to help you troubleshoot.
Once the uninstallation process completes, you can delete the deployment by selecting Deployment actions > Delete.

Wrapping Up
This article showed you how easy it is to take existing Terraform modules and turn them into Cloudify blueprints using the latest features in Cloudify 6.4. Cloudify has a rich DSL that provides a wide range of features, but you don’t need to be an expert to get started. In the next article of this series, you will learn how to extend the automatically created blueprint to configure an EC2 instance with Ansible. Stay tuned!
You may want to read more about: