我有这样的变量映射:
用户.tfvars
users = {
"testterform" = {
path = "/"
force_destroy = true
email_address = "testterform@example.com"
group_memberships = [ "test1" ]
tags = { department : "test" }
ssh_public_key = "ssh-rsa AAAAB3NzaC1yc2EAAA4l7"
}
"testterform2" = {
path = "/"
force_destroy = true
email_address = "testterform2@example.com"
group_memberships = [ "test1" ]
tags = { department : "test" }
ssh_public_key = ""
}
Run Code Online (Sandbox Code Playgroud)
只有当ssh_public_key用户不为空时,我才想上传 ssh 密钥。但不明白如何检查这个
#main.tf
resource "aws_iam_user" "this" {
for_each = var.users
name = each.key
path = …Run Code Online (Sandbox Code Playgroud) terraform ×1