Skip to content

Commit 73fcd4c

Browse files
committed
reorganizing the glue_job policies
1 parent e859b9f commit 73fcd4c

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

aws_setup/workbench_core/workbench_core/workbench_core_stack.py

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ def _workbench_database_arns(self) -> list[str]:
178178
f"arn:aws:glue:{self.region}:{self.account}:table/inference_store/*",
179179
]
180180

181+
#####################
182+
# Glue Jobs #
183+
#####################
181184
def glue_pass_role(self) -> iam.PolicyStatement:
182185
"""Allows us to specify the Workbench-Glue role when creating a Glue Job"""
183186
return iam.PolicyStatement(
@@ -186,33 +189,35 @@ def glue_pass_role(self) -> iam.PolicyStatement:
186189
conditions={"StringEquals": {"iam:PassedToService": "glue.amazonaws.com"}},
187190
)
188191

189-
def glue_job_read_policy(self) -> iam.PolicyStatement:
190-
"""Policy for read-only Glue job actions."""
192+
@staticmethod
193+
def glue_jobs_discover() -> iam.PolicyStatement:
194+
"""Discovery access to list all Glue jobs."""
195+
return iam.PolicyStatement(
196+
actions=["glue:GetJobs"],
197+
resources=["*"],
198+
)
199+
200+
def glue_jobs_read(self) -> iam.PolicyStatement:
201+
"""Read-only access to specific Glue jobs."""
191202
return iam.PolicyStatement(
192203
actions=[
193-
"glue:GetJobs",
194204
"glue:GetJob",
195205
"glue:GetJobRun",
196206
"glue:GetJobRuns",
197207
],
198-
resources=[
199-
"*", # Needed for GetJobs
200-
],
208+
resources=[f"arn:aws:glue:{self.region}:{self.account}:job/*"],
201209
)
202210

203-
def glue_job_create_policy(self) -> iam.PolicyStatement:
204-
"""Policy for create/update Glue jobs and triggers."""
211+
def glue_jobs_full(self) -> iam.PolicyStatement:
212+
"""Full access to specific Glue jobs."""
205213
return iam.PolicyStatement(
206214
actions=[
215+
*self.glue_jobs_read().actions,
207216
"glue:CreateJob",
208217
"glue:UpdateJob",
209218
"glue:StartJobRun",
210-
"glue:CreateTrigger",
211-
],
212-
resources=[
213-
f"arn:aws:glue:{self.region}:{self.account}:job/*",
214-
f"arn:aws:glue:{self.region}:{self.account}:trigger/*",
215219
],
220+
resources=[f"arn:aws:glue:{self.region}:{self.account}:job/*"],
216221
)
217222

218223
@staticmethod
@@ -704,8 +709,8 @@ def workbench_datasource_policy(self) -> iam.ManagedPolicy:
704709
self.s3_public(),
705710
self.glue_catalog_full(),
706711
self.glue_databases_full(),
707-
self.glue_job_read_policy(),
708-
self.glue_job_create_policy(),
712+
self.glue_jobs_discover(),
713+
self.glue_jobs_full(),
709714
self.glue_job_connections_policy_statement(),
710715
self.athena_policy_statement(),
711716
self.athena_workgroup_policy_statement(),

0 commit comments

Comments
 (0)