Module #3 Challenge

Sign Up to Build

About this Architecture

Here is some information about this architecture.

How to Build This Solution

Here are the steps you can follow to build this solution on your own.

Congrats on making it this far! We’ve covered a lot of ground. This module was all about working with the CLI. You should now have a better understanding of how to inspect infrastructure state, import infrastructure, manipulate state, and create workspaces.

In this module challenge, your knowledge and skills will be put to the test!

Lab Goal

In this lab you will start off with an AWS account that has existing resources. You will then need to

  • Create a new Terraform project

  • Add the terraform and provider blocks

  • Import some existing resources on your AWS account

  • Inspect your state to make sure it’s correct

  • Delete one of the EC2 instances on your account and then remove it from Terraform

Get Your AWS Credentials

If you're using the Skillmix Labs feature, open the lab settings (the beaker icon) on the right side of the code editor. Then, click the Start Lab button to start hte lab environment.

Wait for the credentials to load. Then run this in the terminal.

Be sure to enter in your own access key and secret key and name your profile 'smx-lab'.

$ aws configure --profile smx-lab
AWS Access Key ID [None]: 
AWS Secret Access Key [None]: 
Default region name [None]: us-west-2
Default output format [None]: 

Note: If you're using your own AWS account you'll need to ensure that you've created and configured a named AWS CLI profile named smx-lab.

Create a Project Directory

You need a directory to create the Terraform files in. Find a good place on your computer to create this directory in. Use your CLI or Command Prompt to navigate to it.

# create the diretory and open it
$ mkdir cli-challenge-lab && cd cli-challenge-lab

Task #1: Create a New Terraform Project and Initialize It

Your first task is to create a new Terraform project in the working directory.

Hint: that means create the first Terraform configuration file and add the terraform and provider blocks

Task #2: Import the Existing EC2 Instances & Security Group

Next, using the lab environment, open the EC2 Console. Find the existing EC2 instances & the Security Group with the name “ImportMe”. Create a Terraform configuration for them. Then, run the Terraform command to import them into your state file.

Task #3: Inspect Your State File

Use the CLI commands that let you inspect state. You should inspect the entire contents of the state file, and inspect each resource one by one.

Task #4: Terminate an Instance & Remove from State

Now, go to the EC2 Console and terminate one of your instances. Then, go to the Terraform CLI and issue the commands to remove the resource from state.