Skip to content

Commit 47a3df3

Browse files
ludookarpok78
authored andcommitted
don't create resources for aservice agents not in services (GoogleCloudPlatform#2820)
1 parent 2c8a52b commit 47a3df3

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

modules/project/service-agents.tf

+8-5
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,20 @@ locals {
3131
for api in concat(local.services, ["cloudservices"]) : {
3232
for agent in lookup(local._service_agents_by_api, api, []) :
3333
(agent.name) => merge(agent, {
34-
email = format(agent.identity, local.project.number)
35-
iam_email = "serviceAccount:${format(agent.identity, local.project.number)}"
34+
email = format(agent.identity, local.project.number)
35+
iam_email = "serviceAccount:${format(agent.identity, local.project.number)}"
36+
create_jit = api == "cloudservices" || contains(var.services, api)
3637
})
3738
}
3839
]...)
3940
# list of APIs with primary agents that should be created for the
4041
# current project, if the user requested it
4142
primary_service_agents = [
42-
for agent in local._project_service_agents :
43-
agent.api
44-
if agent.is_primary && var.service_agents_config.create_primary_agents
43+
for agent in local._project_service_agents : agent.api if(
44+
agent.is_primary &&
45+
var.service_agents_config.create_primary_agents &&
46+
agent.create_jit
47+
)
4548
]
4649
# list of roles that should be granted to service agents for the
4750
# current project, if the user requested it

0 commit comments

Comments
 (0)