Skip to content

Commit a3baf3c

Browse files
committed
Deny non-HTTPS access on S3 Bucket Policy
1 parent ff01480 commit a3baf3c

File tree

1 file changed

+34
-22
lines changed

1 file changed

+34
-22
lines changed

examples/windows/main.tf

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,27 @@ locals {
2626

2727
module "ec2-image-builder" {
2828
# source = "aws-ia/ec2-image-builder/aws"
29-
source = "../.."
30-
name = local.name
31-
aws_region = local.aws_region
32-
vpc_id = module.vpc.vpc_id
33-
subnet_id = module.vpc.private_subnets[0]
34-
source_cidr = [local.vpc_cidr] #["<ENTER your IP here to access EC2 Image Builder Instances through RDP or SSH>]"
35-
create_security_group = true
36-
instance_types = ["c5.large"]
37-
instance_key_pair = aws_key_pair.imagebuilder.key_name
38-
source_ami_name = "Windows_Server-2022-English-Core-Base-*"
39-
ami_name = "Windows 2022 core AMI"
40-
ami_description = "Windows 2022 core AMI provided by AWS"
41-
recipe_version = "0.0.1"
42-
build_component_arn = [aws_imagebuilder_component.win2022build.arn]
43-
test_component_arn = [aws_imagebuilder_component.win2022test.arn]
44-
s3_bucket_name = aws_s3_bucket.ec2_image_builder_components.id
45-
attach_custom_policy = true
46-
custom_policy_arn = aws_iam_policy.policy.arn
47-
platform = "Windows"
48-
imagebuilder_image_recipe_kms_key_arn = aws_kms_key.imagebuilder_image_recipe_kms_key.arn
49-
tags = local.tags
29+
source = "../.."
30+
name = local.name
31+
aws_region = local.aws_region
32+
vpc_id = module.vpc.vpc_id
33+
subnet_id = module.vpc.private_subnets[0]
34+
source_cidr = [local.vpc_cidr] #["<ENTER your IP here to access EC2 Image Builder Instances through RDP or SSH>]"
35+
create_security_group = true
36+
instance_types = ["c5.large"]
37+
instance_key_pair = aws_key_pair.imagebuilder.key_name
38+
source_ami_name = "Windows_Server-2022-English-Core-Base-*"
39+
ami_name = "Windows 2022 core AMI"
40+
ami_description = "Windows 2022 core AMI provided by AWS"
41+
recipe_version = "0.0.1"
42+
build_component_arn = [aws_imagebuilder_component.win2022build.arn]
43+
test_component_arn = [aws_imagebuilder_component.win2022test.arn]
44+
s3_bucket_name = aws_s3_bucket.ec2_image_builder_components.id
45+
attach_custom_policy = true
46+
custom_policy_arn = aws_iam_policy.policy.arn
47+
platform = "Windows"
48+
imagebuilder_image_recipe_kms_key_arn = aws_kms_key.imagebuilder_image_recipe_kms_key.arn
49+
tags = local.tags
5050

5151
managed_components = [{
5252
name = "powershell-windows",
@@ -196,7 +196,19 @@ resource "aws_s3_bucket_policy" "bucket_policy" {
196196
"${aws_s3_bucket.ec2_image_builder_components.arn}",
197197
"${aws_s3_bucket.ec2_image_builder_components.arn}/*"
198198
]
199-
}
199+
},
200+
{
201+
"Sid": "Deny non-HTTPS access",
202+
"Effect": "Deny",
203+
"Principal": "*",
204+
"Action": [ "s3:*" ],
205+
"Resource": "${aws_s3_bucket.ec2_image_builder_components.arn}/*",
206+
"Condition": {
207+
"Bool": {
208+
"aws:SecureTransport": "false"
209+
}
210+
}
211+
}
200212
]
201213
}
202214
EOF

0 commit comments

Comments
 (0)