Terraform the tfstate bucket
It's terraform all the way down
This commit is contained in:
parent
a80cc472cc
commit
a307c53808
2 changed files with 40 additions and 0 deletions
|
@ -8,3 +8,7 @@ provider "cloudflare" {
|
|||
email = "hosting+cloudflare@theorangeone.net"
|
||||
api_key = var.cloudflare_api_key
|
||||
}
|
||||
|
||||
provider "aws" {
|
||||
region = "eu-west-2"
|
||||
}
|
||||
|
|
36
terraform/state.tf
Normal file
36
terraform/state.tf
Normal file
|
@ -0,0 +1,36 @@
|
|||
resource "aws_iam_user" "terraform" {
|
||||
name = "terraform"
|
||||
}
|
||||
|
||||
resource "aws_s3_bucket" "tfstate" {
|
||||
bucket = "0rng-terraform"
|
||||
acl = "private"
|
||||
}
|
||||
|
||||
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
|
||||
}
|
Loading…
Reference in a new issue