generated from clowdhaus/terraform-aws-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
aws_gateway_controller.tf
80 lines (66 loc) · 2.66 KB
/
aws_gateway_controller.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
################################################################################
# AWS Gateway Controller Policy
################################################################################
# https://github.com/aws/aws-application-networking-k8s/blob/main/files/controller-installation/recommended-inline-policy.json
data "aws_iam_policy_document" "aws_gateway_controller" {
count = var.create && var.attach_aws_gateway_controller_policy ? 1 : 0
source_policy_documents = [data.aws_iam_policy_document.base[0].json]
override_policy_documents = var.override_policy_documents
statement {
actions = [
"vpc-lattice:*",
"ec2:DescribeVpcs",
"ec2:DescribeSubnets",
"ec2:DescribeTags",
"ec2:DescribeSecurityGroups",
"logs:CreateLogDelivery",
"logs:GetLogDelivery",
"logs:DescribeLogGroups",
"logs:PutResourcePolicy",
"logs:DescribeResourcePolicies",
"logs:UpdateLogDelivery",
"logs:DeleteLogDelivery",
"logs:ListLogDeliveries",
"tag:GetResources",
"firehose:TagDeliveryStream",
"s3:GetBucketPolicy",
"s3:PutBucketPolicy",
]
resources = ["*"]
}
statement {
actions = ["iam:CreateServiceLinkedRole"]
resources = ["arn:${local.partition}:iam::*:role/aws-service-role/vpc-lattice.amazonaws.com/AWSServiceRoleForVpcLattice"]
condition {
test = "StringLike"
variable = "iam:AWSServiceName"
values = ["vpc-lattice.amazonaws.com"]
}
}
statement {
actions = ["iam:CreateServiceLinkedRole"]
resources = ["arn:${local.partition}:iam::*:role/aws-service-role/delivery.logs.amazonaws.com/AWSServiceRoleForLogDelivery"]
condition {
test = "StringLike"
variable = "iam:AWSServiceName"
values = ["delivery.logs.amazonaws.com"]
}
}
}
locals {
aws_gateway_controller_policy_name = coalesce(var.aws_gateway_controller_policy_name, "${var.policy_name_prefix}GatewayController")
}
resource "aws_iam_policy" "aws_gateway_controller" {
count = var.create && var.attach_aws_gateway_controller_policy ? 1 : 0
name = var.use_name_prefix ? null : local.aws_gateway_controller_policy_name
name_prefix = var.use_name_prefix ? "${local.aws_gateway_controller_policy_name}-" : null
path = var.path
description = "Permissions for the AWS Gateway Controller"
policy = data.aws_iam_policy_document.aws_gateway_controller[0].json
tags = var.tags
}
resource "aws_iam_role_policy_attachment" "aws_gateway_controller" {
count = var.create && var.attach_aws_gateway_controller_policy ? 1 : 0
role = aws_iam_role.this[0].name
policy_arn = aws_iam_policy.aws_gateway_controller[0].arn
}