infrastructure/terraform/state.tf

50 lines
907 B
Terraform
Raw Normal View History

resource "aws_iam_user" "terraform" {
name = "terraform"
}
resource "aws_s3_bucket" "tfstate" {
bucket = "0rng-terraform"
acl = "private"
2020-04-02 18:26:18 +01:00
versioning {
enabled = true
}
lifecycle_rule {
enabled = true
noncurrent_version_expiration {
2021-05-18 19:33:38 +01:00
days = 10
2020-04-02 18:26:18 +01:00
}
}
}
resource "aws_iam_user_policy" "terraform" {
name = "terraform"
user = aws_iam_user.terraform.name
policy = <<EOF
{
"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
}