You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I know this isn't the latest version, but it's the version specified in the go.mod file of github.com/hashicorp/terraform-provider-vault v3.10.0 (latest) and the relevant pieces of code do not appear to have changed since this version.
Relevant provider source code
The Vault provider's auth_login_aws attribute has attributes aws_access_key_id and aws_secret_access_key and uses RequiredWith to assert that they must be set together. Schemata for these fields are defined in internal/provider/auth_aws.go:
When the environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are set, the provider configuration above is valid and well-formed. Validation of the auth_login_aws attribute should succeed even though its aws_access_key_id and aws_secret_access_key attributes are not set.
As far as I can tell, this happens because validateRequiredWithAttribute() does not take the default values for these attributes as provided by their DefaultFuncs into account.
Actual Behavior
Validation of the auth_login_aws attribute fails:
╷
│ Error: Missing required argument
│
│ with provider["registry.terraform.io/hashicorp/vault"],
│ on providers.tf line 13, in provider "vault":
│ 13: auth_login_aws {
│
│ "auth_login_aws.0.aws_secret_access_key": all of `auth_login_aws.0.aws_access_key_id,auth_login_aws.0.aws_secret_access_key` must be specified
╵
Steps to Reproduce
Create a Terraform environment that includes the Vault provider as configured above.
Set values (doesn't matter what) for environment variables AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY.
Run any Terraform command that validates the configuration, e.g. terraform validate, terraform plan, or terraform apply.
Unfortunately, the above-mentioned article does not work as a workaround in this case because it ends up putting sensitive AWS credentials in the statefile that otherwise would not be there.
SDK version
I know this isn't the latest version, but it's the version specified in the go.mod file of github.com/hashicorp/terraform-provider-vault v3.10.0 (latest) and the relevant pieces of code do not appear to have changed since this version.
Relevant provider source code
The Vault provider's
auth_login_aws
attribute has attributesaws_access_key_id
andaws_secret_access_key
and usesRequiredWith
to assert that they must be set together. Schemata for these fields are defined in internal/provider/auth_aws.go:The validator in play is
validateRequiredWithAttribute()
in helper/schema/schema.go:(*ResourceConfig).Get()
calls(*ResourceConfig).get()
which I won't reproduce here.Terraform Configuration Files
Debug Output
I've encrypted the output of
TF_LOG=trace terraform validate
with Hashicorp's PGP key72D7468F
and uploaded the result as a Gist here.Expected Behavior
When the environment variables
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
are set, the provider configuration above is valid and well-formed. Validation of theauth_login_aws
attribute should succeed even though itsaws_access_key_id
andaws_secret_access_key
attributes are not set.As far as I can tell, this happens because
validateRequiredWithAttribute()
does not take the default values for these attributes as provided by theirDefaultFunc
s into account.Actual Behavior
Validation of the
auth_login_aws
attribute fails:Steps to Reproduce
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
.terraform validate
,terraform plan
, orterraform apply
.References
The text was updated successfully, but these errors were encountered: