Skip to content

Commit 169c6ac

Browse files
aknyshclaude
andauthored
Remove cloudposse/template provider; migrate to templatefile() (#60)
* Remove cloudposse/template provider; migrate to templatefile() Replace the deprecated `data "template_file"` user-data rendering with the core `templatefile()` function and drop the `cloudposse/template` provider from `required_providers`. Also bumps Go test module to 1.26.1 and refreshes all test dependencies. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Gate templatefile() behind local.enabled Preserve the disabled-path behavior of the original `data "template_file"` resource, which was scoped via `count = local.enabled ? 1 : 0`. The `local` is now only evaluated when the component is enabled, avoiding potential plan-time failures when `var.user_data` is unset in disabled deployments. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Bump cloudposse/stack-config/yaml remote-state module to 2.0.0 The v1.8.0 module pinned `cloudposse/utils` to `>= 1.7.1, < 2.0.0`, which conflicts with modern components that require `utils >= 2.0.0`. v2.0.0 of the remote-state module pins `utils >= 2.0.0, < 3.0.0`, resolving the `terraform init` provider-resolution failure. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Bump vendored test fixture components to modern versions Point `account-map` at `cloudposse-terraform-components/aws-account-map` v1.537.2 (instead of the old monorepo `terraform-aws-components` 1.520.0 which used stack-config 1.5.0 → pinning utils < 2.0.0). Point `vpc` at aws-vpc v2.2.0 (from v1.536.0). Both modern versions use `cloudposse/stack-config/yaml//modules/remote-state` 2.0.0, which pins `cloudposse/utils >= 2.0.0, < 3.0.0` — compatible with the bumped src. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent cb0f630 commit 169c6ac

8 files changed

Lines changed: 475 additions & 328 deletions

File tree

README.md

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/README.md

Lines changed: 1 addition & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.tf

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ locals {
55
# basic usage picks the first private subnet from the vpc component
66
vpc_private_subnet_ids = sort(module.vpc.outputs.private_subnet_ids)
77
subnet_id = local.vpc_private_subnet_ids[0]
8+
9+
userdata = local.enabled ? templatefile("${path.module}/templates/userdata.sh.tmpl", {
10+
user_data = var.user_data
11+
}) : ""
812
}
913

1014
data "aws_ami" "this" {
@@ -23,15 +27,6 @@ data "aws_ami" "this" {
2327
}
2428
}
2529

26-
data "template_file" "userdata" {
27-
count = local.enabled ? 1 : 0
28-
template = file("${path.module}/templates/userdata.sh.tmpl")
29-
30-
vars = {
31-
user_data = var.user_data
32-
}
33-
}
34-
3530
module "ec2_instance" {
3631
source = "cloudposse/ec2-instance/aws"
3732
version = "2.0.0"
@@ -41,7 +36,7 @@ module "ec2_instance" {
4136
ami = local.enabled ? data.aws_ami.this[0].id : ""
4237
ami_owner = var.ami_owner
4338
instance_type = var.instance_type
44-
user_data_base64 = local.enabled ? base64encode(data.template_file.userdata[0].rendered) : ""
39+
user_data_base64 = local.enabled ? base64encode(local.userdata) : ""
4540

4641
subnet = local.subnet_id
4742
vpc_id = local.vpc_id

src/remote-state.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module "vpc" {
22
source = "cloudposse/stack-config/yaml//modules/remote-state"
3-
version = "1.8.0"
3+
version = "2.0.0"
44

55
component = "vpc"
66

src/versions.tf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,5 @@ terraform {
66
source = "hashicorp/aws"
77
version = ">= 4.0, < 6.0.0"
88
}
9-
template = {
10-
source = "cloudposse/template"
11-
version = ">= 2.2"
12-
}
139
}
1410
}

test/fixtures/vendor.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ metadata:
66
spec:
77
sources:
88
- component: "account-map"
9-
source: github.com/cloudposse/terraform-aws-components.git//modules/account-map?ref={{.Version}}
10-
version: 1.520.0
9+
source: github.com/cloudposse-terraform-components/aws-account-map.git//src?ref={{.Version}}
10+
version: v1.537.2
1111
targets:
1212
- "components/terraform/account-map"
1313
included_paths:
@@ -19,7 +19,7 @@ spec:
1919

2020
- component: "vpc"
2121
source: github.com/cloudposse-terraform-components/aws-vpc.git//src?ref={{.Version}}
22-
version: v1.536.0
22+
version: v2.2.0
2323
targets:
2424
- "components/terraform/vpc"
2525
included_paths:

0 commit comments

Comments
 (0)