Challenge 1: Bootstrapping

Next Challenge

Introduction

In this challenge we’ll set up a few prerequisites for the hack. Since we’ll be working in a team, we’ll need to share the assets with each other and keep track of the changes. For that purpose we’ll create and configure a Git version control system. In addition, Terraform needs to store its state somewhere. By default it does that on the local file system, but that’s not practical if multiple people would need access to the same state. So, we’ll have to configure a remote backend.

Description

For this challenge you could use any external Git repository (Github/Bitbucket/Gitlab etc.), however the easiest option is to use a Cloud Source Repository on GCP. We’ve already created a Cloud Source Repository with the name iac-with-tf in your project. Create an SSH key and register that with your Cloud Source Repository (everyone on the team should complete this task).

We’ve prepared a sample project for you, download it and extract the contents. Make sure that code is pushed to the external repository.

Create a new bucket to hold the Terraform state using best practices and configure Terraform to use that as the backend.

Note
For the sake of simplicity we’ll stick to a single environment for this challenge. But in real world you’ll probably have to deal with multiple environments (dev/test/acc/prod) and might need to track the state for these environments separately.

Success Criteria

  1. There’s a new bucket for the Terraform state following best practices
  2. Terraform is configured to use that bucket as the backend
  3. All of this configuration is in the Cloud Source Repository

Learning Resources

Tips

  • You’ll need a CLI environment to run Git and Terraform commands, Cloud Shell has all of that pre-installed

Next Challenge