This is a generic workflow terraform question (I am a terraform beginner).
I need to create a new aws resource via terraform. The structure I have is
resource "some_aws_resource" "resource_name" {
name = var.resource_name
role_name = var.role_name
another_key = another_value
}
The value another_value is derived from vars entered by the user through a bash script
find_another_value.sh for example
resource "null_resource" "find_another_value" {
provisioner "local-exec" {
command = "shell_scripts/find_another_value.sh"
interpreter = ["/bin/bash"]
working_dir = path.module
environment = {
DAR = var.aws_dar
RAD = var.aws_rad
}
}
}
should return another_value
How do I pass the output another_value of the null_resource to the first resource and make sure that the non null resource waits until the null_resource returns the value?
The find_another_value.sh script will use the input variables to query aws via the aws cli to find the value it needs to return.
If there is a better/easier way that would also be good to know.
null_resourceis not for returning anything to TF. I think you have to re-thing your design as Marko suggested.