Skip to content

Commit 9487b8d

Browse files
Make template for output file configurable (#38)
* Make template for output file configurable * Document new variable * Updated README.md Co-authored-by: actions-bot <[email protected]>
1 parent d39f19c commit 9487b8d

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ Available targets:
187187
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map(string) | `<map>` | no |
188188
| terraform_backend_config_file_name | Name of terraform backend config file | string | `terraform.tf` | no |
189189
| terraform_backend_config_file_path | The path to terrafrom project directory | string | `` | no |
190+
| terraform_backend_config_template_file | The path to the template used to generate the config file | string | `` | no |
190191
| terraform_state_file | The path to the state file inside the bucket | string | `terraform.tfstate` | no |
191192
| terraform_version | The minimum required terraform version | string | `0.12.2` | no |
192193
| write_capacity | DynamoDB write capacity units | string | `5` | no |

docs/terraform.md

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map(string) | `<map>` | no |
3232
| terraform_backend_config_file_name | Name of terraform backend config file | string | `terraform.tf` | no |
3333
| terraform_backend_config_file_path | The path to terrafrom project directory | string | `` | no |
34+
| terraform_backend_config_template_file | The path to the template used to generate the config file | string | `` | no |
3435
| terraform_state_file | The path to the state file inside the bucket | string | `terraform.tfstate` | no |
3536
| terraform_version | The minimum required terraform version | string | `0.12.2` | no |
3637
| write_capacity | DynamoDB write capacity units | string | `5` | no |

main.tf

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ locals {
1212
var.terraform_backend_config_file_name
1313
)
1414

15+
terraform_backend_config_template_file = var.terraform_backend_config_template_file != "" ? var.terraform_backend_config_template_file : "${path.module}/templates/terraform.tf.tpl"
16+
1517
bucket_name = var.s3_bucket_name != "" ? var.s3_bucket_name : module.s3_bucket_label.id
1618
}
1719

@@ -197,7 +199,7 @@ resource "aws_dynamodb_table" "without_server_side_encryption" {
197199
}
198200

199201
data "template_file" "terraform_backend_config" {
200-
template = file("${path.module}/templates/terraform.tf.tpl")
202+
template = file(local.terraform_backend_config_template_file)
201203

202204
vars = {
203205
region = var.region

variables.tf

+7-1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,12 @@ variable "terraform_backend_config_file_path" {
191191
description = "The path to terrafrom project directory"
192192
}
193193

194+
variable "terraform_backend_config_template_file" {
195+
type = string
196+
default = ""
197+
description = "The path to the template used to generate the config file"
198+
}
199+
194200
variable "terraform_version" {
195201
type = string
196202
default = "0.12.2"
@@ -207,4 +213,4 @@ variable "s3_bucket_name" {
207213
type = string
208214
default = ""
209215
description = "S3 bucket name. If not provided, the name will be generated by the label module in the format namespace-stage-name"
210-
}
216+
}

0 commit comments

Comments
 (0)