hashicorp / hashicorp/terraform-provider-cloudinit

Add `cloudinit_config` ephemeral resource

Open
#396 2 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Go
Stars
131
Forks
19
Avg merge
16h 56m
Merged PRs (30d)
6

Description

### Terraform CLI and Provider Versions

Terraform v1.14.3
Provider cloudinit v2.3.7
Provider vault v5.7.0

### Terraform Configuration

```terraform
ephemeral "vault_kv_secret_v2" "secret" {
mount = "mount"
name = "path" // to do: use variables
}

data "cloudinit_config" "conf" {
gzip = false
base64_encode = true

part {
filename = "cloud-config.tpl"
content_type = "text/cloud-config"
content = templatefile(
"${path.module}/path/cloud-init.yaml",
{ key = ephemeral.vault_kv_secret_v2.secret.data.key }
)
}
}
```

### Expected Behavior

The `cloudinit_config.part.content` attribute should accept **ephemeral values**, allowing secrets to be injected directly from Vault KV v2 into cloud-init templates **without storing them in Terraform state**. This would enable fully dynamic and secure cloud-init generation entirely within Terraform.

### Actual Behavior

Terraform returns an error:
```
Error: Invalid use of ephemeral value

with data.cloudinit_config.conf,
on main.tf line XXX, in data "cloudinit_config" "conf":
XXX: data "cloudinit_config" "conf" {

Ephemeral values are not valid for "part", because it is not an assignable
attribute.
```

### Steps to Reproduce

List of steps to reproduce the issue.

1. Define an ephemeral `vault_kv_secret_v2` block
3. Reference `ephemeral.vault_kv_secret_v2.secret.data.key` in cloudinit_config.part.content
5. Run `terraform apply`

### How much impact is this issue causing?

High

### Logs

_No response_

### Additional Information

Current workaround exists using the **deprecated data source**:

```
data "vault_kv_secret_v2" "secret" {
mount = "mount"
name = "path"
}
```

- But relying on the **deprecated** data source is not a long-term solution.
- This feature would allow fully declarative, secret-safe cloud-init generation entirely within Terraform.

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Start at the cloudinit_config data source, specifically the part.content attribute and its handling of values. Reproduce the Terraform configuration with an ephemeral Vault value, then determine the provider changes needed for that value to be accepted without being stored in state; done means the configuration applies successfully and preserves the existing cloud-init output.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cloud
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.