Handle optional values and guard against invalid access.
Section: Expressions and Functions
try and can
hcl
hcl
locals {
instance_arn = try(aws_instance.web.arn, null)
has_name = can(var.config.name)
}Explanation
Handle optional values and guard against invalid access.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing Expressions and Functions