Skip to content

Commit 6450d3d

Browse files
committed
docs: document the minimal IAM policy for the executor
Add a "Required IAM permissions" section to docs/further.md giving the minimal core policy the executor role needs (batch:SubmitJob/DescribeJobs/ RegisterJobDefinition/DeregisterJobDefinition/TerminateJob/DescribeJobQueues/ DescribeComputeEnvironments and iam:PassRole), plus a single tags add-on (batch:TagResource, with an ecs:TagResource note for tag propagation). Each permission is tied to the feature that needs it, and the register/deregister and PassRole statements are called out as conditional (pre-existing job definitions, and only when --aws-batch-job-role is set). Cross-linked from the README.
1 parent 47e8027 commit 6450d3d

2 files changed

Lines changed: 73 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Snakemake executor plugin: aws-batch
22

33
A Snakemake executor plugin for submitting jobs to AWS Batch. Documentation can be found in the [Snakemake plugin catalog](https://snakemake.github.io/snakemake-plugin-catalog/plugins/executor/aws-batch.html).
4+
5+
For the minimal IAM policy and the tags add-on required to run the executor, see [docs/further.md — Required IAM permissions](docs/further.md#required-iam-permissions).

docs/further.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,77 @@ SNAKEMAKE_AWS_BATCH_REGION
2828
SNAKEMAKE_AWS_BATCH_JOB_QUEUE
2929
SNAKEMAKE_AWS_BATCH_JOB_ROLE
3030

31+
# Required IAM permissions
32+
33+
The principal that runs Snakemake (the *executor role*) needs the following
34+
permissions to submit and monitor jobs. The policy is split into a mandatory
35+
core set and an add-on statement that is only needed when tags are configured.
36+
37+
## Core policy (always required)
38+
39+
```json
40+
{
41+
"Version": "2012-10-17",
42+
"Statement": [
43+
{
44+
"Sid": "BatchCore",
45+
"Effect": "Allow",
46+
"Action": [
47+
"batch:SubmitJob",
48+
"batch:DescribeJobs",
49+
"batch:RegisterJobDefinition",
50+
"batch:DeregisterJobDefinition",
51+
"batch:TerminateJob",
52+
"batch:DescribeJobQueues",
53+
"batch:DescribeComputeEnvironments"
54+
],
55+
"Resource": "*"
56+
},
57+
{
58+
"Sid": "PassJobRole",
59+
"Effect": "Allow",
60+
"Action": "iam:PassRole",
61+
"Resource": "arn:aws:iam::<account-id>:role/<job-role-name>"
62+
}
63+
]
64+
}
65+
```
66+
67+
- `batch:DescribeJobQueues` and `batch:DescribeComputeEnvironments` detect
68+
whether a queue is backed by EC2 or Fargate so the plugin builds a compatible
69+
job definition. They are used only by the default register-per-job path; with
70+
a pre-existing job definition (`--aws-batch-job-definition`) they can be
71+
omitted too.
72+
- `batch:RegisterJobDefinition` and `batch:DeregisterJobDefinition` are only
73+
needed when the plugin registers a job definition per job (the default). If
74+
you use a pre-existing job definition (`--aws-batch-job-definition`), both can
75+
be omitted — see [Pre-existing Job Definitions](#pre-existing-job-definitions).
76+
- The `PassJobRole` statement is required in the default (register-per-job)
77+
mode: a job role is mandatory (`--aws-batch-job-role` /
78+
`SNAKEMAKE_AWS_BATCH_JOB_ROLE`) and is baked into every registered job
79+
definition, so `iam:PassRole` on that role is always exercised. It can be
80+
omitted only when you use a pre-existing job definition
81+
(`--aws-batch-job-definition`), where the plugin neither registers a
82+
definition nor passes a role (the pre-existing definition carries its own
83+
role). Scope its `Resource` to that specific job role ARN.
84+
85+
## Add-on: tags (`--aws-batch-tags` or `SNAKEMAKE_AWS_BATCH_JOB_TAGS`)
86+
87+
```json
88+
{
89+
"Sid": "BatchTagResource",
90+
"Effect": "Allow",
91+
"Action": "batch:TagResource",
92+
"Resource": "*"
93+
}
94+
```
95+
96+
`batch:TagResource` authorizes the tag-on-create when jobs and job definitions
97+
are submitted with tags; without it, submission fails with `AccessDenied`
98+
whenever tags are configured. Depending on your account's ECS
99+
tagging-authorization settings you may additionally need `ecs:TagResource` on
100+
`*`, because AWS Batch propagates tags to the ECS resources it manages.
101+
31102
# Rule-Specific Container Images
32103

33104
By default, all jobs use the global container image specified via `--container-image`. However, you can specify a different container image for individual rules using the `aws_batch_container_image` resource parameter:

0 commit comments

Comments
 (0)