Created
May 1, 2020 09:06
-
-
Save valery-zhurbenko/0ebeca3b0e4f173c0d2b0bf4b94b33b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "aws_secretsmanager_secret" "my_secret" { | |
name = "my_secret_name" | |
} | |
data "aws_secretsmanager_secret_version" "global_secret_version" { | |
secret_id = "${data.aws_secretsmanager_secret.my_secret.id}" | |
} | |
variable volume_size { | |
default = null | |
} | |
resource "aws_instance" "web" { | |
ami = "AL2_x86_64" | |
instance_type = "t2.micro" | |
root_block_device { | |
### If volume_size variable is set (not null) - take the value from there, else (if null, which is default) - take value from secrets manager data. | |
volume_size = ${var.volume_size != null ? var.volume_size : jsonencode(data.aws_secretsmanager_secret_version.global_secret_version.secret_string)["volume_size"]} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment