2 min read
Hard coding values is never a good idea, using the aws_ami datasource we can query AWS to fetch the latest AMI available, or any AMI really, as long as we properly set the filters so than just one AMI is selected.
06/04/2022
Read more...2 min read
When running terraform on an AWS account we might need to have some context information such as it's account ID or the region we are in. Instead of having to set them as variables we can use the aws_caller_identity, aws_partition and aws_region datasources to retrieve this information
19/01/2022
Read more...2 min read
To be able to execute an arbitrary command to retrieve some data and being able to use it as a variable in terraform we can use the external data-source
17/08/2021
Read more...2 min read
Sometimes if you have some externally managed data it can come handy to be able to import it into terraform as a CSV file instead of having to manually enter all the date. To do so we can use the csvdecode() function
10/08/2021
Read more...2 min read
On terraform, besides returning some information to the user, returning data as output can be used as an input for terraform code that needs to use a resource created by another team.
On the terraform code that creates the resource, we will have to set the variable and it's value:
output endpoint {
vpc_id = aws_vpc.databases.id
}
Then, on the code that uses this resource we will have to declare the tfstate as a data source using terraform_remote_state
11/03/2021
Read more...