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.
- 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.
1. Log into your personal GitHub and fork this repo.

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.

- On the bottom left click on the >< button to open the remote repositories


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

- Trust the workspace so your extensions work.

- You can clone the repo to your local machine and push the changes remotely.
- Follow these steps on Microsoft Learn
- 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.

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.




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


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


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


- Go to Runs on the left navigation pane.

- On the right side click new run and click plan and apply.

- If your plan errors you need to continue fixing your code.

- If your plan is successful you can go ahead and scroll down and hit confirm to deploy the infrastructure.

- Scroll down to your successful plan and click confirm & apply.

β οΈ This will actually create the resources in AWS.
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