Restructure state IAM to use separate role
This commit is contained in:
parent
1555803d25
commit
9ac9380387
1 changed files with 28 additions and 6 deletions
|
@ -20,8 +20,8 @@ resource "aws_s3_bucket" "tfstate" {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_iam_user_policy" "terraform" {
|
resource "aws_iam_user_policy" "modify-terraform-user" {
|
||||||
name = "terraform"
|
name = "modify-terraform-user"
|
||||||
user = aws_iam_user.terraform.name
|
user = aws_iam_user.terraform.name
|
||||||
|
|
||||||
policy = <<EOF
|
policy = <<EOF
|
||||||
|
@ -29,13 +29,26 @@ resource "aws_iam_user_policy" "terraform" {
|
||||||
"Version": "2012-10-17",
|
"Version": "2012-10-17",
|
||||||
"Statement": [
|
"Statement": [
|
||||||
{
|
{
|
||||||
"Sid": "VisualEditor0",
|
"Sid": "ModifyTerraformUser",
|
||||||
"Effect": "Allow",
|
"Effect": "Allow",
|
||||||
"Action": "iam:*",
|
"Action": "iam:*",
|
||||||
"Resource": "${aws_iam_user.terraform.arn}"
|
"Resource": "*"
|
||||||
},
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resource "aws_iam_policy" "terraform_state" {
|
||||||
|
name = "terraform-state"
|
||||||
|
|
||||||
|
policy = <<EOF
|
||||||
|
{
|
||||||
|
"Version": "2012-10-17",
|
||||||
|
"Statement": [
|
||||||
{
|
{
|
||||||
"Sid": "VisualEditor1",
|
"Sid": "TerraformState",
|
||||||
"Effect": "Allow",
|
"Effect": "Allow",
|
||||||
"Action": "s3:*",
|
"Action": "s3:*",
|
||||||
"Resource": [
|
"Resource": [
|
||||||
|
@ -47,3 +60,12 @@ resource "aws_iam_user_policy" "terraform" {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resource "aws_iam_user_policy_attachment" "terraform-state" {
|
||||||
|
for_each = toset([
|
||||||
|
aws_iam_user.terraform.name
|
||||||
|
])
|
||||||
|
|
||||||
|
user = each.key
|
||||||
|
policy_arn = aws_iam_policy.terraform_state.arn
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue