Skip to content

Commit

Permalink
Make template for output file configurable (#38)
Browse files Browse the repository at this point in the history
* Make template for output file configurable

* Document new variable

* Updated README.md

Co-authored-by: actions-bot <58130806+actions-bot@users.noreply.github.com>
  • Loading branch information
mabadillamycwt and actions-bot authored Mar 4, 2020
1 parent d39f19c commit 9487b8d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ Available targets:
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map(string) | `<map>` | no |
| terraform_backend_config_file_name | Name of terraform backend config file | string | `terraform.tf` | no |
| terraform_backend_config_file_path | The path to terrafrom project directory | string | `` | no |
| terraform_backend_config_template_file | The path to the template used to generate the config file | string | `` | no |
| terraform_state_file | The path to the state file inside the bucket | string | `terraform.tfstate` | no |
| terraform_version | The minimum required terraform version | string | `0.12.2` | no |
| write_capacity | DynamoDB write capacity units | string | `5` | no |
Expand Down
1 change: 1 addition & 0 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
| tags | Additional tags (e.g. `map('BusinessUnit','XYZ')` | map(string) | `<map>` | no |
| terraform_backend_config_file_name | Name of terraform backend config file | string | `terraform.tf` | no |
| terraform_backend_config_file_path | The path to terrafrom project directory | string | `` | no |
| terraform_backend_config_template_file | The path to the template used to generate the config file | string | `` | no |
| terraform_state_file | The path to the state file inside the bucket | string | `terraform.tfstate` | no |
| terraform_version | The minimum required terraform version | string | `0.12.2` | no |
| write_capacity | DynamoDB write capacity units | string | `5` | no |
Expand Down
4 changes: 3 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ locals {
var.terraform_backend_config_file_name
)

terraform_backend_config_template_file = var.terraform_backend_config_template_file != "" ? var.terraform_backend_config_template_file : "${path.module}/templates/terraform.tf.tpl"

bucket_name = var.s3_bucket_name != "" ? var.s3_bucket_name : module.s3_bucket_label.id
}

Expand Down Expand Up @@ -197,7 +199,7 @@ resource "aws_dynamodb_table" "without_server_side_encryption" {
}

data "template_file" "terraform_backend_config" {
template = file("${path.module}/templates/terraform.tf.tpl")
template = file(local.terraform_backend_config_template_file)

vars = {
region = var.region
Expand Down
8 changes: 7 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ variable "terraform_backend_config_file_path" {
description = "The path to terrafrom project directory"
}

variable "terraform_backend_config_template_file" {
type = string
default = ""
description = "The path to the template used to generate the config file"
}

variable "terraform_version" {
type = string
default = "0.12.2"
Expand All @@ -207,4 +213,4 @@ variable "s3_bucket_name" {
type = string
default = ""
description = "S3 bucket name. If not provided, the name will be generated by the label module in the format namespace-stage-name"
}
}

0 comments on commit 9487b8d

Please sign in to comment.