Skip to content

Commit cb7ab00

Browse files
committed
Support for CodeDeploy deployments
1 parent 2e35595 commit cb7ab00

File tree

7 files changed

+8328
-32
lines changed

7 files changed

+8328
-32
lines changed

README.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ This action requires the following minimum set of permissions:
6363
"ecs:DescribeServices"
6464
],
6565
"Resource":[
66-
"arn:aws:ecs:region:<aws_account_id>:service/<cluster_name>/<service_name>"
66+
"arn:aws:ecs:<region>:<aws_account_id>:service/<cluster_name>/<service_name>"
6767
]
6868
}
6969
]
@@ -72,6 +72,70 @@ This action requires the following minimum set of permissions:
7272

7373
Note: the policy above assumes the account has opted in to the ECS long ARN format.
7474

75+
## CodeDeploy Support
76+
77+
For ECS services that uses the `CODE_DEPLOY` deployment controller, additional configuration is needed for this action:
78+
79+
```yaml
80+
- name: Deploy to Amazon ECS
81+
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
82+
with:
83+
task-definition: task-definition.json
84+
service: my-service
85+
cluster: my-cluster
86+
wait-for-service-stability: true
87+
codedeploy-appspec: appspec.json
88+
codedeploy-application: my-codedeploy-application
89+
codedeploy-deployment-group: my-codedeploy-deployment-group
90+
```
91+
92+
The minimal permissions require access to CodeDeploy:
93+
94+
```
95+
{
96+
"Version":"2012-10-17",
97+
"Statement":[
98+
{
99+
"Sid":"RegisterTaskDefinition",
100+
"Effect":"Allow",
101+
"Action":[
102+
"ecs:RegisterTaskDefinition"
103+
],
104+
"Resource":"*"
105+
},
106+
{
107+
"Sid":"PassRolesInTaskDefinition",
108+
"Effect":"Allow",
109+
"Action":[
110+
"iam:PassRole"
111+
],
112+
"Resource":[
113+
"arn:aws:iam::<aws_account_id>:role/<task_definition_task_role_name>",
114+
"arn:aws:iam::<aws_account_id>:role/<task_definition_task_execution_role_name>"
115+
]
116+
},
117+
{
118+
"Sid":"DeployService",
119+
"Effect":"Allow",
120+
"Action":[
121+
"ecs:DescribeServices",
122+
"codedeploy:GetDeploymentGroup",
123+
"codedeploy:CreateDeployment",
124+
"codedeploy:GetDeployment",
125+
"codedeploy:GetDeploymentConfig",
126+
"codedeploy:RegisterApplicationRevision"
127+
],
128+
"Resource":[
129+
"arn:aws:ecs:<region>:<aws_account_id>:service/<cluster_name>/<service_name>",
130+
"arn:aws:codedeploy:<region>:<aws_account_id>:deploymentgroup:<application_name>/<deployment_group_name>",
131+
"arn:aws:codedeploy:<region>:<aws_account_id>:deploymentconfig:*",
132+
"arn:aws:codedeploy:<region>:<aws_account_id>:application:<application_name>"
133+
]
134+
}
135+
]
136+
}
137+
```
138+
75139
## License Summary
76140

77141
This code is made available under the MIT license.

action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,20 @@ inputs:
1616
wait-for-service-stability:
1717
description: 'Whether to wait for the ECS service to reach stable state after deploying the new task definition. Valid value is "true". Will default to not waiting.'
1818
required: false
19+
codedeploy-appspec:
20+
description: "The path to the CodeDeploy AppSpec file, if the ECS service uses the CODE_DEPLOY deployment controller. Will default to 'appspec.yaml'."
21+
required: false
22+
codedeploy-application:
23+
description: "The name of the CodeDeploy application, if the ECS service uses the CODE_DEPLOY deployment controller. Will default to 'AppECS-{cluster}-{service}'."
24+
required: false
25+
codedeploy-deployment-group:
26+
description: "The name of the CodeDeploy deployment group, if the ECS service uses the CODE_DEPLOY deployment controller. Will default to 'DgpECS-{cluster}-{service}'."
27+
required: false
1928
outputs:
2029
task-definition-arn:
2130
description: 'The ARN of the registered ECS task definition'
31+
codedeploy-deployment-id:
32+
description: 'The deployment ID of the CodeDeploy deployment (if the ECS service uses the CODE_DEPLOY deployment controller'
2233
runs:
2334
using: 'node12'
2435
main: 'dist/index.js'

0 commit comments

Comments
 (0)