-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmain.tf
63 lines (54 loc) · 1.54 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
59
60
61
62
63
// Local variables are used to define the bucket name and ACL based on the environment.
locals {
environment = {
staging = {
bucket_name = "staging-bucket"
acl = "public-read"
}
production = {
bucket_name = "production-bucket"
acl = "private"
}
}
}
# resource "aws_kms_key" "mykey" {
# description = "This key is used to encrypt bucket objects"
# deletion_window_in_days = 10
# }
// This simple bucket configuration will cause failures.
resource "aws_s3_bucket" "static_bucket" {
bucket = "run-task-demo-bucket"
acl = "public-read"
tags = {
Name = "Public"
Environment = "Production"
}
}
// This dynamic bucket configuration will cause failures.
resource "aws_s3_bucket" "dynamic_bucket" {
count = (var.environment == "production") ? 1 : 0
bucket = local.environment[var.environment].bucket_name
acl = local.environment[var.environment].acl
# server_side_encryption_configuration {
# rule {
# apply_server_side_encryption_by_default {
# kms_master_key_id = aws_kms_key.mykey.arn
# sse_algorithm = "aws:kms"
# }
# }
# }
# versioning {
# enabled = true
# }
tags = {
Name = local.environment[var.environment].acl
Environment = var.environment
}
}
# resource "aws_s3_bucket_public_access_block" "public" {
# bucket = aws_s3_bucket.bucket.id
# block_public_acls = true
# block_public_policy = true
# restrict_public_buckets = true
# ignore_public_acls = true
# }