Skip to content

Instantly share code, notes, and snippets.

@ismail0352
Created August 17, 2020 17:28
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 ismail0352/9c165ce506ca129a0e68f79147991a6f to your computer and use it in GitHub Desktop.
Save ismail0352/9c165ce506ca129a0e68f79147991a6f to your computer and use it in GitHub Desktop.
Sample for Terraform backend
provider "aws" {
region = "us-west-2"
shared_credentials_file = "~/.aws/credentials"
profile = "default"
}
resource "aws_s3_bucket" "terraform_state" {
bucket = "terraform-backend-state"
versioning {
enabled = true
}
lifecycle {
prevent_destroy = true
}
tags = {
Name = "S3 backend"
}
server_side_encryption_configuration {
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
}
resource "aws_dynamodb_table" "terraform_locks" {
name = "terraform-backend-locks"
billing_mode = "PAY_PER_REQUEST"
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
tags = {
Name = "Dynamo-Backend"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment