Skip to content

Instantly share code, notes, and snippets.

@manuke
Last active May 8, 2020 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manuke/4fd1e0a32768b19a3f7d5def83e6ac5a to your computer and use it in GitHub Desktop.
Save manuke/4fd1e0a32768b19a3f7d5def83e6ac5a to your computer and use it in GitHub Desktop.
terraform.md
 git clone https://github.com/tfutils/tfenv.git ~/.tfenv
 echo 'export PATH="$HOME/.tfenv/bin:$PATH"' >> ~/.bash_profile
 tfenv install 0.12.0-rc1

https://qiita.com/takumiabe/items/07943f23436aa983f397

https://int128.hatenablog.com/entry/2018/06/28/180504

terraform auth pattern (if .tfstate bucket account diffrent from resoure aws account, modify also provider.tf)

terraform {
  required_version = ">= 0.12.10"
  backend "s3" {
    region = "ap-northeast-1"
    session_name = "user_by_terraform"
    #################NEED CHECK
    bucket = "terraform_somebucketname"
    key    = "test_sg.tfstate"

    #################ACCESS METHOD
    ###SWITCHROLE WITH MFA
    #temp switch role mfa user auth to envs
    #https://github.com/coinbase/assume-role
    #cf. eval $(assume-role 1234567890 switchrole_name)

    ###ACCESSKEY FILE
    #shared_credentials_file = "/opt/awscredentials"
    #profile = "profile_stg"

    ###SWITCHROLE WITHOUT MFA
    #role_arn = "arn:aws:iam::1234567890:role/switchrole_name"
  }
}

terraform.tfvars.jsonはrootのところに一つだけ存在するらしい。個別にモジュール動作をさせるような手法だと利用できなさそう。

lambdaなら以下モジュールになりそう。 https://github.com/claranet/terraform-aws-lambda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment