Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update splat expressions in directives #32074

Merged
merged 1 commit into from
Jul 14, 2023
Merged

Conversation

bendrucker
Copy link
Contributor

Updates the Expressions > Strings and Templates docs to use the recommend splat expression syntax, with square brackets. While Terraform continues to support the .* syntax for resources with count, the docs describe them as "legacy 'attribute-only' splat expressions."

For good measure, I tested to confirm this works:

output "ips" {
  value = <<-EOF
    %{ for ip in aws_instance.example[*].private_ip }
    server ${ip}
    %{ endfor }
  EOF
}

resource "aws_instance" "example" {
  count = 2
  instance_type = "t3.nano"
  ami = "ami-0d593311db5abb72b"
}
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.

Outputs:

ips = <<EOT

server 172.31.52.27

server 172.31.53.123


EOT

@bendrucker
Copy link
Contributor Author

bendrucker commented Oct 25, 2022

See also terraform-linters/tflint-ruleset-terraform#43 — TFLint will soon be able to detect the use of legacy splat expressions in directives and recommend that square brackets be used instead.

@crw
Copy link
Collaborator

crw commented Oct 26, 2022

Thanks for this submission! It is appreciated! I've notified the docs team.

Copy link
Contributor

@trujillo-adam trujillo-adam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates!

@trujillo-adam trujillo-adam added the tw-reviewed Technical Writing has reviewed this PR. label Jul 14, 2023
@crw crw added the 1.5-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Jul 14, 2023
@crw crw merged commit 7d1e918 into hashicorp:main Jul 14, 2023
@github-actions
Copy link
Contributor

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1.5-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged documentation tw-reviewed Technical Writing has reviewed this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants