Skip to content

Instantly share code, notes, and snippets.

@roylee0704
Last active September 23, 2020 04:56
Show Gist options
  • Select an option

  • Save roylee0704/daa8f68dae8ee6afc32b7ac17d257262 to your computer and use it in GitHub Desktop.

Select an option

Save roylee0704/daa8f68dae8ee6afc32b7ac17d257262 to your computer and use it in GitHub Desktop.

Revisions

  1. roylee0704 revised this gist Sep 23, 2020. 1 changed file with 19 additions and 0 deletions.
    19 changes: 19 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    version: "3.8"

    services:
    # service name to run in docker-compose command
    terraform:
    image: hashicorp/terraform:0.13.3

    # map all files under host dir './aws' to container dir '/infra'
    volumes:
    - ./aws:/infra

    # when we run the service, it will start from this working dir
    working_dir: /infra

    # you don't want to hard-code your secrets, you could use aws-vault to auto setup aws credentials in your session env
    environment:
    - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
    - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
    - AWS_SESSION_TOKEN=${AWS_SESSION_TOKEN}
  2. roylee0704 created this gist Sep 23, 2020.
    20 changes: 20 additions & 0 deletions main.tf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    provider "aws" {
    region = "ap-southeast-1"

    # https://github.com/terraform-providers/terraform-provider-aws/blob/master/CHANGELOG.md
    version = "~>3.7.0"
    }

    # by default, it's local backend. You need remote access and sharing,
    # setup as below (easiest)
    terraform {
    # https://www.terraform.io/docs/backends/types/s3.html
    backend "s3" {
    bucket = "gobike-devops-tfstate"
    key = "gobike-devops.tfstate" # bucket key name

    dynamodb_table = "gobike-devops-tfstate-lock"
    encrypt = true
    region = "ap-southeast-1"
    }
    }