Remote State Data Source Error

Hi,
I’m trying to retrieve state from a “terraform_remote_state” data source in my code. Am getting the following log output:

$ terraform plan
2020/10/20 09:12:38 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----
2020/10/20 09:12:38 [INFO] Terraform version: 0.13.0  
2020/10/20 09:12:38 [INFO] Go runtime version: go1.14.7
2020/10/20 09:12:38 [INFO] CLI args: []string{"/usr/local/bin/terraform", "plan"}
2020/10/20 09:12:38 [INFO] CLI command args: []string{"plan"}
2020/10/20 09:12:38 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----
2020/10/20 09:12:38 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----
2020/10/20 09:12:38 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2020/10/20 09:12:39 [INFO] Failed to read plugin lock file .terraform/plugins/darwin_amd64/lock.json: open .terraform/plugins/darwin_amd64/lock.json: no such file or directory
2020/10/20 09:12:39 [INFO] backend/local: starting Plan operation
2020-10-20T09:12:40.590+0100 [INFO]  plugin: configuring client automatic mTLS
2020-10-20T09:12:40.669+0100 [INFO]  plugin.terraform-provider-aws_v3.2.0_x5: configuring server automatic mTLS: timestamp=2020-10-20T09:12:40.669+0100
2020-10-20T09:12:40.853+0100 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2020/10/20 09:12:40 [INFO] terraform: building graph: GraphTypeValidate
2020/10/20 09:12:40 [ERROR] AttachSchemaTransformer: No provider config schema available for provider["terraform.io/builtin/terraform"]
2020/10/20 09:12:40 [WARN] EvalValidateProvider: no config schema is available for provider["terraform.io/builtin/terraform"], so using empty schema
2020-10-20T09:12:40.860+0100 [INFO]  plugin: configuring client automatic mTLS
2020-10-20T09:12:40.927+0100 [INFO]  plugin.terraform-provider-aws_v3.2.0_x5: configuring server automatic mTLS: timestamp=2020-10-20T09:12:40.927+0100
2020/10/20 09:12:41 [WARN] Not fixing up EachModes for module.master_nodes because it has no config
2020/10/20 09:12:41 [WARN] Not fixing up EachModes for module.master_nodes.module.subnets because it has no config
2020/10/20 09:12:41 [WARN] Not fixing up EachModes for module.master_nodes.module.node_scaling_group because it has no config
2020-10-20T09:12:41.156+0100 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2020/10/20 09:12:41 [INFO] backend/local: plan calling Refresh
2020/10/20 09:12:41 [INFO] terraform: building graph: GraphTypeRefresh
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.

2020/10/20 09:12:41 [ERROR] AttachSchemaTransformer: No provider config schema available for provider["terraform.io/builtin/terraform"]
2020-10-20T09:12:41.160+0100 [INFO]  plugin: configuring client automatic mTLS
2020/10/20 09:12:41 [WARN] ReferenceTransformer: reference not found: "var.tf_bucket"
2020/10/20 09:12:41 [WARN] ReferenceTransformer: reference not found: "var.region_state_key"
2020/10/20 09:12:41 [WARN] ReferenceTransformer: reference not found: "var.region"
2020-10-20T09:12:41.227+0100 [INFO]  plugin.terraform-provider-aws_v3.2.0_x5: configuring server automatic mTLS: timestamp=2020-10-20T09:12:41.227+0100
data.terraform_remote_state.region_state: Refreshing state...
2020/10/20 09:12:41 [WARN] Log levels other than TRACE are currently unreliable, and are supported only for backward compatibility.
  Use TF_LOG=TRACE to see Terraform's internal logs.
  ----
2020/10/20 09:12:41 [INFO] Attempting to use session-derived credentials
module.master_nodes.module.node_scaling_group.aws_launch_configuration.instance_config: Refreshing state... [id=es-idt-atm-platform-dev-masternode-launcher20201020074232299300000001]
2020-10-20T09:12:42.920+0100 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2020/10/20 09:12:47 [ERROR] eval: *terraform.evalReadDataRefresh, err: error configuring S3 Backend: no valid credential sources for S3 Backend found.

Please see https://www.terraform.io/docs/backends/types/s3.html
for more information about providing credentials.

Error: NoCredentialProviders: no valid providers in chain. Deprecated.
	For verbose messaging see aws.Config.CredentialsChainVerboseErrors
2020/10/20 09:12:47 [ERROR] eval: *terraform.EvalSequence, err: error configuring S3 Backend: no valid credential sources for S3 Backend found.

Please see https://www.terraform.io/docs/backends/types/s3.html
for more information about providing credentials.

Error: NoCredentialProviders: no valid providers in chain. Deprecated.
	For verbose messaging see aws.Config.CredentialsChainVerboseErrors

Error: error configuring S3 Backend: no valid credential sources for S3 Backend found.

Please see https://www.terraform.io/docs/backends/types/s3.html
for more information about providing credentials.

Error: NoCredentialProviders: no valid providers in chain. Deprecated.
	For verbose messaging see aws.Config.CredentialsChainVerboseErrors

However, if I remove the data source config then terraform plan succeeds. So my provider and backend configs are fine. I’ve stripped back the code right back to highlight the issue. It looks like this:

terraform {

  required_version = "~> 0.13"

  backend "s3" {

    key = "path/to/this/statefile/terraform.tfstate"

  }
}

data "terraform_remote_state" "other_state" {

  backend = "s3"

  config = {
    bucket = var.bucket
    key    = "path/to/other/statefile/terraform.tfstate"
    region = var.region
  }

}

Would appreciate help understanding what I need to do stop this remote state call throwing errors.

Note I am reading credentials from a local credentials file seeing as I’m testing atm.

Regards

1 Like