Skip to content

Instantly share code, notes, and snippets.

@valery-zhurbenko
Created May 1, 2020 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valery-zhurbenko/0ebeca3b0e4f173c0d2b0bf4b94b33b6 to your computer and use it in GitHub Desktop.
Save valery-zhurbenko/0ebeca3b0e4f173c0d2b0bf4b94b33b6 to your computer and use it in GitHub Desktop.
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