We don't currently track references from resource blocks to data blocks, because upstream we don't really know what we're going to get back. For static analysis those references can still be useful though, for instance...
data "aws_rds_reserved_instance_offering" "example" {
db_instance_class = "db.m7g.large"
}
resource "aws_rds_reserved_instance" "example" {
offering_id = data.aws_rds_reserved_instance_offering.example.offering_id
instance_count = 1
}
resource "aws_db_instance" "example" {
instance_class = aws_rds_reserved_instance.example.db_instance_class
}
Produces the dump below. We can see traces of references in two different spots:
Attribute Level
aws_db_instance includes this reference to aws_rds_reserved_instance for its instance_class attribute:
"instance_class": {
"__attribute__": "aws_rds_reserved_instance.example.db_instance_class",
"__name__": "example"
}
In turn, that aws_rds_reserved_instance references an offering:
"offering_id": {
"__attribute__": "data.aws_rds_reserved_instance_offering.example.offering_id",
"__name__": "example",
"__ref__": "aws_rds_reserved_instance_offering.example",
"__type__": "aws_rds_reserved_instance_offering"
}
Resource Level
The aws_db_instance resource's __tfmeta attribute captures its aws_rds_reserved_instance reference:
"references": [
{
"id": "0c547493-9654-447a-959b-31ae3dd2cacc",
"label": "aws_rds_reserved_instance",
"name": "example"
}
]
...but the aws_rds_reserved_instance resources does not have any references listed in its __tfmeta attribute, so the chain from aws_db_instance --> aws_rds_reserved_instance --> data.aws_rds_reserved_instance_offering is broken.
Full `tfparse.load_from_path()` output
{
"aws_db_instance": [
{
"__tfmeta": {
"filename": "rds.tf",
"label": "aws_db_instance",
"line_end": 12,
"line_start": 10,
"path": "aws_db_instance.example",
"references": [
{
"id": "db6030c1-fad0-4d0a-a6d5-708d9e34c83a",
"label": "aws_rds_reserved_instance",
"name": "example"
}
],
"type": "resource"
},
"id": "822d10d1-08f4-4886-85b4-8740bb9ea4c4",
"instance_class": {
"__attribute__": "aws_rds_reserved_instance.example.db_instance_class",
"__name__": "example"
}
}
],
"aws_rds_reserved_instance": [
{
"__tfmeta": {
"filename": "rds.tf",
"label": "aws_rds_reserved_instance",
"line_end": 8,
"line_start": 5,
"path": "aws_rds_reserved_instance.example",
"type": "resource"
},
"id": "db6030c1-fad0-4d0a-a6d5-708d9e34c83a",
"instance_count": 1,
"offering_id": {
"__attribute__": "data.aws_rds_reserved_instance_offering.example.offering_id",
"__name__": "example",
"__ref__": "aws_rds_reserved_instance_offering.example",
"__type__": "aws_rds_reserved_instance_offering"
}
}
],
"aws_rds_reserved_instance_offering": [
{
"__tfmeta": {
"filename": "rds.tf",
"label": "aws_rds_reserved_instance_offering",
"line_end": 3,
"line_start": 1,
"path": "data.aws_rds_reserved_instance_offering.example",
"type": "data"
},
"db_instance_class": "db.m7g.large",
"id": "9251a42c-9126-413c-9350-d6fc390ce42d"
}
]
}
We don't currently track references from
resourceblocks todatablocks, because upstream we don't really know what we're going to get back. For static analysis those references can still be useful though, for instance...Produces the dump below. We can see traces of references in two different spots:
Attribute Level
aws_db_instanceincludes this reference toaws_rds_reserved_instancefor itsinstance_classattribute:In turn, that
aws_rds_reserved_instancereferences an offering:Resource Level
The
aws_db_instanceresource's__tfmetaattribute captures itsaws_rds_reserved_instancereference:...but the
aws_rds_reserved_instanceresources does not have any references listed in its__tfmetaattribute, so the chain fromaws_db_instance-->aws_rds_reserved_instance-->data.aws_rds_reserved_instance_offeringis broken.Full `tfparse.load_from_path()` output
{ "aws_db_instance": [ { "__tfmeta": { "filename": "rds.tf", "label": "aws_db_instance", "line_end": 12, "line_start": 10, "path": "aws_db_instance.example", "references": [ { "id": "db6030c1-fad0-4d0a-a6d5-708d9e34c83a", "label": "aws_rds_reserved_instance", "name": "example" } ], "type": "resource" }, "id": "822d10d1-08f4-4886-85b4-8740bb9ea4c4", "instance_class": { "__attribute__": "aws_rds_reserved_instance.example.db_instance_class", "__name__": "example" } } ], "aws_rds_reserved_instance": [ { "__tfmeta": { "filename": "rds.tf", "label": "aws_rds_reserved_instance", "line_end": 8, "line_start": 5, "path": "aws_rds_reserved_instance.example", "type": "resource" }, "id": "db6030c1-fad0-4d0a-a6d5-708d9e34c83a", "instance_count": 1, "offering_id": { "__attribute__": "data.aws_rds_reserved_instance_offering.example.offering_id", "__name__": "example", "__ref__": "aws_rds_reserved_instance_offering.example", "__type__": "aws_rds_reserved_instance_offering" } } ], "aws_rds_reserved_instance_offering": [ { "__tfmeta": { "filename": "rds.tf", "label": "aws_rds_reserved_instance_offering", "line_end": 3, "line_start": 1, "path": "data.aws_rds_reserved_instance_offering.example", "type": "data" }, "db_instance_class": "db.m7g.large", "id": "9251a42c-9126-413c-9350-d6fc390ce42d" } ] }