Difference between revisions of "Terraform backends"

From wikieduonline
Jump to navigation Jump to search
Line 13: Line 13:
 
     [[profile]] = "your-profile"
 
     [[profile]] = "your-profile"
 
     [[workspace_key_prefix]] = "your-workspace"
 
     [[workspace_key_prefix]] = "your-workspace"
 +
  }
 +
}
 +
 +
Example using variables:
 +
terraform {
 +
  backend "s3" {
 +
    region        =  "$(AWS_MYREGION)"
 +
    bucket        =  "$(aws-backend-bucket)"
 +
    key            =  "yourkeyname/$(AWS_ACCOUNTNAME)/$(AWS_MYREGION)"
 +
    dynamodb_table =  "$(aws-backend-dynamoDbTable)"
 +
    encrypt        =  true
 +
    [[role_arn]]      =  "$(aws-cicd-role-arn)"
 
   }
 
   }
 
  }
 
  }

Revision as of 13:23, 10 February 2022

https://www.terraform.io/language/settings/backends


S3 Example with DynamoDB

terraform {
  backend "s3" {
    bucket = "your-terraform-states"
    key[1]    = "terraform.tfstate"
    region = "us-west-2"
    dynamodb_table = "your-terraform-states"
    profile = "your-profile"
    workspace_key_prefix = "your-workspace"
  }
}

Example using variables:

terraform {
  backend "s3" {
    region         =  "$(AWS_MYREGION)"
    bucket         =  "$(aws-backend-bucket)"
    key            =  "yourkeyname/$(AWS_ACCOUNTNAME)/$(AWS_MYREGION)"
    dynamodb_table =  "$(aws-backend-dynamoDbTable)"
    encrypt        =  true
    role_arn       =  "$(aws-cicd-role-arn)"
  }
}

Related terms

See also

  • https://www.terraform.io/docs/language/settings/backends/s3.html#key
  • Advertising: