generated from memes/repo-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
160 lines (156 loc) · 5.03 KB
/
main.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
terraform {
required_version = ">= 1.3"
required_providers {
google = {
source = "hashicorp/google"
version = ">= 4.38, < 7.0"
}
random = {
source = "hashicorp/random"
version = ">= 3.4"
}
}
}
resource "random_id" "role_id" {
byte_length = 2
keepers = {
target_type = var.target_type
target_id = var.target_id
}
}
locals {
title = coalesce(var.title, "Custom F5 Distributed Cloud role")
description = coalesce(var.description, "Allow F5 Distributed Cloud to fully manage Google Cloud resources")
permissions = distinct(concat([
"compute.addresses.create",
"compute.addresses.createInternal",
"compute.addresses.delete",
"compute.addresses.deleteInternal",
"compute.addresses.get",
"compute.addresses.list",
"compute.addresses.use",
"compute.addresses.useInternal",
"compute.backendServices.create",
"compute.backendServices.delete",
"compute.backendServices.get",
"compute.backendServices.list",
"compute.disks.create",
"compute.disks.delete",
"compute.disks.get",
"compute.disks.list",
"compute.disks.resize",
"compute.disks.setLabels",
"compute.firewalls.create",
"compute.firewalls.delete",
"compute.firewalls.get",
"compute.firewalls.list",
"compute.firewalls.update",
"compute.forwardingRules.create",
"compute.forwardingRules.delete",
"compute.forwardingRules.get",
"compute.forwardingRules.list",
"compute.forwardingRules.setLabels",
"compute.globalOperations.get",
"compute.healthChecks.create",
"compute.healthChecks.delete",
"compute.healthChecks.get",
"compute.healthChecks.list",
"compute.healthChecks.useReadOnly",
"compute.images.create",
"compute.images.get",
"compute.images.list",
"compute.images.useReadOnly",
"compute.instanceGroupManagers.create",
"compute.instanceGroupManagers.delete",
"compute.instanceGroupManagers.get",
"compute.instanceGroupManagers.list",
"compute.instanceGroupManagers.update",
"compute.instanceGroups.create",
"compute.instanceGroups.delete",
"compute.instanceGroups.get",
"compute.instanceGroups.list",
"compute.instanceGroups.use",
"compute.instanceTemplates.create",
"compute.instanceTemplates.delete",
"compute.instanceTemplates.get",
"compute.instanceTemplates.list",
"compute.instanceTemplates.useReadOnly",
"compute.instances.attachDisk",
"compute.instances.create",
"compute.instances.delete",
"compute.instances.deleteAccessConfig",
"compute.instances.detachDisk",
"compute.instances.get",
"compute.instances.list",
"compute.instances.reset",
"compute.instances.resume",
"compute.instances.setLabels",
"compute.instances.setMachineResources",
"compute.instances.setMachineType",
"compute.instances.setMetadata",
"compute.instances.setServiceAccount",
"compute.instances.setTags",
"compute.instances.start",
"compute.instances.stop",
"compute.instances.update",
"compute.instances.updateAccessConfig",
"compute.instances.updateNetworkInterface",
"compute.instances.use",
"compute.interconnectAttachments.get",
"compute.machineTypes.get",
"compute.machineTypes.list",
"compute.networkEndpointGroups.attachNetworkEndpoints",
"compute.networks.access",
"compute.networks.create",
"compute.networks.delete",
"compute.networks.get",
"compute.networks.list",
"compute.networks.update",
"compute.networks.updatePolicy",
"compute.networks.use",
"compute.networks.useExternalIp",
"compute.projects.get",
"compute.regionBackendServices.create",
"compute.regionBackendServices.delete",
"compute.regionBackendServices.get",
"compute.regionBackendServices.list",
"compute.regionBackendServices.use",
"compute.regionOperations.get",
"compute.regions.get",
"compute.routers.get",
"compute.routes.create",
"compute.routes.delete",
"compute.routes.get",
"compute.routes.list",
"compute.subnetworks.create",
"compute.subnetworks.delete",
"compute.subnetworks.get",
"compute.subnetworks.list",
"compute.subnetworks.setPrivateIpGoogleAccess",
"compute.subnetworks.update",
"compute.subnetworks.use",
"compute.subnetworks.useExternalIp",
"compute.zones.get",
"iam.serviceAccounts.actAs",
"iam.serviceAccounts.get",
"iam.serviceAccounts.list",
"resourcemanager.projects.get",
],
var.target_type == "org" ? [
"resourcemanager.projects.list",
] : [],
))
}
# Create a custom IAM role for F5 Distributed Cloud; service accounts should be
# granted this role.
module "role" {
source = "terraform-google-modules/iam/google//modules/custom_role_iam"
version = "8.0.0"
target_level = var.target_type
target_id = var.target_id
role_id = coalesce(var.id, format("%s_%s", var.random_id_prefix, random_id.role_id.hex))
title = local.title
description = local.description
permissions = local.permissions
members = var.members
}