In this lab assignment, you will explore Infrastructure as Code (IAC) using Terraform. You'll build Docker and AWS infrastructures and dive into managing GitHub repositories through Terraform. Additionally, there are bonus tasks to enhance your Terraform skills. Follow the tasks below to complete the lab assignment.
6 Points:
-
You will need a VPN tool for this lab
-
Get Familiar with Terraform:
- Begin by familiarizing yourself with Terraform by reading the introduction and exploring best practices.
-
Set Up Terraform Workspace:
- Create a
terraform
folder to organize your Terraform workspaces. - Inside the
terraform
folder, create a file namedTF.md
.
- Create a
-
Docker Infrastructure Using Terraform:
- Follow the Docker tutorial for building a Docker infrastructure with Terraform.
- Perform the following tasks as instructed in the tutorial:
-
Install Terraform.
-
Build the Infrastructure.
-
Provide the output of the following commands in the
TF.md
file:terraform state show terraform state list
-
Document a part of the log with the applied changes.
-
Utilize input variables to rename your Docker container.
-
Finish the tutorial and provide the output of the
terraform output
command in theTF.md
file.
-
-
AWS Infrastructure Using Terraform:
- Follow the AWS tutorial alongside the instructions from the previous step.
4 Points:
-
GitHub Infrastructure Using Terraform:
- Utilize the GitHub provider for Terraform.
- Create a directory inside the
terraform
folder specifically for managing your GitHub project infrastructure. - Build GitHub infrastructure following a reference like this example. Prepare
.tf
files that include:- Repository name
- Repository description
- Visibility settings
- Default branch
- Branch protection rule for the default branch
- Avoid placing your token as a variable in the code; instead, use an environment variable.
-
Import Existing Repository:
- Use the
terraform import
command to import your existing GitHub repository into your Terraform configuration. Example:terraform import "github_repository.core-course-labs" "core-course-labs"
.
- Use the
-
Apply Terraform Changes:
- Apply changes from your Terraform configuration to your GitHub repository.
-
Document Best Practices:
- Provide Terraform-related best practices that you applied in the
TF.md
file.
- Provide Terraform-related best practices that you applied in the
2.5 Points:
- GitHub Teams Using Terraform:
- Extend your Terraform configuration to add several teams to your GitHub repository, each with different levels of access.
- Apply the changes and ensure they take effect in your GitHub repository.
- Use proper Markdown formatting and structure for documentation files.
- Organize files within the lab folder with suitable naming conventions.
- Create pull requests (PRs) as needed: from your fork to the main branch of this repository, and from your fork's branch to your fork's master branch.
Note: Dive into Terraform to manage infrastructures efficiently. Explore the AWS and Docker tutorials, and don't forget to document your process and best practices in the
TF.md
file.