Skip to content

This repo is a code challenge with two branches. The main branch has some Terraform that needs to be completed / fixed. The solution is in the fixed branch.

Notifications You must be signed in to change notification settings

tkerbe2/iac-intro-challenge-1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

39 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

tkdev_space_200


πŸ› οΈ Challenge 1 - Fix and deploy Terraform to AWS

Welcome to your first challenge! In this challenge you will put yourself in the role of a DevOps professional who has been given this code from a colleague. Your colleague is trying to deploy a simple EC2 instance to AWS that they can SSH into and run some tests. Your colleague has given you this code and mentioned that they're not very experienced with Terraform and need some help. I've left parts of this code blank and expect you to use your current knowledge, existing course material, and resources such as the Terraform Registry to make some simple fixes and deploy it. When you're finished or you have gotten stuck - the "fixed" branch of this repo has the correct working code.

High-Level Steps

  • Log into your personal GitHub.
  • Fork this repo to your own personal GitHub.
  • Clone the repo to your local machine.
  • Open the it with Visual Studio Code.
  • Look for comments marked by a #.
  • Make the necessary fixes to the code.
  • Commit your code changes.
  • Open HCP Terraform and create a new workspace under workspaces.
  • Set variables.
  • Perform a plan and apply.
  • Deploy your code.
  • Verify resources in the AWS Console.
  • (Optional) Add an SSH allow policy to the EC2 instance security group.
  • (Optional) Log into the EC2 instance.

🏁 When ready start challenge walk-through here


GitHub and Visual Studio Code Steps

1. Log into your personal GitHub and fork this repo.

image

2. On your local machine open the code.

You can access and modify this code how you want. Ultimately all that matters is the changes get pushed to your GitHub repo.

  • You can open this code remotely in Visual Studio Code (which is what I am doing in this walk-through).
  • In Visual Studio Code you will want the Remote Repositories extension.
image
  • On the bottom left click on the >< button to open the remote repositories

image
image
  • You may need to sign into GitHub and authorize it for this to work first if you didn't do that already.

image
  • Trust the workspace so your extensions work.

image

OR




3. πŸ›‘ Fix the code!

  • Look for commented code and start finding solutions. This is where you actually will be spending a majority of your time in this challenge. Use your resources and other lab material!
  • Remeber you're role playing as a DevOps Engineer and your colleague has given you some unfinished code. Read their comments and try to fix it so that you can deploy it using HCP Terraform.
  • Once you're ready and believe you've fixed the code you can proceed.


4. Commit and Push your changes.

image

HCP Terraform Steps

When you're finished modifying your code and think you have the right solution, you can test it with HCP Terraform. These next steps will walk your through this process.



1. Log into the HCP Terraform web console.

image
image

2. Select a project or use the default.

image

3. Select Version Control Workflow.

image

4. Click on GitHub and choose a repo. (You may have to log into and authenticate to GitHub first to allow this)

image

5. Give it a name and click create.

image

6. Go to the new workspace overview and click on the Configure variables button. Alternatively you can just click on variables.

image
image

7. Create two new workspace env variables for AWS.

We learned how to create and obtain these in the following course section: Setup a new AWS account - Guided Lab

image image

8. Perform a plan and apply.

  • Go to Runs on the left navigation pane.
image
  • On the right side click new run and click plan and apply.
image

9. Plan results.

  • If your plan errors you need to continue fixing your code.
image
  • If your plan is successful you can go ahead and scroll down and hit confirm to deploy the infrastructure.
image

10. Apply your plan.

  • Scroll down to your successful plan and click confirm & apply.
image
  • ⚠️ This will actually create the resources in AWS.


πŸ”‘ Testing and Solution

You will want to log into the AWS web console and look for your resources in VPC and EC2 services.

If you're having any issues at all and want to see the solution or think you're ready to grade yourself proceed to the solution page: Challenge 1 Solution

About

This repo is a code challenge with two branches. The main branch has some Terraform that needs to be completed / fixed. The solution is in the fixed branch.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages