-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.tf
94 lines (79 loc) · 1.7 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}
provider "aws" {
region = "us-east-1"
}
#Random for TFC
resource "random_id" "random" {
keepers = {
uuid = uuid()
}
byte_length = 11
}
output "random" {
value = random_id.random.hex
}
#terragoat resources
resource "aws_s3_bucket" "data" {
# Test
# bucket is public
# bucket is not encrypted
# bucket does not have access logs
# bucket does not have versioning
bucket = "data"
#tests vars
acl = var.acl_value
force_destroy = true
tags = {
Name = "data"
Environment = "env"
Test = "This is a TFC test"
}
}
resource "aws_s3_bucket_object" "data_object" {
bucket = aws_s3_bucket.data.id
key = "customer-master.xlsx"
source = "resources/customer-master.xlsx"
tags = {
Name = "customer-master"
Environment = "env"
}
}
resource "aws_s3_bucket" "financials" {
# bucket is not encrypted
# bucket does not have access logs
# bucket does not have versioning
bucket = "financials"
acl = "private"
force_destroy = true
tags = {
Name = "financials"
Environment = "financials"
}
}
resource "aws_s3_bucket" "operations" {
# bucket is not encrypted
# bucket does not have access logs
bucket = "operations"
acl = "private"
versioning {
enabled = true
}
force_destroy = true
tags = {
Name = "operations"
Environment = "operations"
}
}
#test modules
module "s3_bucket" {
source = "./s3_module"
bucket = var.bucket
acl = var.acl_value
}