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

Allow to override global token in the remote backend #28921

Closed
wants to merge 1 commit into from

Conversation

samm-git
Copy link

@samm-git samm-git commented Jun 10, 2021

This PR allows to override token in the backend or data source configuration. This should allow to use different tokens, e.g. in the multi-org setup when main token will be used for the state storage and data source will set own token set.

This unblocks multi-org data sources in TFE using remote_state data source.

This should fix #23093 issue

testcase:

variable "tftoken" {
  type    = string
  default = "<token1>"
}

data "terraform_remote_state" "foo" {
  backend = "remote"

  config = {
    organization = "ORG1"
    hostname = "terraform.example.cloud"
    token =  var.tftoken

    workspaces = {
      name = "test1"
    }
  }
}

data "terraform_remote_state" "bar" {
  backend = "remote"

  config = {
    token = var.tftoken


    organization = "ORG1"
    hostname = "terraform.example.cloud"

    workspaces = {
      name = "test2"
    }
  }
}

data "terraform_remote_state" "neworg" {
  backend = "remote"

  config = {
    token = <token2>

    organization = "ORG2"
    hostname = "terraform.example.cloud"

    workspaces = {
      name = "test"
    }
  }
}
output "foo" {
  value=data.terraform_remote_state.foo.outputs
}

output "bar" {
  value=data.terraform_remote_state.bar.outputs
}

output "neworg" {
  value=data.terraform_remote_state.neworg.outputs
}

@samm-git samm-git changed the title Allow to override token in the remote backend Allow to override global token in the remote backend Jun 10, 2021
@samm-git
Copy link
Author

Ping. Anyone around to review?

@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 May 19, 2022

Thanks for the submission! Since this was filed, as I understand it this issue has been fixed with subsequent PRs. Please see: #30917 and previously #30663 which closed #30664. I am digging into whether or not this closed your issue #23093. I am going to proactively close this PR as it looks like it would require a revisiting in any case even if that issue is still open. Please let me know if you think I am doing so in error. Thanks again for your submission!

@crw crw closed this May 19, 2022
@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 Jun 19, 2022
@samm-git samm-git deleted the patch-1 branch June 29, 2022 05:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remote backend token is ignored by global setting.
3 participants