diff --git a/CHANGELOG.md b/CHANGELOG.md index c746dc2..81b73bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -91,3 +91,9 @@ * v1.10.3 -- 20210414 - iam-general-policies - add deny-readonly-data + +* v1.10.4 -- 20210421 + - s3-access-logs + - add 120s delay before applying bucket policy + - s3-flow-logs + - add 120s delay before applying bucket policy diff --git a/common/version.tf b/common/version.tf index 8fa9c1f..139b925 100644 --- a/common/version.tf +++ b/common/version.tf @@ -1,3 +1,3 @@ locals { - _module_version = "1.10.3" + _module_version = "1.10.4" } diff --git a/s3-access-logs/README.md b/s3-access-logs/README.md index c44b539..0ac9c67 100644 --- a/s3-access-logs/README.md +++ b/s3-access-logs/README.md @@ -1,13 +1,13 @@ # aws-inf-setup :: s3-access-logs -This set up the needed components for S3 access log bucket. An access log must exist in each region +This set up the needed components for S3 access log bucket. An access log must exist in each region where there are components wishing to use access logs (S3, ALB, etc.). * S3 bucket * S3 bucket objects (key prefixes, aka "directories") * S3 bucket policy -# Usage +# Usage Here is a simple example, the one most commonly expected to be used. ```hcl @@ -16,8 +16,8 @@ module "logs" { } ``` -This one can be used if you need to customize stuff, though really, the defaults are all built -for a reason, and deployment code (i.e., Ansible) will expect these defaults to be used in +This one can be used if you need to customize stuff, though really, the defaults are all built +for a reason, and deployment code (i.e., Ansible) will expect these defaults to be used in variable file generation. ```hcl @@ -46,40 +46,42 @@ No requirements. | Name | Version | |------|---------| -| aws | n/a | +| [aws](#provider\_aws) | n/a | +| [null](#provider\_null) | n/a | ## Modules -No Modules. +No modules. ## Resources -| Name | -|------| -| [aws_arn](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | -| [aws_caller_identity](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | -| [aws_iam_policy_document](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | -| [aws_region](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | -| [aws_s3_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | -| [aws_s3_bucket_object](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object) | -| [aws_s3_bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | -| [aws_s3_bucket_public_access_block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | +| Name | Type | +|------|------| +| [aws_s3_bucket.logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | +| [aws_s3_bucket_object.logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_object) | resource | +| [aws_s3_bucket_policy.logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | +| [aws_s3_bucket_public_access_block.logs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | +| [null_resource.policy_delay](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | +| [aws_arn.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source | +| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | +| [aws_iam_policy_document.logs_s3](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | +| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| account\_alias | AWS Account Alias | `string` | `""` | no | -| account\_id | AWS Account ID (default will pull from current user) | `string` | `""` | no | -| bucket\_name | Logging S3 bucket name | `string` | `""` | no | -| bucket\_name\_prefix | Logging S3 bucket prefix, prepended to the AWS account ID and region to make the bucket name. | `string` | `"inf-logs"` | no | -| component\_tags | Additional tags for Components (s3, kms, ddb) | `map(map(string))` |
{
"ddb": {},
"kms": {},
"s3": {}
}
| no | -| override\_prefixes | Override built-in prefixes by component (efs, s3, ebs, kms, role, policy, security-group). This should be used primarily for common infrastructure things | `map(string)` | `{}` | no | -| tags | AWS Tags to apply to appropriate resources (S3, KMS). Do not include safeguard tags here, use the data\_safeguard field for such things. | `map(string)` | `{}` | no | +| [account\_alias](#input\_account\_alias) | AWS Account Alias | `string` | `""` | no | +| [account\_id](#input\_account\_id) | AWS Account ID (default will pull from current user) | `string` | `""` | no | +| [bucket\_name](#input\_bucket\_name) | Logging S3 bucket name | `string` | `""` | no | +| [bucket\_name\_prefix](#input\_bucket\_name\_prefix) | Logging S3 bucket prefix, prepended to the AWS account ID and region to make the bucket name. | `string` | `"inf-logs"` | no | +| [component\_tags](#input\_component\_tags) | Additional tags for Components (s3, kms, ddb) | `map(map(string))` |
{
"ddb": {},
"kms": {},
"s3": {}
}
| no | +| [override\_prefixes](#input\_override\_prefixes) | Override built-in prefixes by component (efs, s3, ebs, kms, role, policy, security-group). This should be used primarily for common infrastructure things | `map(string)` | `{}` | no | +| [tags](#input\_tags) | AWS Tags to apply to appropriate resources (S3, KMS). Do not include safeguard tags here, use the data\_safeguard field for such things. | `map(string)` | `{}` | no | ## Outputs | Name | Description | |------|-------------| -| bucket\_arn | Logging S3 bucket ARN | -| bucket\_id | Logging S3 bucket ID | +| [bucket\_arn](#output\_bucket\_arn) | Logging S3 bucket ARN | +| [bucket\_id](#output\_bucket\_id) | Logging S3 bucket ID | diff --git a/s3-access-logs/main.tf b/s3-access-logs/main.tf index 339220c..e31aa60 100644 --- a/s3-access-logs/main.tf +++ b/s3-access-logs/main.tf @@ -117,7 +117,18 @@ resource "aws_s3_bucket_object" "logs" { } resource "aws_s3_bucket_policy" "logs" { - bucket = aws_s3_bucket.logs.id - policy = data.aws_iam_policy_document.logs_s3.json + bucket = aws_s3_bucket.logs.id + policy = data.aws_iam_policy_document.logs_s3.json + depends_on = [null_resource.policy_delay] } +# consider making sleep value a variable +resource "null_resource" "policy_delay" { + triggers = { + bucket = aws_s3_bucket.logs.id + } + provisioner "local-exec" { + when = create + command = "sleep 120" + } +} diff --git a/s3-flow-logs/README.md b/s3-flow-logs/README.md index 20a076f..c105b0d 100644 --- a/s3-flow-logs/README.md +++ b/s3-flow-logs/README.md @@ -1,13 +1,13 @@ # aws-inf-setup :: s3-flow-logs -This set up the needed components for S3 VPC flow log bucket. Only one flow log bucket is +This set up the needed components for S3 VPC flow log bucket. Only one flow log bucket is needed * S3 bucket * S3 bucket objects (key prefixes, aka "directories") * S3 bucket policy -# Usage +# Usage Here is a simple example, the one most commonly expected to be used. ```hcl @@ -16,8 +16,8 @@ module "flowlogs" { } ``` -This one can be used if you need to customize stuff, though really, the defaults are all built -for a reason, and deployment code (i.e., Ansible) will expect these defaults to be used in +This one can be used if you need to customize stuff, though really, the defaults are all built +for a reason, and deployment code (i.e., Ansible) will expect these defaults to be used in variable file generation. ```hcl @@ -46,39 +46,41 @@ No requirements. | Name | Version | |------|---------| -| aws | n/a | +| [aws](#provider\_aws) | n/a | +| [null](#provider\_null) | n/a | ## Modules -No Modules. +No modules. ## Resources -| Name | -|------| -| [aws_arn](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | -| [aws_caller_identity](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | -| [aws_iam_policy_document](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | -| [aws_region](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | -| [aws_s3_bucket](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | -| [aws_s3_bucket_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | -| [aws_s3_bucket_public_access_block](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | +| Name | Type | +|------|------| +| [aws_s3_bucket.flowlogs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | +| [aws_s3_bucket_policy.flowlogs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | +| [aws_s3_bucket_public_access_block.flowlogs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | +| [null_resource.policy_delay](https://registry.terraform.io/providers/hashicorp/null/latest/docs/resources/resource) | resource | +| [aws_arn.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/arn) | data source | +| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | +| [aws_iam_policy_document.flowlogs_s3](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | +| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source | ## Inputs | Name | Description | Type | Default | Required | |------|-------------|------|---------|:--------:| -| account\_alias | AWS Account Alias | `string` | `""` | no | -| account\_id | AWS Account ID (default will pull from current user) | `string` | `""` | no | -| bucket\_name | VPC Flow Logs S3 bucket name | `string` | `""` | no | -| bucket\_name\_prefix | VPC Flow Logs S3 bucket prefix, prepended to the AWS account ID to make the bucket name. | `string` | `"inf-flowlogs"` | no | -| component\_tags | Additional tags for Components (s3, kms, ddb) | `map(map(string))` |
{
"ddb": {},
"kms": {},
"s3": {}
}
| no | -| override\_prefixes | Override built-in prefixes by component (efs, s3, ebs, kms, role, policy, security-group). This should be used primarily for common infrastructure things | `map(string)` | `{}` | no | -| tags | AWS Tags to apply to appropriate resources (S3, KMS). Do not include safeguard tags here, use the data\_safeguard field for such things. | `map(string)` | `{}` | no | +| [account\_alias](#input\_account\_alias) | AWS Account Alias | `string` | `""` | no | +| [account\_id](#input\_account\_id) | AWS Account ID (default will pull from current user) | `string` | `""` | no | +| [bucket\_name](#input\_bucket\_name) | VPC Flow Logs S3 bucket name | `string` | `""` | no | +| [bucket\_name\_prefix](#input\_bucket\_name\_prefix) | VPC Flow Logs S3 bucket prefix, prepended to the AWS account ID to make the bucket name. | `string` | `"inf-flowlogs"` | no | +| [component\_tags](#input\_component\_tags) | Additional tags for Components (s3, kms, ddb) | `map(map(string))` |
{
"ddb": {},
"kms": {},
"s3": {}
}
| no | +| [override\_prefixes](#input\_override\_prefixes) | Override built-in prefixes by component (efs, s3, ebs, kms, role, policy, security-group). This should be used primarily for common infrastructure things | `map(string)` | `{}` | no | +| [tags](#input\_tags) | AWS Tags to apply to appropriate resources (S3, KMS). Do not include safeguard tags here, use the data\_safeguard field for such things. | `map(string)` | `{}` | no | ## Outputs | Name | Description | |------|-------------| -| bucket\_arn | VPC Flow Logs S3 bucket ARN | -| bucket\_id | VPC Flow Logs S3 bucket ID | +| [bucket\_arn](#output\_bucket\_arn) | VPC Flow Logs S3 bucket ARN | +| [bucket\_id](#output\_bucket\_id) | VPC Flow Logs S3 bucket ID | diff --git a/s3-flow-logs/main.tf b/s3-flow-logs/main.tf index 5ef71a5..14718cb 100644 --- a/s3-flow-logs/main.tf +++ b/s3-flow-logs/main.tf @@ -105,6 +105,18 @@ resource "aws_s3_bucket_public_access_block" "flowlogs" { } resource "aws_s3_bucket_policy" "flowlogs" { - bucket = aws_s3_bucket.flowlogs.id - policy = data.aws_iam_policy_document.flowlogs_s3.json + bucket = aws_s3_bucket.flowlogs.id + policy = data.aws_iam_policy_document.flowlogs_s3.json + depends_on = [null_resource.policy_delay] +} + +# consider making sleep value a variable +resource "null_resource" "policy_delay" { + triggers = { + bucket = aws_s3_bucket.flowlogs.id + } + provisioner "local-exec" { + when = create + command = "sleep 120" + } }