Hi I need to assign the value from an input variable based on 3 values that are on 3 AWS SSM parameters, and then update the value of 1 of those 3 AWS SSM parameters.
Here I explain one case in order to be more clear: I have an input variable filename1 and 3 local variables
variable "filename1" {
type = string
}
locals {
path1 = "filevar1"
path2 = "filevar2"
path3 = "filevar3"
}
Then I get the values of 3 AWS SSM parameters
data "aws_ssm_parameter" "variable1" {
name = local.path1
}
data "aws_ssm_parameter" "variable2" {
name = local.path2
}
data "aws_ssm_parameter" "variable3" {
name = local.path3
}
Based on the values that I get if variable 1 is different from the other 2 variables I shoud assign the input variable to variable2.
Based on some research I assume that I should do it with this
locals {
file2 = "${data.aws_ssm_parameter.variable2.value}" == "${data.aws_ssm_parameter.variable3.value}" != "${data.aws_ssm_parameter.variable1.value}" ? "${data.aws_ssm_parameter.variable2.value}" : "${var.filename1}"
then update SSM value with this
resource "aws_ssm_parameter" "variable2" {
name = local.path2
type = "String"
value = "${local.file2}"
overwrite = true
}
It doesn't work, do you have some example on how to assign a value for a any type of variable based on 3 values?
I have other different conditions, I just need to understand how to declare in order to replicate on the other conditions.
Thanks for your help!!