Skip to content

Commit 7472786

Browse files
feat: add ability to turn off S3 public access block (#164)
Copy of #162 with renaming of variables. --------- Co-authored-by: jameslarrea <[email protected]>
1 parent 162875e commit 7472786

File tree

9 files changed

+36
-15
lines changed

9 files changed

+36
-15
lines changed

examples/organizational/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ $ terraform apply
208208
| <a name="input_name"></a> [name](#input\_name) | Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances | `string` | `"sfc"` | no |
209209
| <a name="input_organizational_member_default_admin_role"></a> [organizational\_member\_default\_admin\_role](#input\_organizational\_member\_default\_admin\_role) | Default role created by AWS for management-account users to be able to admin member accounts.<br/>https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_accounts_access.html | `string` | `"OrganizationAccountAccessRole"` | no |
210210
| <a name="input_tags"></a> [tags](#input\_tags) | customization of tags to be assigned to all resources. <br/>always include 'product' default tag for resource-group proper functioning.<br/>can also make use of the [provider-level `default-tags`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags) | `map(string)` | <pre>{<br> "product": "sysdig-secure-for-cloud"<br>}</pre> | no |
211+
| <a name="input_temporary_cloudtrail_s3_bucket_public_block"></a> [temporary\_cloudtrail\_s3\_bucket\_public\_block](#input\_temporary\_cloudtrail\_s3\_bucket\_public\_block) | Create a S3 bucket public access block configuration.<br/>This is a temporary variable that will be removed once https://aws.amazon.com/blogs/aws/heads-up-amazon-s3-security-changes-are-coming-in-april-of-2023/ is made effective.<br/>After it, the resource will never be created. | `bool` | `true` | no |
211212

212213
## Outputs
213214

examples/organizational/cloudtrail.tf

+5-5
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ module "cloudtrail" {
1616
sysdig_secure_for_cloud_member_account_id = var.sysdig_secure_for_cloud_member_account_id
1717
organizational_role_per_account = var.organizational_member_default_admin_role
1818
}
19-
is_multi_region_trail = var.cloudtrail_is_multi_region_trail
20-
cloudtrail_kms_enable = var.cloudtrail_kms_enable
21-
s3_bucket_expiration_days = var.cloudtrail_s3_bucket_expiration_days
22-
23-
tags = var.tags
19+
is_multi_region_trail = var.cloudtrail_is_multi_region_trail
20+
cloudtrail_kms_enable = var.cloudtrail_kms_enable
21+
s3_bucket_expiration_days = var.cloudtrail_s3_bucket_expiration_days
22+
temporary_s3_bucket_public_block = var.temporary_cloudtrail_s3_bucket_public_block
23+
tags = var.tags
2424
}

examples/organizational/variables.tf

+6-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ variable "cloudtrail_s3_bucket_expiration_days" {
4646
description = "Number of days that the logs will persist in the bucket"
4747
}
4848

49+
variable "temporary_cloudtrail_s3_bucket_public_block" {
50+
type = bool
51+
default = true
52+
description = "Create a S3 bucket public access block configuration.<br/>This is a temporary variable that will be removed once https://aws.amazon.com/blogs/aws/heads-up-amazon-s3-security-changes-are-coming-in-april-of-2023/ is made effective.<br/>After it, the resource will never be created."
53+
}
54+
4955
variable "existing_cloudtrail_config" {
5056
type = object({
5157
cloudtrail_s3_arn = optional(string)
@@ -170,7 +176,6 @@ variable "ecs_task_memory" {
170176
}
171177

172178

173-
174179
#
175180
# general
176181
#

examples/single-account-ecs/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ $ terraform apply
117117
| <a name="input_enable_autoscaling"></a> [enable\_autoscaling](#input\_enable\_autoscaling) | Whether to enable autoscaling or not | `bool` | `false` | no |
118118
| <a name="input_name"></a> [name](#input\_name) | Name to be assigned to all child resources. A suffix may be added internally when required. Use default value unless you need to install multiple instances | `string` | `"sfc"` | no |
119119
| <a name="input_tags"></a> [tags](#input\_tags) | customization of tags to be assigned to all resources. <br/>always include 'product' default tag for resource-group proper functioning.<br/>can also make use of the [provider-level `default-tags`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags) | `map(string)` | <pre>{<br> "product": "sysdig-secure-for-cloud"<br>}</pre> | no |
120+
| <a name="input_temporary_cloudtrail_s3_bucket_public_block"></a> [temporary\_cloudtrail\_s3\_bucket\_public\_block](#input\_temporary\_cloudtrail\_s3\_bucket\_public\_block) | Create a S3 bucket public access block configuration<br/>This is a temporary variable that will be removed once https://aws.amazon.com/blogs/aws/heads-up-amazon-s3-security-changes-are-coming-in-april-of-2023/ is made effective.<br/>After it, the resource will never be created. | `bool` | `true` | no |
120121

121122
## Outputs
122123

examples/single-account-ecs/cloudtrail.tf

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ locals {
44
}
55

66
module "cloudtrail" {
7-
count = local.cloudtrail_deploy ? 1 : 0
8-
source = "../../modules/infrastructure/cloudtrail"
9-
name = var.name
10-
is_organizational = false
11-
is_multi_region_trail = var.cloudtrail_is_multi_region_trail
12-
cloudtrail_kms_enable = var.cloudtrail_kms_enable
13-
s3_bucket_expiration_days = var.cloudtrail_s3_bucket_expiration_days
14-
15-
tags = var.tags
7+
count = local.cloudtrail_deploy ? 1 : 0
8+
source = "../../modules/infrastructure/cloudtrail"
9+
name = var.name
10+
is_organizational = false
11+
is_multi_region_trail = var.cloudtrail_is_multi_region_trail
12+
cloudtrail_kms_enable = var.cloudtrail_kms_enable
13+
s3_bucket_expiration_days = var.cloudtrail_s3_bucket_expiration_days
14+
temporary_s3_bucket_public_block = var.temporary_cloudtrail_s3_bucket_public_block
15+
tags = var.tags
1616
}

examples/single-account-ecs/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ variable "cloudtrail_s3_bucket_expiration_days" {
2929
default = 5
3030
description = "Number of days that the logs will persist in the bucket"
3131
}
32+
33+
variable "temporary_cloudtrail_s3_bucket_public_block" {
34+
type = bool
35+
default = true
36+
description = "Create a S3 bucket public access block configuration<br/>This is a temporary variable that will be removed once https://aws.amazon.com/blogs/aws/heads-up-amazon-s3-security-changes-are-coming-in-april-of-2023/ is made effective.<br/>After it, the resource will never be created."
37+
}
3238
#
3339
# ecs, security group, vpc
3440
#

modules/infrastructure/cloudtrail/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ No modules.
4949
| <a name="input_organizational_config"></a> [organizational\_config](#input\_organizational\_config) | organizational\_config. following attributes must be given<br><ul><li>`sysdig_secure_for_cloud_member_account_id` to enable reading permission</li><br><li>`organizational_role_per_account` to enable SNS topic subscription. by default "OrganizationAccountAccessRole"</li></ul> | <pre>object({<br> sysdig_secure_for_cloud_member_account_id = string<br> organizational_role_per_account = string<br> })</pre> | <pre>{<br> "organizational_role_per_account": null,<br> "sysdig_secure_for_cloud_member_account_id": null<br>}</pre> | no |
5050
| <a name="input_s3_bucket_expiration_days"></a> [s3\_bucket\_expiration\_days](#input\_s3\_bucket\_expiration\_days) | Number of days that the logs will persist in the bucket | `number` | `5` | no |
5151
| <a name="input_tags"></a> [tags](#input\_tags) | customization of tags to be assigned to all resources. <br/>always include 'product' default tag for resource-group proper functioning.<br/>can also make use of the [provider-level `default-tags`](https://registry.terraform.io/providers/hashicorp/aws/latest/docs#default_tags) | `map(string)` | <pre>{<br> "product": "sysdig-secure-for-cloud"<br>}</pre> | no |
52+
| <a name="input_temporary_s3_bucket_public_block"></a> [temporary\_s3\_bucket\_public\_block](#input\_temporary\_s3\_bucket\_public\_block) | Create a S3 bucket public access block configuration<br/>This is a temporary variable that will be removed once https://aws.amazon.com/blogs/aws/heads-up-amazon-s3-security-changes-are-coming-in-april-of-2023/ is made effective.<br/>After it, the resource will never be created. | `bool` | `true` | no |
5253

5354
## Outputs
5455

modules/infrastructure/cloudtrail/s3.tf

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ resource "aws_s3_bucket_acl" "cloudtrail" {
4545
# -------------------------
4646

4747
resource "aws_s3_bucket_public_access_block" "cloudtrail" {
48+
count = var.temporary_s3_bucket_public_block == false ? 0 : 1
4849
bucket = aws_s3_bucket.cloudtrail.id
4950
block_public_acls = true
5051
block_public_policy = true

modules/infrastructure/cloudtrail/variables.tf

+6
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ variable "s3_bucket_expiration_days" {
3939
description = "Number of days that the logs will persist in the bucket"
4040
}
4141

42+
variable "temporary_s3_bucket_public_block" {
43+
type = bool
44+
default = true
45+
description = "Create a S3 bucket public access block configuration<br/>This is a temporary variable that will be removed once https://aws.amazon.com/blogs/aws/heads-up-amazon-s3-security-changes-are-coming-in-april-of-2023/ is made effective.<br/>After it, the resource will never be created."
46+
}
47+
4248
variable "cloudtrail_kms_enable" {
4349
type = bool
4450
default = true

0 commit comments

Comments
 (0)