인스턴스에 AdministratorAccess
권한을 부여 합니다.
resource "aws_iam_role" "this" {
name = var.name
description = "iam role for ${var.name}"
assume_role_policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
POLICY
}
resource "aws_iam_instance_profile" "this" {
name = var.name
role = aws_iam_role.this.name
}
# AdministratorAccess
resource "aws_iam_role_policy_attachment" "admin" {
count = var.administrator ? 1 : 0
role = aws_iam_role.this.name
policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
}