Skip to content

Commit 99ccd12

Browse files
committed
Add variables for customizing S3 access logging bucket
1 parent e81c098 commit 99ccd12

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ region = "us-east-1"
6262
| allowed\_account\_ids | Account IDs that are allowed to access the bucket/KMS key | list(string) | `[]` | no |
6363
| bucket | Name of bucket to create \(do not provide if using `remote_bucket`\) | string | `""` | no |
6464
| kms\_key\_id | ARN for KMS key for all encryption operations. | string | `""` | no |
65+
| logging\_target\_bucket | The name of the bucket that will receive the log objects | string | `var.bucket` | no |
66+
| logging\_target\_prefix | A key prefix for log objects | string | `"TFStateLogs/"` | no |
6567
| region | Region bucket will be created in | string | n/a | yes |
6668
| remote\_bucket | If specified, the remote bucket will be used for the backend. A new bucket will not be created | string | `""` | no |
6769
| table | Name of Dynamo Table to create | string | `"tf-locktable"` | no |

main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ resource "aws_s3_bucket" "this" {
4949
}
5050

5151
logging {
52-
target_bucket = var.bucket
53-
target_prefix = "TFStateLogs/"
52+
target_bucket = var.logging_target_bucket != "" ? var.logging_target_bucket : var.bucket
53+
target_prefix = var.logging_target_prefix
5454
}
5555
}
5656

variables.tf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ variable "kms_key_id" {
1616
type = string
1717
}
1818

19+
variable "logging_target_bucket" {
20+
default = ""
21+
description = "The name of the bucket that will receive the log objects"
22+
type = string
23+
}
24+
25+
variable "logging_target_prefix" {
26+
default = "TFStateLogs/"
27+
description = "A key prefix for log objects"
28+
type = string
29+
}
30+
1931
variable "region" {
2032
description = "Region bucket will be created in"
2133
type = string

0 commit comments

Comments
 (0)