Skip to content

Latest commit

 

History

History
77 lines (54 loc) · 3.75 KB

lab4.md

File metadata and controls

77 lines (54 loc) · 3.75 KB

Lab 4: Infrastructure as Code Lab

Overview

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.

Task 1: Introduction to Terraform

6 Points:

  1. You will need a VPN tool for this lab

  2. Get Familiar with Terraform:

  3. Set Up Terraform Workspace:

    • Create a terraform folder to organize your Terraform workspaces.
    • Inside the terraform folder, create a file named TF.md.
  4. 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 the TF.md file.

  5. AWS Infrastructure Using Terraform:

    • Follow the AWS tutorial alongside the instructions from the previous step.

Task 2: Terraform for GitHub

4 Points:

  1. 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.
  2. 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".
  3. Apply Terraform Changes:

    • Apply changes from your Terraform configuration to your GitHub repository.
  4. Document Best Practices:

    • Provide Terraform-related best practices that you applied in the TF.md file.

Bonus Task: Adding Teams

2.5 Points:

  1. 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.

Guidelines

  • 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.