2020-02-22 23:41:01 +00:00
|
|
|
resource "aws_iam_user" "terraform" {
|
|
|
|
name = "terraform"
|
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_s3_bucket" "tfstate" {
|
2020-02-22 23:43:00 +00:00
|
|
|
bucket = "0rng-terraform"
|
|
|
|
acl = "private"
|
2020-04-02 18:26:18 +01:00
|
|
|
|
|
|
|
versioning {
|
|
|
|
enabled = true
|
|
|
|
}
|
|
|
|
|
|
|
|
lifecycle_rule {
|
|
|
|
enabled = true
|
|
|
|
|
|
|
|
noncurrent_version_expiration {
|
|
|
|
days = 30
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-22 23:41:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resource "aws_iam_user_policy" "terraform" {
|
2020-02-22 23:43:00 +00:00
|
|
|
name = "terraform"
|
|
|
|
user = aws_iam_user.terraform.name
|
2020-02-22 23:41:01 +00:00
|
|
|
|
2020-02-22 23:43:00 +00:00
|
|
|
policy = <<EOF
|
2020-02-22 23:41:01 +00:00
|
|
|
{
|
|
|
|
"Version": "2012-10-17",
|
|
|
|
"Statement": [
|
|
|
|
{
|
|
|
|
"Sid": "VisualEditor0",
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Action": "iam:*",
|
|
|
|
"Resource": "${aws_iam_user.terraform.arn}"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Sid": "VisualEditor1",
|
|
|
|
"Effect": "Allow",
|
|
|
|
"Action": "s3:*",
|
|
|
|
"Resource": [
|
|
|
|
"${aws_s3_bucket.tfstate.arn}",
|
|
|
|
"${aws_s3_bucket.tfstate.arn}/*"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
}
|