-
Notifications
You must be signed in to change notification settings - Fork 135
/
main.tf
56 lines (50 loc) · 1.39 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
provider "aws" {
region = var.region
}
terraform {
backend "s3" {
bucket = "tf-backend-bucket-haowang" # Replace this with your bucket name!
key = "global/s3/terraform.tfstate"
region = "ap-southeast-1"
dynamodb_table = "tf-backend-dynamodb-haowang" # Replace this with your DynamoDB table name!
encrypt = true
}
}
resource "aws_s3_bucket" "terraform_state" {
bucket = var.bucket_name
force_destroy = true
}
# Enable versioning so we can see the full revision history of state files
resource "aws_s3_bucket_versioning" "terraform_state" {
bucket = aws_s3_bucket.terraform_state.id
versioning_configuration {
status = "Enabled"
}
}
# Enable server-side encryption by default
resource "aws_s3_bucket_server_side_encryption_configuration" "terraform_state" {
bucket = aws_s3_bucket.terraform_state.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
resource "aws_dynamodb_table" "terraform_locks" {
name = var.dynamodb_table
billing_mode = "PAY_PER_REQUEST"
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
}
resource "aws_dynamodb_table" "terraform_locks_databricks_project" {
name = var.dynamodb_table_databricks_project
billing_mode = "PAY_PER_REQUEST"
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
}