-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
58 lines (47 loc) · 1.47 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
57
58
resource "aws_s3_bucket" "terraform_state" {
bucket = var.bucket_name
# set variable to true when you want to delete the bucket
force_destroy = var.force_destroy
tags = var.tags
}
resource "aws_s3_bucket_ownership_controls" "tf_state_ownership" {
bucket = aws_s3_bucket.terraform_state.id
rule {
object_ownership = "BucketOwnerPreferred"
}
}
resource "aws_s3_bucket_request_payment_configuration" "tf_state_payment" {
bucket = aws_s3_bucket.terraform_state.id
payer = "Requester"
}
resource "aws_s3_bucket_versioning" "enabled" {
bucket = aws_s3_bucket.terraform_state.id
versioning_configuration {
status = var.enable_versioning ? "Enabled" : "Suspended"
}
}
# enable server-side encryption by default
resource "aws_s3_bucket_server_side_encryption_configuration" "default" {
bucket = aws_s3_bucket.terraform_state.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
resource "aws_s3_bucket_public_access_block" "public_access" {
bucket = aws_s3_bucket.terraform_state.id
block_public_acls = var.block_public_access
block_public_policy = var.block_public_access
ignore_public_acls = var.block_public_access
restrict_public_buckets = var.block_public_access
}
resource "aws_dynamodb_table" "terraform_locks" {
name = var.dynamodb_table_name
billing_mode = "PAY_PER_REQUEST"
hash_key = "LockID"
attribute {
name = "LockID"
type = "S"
}
}