Skip to content

Commit dbfb96e

Browse files
authored
fix: allow_s3 on logs bucket and define log_prefix (#123)
* fix: fixes #122 * chore: use latest version of s3-private-bucket module * chore: use newer version of private bucket module
1 parent d09b4f4 commit dbfb96e

File tree

8 files changed

+97
-94
lines changed

8 files changed

+97
-94
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
terraform.tfstate
44
terraform.tfstate.backup
55
terraform.tfstate.*.backup
6+
.terraform.lock.hcl

.markdownlintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"first-line-h1": false,
55
"line_length": false,
66
"no-multiple-blanks": false,
7-
"no-inline-html": false
7+
"no-inline-html": false,
8+
"no-alt-text": false
89
}

.pre-commit-config.yaml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v5.0.0
44
hooks:
55
- id: check-json
66
- id: check-merge-conflict
@@ -15,7 +15,7 @@ repos:
1515
- id: mixed-line-ending
1616

1717
- repo: https://github.com/executablebooks/mdformat
18-
rev: 0.7.16
18+
rev: 0.7.21
1919
hooks:
2020
- id: mdformat
2121
additional_dependencies:
@@ -25,22 +25,16 @@ repos:
2525
exclude: README.m(ark)?d(own)?
2626

2727
- repo: https://github.com/igorshubovych/markdownlint-cli
28-
rev: v0.33.0
28+
rev: v0.43.0
2929
hooks:
3030
- id: markdownlint
3131

32-
- repo: https://github.com/detailyang/pre-commit-shell
33-
rev: 1.0.5
34-
hooks:
35-
- id: shell-lint
36-
3732
- repo: https://github.com/terraform-docs/terraform-docs
38-
rev: "v0.16.0"
33+
rev: "v0.19.0"
3934
hooks:
40-
- id: terraform-docs-go
41-
args: ["markdown", "table", "--output-file", "README.md", "."]
35+
- id: terraform-docs-system
4236

4337
- repo: https://github.com/antonbabenko/pre-commit-terraform
44-
rev: v1.77.1
38+
rev: v1.96.3
4539
hooks:
4640
- id: terraform_fmt

.terraform-docs.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,35 @@
1+
version: ">= 0.19.0, < 1.0.0"
2+
13
settings:
24
html: false
35
anchor: false
6+
escape: false
7+
lockfile: false
8+
hide-empty: true
49
formatter: "markdown table"
10+
11+
sort:
12+
enabled: true
13+
by: required
14+
15+
sections:
16+
show:
17+
- requirements
18+
- providers
19+
- modules
20+
- data-sources
21+
- resources
22+
- inputs
23+
- outputs
24+
25+
recursive:
26+
enabled: false
27+
include-main: false
28+
29+
output:
30+
file: README.md
31+
mode: inject
32+
template: |-
33+
<!-- BEGIN_TF_DOCS -->
34+
{{ .Content }}
35+
<!-- END_TF_DOCS -->

README.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ module "bootstrap" {
2626
| Name | Version |
2727
|------|---------|
2828
| terraform | >= 1.0 |
29-
| aws | >= 3.75.0 |
29+
| aws | >= 5.43.0 |
3030

3131
## Providers
3232

3333
| Name | Version |
3434
|------|---------|
35-
| aws | >= 3.75.0 |
35+
| aws | >= 5.43.0 |
3636

3737
## Modules
3838

3939
| Name | Source | Version |
4040
|------|--------|---------|
41-
| terraform\_state\_bucket | trussworks/s3-private-bucket/aws | ~> 7.1.0 |
42-
| terraform\_state\_bucket\_logs | trussworks/logs/aws | ~> 16.2.0 |
41+
| terraform_state_bucket | trussworks/s3-private-bucket/aws | ~> 7.1.0 |
42+
| terraform_state_bucket_logs | trussworks/logs/aws | ~> 16.2.0 |
4343

4444
## Resources
4545

@@ -52,29 +52,26 @@ module "bootstrap" {
5252

5353
| Name | Description | Type | Default | Required |
5454
|------|-------------|------|---------|:--------:|
55-
| account\_alias | The desired AWS account alias. | `string` | n/a | yes |
56-
| bucket\_key\_enabled | Whether or not to use Amazon S3 Bucket Keys for SSE-KMS. | `bool` | `false` | no |
57-
| bucket\_purpose | Name to identify the bucket's purpose | `string` | `"tf-state"` | no |
58-
| dynamodb\_point\_in\_time\_recovery | Point-in-time recovery options | `bool` | `false` | no |
59-
| dynamodb\_table\_name | Name of the DynamoDB Table for locking Terraform state. | `string` | `"terraform-state-lock"` | no |
60-
| dynamodb\_table\_tags | Tags of the DynamoDB Table for locking Terraform state. | `map(string)` | `{}` | no |
61-
| enable\_s3\_public\_access\_block | Bool for toggling whether the s3 public access block resource should be enabled. | `bool` | `true` | no |
62-
| kms\_master\_key\_id | The AWS KMS master key ID used for the SSE-KMS encryption of the state bucket. | `string` | `""` | no |
63-
| log\_bucket\_tags | Tags to associate with the bucket storing the Terraform state bucket logs | `map(string)` | `{}` | no |
64-
| log\_bucket\_versioning | A string that indicates the versioning status for the log bucket. | `string` | `"Disabled"` | no |
65-
| log\_name | Log name (for backwards compatibility this can be modified to logs) | `string` | `"log"` | no |
66-
| log\_retention | Log retention of access logs of state bucket. | `number` | `90` | no |
67-
| manage\_account\_alias | Manage the account alias as a resource. Set to 'false' if this behavior is not desired. | `bool` | `true` | no |
55+
| account_alias | The desired AWS account alias. | `string` | n/a | yes |
6856
| region | AWS region. | `string` | n/a | yes |
69-
| state\_bucket\_tags | Tags to associate with the bucket storing the Terraform state files | `map(string)` | `{}` | no |
57+
| bucket_key_enabled | Whether or not to use Amazon S3 Bucket Keys for SSE-KMS. | `bool` | `false` | no |
58+
| bucket_purpose | Name to identify the bucket's purpose | `string` | `"tf-state"` | no |
59+
| dynamodb_point_in_time_recovery | Point-in-time recovery options | `bool` | `false` | no |
60+
| dynamodb_table_name | Name of the DynamoDB Table for locking Terraform state. | `string` | `"terraform-state-lock"` | no |
61+
| enable_s3_public_access_block | Bool for toggling whether the s3 public access block resource should be enabled. | `bool` | `true` | no |
62+
| kms_master_key_id | The AWS KMS master key ID used for the SSE-KMS encryption of the state bucket. | `string` | `""` | no |
63+
| log_bucket_versioning | A string that indicates the versioning status for the log bucket. | `string` | `"Disabled"` | no |
64+
| log_name | Log name (for backwards compatibility this can be modified to logs) | `string` | `"log"` | no |
65+
| log_retention | Log retention of access logs of state bucket. | `number` | `90` | no |
66+
| manage_account_alias | Manage the account alias as a resource. Set to 'false' if this behavior is not desired. | `bool` | `true` | no |
7067

7168
## Outputs
7269

7370
| Name | Description |
7471
|------|-------------|
75-
| dynamodb\_table | The name of the dynamo db table |
76-
| logging\_bucket | The logging\_bucket name |
77-
| state\_bucket | The state\_bucket name |
72+
| dynamodb_table | The name of the dynamo db table |
73+
| logging_bucket | The logging_bucket name |
74+
| state_bucket | The state_bucket name |
7875
<!-- END_TF_DOCS -->
7976

8077
## Bootstrapping

main.tf

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ resource "aws_iam_account_alias" "alias" {
1414

1515
module "terraform_state_bucket" {
1616
source = "trussworks/s3-private-bucket/aws"
17-
version = "~> 7.1.0"
17+
version = "~> 8.0.2"
1818

1919
bucket = local.state_bucket
2020
logging_bucket = local.logging_bucket
@@ -24,7 +24,6 @@ module "terraform_state_bucket" {
2424
kms_master_key_id = var.kms_master_key_id
2525

2626
enable_s3_public_access_block = var.enable_s3_public_access_block
27-
tags = var.state_bucket_tags
2827

2928
depends_on = [
3029
module.terraform_state_bucket_logs
@@ -37,14 +36,14 @@ module "terraform_state_bucket" {
3736

3837
module "terraform_state_bucket_logs" {
3938
source = "trussworks/logs/aws"
40-
version = "~> 16.2.0"
39+
version = "~> 16.3.0"
4140

4241
s3_bucket_name = local.logging_bucket
4342
default_allow = false
43+
allow_s3 = true
4444
s3_log_bucket_retention = var.log_retention
4545
versioning_status = var.log_bucket_versioning
46-
47-
tags = var.log_bucket_tags
46+
s3_logs_prefix = "s3/${local.state_bucket}"
4847
}
4948

5049
#
@@ -72,6 +71,4 @@ resource "aws_dynamodb_table" "terraform_state_lock" {
7271
point_in_time_recovery {
7372
enabled = var.dynamodb_point_in_time_recovery
7473
}
75-
76-
tags = var.dynamodb_table_tags
7774
}

variables.tf

Lines changed: 34 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,42 @@
1-
variable "dynamodb_table_name" {
2-
description = "Name of the DynamoDB Table for locking Terraform state."
3-
default = "terraform-state-lock"
1+
variable "account_alias" {
2+
description = "The desired AWS account alias."
43
type = string
54
}
65

7-
variable "dynamodb_table_tags" {
8-
description = "Tags of the DynamoDB Table for locking Terraform state."
9-
default = {}
10-
type = map(string)
6+
variable "bucket_key_enabled" {
7+
type = bool
8+
default = false
9+
description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS."
1110
}
1211

13-
variable "region" {
14-
description = "AWS region."
12+
variable "bucket_purpose" {
13+
description = "Name to identify the bucket's purpose"
14+
default = "tf-state"
1515
type = string
1616
}
1717

18-
variable "account_alias" {
19-
description = "The desired AWS account alias."
20-
type = string
18+
variable "dynamodb_point_in_time_recovery" {
19+
type = bool
20+
default = false
21+
description = "Point-in-time recovery options"
2122
}
2223

23-
variable "log_retention" {
24-
description = "Log retention of access logs of state bucket."
25-
default = 90
26-
type = number
24+
variable "dynamodb_table_name" {
25+
description = "Name of the DynamoDB Table for locking Terraform state."
26+
default = "terraform-state-lock"
27+
type = string
2728
}
2829

29-
variable "bucket_purpose" {
30-
description = "Name to identify the bucket's purpose"
31-
default = "tf-state"
32-
type = string
30+
variable "enable_s3_public_access_block" {
31+
description = "Bool for toggling whether the s3 public access block resource should be enabled."
32+
type = bool
33+
default = true
3334
}
3435

35-
variable "log_name" {
36-
description = "Log name (for backwards compatibility this can be modified to logs)"
37-
default = "log"
36+
variable "kms_master_key_id" {
3837
type = string
38+
default = ""
39+
description = "The AWS KMS master key ID used for the SSE-KMS encryption of the state bucket."
3940
}
4041

4142
variable "log_bucket_versioning" {
@@ -48,28 +49,16 @@ variable "log_bucket_versioning" {
4849
}
4950
}
5051

51-
variable "state_bucket_tags" {
52-
type = map(string)
53-
default = {}
54-
description = "Tags to associate with the bucket storing the Terraform state files"
55-
}
56-
57-
variable "log_bucket_tags" {
58-
type = map(string)
59-
default = {}
60-
description = "Tags to associate with the bucket storing the Terraform state bucket logs"
61-
}
62-
63-
variable "enable_s3_public_access_block" {
64-
description = "Bool for toggling whether the s3 public access block resource should be enabled."
65-
type = bool
66-
default = true
52+
variable "log_name" {
53+
description = "Log name (for backwards compatibility this can be modified to logs)"
54+
default = "log"
55+
type = string
6756
}
6857

69-
variable "dynamodb_point_in_time_recovery" {
70-
type = bool
71-
default = false
72-
description = "Point-in-time recovery options"
58+
variable "log_retention" {
59+
description = "Log retention of access logs of state bucket."
60+
default = 90
61+
type = number
7362
}
7463

7564
variable "manage_account_alias" {
@@ -78,14 +67,7 @@ variable "manage_account_alias" {
7867
description = "Manage the account alias as a resource. Set to 'false' if this behavior is not desired."
7968
}
8069

81-
variable "kms_master_key_id" {
70+
variable "region" {
71+
description = "AWS region."
8272
type = string
83-
default = ""
84-
description = "The AWS KMS master key ID used for the SSE-KMS encryption of the state bucket."
85-
}
86-
87-
variable "bucket_key_enabled" {
88-
type = bool
89-
default = false
90-
description = "Whether or not to use Amazon S3 Bucket Keys for SSE-KMS."
9173
}

versions.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = ">= 3.75.0"
7+
version = ">= 5.43.0"
88
}
99
}
1010
}

0 commit comments

Comments
 (0)