Skip to content

Commit

Permalink
Updated buckets
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladyslav Yevsiukov authored and Vladyslav Yevsiukov committed Jul 17, 2023
1 parent d199134 commit 3399de6
Show file tree
Hide file tree
Showing 209 changed files with 2,175 additions and 551 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
resource "aws_s3_bucket" "this" {
bucket = "080-bucket-green"
bucket = "080-bucket-${random_integer.this.result}-green"
force_destroy = true
}

resource "random_integer" "this" {
min = 1
max = 10000000
}


resource "aws_s3_bucket_policy" "this" {
bucket = aws_s3_bucket.this.id
policy = data.aws_iam_policy_document.this.json
Expand All @@ -19,7 +24,7 @@ data "aws_iam_policy_document" "this" {
}

actions = ["s3:*"]
resources = ["arn:aws:s3:::080-bucket-green/*"]
resources = ["${aws_s3_bucket.this.arn}/*"]
condition {
test = "Bool"
variable = "aws:SecureTransport"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
resource "aws_s3_bucket" "this" {
bucket = "080-bucket-red"
bucket = "080-bucket-${random_integer.this.result}-red"
force_destroy = true
}

resource "random_integer" "this" {
min = 1
max = 10000000
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
resource "aws_s3_bucket" "this" {
bucket = "bucket-090-green"
bucket = "bucket-090-${random_integer.this.result}-green"
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "tls_private_key" "this" {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
resource "aws_s3_bucket" "this" {
bucket = "bucket-090-red"
bucket = "bucket-090-${random_integer.this.result}-red"
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "tls_private_key" "this" {
Expand Down
40 changes: 30 additions & 10 deletions terraform/ecc-aws-101-clb_access_logging_disabled/green/s3.tf
Original file line number Diff line number Diff line change
@@ -1,28 +1,48 @@
resource "aws_s3_bucket" "this" {
bucket = "101-bucket-green"
bucket = "101-bucket-${random_integer.this.result}-green"
force_destroy = true
}

resource "aws_s3_bucket_acl" "this" {
resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "aws_s3_bucket_ownership_controls" "this" {
bucket = aws_s3_bucket.this.id
acl = "private"
rule {
object_ownership = "BucketOwnerPreferred"
}
}

resource "aws_s3_bucket_policy" "allow_access_from_another_account" {
resource "aws_s3_bucket_acl" "this" {
depends_on = [aws_s3_bucket_ownership_controls.this]

bucket = aws_s3_bucket.this.id
policy = data.aws_iam_policy_document.this.json
acl = "private"
}


data "aws_elb_service_account" "this" {}

data "aws_iam_policy_document" "this" {
statement {
sid = "AWSLogDeliveryWrite"
effect = "Allow"

actions = ["s3:PutObject"]
resources = ["${aws_s3_bucket.this.arn}/*"]

principals {
type = "*"
identifiers = ["*"]
type = "AWS"
identifiers = [data.aws_elb_service_account.this.arn]
}

actions = ["s3:PutObject"]
resources = ["arn:aws:s3:::101-bucket-green/*"]
}
}

resource "aws_s3_bucket_policy" "this" {
bucket = aws_s3_bucket.this.id
policy = data.aws_iam_policy_document.this.json
}

data "aws_caller_identity" "current" {}
7 changes: 6 additions & 1 deletion terraform/ecc-aws-141-s3_encrypted_using_kms/green/s3.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
resource "aws_s3_bucket" "this" {
bucket = "141-bucket-green"
bucket = "141-bucket-${random_integer.this.result}-green"
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "aws_s3_bucket_ownership_controls" "this" {
Expand Down
7 changes: 6 additions & 1 deletion terraform/ecc-aws-141-s3_encrypted_using_kms/red/s3.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
resource "aws_s3_bucket" "this" {
bucket = "141-bucket-red"
bucket = "141-bucket-${random_integer.this.result}-red"
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "aws_s3_bucket_ownership_controls" "this" {
Expand Down
11 changes: 8 additions & 3 deletions terraform/ecc-aws-162-s3_bucket_lifecycle/green/s3.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
resource "aws_s3_bucket" "this" {
bucket = "162-bucket-green"
bucket = "162-bucket-${random_integer.this.result}-green"
force_destroy = "true"
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "aws_s3_bucket_ownership_controls" "this" {
bucket = aws_s3_bucket.this.id
rule {
Expand Down Expand Up @@ -32,7 +37,7 @@ resource "aws_s3_bucket_lifecycle_configuration" "this" {
prefix = "log/"

tags = {
CustodianRule = "ecc-aws-162-s3_bucket_lifecycle"
CustodianRule = "epam-aws-162-s3_bucket_lifecycle"
ComplianceStatus = "Green"
}
}
Expand All @@ -45,4 +50,4 @@ resource "aws_s3_bucket_lifecycle_configuration" "this" {
storage_class = "GLACIER"
}
}
}
}
7 changes: 6 additions & 1 deletion terraform/ecc-aws-162-s3_bucket_lifecycle/red/s3.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
resource "aws_s3_bucket" "this" {
bucket = "162-bucket-red"
bucket = "162-bucket-${random_integer.this.result}-red"
force_destroy = "true"
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "aws_s3_bucket_ownership_controls" "this" {
bucket = aws_s3_bucket.this.id
rule {
Expand Down
7 changes: 6 additions & 1 deletion terraform/ecc-aws-163-s3_buckets_without_tags/green/s3.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
resource "aws_s3_bucket" "this" {
bucket = "163-bucket-green"
bucket = "163-bucket-${random_integer.this.result}-green"
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "aws_s3_bucket_ownership_controls" "this" {
Expand Down
7 changes: 6 additions & 1 deletion terraform/ecc-aws-163-s3_buckets_without_tags/red/s3.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
resource "aws_s3_bucket" "this" {
bucket = "163-bucket-red"
bucket = "163-bucket-${random_integer.this.result}-red"
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "aws_s3_bucket_ownership_controls" "this" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@ resource "aws_cloudtrail" "this" {
}

resource "aws_s3_bucket" "this" {
bucket = "bucket-175-green"
bucket = "175-bucket-${random_integer.this.result}-green"
force_destroy = true
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "aws_s3_bucket_policy" "this" {
bucket = aws_s3_bucket.this.id
policy = data.aws_iam_policy_document.this.json
Expand All @@ -27,7 +32,7 @@ data "aws_iam_policy_document" "this" {
}

actions = ["s3:GetBucketAcl"]
resources = ["arn:aws:s3:::bucket-175-green"]
resources = [aws_s3_bucket.this.arn]
}

statement {
Expand All @@ -39,7 +44,7 @@ data "aws_iam_policy_document" "this" {
}

actions = ["s3:PutObject"]
resources = ["arn:aws:s3:::bucket-175-green/AWSLogs/${data.aws_caller_identity.this.account_id}/*"]
resources = ["${aws_s3_bucket.this.arn}/AWSLogs/${data.aws_caller_identity.this.account_id}/*"]
condition {
test = "StringEquals"
variable = "s3:x-amz-acl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ resource "aws_cloudtrail" "this" {
}
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "aws_s3_bucket" "this" {
bucket = "bucket-175-green1"
bucket = "175-bucket-${random_integer.this.result}-green1"
force_destroy = true
}

Expand All @@ -34,7 +39,7 @@ data "aws_iam_policy_document" "this" {
}

actions = ["s3:GetBucketAcl"]
resources = ["arn:aws:s3:::bucket-175-green1"]
resources = [aws_s3_bucket.this.arn]
}

statement {
Expand All @@ -46,7 +51,7 @@ data "aws_iam_policy_document" "this" {
}

actions = ["s3:PutObject"]
resources = ["arn:aws:s3:::bucket-175-green1/AWSLogs/${data.aws_caller_identity.this.account_id}/*"]
resources = ["${aws_s3_bucket.this.arn}/AWSLogs/${data.aws_caller_identity.this.account_id}/*"]
condition {
test = "StringEquals"
variable = "s3:x-amz-acl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ resource "aws_cloudtrail" "this" {
}

resource "aws_s3_bucket" "this" {
bucket = "bucket-175-red"
bucket = "175-bucket-${random_integer.this.result}-red"
force_destroy = true
}

Expand All @@ -28,7 +28,7 @@ data "aws_iam_policy_document" "this" {
}

actions = ["s3:GetBucketAcl"]
resources = ["arn:aws:s3:::bucket-175-red"]
resources = [aws_s3_bucket.this.arn]
}

statement {
Expand All @@ -40,7 +40,7 @@ data "aws_iam_policy_document" "this" {
}

actions = ["s3:PutObject"]
resources = ["arn:aws:s3:::bucket-175-red/AWSLogs/${data.aws_caller_identity.this.account_id}/*"]
resources = ["${aws_s3_bucket.this.arn}/AWSLogs/${data.aws_caller_identity.this.account_id}/*"]
condition {
test = "StringEquals"
variable = "s3:x-amz-acl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ resource "aws_cloudtrail" "this" {
}

resource "aws_s3_bucket" "this" {
bucket = "bucket-176-green"
bucket = "176-bucket-${random_integer.this.result}-green"
force_destroy = true
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "aws_s3_bucket_policy" "this" {
bucket = aws_s3_bucket.this.id
policy = data.aws_iam_policy_document.this.json
Expand All @@ -26,7 +31,7 @@ data "aws_iam_policy_document" "this" {
}

actions = ["s3:GetBucketAcl"]
resources = ["arn:aws:s3:::bucket-176-green"]
resources = [aws_s3_bucket.this.arn]
}

statement {
Expand All @@ -38,7 +43,7 @@ data "aws_iam_policy_document" "this" {
}

actions = ["s3:PutObject"]
resources = ["arn:aws:s3:::bucket-176-green/AWSLogs/${data.aws_caller_identity.this.account_id}/*"]
resources = ["${aws_s3_bucket.this.arn}/AWSLogs/${data.aws_caller_identity.this.account_id}/*"]
condition {
test = "StringEquals"
variable = "s3:x-amz-acl"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ resource "aws_cloudtrail" "this" {
}

resource "aws_s3_bucket" "this" {
bucket = "bucket-176-red"
bucket = "176-bucket-${random_integer.this.result}-red"
force_destroy = true
}

resource "random_integer" "this" {
min = 1
max = 10000000
}

resource "aws_s3_bucket_policy" "this" {
bucket = aws_s3_bucket.this.id
policy = data.aws_iam_policy_document.this.json
Expand All @@ -26,7 +31,7 @@ data "aws_iam_policy_document" "this" {
}

actions = ["s3:GetBucketAcl"]
resources = ["arn:aws:s3:::bucket-176-red"]
resources = [aws_s3_bucket.this.arn]
}

statement {
Expand All @@ -38,7 +43,7 @@ data "aws_iam_policy_document" "this" {
}

actions = ["s3:PutObject"]
resources = ["arn:aws:s3:::bucket-176-red/AWSLogs/${data.aws_caller_identity.this.account_id}/*"]
resources = ["${aws_s3_bucket.this.arn}/AWSLogs/${data.aws_caller_identity.this.account_id}/*"]
condition {
test = "StringEquals"
variable = "s3:x-amz-acl"
Expand Down
Loading

0 comments on commit 3399de6

Please sign in to comment.