- Lab
- A Cloud Guru
Create a Terraform Configuration for Multi-Cloud Use
In this lab, you will create a multi-cloud Terraform configuration that can deploy an EC2 instance and/or an Azure VM. These instances are the same resource type with the same image (Ubuntu 18.04 LTS). You will use modules, variables, and outputs to accomplish this deployment. You should be able to choose which cloud environment you would like to deploy the resources to and even do the deployment simultaneously. **_Note:_** In order to complete this lab, you will need to spin up an Azure sandbox from our Cloud Playground once the lab starts. Visit [the Cloud Playground](https://learn.acloud.guru/cloud-playground/cloud-sandboxes).
Path Info
Table of Contents
-
Challenge
Create the Terraform Project
In the AWS Console
- Create the AWS access key and secret access key for the
cloud_user
.
In the Terminal
- Configure the AWS CLI with your credentials.
- Configure the Azure CLI.
- Create the
eightbit_studios
directory with amodules
directory containing theaws_instance
andazure_instance
directories. - Create the
providers.tf
file in the Terraform working directoryeightbit_studio
with the AWS and Azure providers. - Initialize the
eightbit_studio
working directory.
- Create the AWS access key and secret access key for the
-
Challenge
Create the AWS Module
- Create the
aws_instance.tf
Terraform configuration file that declares the resources necessary to create multiple EC2 instances in the.modules/aws_instance
directory. - Create the
variables.tf
Terraform configuration file that declares the variables necessary for the AWS module in the.modules/aws_instance
directory. These variables should includeinstances
,subnet
,ami id
, andinstance type
. - Create the
outputs.tf
Terraform configuration file that declares the output necessary to output the AWS instance names for the AWS module in the.modules/aws_instance
directory.
- Create the
-
Challenge
Create the Azure Module
- Create the
azure_instance.tf
Terraform configuration file that declares the resources necessary to create multiple Virtual Machines in the.modules/azure_instance
directory. - Create the
variables.tf
Terraform configuration file that declares the variables necessary for the Azure module in the.modules/azure_instance
directory. These variables should includeinstances
,resource group name
, andresource group location
. - Create the
outputs.tf
Terraform configuration file that declares the output necessary to output the Azure instance names for the Azure module in the.modules/azure_instance
directory.
- Create the
-
Challenge
Create the Root Module
- Create the
main.tf
Terraform configuration file in the8bit_studio
working directory that declares both modules. This root module should be able to pass an enable/disable selector, the number of instances, and the subnet to the AWS module, as well as pass the resource group name and resource group location to the Azure module. - Create the
variables.tf
Terraform configuration file that declares the variables necessary for the root module in the8bit_studio
working directory. These variables should include theenable_aws
andenable_azure
variable for each,instance_count
,aws subnet
, and theAzure resource group name and location
. - Create the
outputs.tf
Terraform configuration file that declares the outputs necessary to output the AWS instance names and the Azure instance names.
- Create the
-
Challenge
Deploy and Verify
- Initialize the Terraform working directory again to pull in the module information.
- Import the Azure resource group into your Terraform state.
- Deploy three EC2 instances to AWS and three VMs to Azure simultaneously.
- Verify that all instances have been deployed.
What's a lab?
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Provided environment for hands-on practice
We will provide the credentials and environment necessary for you to practice right within your browser.
Guided walkthrough
Follow along with the author’s guided walkthrough and build something new in your provided environment!
Did you know?
On average, you retain 75% more of your learning if you get time for practice.