Skip to content

Commit 72b57ae

Browse files
authored
Update README.md (#145)
1 parent ef9e764 commit 72b57ae

1 file changed

Lines changed: 107 additions & 30 deletions

File tree

README.md

Lines changed: 107 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -107,60 +107,147 @@ $ cage audit --region ${AWS_REGION} --cluster ${ECS_CLUSTER} --service ${ECS_SER
107107

108108
By default, the output is a table with per-container status and severity counts. Use `--detail` to include vulnerability descriptions and `--json` to output the aggregated result as JSON.
109109

110-
### IAM Policy
110+
### IAM Policy (for `cage rollout`)
111111

112-
`cararycage` requires several IAM policies to run. Here is an example of IAM policy for `canarycage`:
112+
`canarycage` requires several IAM policies to run. Here is a recommended example of IAM policy for `cage rollout` command with Fargate:
113113

114114
```json
115115
{
116116
"Version": "2012-10-17",
117117
"Statement": [
118118
{
119+
"Action": ["ecs:CreateService", "ecs:UpdateService"],
120+
"Condition": {
121+
"ArnEquals": {
122+
"ecs:cluster": "arn:aws:ecs::123456789010:cluster/your-cluster-name"
123+
},
124+
"ArnLike": {
125+
"ecs:task-definition": [
126+
"arn:aws:ecs::123456789010:task-definition/your-task-definition-name:*"
127+
]
128+
}
129+
},
119130
"Effect": "Allow",
131+
"Resource": [
132+
"arn:aws:ecs::123456789010:service/your-cluster-name/your-service-name"
133+
]
134+
},
135+
{
136+
"Action": ["ecs:DeleteService", "ecs:DescribeServices"],
137+
"Condition": {
138+
"ArnEquals": {
139+
"ecs:cluster": "arn:aws:ecs::123456789010:cluster/your-cluster-name"
140+
}
141+
},
142+
"Effect": "Allow",
143+
"Resource": [
144+
"arn:aws:ecs::123456789010:service/your-cluster-name/your-service-name"
145+
]
146+
},
147+
{
148+
"Action": ["ecs:RegisterTaskDefinition"],
149+
"Effect": "Allow",
150+
"Resource": [
151+
"arn:aws:ecs::123456789010:task-definition/your-task-definition-name:*"
152+
]
153+
},
154+
{
120155
"Action": [
121-
"ecs:CreateService",
122-
"ecs:UpdateService",
123-
"ecs:DeleteService",
124-
"ecs:StartTask",
125-
"ecs:RegisterTaskDefinition",
126-
"ecs:DescribeServices",
127156
"ecs:DescribeTasks",
128157
"ecs:DescribeContainerInstances",
129158
"ecs:ListTasks",
130-
"ecs:RunTask",
131-
"ecs:StopTask",
132-
"ecs:DescribeTaskDefinition"
159+
"ecs:StopTask"
133160
],
161+
"Condition": {
162+
"ArnEquals": {
163+
"ecs:cluster": "arn:aws:ecs::123456789010:cluster/your-cluster-name"
164+
}
165+
},
166+
"Effect": "Allow",
134167
"Resource": "*"
135168
},
136169
{
170+
"Action": ["ecs:RunTask", "ecs:StartTask"],
171+
"Condition": {
172+
"ArnEquals": {
173+
"ecs:cluster": "arn:aws:ecs::123456789010:cluster/your-cluster-name"
174+
}
175+
},
137176
"Effect": "Allow",
138-
"Action": [
139-
"ecr:BatchGetImage",
140-
"ecr:DescribeImageScanFindings"
141-
],
142-
"Resource": "*"
177+
"Resource": [
178+
"arn:aws:ecs::123456789010:task-definition/your-task-definition-name:*"
179+
]
143180
},
144181
{
182+
"Action": ["ecs:DescribeTaskDefinition"],
145183
"Effect": "Allow",
184+
"Resource": "*"
185+
},
186+
{
146187
"Action": [
147188
"elasticloadbalancing:DescribeTargetGroups",
148189
"elasticloadbalancing:DescribeTargetHealth",
149-
"elasticloadbalancing:DescribeTargetGroupAttributes",
190+
"elasticloadbalancing:DescribeTargetGroupAttributes"
191+
],
192+
"Effect": "Allow",
193+
"Resource": "*"
194+
},
195+
{
196+
"Action": [
150197
"elasticloadbalancing:RegisterTargets",
151198
"elasticloadbalancing:DeregisterTargets"
152199
],
200+
"Effect": "Allow",
201+
"Resource": [
202+
"arn:aws:elasticloadbalancing::123456789010:targetgroup/your-target-group-name/your-target-group-id"
203+
]
204+
},
205+
{
206+
"Action": ["ec2:DescribeSubnets", "ec2:DescribeInstances"],
207+
"Effect": "Allow",
153208
"Resource": "*"
154209
},
155210
{
211+
"Action": ["iam:PassRole"],
212+
"Condition": {
213+
"StringEquals": {
214+
"iam:PassedToService": "ecs-tasks.amazonaws.com"
215+
}
216+
},
217+
"Effect": "Allow",
218+
"Resource": [
219+
"arn:aws:iam::123456789010:role/your-task-execution-role",
220+
"arn:aws:iam::123456789010:role/your-task-role"
221+
]
222+
}
223+
]
224+
}
225+
```
226+
227+
### IAM Policy (for `cage audit`)
228+
229+
Here is a recommended example of IAM policy for `cage audit` command:
230+
231+
```json
232+
{
233+
"Version": "2012-10-17",
234+
"Statement": [
235+
{
236+
"Action": ["ecr:BatchGetImage", "ecr:DescribeImageScanFindings"],
237+
"Effect": "Allow",
238+
"Resource": ["arn:aws:ecr::123456789010:repository/your-repository-name"]
239+
},
240+
{
241+
"Action": ["ecs:DescribeServices", "ecs:DescribeTaskDefinition"],
156242
"Effect": "Allow",
157-
"Action": ["ec2:DescribeSubnets", "ec2:DescribeInstances"],
158243
"Resource": "*"
159244
}
160245
]
161246
}
162247
```
163248

249+
You can restrict the `Resource` field of `ecs:DescribeServices` and `ecs:DescribeTaskDefinition` actions to specific services and task definitions if you want to limit the scope of the policy.
250+
164251
### Why we need `canarycage`
165252

166253
Currently, AWS ECS provides several ways to deploy task to service. [DeploymentCircuitBreaker](https://docs.aws.amazon.com/ja_jp/AmazonECS/latest/APIReference/API_DeploymentCircuitBreaker.html) is one of the choices. This feature is useful for preventing service from being unavailable during deployment. However, it is not enough for us. We need more robust and reliable deployment tool. `canarycage` is designed to be a tool that can deploy tasks to services with high availability.
@@ -169,19 +256,9 @@ DeploymentCircuitBreaker automatically detects the failure of the deployment and
169256

170257
This approach is very robust and reliable. For past 5 years, we have been using this tool for all production microservices running on ECS Fargate with no downtime caused by deployment. Many misconfigurations and bugs have been detected by canary task before updating the service.
171258

172-
## With GitHub Actions
259+
## GitHub Actions
173260

174-
You can use `canarycage` with GitHub Actions. Here is an example of GitHub Actions workflow:
175-
176-
```yaml
177-
- uses: loilo-inc/actions-setup-cage@7
178-
with:
179-
github-token: ${{ secrets.GITHUB_TOKEN }}
180-
- uses: loilo-inc/actions-deploy-cage@v7
181-
with:
182-
region: your-region
183-
deploy-context: deploy
184-
```
261+
Canarycage Github Actions are now unavailable due to security concerns.
185262

186263
## Licence
187264

0 commit comments

Comments
 (0)