Querying Existing Info
What if you need to find the ID of an Ubuntu image in AWS without hardcoding it? You use a Data Source.
hcl data "aws_ami" "ubuntu" { most_recent = true owners = ["099720109477"] # Canonical
filter { name = "name" values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] } }
Unlike resources (which create things), data sources fetch things. You can then use data.aws_ami.ubuntu.id in your server configuration.