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

Always use token in backend config when provided #30663

Closed
wants to merge 1 commit into from
Closed

Always use token in backend config when provided #30663

wants to merge 1 commit into from

Conversation

tangentspace
Copy link
Contributor

@tangentspace tangentspace commented Mar 12, 2022

This allows overriding a token included in a .terraformrc file by providing a different token in the config block for a terraform_remote_state data source.

Resolves #30664

@hashicorp-cla
Copy link

hashicorp-cla commented Mar 12, 2022

CLA assistant check
All committers have signed the CLA.

@crw
Copy link
Collaborator

crw commented Mar 14, 2022

Thanks for the submission!

@apparentlymart apparentlymart added backend/remote cloud Related to Terraform Cloud's integration with Terraform labels Mar 17, 2022
Copy link
Contributor

@sebasslash sebasslash left a comment

Choose a reason for hiding this comment

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

Wondering if these changes should also be applied here?

token, err := b.token()
if err != nil {
diags = diags.Append(tfdiags.AttributeValue(
tfdiags.Error,
strings.ToUpper(err.Error()[:1])+err.Error()[1:],
"", // no description is needed here, the error is clear
cty.Path{cty.GetAttrStep{Name: "hostname"}},
))
return diags
}
// Get the token from the config if no token was configured for this
// host in credentials section of the CLI Config File.
if token == "" {
if val := obj.GetAttr("token"); !val.IsNull() {
token = val.AsString()
}
}

@github-actions
Copy link

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 May 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
backend/remote bug cloud Related to Terraform Cloud's integration with Terraform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

terraform_remote_state remote backend ignores token in config block when token is present in CLI config
5 participants