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

Pass ephemeral variables to terraform apply #35903

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

DanielMSchmidt
Copy link
Collaborator

@DanielMSchmidt DanielMSchmidt commented Oct 25, 2024

This PR improves how we can pass values to ephemeral variables in the apply command, now CLI flags, environment variables, and vars files are supported. We will deal with interactive inputs in a separate PR to keep this one smaller.

Jira: TF-21848

Target Release

1.10.x

Draft CHANGELOG entry

ENHANCEMENTS

  • Allow apply-time ephemeral variables

@DanielMSchmidt DanielMSchmidt marked this pull request as ready for review November 4, 2024 14:35
@DanielMSchmidt DanielMSchmidt force-pushed the pass-ephemeral-variables-to-terraform-apply branch from 92c559a to 3207836 Compare November 4, 2024 14:35
@radeksimko radeksimko added the 1.10-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged label Nov 4, 2024
Copy link
Member

@jbardin jbardin left a comment

Choose a reason for hiding this comment

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

Just a couple things inline, but overall this look good.

Subject: rng,
})
} else {
if v.Value.Equals(val) == cty.False {
Copy link
Member

Choose a reason for hiding this comment

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

cty.Values can't be directly compared (which is why you're using Equals). cty.Value has True() and False() methods for boolean operations.

Copy link
Member

Choose a reason for hiding this comment

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

Note this probably works fine here due to the context so we don't ned to deal with nulls, unknowns, marks, etc. it's just that comparing a boolean in a boolean expression just looks so wrong ;)

}
},

// "passing ephemeral variable through interactive prompts": func(t *testing.T, c *ApplyCommand, statePath, planPath string, done func(*testing.T) *terminal.TestOutput) {
Copy link
Member

Choose a reason for hiding this comment

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

Is this something we intend to support?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we do, I was planning on doing it in a separate PR though.

Copy link
Member

Choose a reason for hiding this comment

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

hmm, I just tried the interactive prompt workflow, which is broken by this. Is there an easy way to disable interactive prompts in plan for now? The most common case for interactive prompts is someone simply running a combined plan+apply with terraform apply, which fails with No value for required variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.10-backport If you add this label to a PR before merging, backport-assistant will open a new PR once merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants