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 setting HTTP headers #730

Merged
merged 4 commits into from
May 21, 2020

Conversation

Lucretius
Copy link
Contributor

This PR adds the ability to set HTTP headers for Vault API requests made by the Terraform Vault provider. A sample configuration:

provider "vault" {
  address = "https://testvault.123"

  headers {
    name = "header1"
    value = "valueofheader1"
  }

  headers {
    name = "X-Special-Header"
    value = "specialheadervalue"
  }
}

I have run the acceptance tests locally and also ran this against a Vault cluster in the cloud that requires specific headers in order for requests to forward to the cluster properly.

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Relates OR Closes #0000

Release note for CHANGELOG:

Added `headers` provider configuration setting to allow setting HTTP headers for all requests to the Vault server.

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'
PASS
ok      github.com/terraform-providers/terraform-provider-vault/vault   94.623s

Copy link
Contributor

@tyrannosaurus-becks tyrannosaurus-becks left a comment

Choose a reason for hiding this comment

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

This looks great so far! Just a couple minor things needed.

vault/provider.go Show resolved Hide resolved
Required: true,
Description: "The header name",
},
"value": {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to get test coverage of the name and value fields? It would be cool to see what the Terraform config looks like when they're populated.

Copy link
Contributor Author

@Lucretius Lucretius May 15, 2020

Choose a reason for hiding this comment

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

I copied the basic token name test, and just added a custom provider configuration which included a header. It doesn't test any header related functionality (which would depend on individual use cases), only that the headers don't cause errors when Vault is doing things (in the case of this test, token lookup)

vault/provider.go Show resolved Hide resolved
@ghost ghost added size/M and removed size/S labels May 15, 2020
Copy link
Contributor

@tyrannosaurus-becks tyrannosaurus-becks left a comment

Choose a reason for hiding this comment

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

Thank you!

@tyrannosaurus-becks tyrannosaurus-becks merged commit 29e93a5 into hashicorp:master May 21, 2020
dandandy pushed a commit to dandandy/terraform-provider-vault that referenced this pull request Jun 17, 2021
* allow the config of headers for vault client

* add documentation

* clone existing headers before adding

* PR recommendations, add test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants