-
Notifications
You must be signed in to change notification settings - Fork 88
/
policy.tf
61 lines (58 loc) · 1.68 KB
/
policy.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#---------------------------------------------------------------------------------------------------
# IAM Policy
# See below for permissions necessary to run Terraform.
# https://www.terraform.io/docs/backends/types/s3.html#example-configuration
#
# terragrunt users would also need additional permissions.
# https://github.com/nozaq/terraform-aws-remote-state-s3-backend/issues/74
#---------------------------------------------------------------------------------------------------
resource "aws_iam_policy" "terraform" {
count = var.terraform_iam_policy_create ? 1 : 0
name_prefix = var.override_terraform_iam_policy_name ? null : var.terraform_iam_policy_name_prefix
name = var.override_terraform_iam_policy_name ? var.terraform_iam_policy_name : null
policy = <<POLICY
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:ListBucket", "s3:GetBucketVersioning"],
"Resource": "${aws_s3_bucket.state.arn}"
},
{
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "${aws_s3_bucket.state.arn}/*"
},
{
"Effect": "Allow",
"Action": [
"dynamodb:GetItem",
"dynamodb:PutItem",
"dynamodb:DeleteItem",
"dynamodb:DescribeTable"
],
"Resource": "${aws_dynamodb_table.lock.arn}"
},
{
"Effect": "Allow",
"Action": [
"kms:ListKeys"
],
"Resource": "*"
},
{
"Effect": "Allow",
"Action": [
"kms:Encrypt",
"kms:Decrypt",
"kms:DescribeKey",
"kms:GenerateDataKey"
],
"Resource": "${aws_kms_key.this.arn}"
}
]
}
POLICY
tags = var.tags
}