I am trying to read a value from AWS Parameter Store and assign its value to a variable.
# data source
data "aws_ssm_parameter" "environment" {
name = "environment"
}
# variable
variable "environment" {
type = string
description = "AWS Environment Name"
default = data.aws_ssm_parameter.environment.value
}
Is this possible?
I know you can use data.aws_ssm_parameter.environment.value
wherever I need to use a variable but is it possible to simplify it by assigning it to a variable.
CodePudding user response:
That is not possible. However, you can use local variables [1] for that. For example:
locals {
environment = data.aws_ssm_parameter.environment.value
}
You would then reference that value elsewhere in the code with local.environment
.
[1] https://developer.hashicorp.com/terraform/language/values/locals