I'm trying to use the random_string terraform resource with keepers attributes like so.
resource "random_string" "rand" {
length = 16
special = false
upper = false
keepers = {
md5 = "${md5(file("./terraform/batch.tf"))}"
service_role = "arn:aws:iam::${var.target_aws_account_id}:role/BatchService"
instance_role = "${aws_iam_instance_profile.service_role.arn}"
spot_iam_fleet_role = "${aws_iam_role.spot_fleet_role.arn}"
image_id = "${data.aws_ami.base_ami.image_id}"
max_vcpus = 1000
min_vcpus = 0
bid_percentage = 50
security_group_id = "${aws_security_group.outbound_sg.id}"
private_subnets = "${join(", ", var.private_subnets)}"
}
}
I then try to reference the keepers attributes from other resources like this
resource "aws_batch_compute_environment" "compute_env" {
compute_environment_name = "compute-env-v1-${random_string.rand.result}"
compute_resources {
instance_role = "${random_string.rand.keepers.instance_role}"
...
}
type = "MANAGED"
lifecycle {
create_before_destroy = true
}
}
However, this is resulting in errors such as
aws_batch_compute_environment.compute_env: Resource 'random_string.rand' does not have attribute 'keepers.instance_role' for variable 'random_string.rand.keepers.instance_role'
What am I doing wrong here? Why does the random_string resource not have these attributes for the keepers values?
Thanks, David
Aucun commentaire:
Enregistrer un commentaire