• Get attributes of a conditionally included resource

    2 min read

    terraform attributes conditionally included resource HCL get value

    To be able to conditionally include a given resource we can use the count argument but if we do so it is not as straightforward to use it's outputs (attributes) because now on this resource we have an array of outputs even thought we are confident that it will just have one if enabled. Let's take a deeper look on how to deal with this using the following conditional resource as an example:

    resource "aws_route53_record" "ampa_public_r53_cname_record" {
      count   = try(length(var.public_alias_name)>0, false)?1:0
      zone_id = data.aws_route53_zone.public_r53_zone.zone_id
      name    = var.public_alias_name
      type    = "CNAME"
    
      records = [ aws_route53_record.ampa_web_public_r53_record.fqdn ]
      ttl     = "3600"
    }
    

    10/02/2021

    Read more...
  • How to conditionally include a resource in terraform

    1 min read

    terraform conditionally include resource HCL

    On terraform modules sometimes it make sense to completely get rid of some resources using some condition. Since we don't have an if statement, we can use count instead

    27/01/2021

    Read more...

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