I have a remote state on s3 and i don't know how to access to the second block of the tfstate json file.
My tfstate looks like this:
{
"version": 3,
"terraform_version": "0.11.7",
"serial": 1,
"lineage": "79b7840d-5998-1ea8-2b63-ca49c289ec13",
"modules": [
{
"path": [
"root"
],
"outputs": {},
"resources": {},
"depends_on": []
},
{
"path": [
"root",
"vpc"
],
"outputs": {
"database_subnet_group": {
all my resources are listed here...
}
and I can access it this code:
data "terraform_remote_state" "network" {
backend = "s3"
config = {
bucket = "bakka-tfstate"
key = "global/network.tfstate"
region = "eu-west-1"
}
}
but the output
output "tfstate" {
value = data.terraform_remote_state.network.outputs
}
shows me nothing
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
tfstate = {}
I believe it's because there's two json blocks in this tfstate and terraform read the first one which is empty, so i'm asking how to read the second one ?
Only root outputs are accessible through remote state. This limitation is documented here. It also suggests a solution - in the project that produces the state you're referring to, you will need to thread the output through to a root output.