如何使用Terraform在现有组中添加新用户?
我正在使用:terraform import aws_iam_group.group [name-group]
我的鳕鱼
resource "aws_iam_group" "group"{
name = "default"
}
resource "aws_iam_group_membership" "member"{
name = "${var.aws_iam_group_member_name}"
users = ["${aws_iam_user.user.name}"]
group = "${aws_iam_group.group.name}"
}
resource "aws_iam_user" "user" {
name = "${var.aws_iam_username}"
path = "/"
force_destroy = true
}
运行:
terraform plan --target=aws_iam_group.group
terraform apply
发生1个错误:
aws_iam_group.group:发生1个错误:
aws_iam_group.group:创建IAM时出错组默认值:EntityAlreadyExists:名称默认值的组已存在。 状态码:409,请求ID:54c27edd-02fb-11e9-b510-a7c53bb3d8e2
答案 0 :(得分:1)
尝试引用这样的组
data "aws_iam_group" "example" {
group_name = "default"
}
这将获取组信息,然后您可以引用用户的属性。
https://www.terraform.io/docs/providers/aws/d/iam_group.html