Skip to content

Commit 0d1eb8d

Browse files
authored
docs: add iam role information (#1)
* docs: add iam role information * docs: remove pipe escape entity
1 parent febafb3 commit 0d1eb8d

File tree

1 file changed

+93
-2
lines changed

1 file changed

+93
-2
lines changed

README.md

+93-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ _includes examples from other packages to give context_
4646
with:
4747
ecs_service_name: project
4848
service_task_definition_name: project-alpha
49+
prepare_task_definition_name: project-alpha-migrations
50+
prepare_task_container_network_config_filepath: ".github/networks/alpha.json"
51+
prepare_task_container_image_changes: php|123456789100.dkr.ecr.us-east-1.amazonaws.com/php:version
4952
container_image_changes: >
5053
nginx|123456789100.dkr.ecr.us-east-1.amazonaws.com/nginx:version
5154
php|123456789100.dkr.ecr.us-east-1.amazonaws.com/php:version
@@ -64,9 +67,9 @@ Following inputs can be used as `step.with` keys
6467
| `ecs_service_name` | yes | string | ECS Service Name |
6568
| `ecs_launch_type` | no | string | ECS Launch Type for tasks. (default: `FARGATE`) |
6669
| `service_task_definition_name` | yes | string | ECS Task Definition Name |
67-
| `service_container_image_changes` | yes | string | space delimited keypairs (`container|image`) |
70+
| `service_container_image_changes` | yes | string | space delimited keypairs (`container(pipe)image`) |
6871
| `prepare_task_definition_name` | no | string | ECS Task Definition Name (Runs prior to execution) |
69-
| `prepare_task_container_image_changes` | no | string | space delimited keypairs for prepare step (`container|image`) |
72+
| `prepare_task_container_image_changes` | no | string | space delimited keypairs for prepare step (`container(pipe)image`) |
7073
| `prepare_task_container_network_config_filepath` | no | string | filepath from context of root to json configuration |
7174
| `max_polling_iterations` | no | Number | Number of 15s iterations to poll max (default: `60`) |
7275
| `dry_run` | no | bool | Whether to skip write related AWS commands. |
@@ -109,3 +112,91 @@ Given this example:
109112
* Adapting the `image` property to `123456789100.dkr.ecr.us-east-1.amazonaws.com/nginx:version`
110113
* Finding the next container that has name `php`
111114
* Adapting the `image` property to `123456789100.dkr.ecr.us-east-1.amazonaws.com/php:version`
115+
116+
## IAM Policies
117+
_An example hardened policy for the Role to assume with explanations._
118+
119+
```json5
120+
{
121+
"Version": "2012-10-17",
122+
"Statement": [
123+
// Allows Actions to Register/View Task Definitions.
124+
{
125+
"Effect": "Allow",
126+
"Action": [
127+
"ecs:DescribeTaskDefinition",
128+
"ecs:RegisterTaskDefinition"
129+
],
130+
// Not possible to harden to a specific resource
131+
"Resource": "*"
132+
},
133+
// [Optional] Allows Action to schedule one-off tasks via "prepare"
134+
{
135+
"Effect": "Allow",
136+
"Action": [
137+
"ecs:RunTask"
138+
],
139+
"Condition": {
140+
"ArnEquals": {
141+
"ecs:cluster": "arn:aws:ecs:{region}:{accountId}:cluster/{clusterName}"
142+
}
143+
},
144+
// Hardening must occur via `ArnEquals` condition above.
145+
"Resource": "*"
146+
},
147+
// [Optional] Allows Action to monitor the one-off task.
148+
{
149+
"Effect": "Allow",
150+
"Action": [
151+
"ecs:DescribeTasks"
152+
],
153+
"Resource": "arn:aws:ecs:{region}:{accountId}:task/{clusterName}/*"
154+
},
155+
// Allows Action to trigger a service update with new task definition
156+
{
157+
"Effect": "Allow",
158+
"Action": [
159+
"ecs:UpdateService",
160+
"ecs:DescribeServices"
161+
],
162+
"Resource": "arn:aws:ecs:{region}:{accountId}:service/{clusterName}/*"
163+
},
164+
// Allows Action to create new Task Definitions with the roles included in the Task Definition
165+
{
166+
"Effect": "Allow",
167+
"Action": [
168+
"iam:PassRole"
169+
],
170+
// In order to create a Task Definition w/ Roles. You must have permission to Pass those roles.
171+
"Resource": [
172+
"arn:aws:iam::{accountId}:role/{roleName}",
173+
"arn:aws:iam::{accountId}:role/{roleName}"
174+
]
175+
},
176+
// Allows Action to upload/verify ECR images via Docker Buildx
177+
{
178+
"Effect": "Allow",
179+
"Action": [
180+
"ecr:CompleteLayerUpload",
181+
"ecr:UploadLayerPart",
182+
"ecr:InitiateLayerUpload",
183+
"ecr:BatchCheckLayerAvailability",
184+
"ecr:PutImage",
185+
"ecr:BatchGetImage"
186+
],
187+
"Resource": [
188+
"arn:aws:ecr:{region}:{accountId}:repository/{repositoryName}",
189+
"arn:aws:ecr:{region}:{accountId}:repository/{repositoryName}",
190+
"arn:aws:ecr:{region}:{accountId}:repository/{repositoryName}"
191+
]
192+
},
193+
// Allows Action to authenticate via scoped permission set above against ECR Registry
194+
{
195+
"Effect": "Allow",
196+
"Action": "ecr:GetAuthorizationToken",
197+
// Not possible to harden gaining an ECR Auth token
198+
"Resource": "*"
199+
}
200+
]
201+
}
202+
```

0 commit comments

Comments
 (0)