-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tf-fix: fixed a number of terraform files for policies (see the list …
…in the commit message) 080, 086, 087, 090, 101, 141, 162, 163, 176, 179, 183, 184, 206, 210, 216, 218, 237, 238, 242, 246, 249, 263, 264, 279, 280, 290, 306, 324, 326, 339, 408, 438, 448, 452, 459, 496, 510, 525, 527, 531, 547, 568, 575, 578, 580, 600, 620, 652, 653, 654, 655, 656, 672, 689, 690, 712, 717, 718, 719, 720, 724, 787, 809, 897, 899, 900, 901, 958, 961, 962, 963, 964, 968
- Loading branch information
Vladyslav Yevsiukov
authored and
Vladyslav Yevsiukov
committed
Jul 24, 2023
1 parent
0f9fd94
commit 48114c6
Showing
148 changed files
with
1,660 additions
and
314 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
terraform/ecc-aws-080-bucket_policy_allows_https_requests/red/s3.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
24 changes: 19 additions & 5 deletions
24
terraform/ecc-aws-086_iam_ssl_or_tls_certificates_expire_in_one_month/green/certificate.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
###### The step to be done before run infrastructure is to run command below | ||
# sudo openssl req -x509 -nodes -days 40 -newkey rsa:2048 -keyout private.key -out certificate.crt | ||
resource "null_resource" "this" { | ||
provisioner "local-exec" { | ||
command = "echo -e '\\n\\n\\n\\n\\n\\n\\n\\n' | openssl req -x509 -nodes -days 20 -newkey rsa:2048 -keyout private.key -out certificate.crt" | ||
interpreter = ["/bin/bash", "-c"] | ||
} | ||
} | ||
|
||
data "local_file" "certificate" { | ||
filename = "certificate.crt" | ||
depends_on = [null_resource.this] | ||
} | ||
|
||
data "local_file" "private_key" { | ||
filename = "private.key" | ||
depends_on = [null_resource.this] | ||
} | ||
|
||
resource "aws_iam_server_certificate" "this" { | ||
name = "086_certificate_green" | ||
certificate_body = file("certificate.crt") | ||
private_key = file("private.key") | ||
} | ||
certificate_body = data.local_file.certificate.content | ||
private_key = data.local_file.private_key.content | ||
} |
25 changes: 20 additions & 5 deletions
25
terraform/ecc-aws-086_iam_ssl_or_tls_certificates_expire_in_one_month/red/certificate.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
###### The step to be done before run infrastructure is to run command below | ||
# sudo openssl req -x509 -nodes -days 20 -newkey rsa:2048 -keyout second-private.key -out second-certificate.crt | ||
resource "null_resource" "this" { | ||
provisioner "local-exec" { | ||
command = "echo -e '\\n\\n\\n\\n\\n\\n\\n\\n' | openssl req -x509 -nodes -days 20 -newkey rsa:2048 -keyout private.key -out certificate.crt" | ||
interpreter = ["/bin/bash", "-c"] | ||
} | ||
} | ||
|
||
data "local_file" "certificate" { | ||
filename = "certificate.crt" | ||
depends_on = [null_resource.this] | ||
} | ||
|
||
data "local_file" "private_key" { | ||
filename = "private.key" | ||
depends_on = [null_resource.this] | ||
} | ||
|
||
|
||
resource "aws_iam_server_certificate" "this" { | ||
name = "086_certificate_red" | ||
certificate_body = file("certificate.crt") | ||
private_key = file("private.key") | ||
} | ||
certificate_body = data.local_file.certificate.content | ||
private_key = data.local_file.private_key.content | ||
} |
25 changes: 20 additions & 5 deletions
25
terraform/ecc-aws-087_iam_ssl_or_tls_certificates_expire_in_one_week/green/certificate.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,23 @@ | ||
###### The step to be done before run infrastructure is to run command below | ||
# sudo openssl req -x509 -nodes -days 8 -newkey rsa:2048 -keyout private.key -out certificate.crt | ||
resource "null_resource" "this" { | ||
provisioner "local-exec" { | ||
command = "echo -e '\\n\\n\\n\\n\\n\\n\\n\\n' | openssl req -x509 -nodes -days 8 -newkey rsa:2048 -keyout private.key -out certificate.crt" | ||
interpreter = ["/bin/bash", "-c"] | ||
} | ||
} | ||
|
||
data "local_file" "certificate" { | ||
filename = "certificate.crt" | ||
depends_on = [null_resource.this] | ||
} | ||
|
||
data "local_file" "private_key" { | ||
filename = "private.key" | ||
depends_on = [null_resource.this] | ||
} | ||
|
||
resource "aws_iam_server_certificate" "this" { | ||
name = "087_certificate_green" | ||
certificate_body = file("certificate.crt") | ||
private_key = file("private.key") | ||
} | ||
certificate_body = data.local_file.certificate.content | ||
private_key = data.local_file.private_key.content | ||
|
||
} |
26 changes: 20 additions & 6 deletions
26
terraform/ecc-aws-087_iam_ssl_or_tls_certificates_expire_in_one_week/red/certificate.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,22 @@ | ||
###### The step to be done before run infrastructure is to run command below | ||
# sudo openssl req -x509 -nodes -days 4 -newkey rsa:2048 -keyout second-private.key -out second-certificate.crt | ||
resource "null_resource" "this" { | ||
provisioner "local-exec" { | ||
command = "echo -e '\\n\\n\\n\\n\\n\\n\\n\\n' | openssl req -x509 -nodes -days 4 -newkey rsa:2048 -keyout private.key -out certificate.crt" | ||
interpreter = ["/bin/bash", "-c"] | ||
} | ||
} | ||
|
||
resource "aws_iam_server_certificate" "this" { | ||
name = "087_certificate_red" | ||
certificate_body = file("second-certificate.crt") | ||
private_key = file("second-private.key") | ||
data "local_file" "certificate" { | ||
filename = "certificate.crt" | ||
depends_on = [null_resource.this] | ||
} | ||
|
||
data "local_file" "private_key" { | ||
filename = "private.key" | ||
depends_on = [null_resource.this] | ||
} | ||
|
||
resource "aws_iam_server_certificate" "this" { | ||
name = "086_certificate_red" | ||
certificate_body = data.local_file.certificate.content | ||
private_key = data.local_file.private_key.content | ||
} |
7 changes: 6 additions & 1 deletion
7
terraform/ecc-aws-090-use_secure_ciphers_in_cloudfront_distribution/green/cloudfront.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
terraform/ecc-aws-090-use_secure_ciphers_in_cloudfront_distribution/red/cloudfront.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 30 additions & 10 deletions
40
terraform/ecc-aws-101-clb_access_logging_disabled/green/s3.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.