Here is some information about this architecture.
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!
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
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.
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
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
andprovider
blocks
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.
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.
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.