diff --git a/security_group.tf b/security_group.tf index c65d19b..727fa66 100644 --- a/security_group.tf +++ b/security_group.tf @@ -10,7 +10,7 @@ resource "aws_security_group" "aws-demo-security-group" { to_port = 0 from_port = 0 protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] + cidr_blocks = [""] } egress { diff --git a/vpc.tf b/vpc.tf index 871a758..0b54389 100644 --- a/vpc.tf +++ b/vpc.tf @@ -20,3 +20,163 @@ resource "aws_vpc" "aws-demo3" { } } + +resource "aws_flow_log" "aws-demo" { + vpc_id = "${aws_vpc.aws-demo.id}" + iam_role_arn = "" + log_destination = "${aws_s3_bucket.aws-demo.arn}" + traffic_type = "ALL" + + tags = { + GeneratedBy = "Accurics" + ParentResourceId = "aws_vpc.aws-demo" + } +} +resource "aws_s3_bucket" "aws-demo" { + bucket = "aws-demo_flow_log_s3_bucket" + acl = "private" + force_destroy = true + + versioning { + enabled = true + mfa_delete = true + } + + server_side_encryption_configuration { + rule { + apply_server_side_encryption_by_default { + sse_algorithm = "AES256" + } + } + } +} +resource "aws_s3_bucket_policy" "aws-demo" { + bucket = "${aws_s3_bucket.aws-demo.id}" + + policy = < + ] + } + ], + "Action": "s3:GetObject", + "Resource": "arn:aws:s3:::${aws_s3_bucket.aws-demo.id}/*" + } + ] +} +POLICY +} +resource "aws_flow_log" "aws-demo2" { + vpc_id = "${aws_vpc.aws-demo2.id}" + iam_role_arn = "" + log_destination = "${aws_s3_bucket.aws-demo2.arn}" + traffic_type = "ALL" + + tags = { + GeneratedBy = "Accurics" + ParentResourceId = "aws_vpc.aws-demo2" + } +} +resource "aws_s3_bucket" "aws-demo2" { + bucket = "aws-demo2_flow_log_s3_bucket" + acl = "private" + force_destroy = true + + versioning { + enabled = true + mfa_delete = true + } + + server_side_encryption_configuration { + rule { + apply_server_side_encryption_by_default { + sse_algorithm = "AES256" + } + } + } +} +resource "aws_s3_bucket_policy" "aws-demo2" { + bucket = "${aws_s3_bucket.aws-demo2.id}" + + policy = < + ] + } + ], + "Action": "s3:GetObject", + "Resource": "arn:aws:s3:::${aws_s3_bucket.aws-demo2.id}/*" + } + ] +} +POLICY +} +resource "aws_flow_log" "aws-demo3" { + vpc_id = "${aws_vpc.aws-demo3.id}" + iam_role_arn = "" + log_destination = "${aws_s3_bucket.aws-demo3.arn}" + traffic_type = "ALL" + + tags = { + GeneratedBy = "Accurics" + ParentResourceId = "aws_vpc.aws-demo3" + } +} +resource "aws_s3_bucket" "aws-demo3" { + bucket = "aws-demo3_flow_log_s3_bucket" + acl = "private" + force_destroy = true + + versioning { + enabled = true + mfa_delete = true + } + + server_side_encryption_configuration { + rule { + apply_server_side_encryption_by_default { + sse_algorithm = "AES256" + } + } + } +} +resource "aws_s3_bucket_policy" "aws-demo3" { + bucket = "${aws_s3_bucket.aws-demo3.id}" + + policy = < + ] + } + ], + "Action": "s3:GetObject", + "Resource": "arn:aws:s3:::${aws_s3_bucket.aws-demo3.id}/*" + } + ] +} +POLICY +} \ No newline at end of file