• terraform: Get the latest AMI id

    2 min read

    Terraform AWS AMI datasource latest

    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...
  • Terraform: retrieve AWS information

    1 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...
  • Terraform: Using the external data source

    2 min read

    terraform data-source external

    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...
  • Loading a CSV file into terraform

    2 min read

    terraform csvdecode function csv

    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...
  • Using terraform_remote_state for getting data from another terraform state

    2 min read

    terraform data remote state terraform_remote_state

    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...

From pet to cattle
Treat your kubernetes clusters like cattle, not pets