cloudposse / cloudposse/atmos

terraform.state mishandles some ipv6 strings

Open
#2,155 0 comments 1 reaction 2 assignees Claimed by @osterman View on GitHub
bug
Dominant language
Go
Stars
1.4k
Forks
175
Avg merge
2d 3h
Merged PRs (30d)
134

Description

### Describe the Bug

When a Terraform module outputs an IPv6 string ending in a double colon `::`, `!terraform.state` mishandles the string, converting it into an object where part of the ipv6 is the key, and `null` is the value.

E.g. `2041:0000:140F::875B::` becomes `"2041:0000:140F::875B:": null`

### Expected Behavior

`!terraform.state` should preserve the string type on an output that ends in double colons.

### Steps to Reproduce

Set up a dummy `terraform_data` component, and instantiate it twice like so (I used `examples/quick-start-start-simple`):

```hcl
# components/terraform/dummy/main.tf
variable "ipv6" {
type = string
description = "The IPv6 address"
}

resource "terraform_data" "this" {
input = var.ipv6
}

output "ipv6" {
value = terraform_data.this.output
description = "An IPv6 output"
}
```

```yaml
# stacks/deploy/dev.yaml
components:
terraform:
dummy1:
metadata:
component: dummy
vars:
ipv6: "2041:0000:140F::875B::"
dummy2:
metadata:
component: dummy
vars:
ipv6: !terraform.state dummy1 ipv6
```

`atmos terraform apply -s dev dummy1` applies successfully.
`atmos terraform apply -s dev dummy2` returns error.

```
│ Error: Invalid value for input variable

│ on dev-dummy2.terraform.tfvars.json line 2:
│ 2: "ipv6": {
│ 3: "2041:0000:140F::875B:": null
│ 4: },

│ The given value is not suitable for var.ipv6 declared at main.tf:1,1-16: string required, but have object.

```

### Screenshots

_No response_

### Environment

- OS darwin/arm64
- Atmos 1.204.0

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.