Skip to content

Commit a3915b8

Browse files
authored
module updated as per new version 4.2.0 (#28)
* module updated as per new version 4.2.0 * module updated as per new version 4.2.0 * module updated as per new version 4.2.0 * module updated as per new version 4.2.0
1 parent d127f7b commit a3915b8

File tree

10 files changed

+595
-123
lines changed

10 files changed

+595
-123
lines changed

_example/complete/example.tf

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
provider "aws" {
2+
region = "eu-west-1"
3+
}
4+
5+
module "logging_bucket" {
6+
source = "./../../"
7+
8+
name = "logging"
9+
environment = "test"
10+
attributes = ["public"]
11+
label_order = ["name", "environment"]
12+
acl = "log-delivery-write"
13+
}
14+
15+
module "kms_key" {
16+
source = "clouddrove/kms/aws"
17+
version = "0.15.0"
18+
name = "kms"
19+
environment = "test"
20+
label_order = ["name", "environment"]
21+
22+
enabled = true
23+
description = "KMS key for s3"
24+
deletion_window_in_days = 7
25+
enable_key_rotation = true
26+
alias = "alias/s3"
27+
policy = data.aws_iam_policy_document.default.json
28+
}
29+
30+
data "aws_iam_policy_document" "default" {
31+
version = "2012-10-17"
32+
statement {
33+
sid = "Enable IAM User Permissions"
34+
effect = "Allow"
35+
principals {
36+
type = "AWS"
37+
identifiers = ["*"]
38+
}
39+
actions = ["kms:*"]
40+
resources = ["*"]
41+
}
42+
}
43+
44+
module "s3_bucket" {
45+
source = "./../../"
46+
47+
name = "clouddrove-secure-bucket-new-version"
48+
environment = "test"
49+
attributes = ["private"]
50+
label_order = ["name", "environment"]
51+
52+
acl = ""
53+
#enable of disable versioning of s3
54+
versioning = true
55+
56+
#acceleration and request payer enable or disable.
57+
acceleration_status = true
58+
request_payer = true
59+
60+
# logging of s3 bucket to destination bucket.
61+
logging = true
62+
target_bucket = module.logging_bucket.id
63+
target_prefix = "logs"
64+
65+
#encrption on s3 with default encryption and kms encryption .
66+
enable_server_side_encryption = true
67+
enable_kms = true
68+
kms_master_key_id = module.kms_key.key_arn
69+
70+
#object locking of s3.
71+
object_lock_configuration = {
72+
mode = "GOVERNANCE"
73+
days = 366
74+
years = null
75+
}
76+
77+
#cross replicaton of s3
78+
cors_rule = [{
79+
allowed_headers = ["*"],
80+
allowed_methods = ["PUT", "POST"],
81+
allowed_origins = ["https://s3-website-test.hashicorp.com"],
82+
expose_headers = ["ETag"],
83+
max_age_seconds = 3000
84+
}]
85+
86+
#acl grant permission
87+
grants = [
88+
{
89+
id = null
90+
type = "Group"
91+
permissions = ["READ", "WRITE"]
92+
uri = "http://acs.amazonaws.com/groups/s3/LogDelivery"
93+
},
94+
]
95+
owner_id = data.aws_canonical_user_id.current.id
96+
97+
98+
#lifecycle rule for s3
99+
enable_lifecycle_configuration_rules = true
100+
lifecycle_configuration_rules = [
101+
{
102+
id = "log"
103+
prefix = null
104+
enabled = true
105+
tags = { "temp" : "true" }
106+
107+
enable_glacier_transition = false
108+
enable_deeparchive_transition = false
109+
enable_standard_ia_transition = false
110+
enable_current_object_expiration = true
111+
enable_noncurrent_version_expiration = true
112+
113+
abort_incomplete_multipart_upload_days = null
114+
noncurrent_version_glacier_transition_days = 0
115+
noncurrent_version_deeparchive_transition_days = 0
116+
noncurrent_version_expiration_days = 30
117+
118+
standard_transition_days = 0
119+
glacier_transition_days = 0
120+
deeparchive_transition_days = 0
121+
expiration_days = 365
122+
},
123+
{
124+
id = "log1"
125+
prefix = null
126+
enabled = true
127+
tags = {}
128+
129+
enable_glacier_transition = false
130+
enable_deeparchive_transition = false
131+
enable_standard_ia_transition = false
132+
enable_current_object_expiration = true
133+
enable_noncurrent_version_expiration = true
134+
135+
abort_incomplete_multipart_upload_days = 1
136+
noncurrent_version_glacier_transition_days = 0
137+
noncurrent_version_deeparchive_transition_days = 0
138+
noncurrent_version_expiration_days = 30
139+
140+
standard_transition_days = 0
141+
glacier_transition_days = 0
142+
deeparchive_transition_days = 0
143+
expiration_days = 365
144+
}
145+
]
146+
147+
#static website on s3
148+
website_config_enable = true
149+
150+
}
151+
152+
data "aws_canonical_user_id" "current" {}

_example/complete/output.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
output "id" {
2+
value = module.s3_bucket.*.id
3+
description = "The ID of the s3 bucket."
4+
}
5+
6+
output "tags" {
7+
value = module.s3_bucket.tags
8+
description = "A mapping of tags to assign to the S3."
9+
}

_example/cors_s3/example.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ module "s3_bucket" {
1313
versioning = true
1414
acl = "private"
1515
cors_rule = [{
16-
"allowed_headers" : ["*"]
16+
allowed_headers = ["*"],
1717
allowed_methods = ["PUT", "POST"],
1818
allowed_origins = ["https://s3-website-test.hashicorp.com"],
1919
expose_headers = ["ETag"],
20-
max_age_seconds = 3000 }]
20+
max_age_seconds = 3000
21+
}]
2122
}

_example/default-s3/example.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ module "s3_bucket" {
1212

1313
versioning = true
1414
acl = "private"
15-
}
15+
}

_example/encryption-s3/example.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,10 @@ module "s3_bucket" {
4040
attributes = ["public"]
4141
label_order = ["name", "environment"]
4242

43-
versioning = true
44-
acl = "private"
45-
sse_algorithm = "aws:kms"
43+
versioning = true
44+
acl = "private"
45+
enable_server_side_encryption = true
46+
47+
enable_kms = true
4648
kms_master_key_id = module.kms_key.key_arn
4749
}

_example/logging-encryption-s3/example.tf

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,34 @@ module "logging_bucket" {
1313
acl = "log-delivery-write"
1414
}
1515

16+
module "kms_key" {
17+
source = "clouddrove/kms/aws"
18+
version = "0.15.0"
19+
name = "kms"
20+
environment = "test"
21+
label_order = ["name", "environment"]
22+
23+
enabled = true
24+
description = "KMS key for s3"
25+
deletion_window_in_days = 7
26+
enable_key_rotation = true
27+
alias = "alias/s3"
28+
policy = data.aws_iam_policy_document.default.json
29+
}
30+
31+
data "aws_iam_policy_document" "default" {
32+
version = "2012-10-17"
33+
statement {
34+
sid = "Enable IAM User Permissions"
35+
effect = "Allow"
36+
principals {
37+
type = "AWS"
38+
identifiers = ["*"]
39+
}
40+
actions = ["kms:*"]
41+
resources = ["*"]
42+
}
43+
}
1644

1745
module "s3_bucket" {
1846
source = "./../../"
@@ -22,10 +50,16 @@ module "s3_bucket" {
2250
attributes = ["public"]
2351
label_order = ["name", "environment"]
2452

25-
versioning = true
26-
acl = "private"
27-
sse_algorithm = "AES256"
28-
logging = { target_bucket : module.logging_bucket.id, target_prefix = "logs" }
53+
versioning = true
54+
acl = "private"
55+
56+
enable_server_side_encryption = true
57+
enable_kms = true
58+
kms_master_key_id = module.kms_key.key_arn
59+
60+
logging = true
61+
target_bucket = module.logging_bucket.id
62+
target_prefix = "logs"
2963

3064
depends_on = [module.logging_bucket]
3165
}

_example/logging-s3/example.tf

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ module "s3_bucket" {
2020
attributes = ["public"]
2121
label_order = ["name", "environment"]
2222

23-
versioning = true
24-
acl = "private"
25-
logging = { target_bucket : module.logging_bucket.id, target_prefix = "logs" }
23+
versioning = true
24+
acl = "private"
25+
logging = true
26+
target_bucket = module.logging_bucket.id
27+
target_prefix = "logs"
2628

2729
depends_on = [module.logging_bucket]
2830

_example/website-s3/example.tf

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,58 @@ module "s3_bucket" {
1010
attributes = ["public"]
1111
label_order = ["name", "environment"]
1212

13-
versioning = true
14-
acl = "private"
15-
website = { index_document : "index.html", error_document : "error.html" }
16-
lifecycle_expiration_enabled = true
17-
lifecycle_expiration_object_prefix = "test"
18-
lifecycle_days_to_expiration = 10
13+
versioning = true
14+
acl = "private"
15+
16+
website_config_enable = true
17+
18+
enable_lifecycle_configuration_rules = true
19+
lifecycle_configuration_rules = [
20+
{
21+
id = "log"
22+
prefix = null
23+
enabled = true
24+
tags = { "temp" : "true" }
25+
26+
enable_glacier_transition = false
27+
enable_deeparchive_transition = false
28+
enable_standard_ia_transition = false
29+
enable_current_object_expiration = true
30+
enable_noncurrent_version_expiration = true
31+
32+
abort_incomplete_multipart_upload_days = null
33+
noncurrent_version_glacier_transition_days = 0
34+
noncurrent_version_deeparchive_transition_days = 0
35+
noncurrent_version_expiration_days = 30
36+
37+
standard_transition_days = 0
38+
glacier_transition_days = 0
39+
deeparchive_transition_days = 0
40+
expiration_days = 365
41+
},
42+
{
43+
id = "log1"
44+
prefix = null
45+
enabled = true
46+
tags = {}
47+
48+
enable_glacier_transition = false
49+
enable_deeparchive_transition = false
50+
enable_standard_ia_transition = false
51+
enable_current_object_expiration = true
52+
enable_noncurrent_version_expiration = true
53+
54+
abort_incomplete_multipart_upload_days = 1
55+
noncurrent_version_glacier_transition_days = 0
56+
noncurrent_version_deeparchive_transition_days = 0
57+
noncurrent_version_expiration_days = 30
58+
59+
standard_transition_days = 0
60+
glacier_transition_days = 0
61+
deeparchive_transition_days = 0
62+
expiration_days = 365
63+
}
64+
]
1965

2066
bucket_policy = true
2167
aws_iam_policy_document = data.aws_iam_policy_document.default.json

0 commit comments

Comments
 (0)