Skip to content

Instantly share code, notes, and snippets.

@binario200
Last active April 22, 2018 06: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 binario200/064d9bdc5f37457889e283a59b85e20a to your computer and use it in GitHub Desktop.
Save binario200/064d9bdc5f37457889e283a59b85e20a to your computer and use it in GitHub Desktop.
A set of fixes for some common terraform issues.

Terraform state using a remote storage

In order to have the state of you terraform in a remote place let say at AWS S3 you need to :

  • You need to create the bucket at AWS S3 using terraform
  • you need to add backend to indicate that you will use the bucket created to store the terraform state (encryting it)

provider "aws" {
 region = "us-east-1"
}

resource "aws_s3_bucket" "terraform_state" {
 bucket = "${var.bucket_name}"

 versioning {
   enabled = true
 }

 lifecycle {
   prevent_destroy = true
 }
}

terraform {
 backend "s3" {
   bucket  = "lokisha-s3"
   region  = "us-east-1"
   key     = "terraform.tfstate"
   encrypt = true
 }
}

Terraform v0.10.8 issues with provideer plugins

Sometimes when you run terraform plan you will start watching the next error:

Error: Error asking for user input: 1 error(s) occurred:

* provider.aws: fork/exec /Users/loko/Workspace/TerraformLabs/terraform-up-and-running-code/code/terraform/03-terraform-state/file-layout-example/prod/data-stores/mysql/.terraform/plugins/darwin_amd64/terraform-provider-aws_v1.11.0_x4: permission denied

In order to fix that issue related with the plugin permissions, try

  • The provider binary needs execute permissions, so try using 755
  • at you current terraform module or resource (using Mac)
chmod 755 .terraform/plugins/darwin_amd64/terraform-provider-aws_v1.11.0_x4
  • Then try terraform init and terraform plan it should be fixec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment