Hi Team,
I am facing a situation where we have the terraform remote state file already created and stored in s3 buckets with few values like instance id, Sg id configured to output so if I want to use I am able to call them as
data.terraform_remote_state.project.outputs.instance_id.
I ran in to a place where I have to use the value from remote state file but it isn’t part of outputs as we have not configured it during the state creation time.
eg: something like target group arn or load balancer arn
We have this value in the state file as part of “resources”: block & not in the output block as it isn’t exported.
Please let me know if we can call it something like
data.terraform_remote_state.project.resources.xxxx
SInce in the resource block all the TG’s or SG’s have similar structure and couldn’t find a way to call them.
Below is an example how the resource block looks
“resources”: [
{
“mode”: “managed”,
“type”: “aws_lb_target_group”,
“name”: “internal_tg”,
“provider”: “provider["registry.terraform.io/hashicorp/aws"]”,
“instances”: [
{
“schema_version”: 0,
“attributes”: {
“arn”: “",
“arn_suffix”: “********”,
“connection_termination”: false,
“deregistration_delay”: “30”,
“health_check”: [
{
“enabled”: true,
“healthy_threshold”: 3,
“interval”: 30,
“matcher”: “200”,
“path”: "/",
“port”: “443”,
“protocol”: “HTTPS”,
“timeout”: 5,
“unhealthy_threshold”: 3
}
],
“id”: "”,
“lambda_multi_value_headers_enabled”: false,
“load_balancing_algorithm_type”: “round_robin”,
“name”: “",
“name_prefix”: null,
“port”: 443,
“preserve_client_ip”: null,
“protocol”: “HTTPS”,
“protocol_version”: “HTTP1”,
“proxy_protocol_v2”: false,
“slow_start”: 0,
“stickiness”: [
{
“cookie_duration”: 86400,
“cookie_name”: “”,
“enabled”: false,
“type”: “lb_cookie”
}
],
“tags”: {
“terraform”: “true”
},
“tags_all”: {
“terraform”: “true”
},
“target_type”: “instance”,
“vpc_id”: ""
},
“sensitive_attributes”: [],
“private”: “bnVsbA==”,
“dependencies”: [
“data.terraform_remote_state.network”
],
“create_before_destroy”: true
}
]
},
{
“mode”: “managed”,
“type”: “aws_lb_target_group”,
“name”: “tg”,
“provider”: “provider["registry.terraform.io/hashicorp/aws"]”,
“instances”: [
{
“schema_version”: 0,
“attributes”: {
“arn”: "",
“arn_suffix”: "",
“connection_termination”: false,
“deregistration_delay”: “30”,
“health_check”: [
{
“enabled”: true,
“healthy_threshold”: 3,
“interval”: 30,
“matcher”: “200”,
“path”: "/",
“port”: “443”,
“protocol”: “HTTPS”,
“timeout”: 5,
“unhealthy_threshold”: 3
}
],
“id”: "",
“lambda_multi_value_headers_enabled”: false,
“load_balancing_algorithm_type”: “round_robin”,
“name”: "”,
“name_prefix”: null,
“port”: 443,
“preserve_client_ip”: null,
“protocol”: “HTTPS”,
“protocol_version”: “HTTP1”,
“proxy_protocol_v2”: false,
“slow_start”: 0,
“stickiness”: [
{
“cookie_duration”: 86400,
“cookie_name”: “”,
“enabled”: false,
“type”: “lb_cookie”
}
],
“tags”: {
“terraform”: “true”
},
“tags_all”: {
“terraform”: “true”
},
“target_type”: “instance”,
“vpc_id”: “*******”
},
“sensitive_attributes”: ,
“private”: “bnVsbA==”,
“dependencies”: [
“data.terraform_remote_state.network”
],
“create_before_destroy”: true
}
]
}
]