From 197fbed0dba2a109fb7574ca2b2ea56bba9b2c48 Mon Sep 17 00:00:00 2001 From: jakemulley Date: Mon, 18 Sep 2023 11:19:36 +0100 Subject: [PATCH] fix: remove deprecated 'template' provider --- README.md | 7 ++----- main.tf | 11 +++-------- versions.tf | 6 +----- 3 files changed, 6 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 8b36b25..2fc3c9f 100644 --- a/README.md +++ b/README.md @@ -216,16 +216,14 @@ See the [examples/](examples/) folder for more information. |------|---------| | [terraform](#requirement\_terraform) | >= 1.2.5 | | [aws](#requirement\_aws) | >= 4.0.0 | -| [random](#requirement\_random) | >= 2.0.0 | -| [template](#requirement\_template) | >= 2.0.0 | +| [random](#requirement\_random) | >= 3.0.0 | ## Providers | Name | Version | |------|---------| | [aws](#provider\_aws) | >= 4.0.0 | -| [random](#provider\_random) | >= 2.0.0 | -| [template](#provider\_template) | >= 2.0.0 | +| [random](#provider\_random) | >= 3.0.0 | ## Modules @@ -240,7 +238,6 @@ No modules. | [aws_s3_bucket_public_access_block.block_public_access](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_public_access_block) | resource | | [random_id.id](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/id) | resource | | [aws_iam_policy_document.irsa](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | -| [template_file.bucket_policy](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source | ## Inputs diff --git a/main.tf b/main.tf index 7019dec..b3c51cc 100644 --- a/main.tf +++ b/main.tf @@ -28,13 +28,8 @@ resource "random_id" "id" { ##################### # Generate policies # ##################### -# TODO: the `template` provider has been deprecated, these need to be removed in a future release. -data "template_file" "bucket_policy" { - template = var.bucket_policy - - vars = { - bucket_arn = "arn:aws:s3:::${local.bucket_name}" - } +locals { + bucket_policy = replace(var.bucket_policy, "$${bucket_arn}", "arn:aws:s3:::${local.bucket_name}") } ################# @@ -46,7 +41,7 @@ resource "aws_s3_bucket" "bucket" { bucket = local.bucket_name acl = var.acl force_destroy = "true" - policy = data.template_file.bucket_policy.rendered + policy = local.bucket_policy dynamic "lifecycle_rule" { for_each = var.lifecycle_rule diff --git a/versions.tf b/versions.tf index fef335d..3d4894d 100644 --- a/versions.tf +++ b/versions.tf @@ -7,11 +7,7 @@ terraform { } random = { source = "hashicorp/random" - version = ">= 2.0.0" - } - template = { - source = "hashicorp/template" - version = ">= 2.0.0" + version = ">= 3.0.0" } } }