Code Monkey home page Code Monkey logo

devops-directive-terraform-course's Introduction

DevOps Directive Terraform Course

This is the companion repo to: Complete Terraform Course - From BEGINNER to PRO! (Learn Infrastructure as Code)

thumbnail

01 - Evolution of Cloud + Infrastructure as Code

High level overview of the evolution of cloud computing and infrastructure as code.

This module does not have any corresponding code.

02 - Overview + Setup

Terraform overview and setup instructions.

Includes basic hello world terraform config to provision a single AWS EC2 instance.

03 - Basics

Covers main usage pattern, setting up remote backends (where the terraform state is stored) using terraform Cloud and AWS, and provides a naive implementation of a web application architecture.

04 - Variables and Outputs

Introduces the concepts of variables which enable Terraform configurations to be flexible and composable. Refactors web application to use these features.

05 - Language Features

Describes additional features of the Hashicorp Configuration Language (HCL).

06 - Organization and Modules

Demonstrates how to structure terraform code into reuseable modules and how to instantiate/configure modules.

07 - Managing Multiple Environments

Shows two methods for managing multiple environments (e.g. dev/staging/prodution) with Terraform.

08 - Testing

Explains different types of testing (manual + automated) for Terraform modules and configurations.

09 - Developer Workflows + CI/CD

Covers how teams can work together with Terraform and how to set up CI/CD pipelines to keep infrastructure environments up to date.

devops-directive-terraform-course's People

Contributors

lachlanmulcahy avatar sidpalas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

devops-directive-terraform-course's Issues

Error applying the tf template in 02-Overview exercise

It seems there are missing the definitions of VPC and Subnet resources in the template, because the executing fails as you can see the in the snippet below:

aws_instance.example: Creating...
Error: Error launching source instance: VPCIdNotSpecified: No default VPC for this user. GroupName is only supported for EC2-Classic and default VPC.     status code: 400, request id: ef9266e7-f56a-44fd-b0b3-65cf029252fc
 
with aws_instance.example,
on main.tf line 14, in resource "aws_instance" "example":
14: resource "aws_instance" "example" {

As workaround, I have added the required resources manually.

Remote backend setup issues in 03-basics

The path to the key is not clear as the directory "03-basics/import-bootstrap/terraform.tfstate" does not exist during the aws bootstrap process:

terraform {
  #############################################################
  ## AFTER RUNNING TERRAFORM APPLY (WITH LOCAL BACKEND)
  ## YOU WILL UNCOMMENT THIS CODE THEN RERUN TERRAFORM INIT
  ## TO SWITCH FROM LOCAL BACKEND TO REMOTE AWS BACKEND
  #############################################################
  # backend "s3" {
  #   bucket         = "devops-directive-tf-state" # REPLACE WITH YOUR BUCKET NAME
  #   key            = "03-basics/import-bootstrap/terraform.tfstate"
  #   region         = "us-east-1"
  #   dynamodb_table = "terraform-state-locking"
  #   encrypt        = true
  # }

...

If we use the locally stored terraform.tfstate file while in the path 03-basics/aws-backend we can successfully create the remote s3 backend:

03-basics/aws-backend/ $ cat main.tf 
terraform {
  #############################################################
  ## AFTER RUNNING TERRAFORM APPLY (WITH LOCAL BACKEND)
  ## YOU WILL UNCOMMENT THIS CODE THEN RERUN TERRAFORM INIT
  ## TO SWITCH FROM LOCAL BACKEND TO REMOTE AWS BACKEND
  #############################################################
  # backend "s3" {
  #   bucket         = "devops-directive-tf-state" # REPLACE WITH YOUR BUCKET NAME
  #   key            = "terraform.tfstate"
  #   region         = "us-east-1"
  #   dynamodb_table = "terraform-state-locking"
  #   encrypt        = true
  # }

...
03-basics/aws-backend/ $ terraform init
03-basics/aws-backend/ $ terraform plan
03-basics/aws-backend/ $ terraform apply

# This works! 
  

Then the problem is how to use the aws-backend terraform.tfstate in the web-app terrform config? Doing terrform init and terrform plan with the following config while in the 03-basics/web-app directory shows that it will end up deleting the backend resources:

03-basics/web-app/ $ cat main.tf 

terraform {

    # assuems that the bootstapping process has been done already
    # bootstrapping with done in 03-basics/aws-bootstrap  
    backend "s3" {
        bucket         = "rafay-tf-state-bucket"
        key            = "terraform.tfstate"  # in the code the actual value is "03-basics/web-app/terraform.tfstate"
        region         = "us-east-1"
        dynamodb_table = "terraform-state-locking"
        encrypt        = true
    }

...

plan output

....
      + timezone                              = (known after apply)
      + username                              = "foo"
      + vpc_security_group_ids                = (known after apply)
    }

  # aws_dynamodb_table.terraform_locks will be destroyed
  # (because aws_dynamodb_table.terraform_locks is not in configuration)
  - resource "aws_dynamodb_table" "terraform_locks" {
      - arn                         = "arn:aws:dynamodb:us-east-1:761631971559:table/terraform-state-locking" -> null
      - billing_mode                = "PAY_PER_REQUEST" -> null
      - deletion_protection_enabled = false -> null
      - hash_key                    = "LockID" -> null
      - id                          = "terraform-state-locking" -> null
      - name                        = "terraform-state-locking" -> null
      - read_capacity               = 0 -> null
      - stream_enabled              = false -> null
      - table_class                 = "STANDARD" -> null
      - tags                        = {} -> null
      - tags_all                    = {} -> null
      - write_capacity              = 0 -> null

      - attribute {
          - name = "LockID" -> null
          - type = "S" -> null
        }

      - point_in_time_recovery {
          - enabled = false -> null
        }

      - ttl {
          - enabled = false -> null
        }
    }

...


  # aws_s3_bucket.terraform_state will be destroyed
  # (because aws_s3_bucket.terraform_state is not in configuration)
  - resource "aws_s3_bucket" "terraform_state" {
      - arn                         = "arn:aws:s3:::rafay-tf-state-bucket" -> null
      - bucket                      = "rafay-tf-state-bucket" -> null
      - bucket_domain_name          = "rafay-tf-state-bucket.s3.amazonaws.com" -> null
      - bucket_regional_domain_name = "rafay-tf-state-bucket.s3.us-east-1.amazonaws.com" -> null
      - force_destroy               = true -> null
      - hosted_zone_id              = "Z3AQBSTGFYJSTF" -> null
      - id                          = "rafay-tf-state-bucket" -> null
      - object_lock_enabled         = false -> null
      - region                      = "us-east-1" -> null
      - request_payer               = "BucketOwner" -> null
      - tags                        = {} -> null
      - tags_all                    = {} -> null

      - grant {
          - id          = "57126703ff6a17d5be2bb99b83d081c151f3364c56d1034085f2a0e0e792f925" -> null
          - permissions = [
              - "FULL_CONTROL",
            ] -> null
          - type        = "CanonicalUser" -> null
        }

      - server_side_encryption_configuration {
          - rule {
              - bucket_key_enabled = false -> null

              - apply_server_side_encryption_by_default {
                  - sse_algorithm = "AES256" -> null
                }
            }
        }

      - versioning {
          - enabled    = true -> null
          - mfa_delete = false -> null
        }
    }

06-organization-and-modules authentication error at the S3 buckets

terraform apply fails and seems there is a mismatch on the region settings according to the output:

Error: Error creating S3 bucket: AuthorizationHeaderMalformed: The authorization header is malformed; the region 'us-east-1' is wrong; expecting 'us-west-1'
│       status code: 400, request id: 4RJBY0EQFNJY30Y7, host id: whXFjlyFiu++nd24wkW2gwnzC/lJ8+xrqT5Ihumb1r7dSAjqk4qYFut43pjdnrc3PJFi7ZaU8qs=
│ 
│   with module.web_app_2.aws_s3_bucket.bucket,
│   on ../web-app-module/storage.tf line 1, in resource "aws_s3_bucket" "bucket":
│    1: resource "aws_s3_bucket" "bucket" {

Any idea how to fix this?

Error creating Load Balancer

Thank you for your ultimate Terraform tutorial! But when I follow the steps I got this error.

image

Please help me...

03-basics: Error creating the database instance

Executing terraform apply in the web-app folder the database instance provisioning fails:

aws_db_instance.db_instance: Creating...
╷
│ Error: Error creating DB Instance: InvalidParameterCombination: Cannot find version 9.5 for postgres
│       status code: 400, request id: 9085a882-f29c-4d65-a328-597a9ffa17ba
│ 
│   with aws_db_instance.db_instance,
│   on main.tf line 200, in resource "aws_db_instance" "db_instance":
│  200: resource "aws_db_instance" "db_instance" {
│ 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.