1
1
[ ![ Build Status] ( https://travis-ci.org/monade/ecs-deploy-cli.svg?branch=master )] ( https://travis-ci.org/monade/ecs-deploy-cli )
2
+ [ ![ Gem Version] ( https://badge.fury.io/rb/ecs_deploy_cli.svg )] ( https://badge.fury.io/rb/ecs_deploy_cli )
2
3
3
4
# ECS Deploy CLI
4
5
5
6
A CLI + DSL to simplify deployments on AWS [ Elastic Container Service] ( https://aws.amazon.com/it/ecs/ ) .
6
7
7
- It's partial, incomplete and unstable. Use it at your own risk.
8
-
9
8
## Motivation
10
9
11
10
Once you've configured your cluster on ECS, running Continous Deployment is not that easy.
@@ -48,18 +47,29 @@ aws_region ENV.fetch('AWS_REGION', 'eu-central-1')
48
47
# Used to create ARNs
49
48
aws_profile_id ' 123123'
50
49
51
- # Defining the cluster name
52
- cluster ' yourproject-cluster'
50
+ # Defining the cluster name. The block data is for the cluster creation configuration.
51
+ cluster ' yourproject-cluster' do
52
+ # Default instance type
53
+ instance_type ' t3.small'
54
+ # A keypair with this name must exist in your account
55
+ keypair_name ' test'
56
+
57
+ # This creates a new VPC in your region. You can also use an existing one.
58
+ vpc do
59
+ availability_zones ' eu-central-1a' , ' eu-central-1b' , ' eu-central-1c'
60
+ end
61
+ end
53
62
54
63
# This is used as a template for the next two containers, it will not be used inside a task
55
64
container :base_container do
56
65
image " #{ ENV [' REPO_URL' ]} :#{ ENV [' CURRENT_VERSION' ]} "
57
66
load_envs ' envs/base.yml'
58
67
load_envs ' envs/production.yml'
59
68
env key: ' MANUAL_ENV' , value: ' 123'
60
- secret key: ' RAILS_MASTER_KEY ' , value: ' railsMasterKey ' # Taking the secret from AWS System Manager with name "arn:aws:ssm:__AWS_REGION__:__AWS_PROFILE_ID__:parameter/railsMasterKey "
69
+ secret key: ' SUPER_SECRET_VARIABLE ' , value: ' superSecretKey ' # Taking the secret from AWS System Manager with name "arn:aws:ssm:__AWS_REGION__:__AWS_PROFILE_ID__:parameter/superSecretKey "
61
70
working_directory ' /app'
62
- cloudwatch_logs ' yourproject' # Configuring cloudwatch logs
71
+ # Configuring cloudwatch logs. It automatically creates a log group `/ecs/yourproject`
72
+ cloudwatch_logs ' yourproject'
63
73
end
64
74
65
75
# The rails web application
97
107
# The main service
98
108
service :'yourproject-service' do
99
109
task :yourproject
110
+
111
+ # You can also link an existing load balancer to a task, for instance:
112
+ # load_balancer :'yourproject-load-balancer' do
113
+ # target_group_arn 'loader-target-group/123abc'
114
+ # container_name :web
115
+ # container_port 3000
116
+ # end
100
117
end
101
118
102
119
# A task for cron jobs
103
120
task :'yourproject-cron' do
104
121
containers :cron
105
122
cpu 256
106
123
memory 1024
124
+ # This is automatically converted to the relative ARN
107
125
execution_role ' ecsTaskExecutionRole'
108
126
network_mode ' awsvpc'
109
127
@@ -129,57 +147,79 @@ cron :scheduled_emails do
129
147
end
130
148
```
131
149
132
- Now you can run the commands from the CLI .
150
+ Now you can use the cli commands to control your cluster .
133
151
134
- For instance, you can run deploy:
135
- ``` bash
136
- $ ecs-deploy deploy
137
- ```
152
+ ## Use cases
153
+
154
+ This DSL can be used both to create new clusters or to control/modify existing ones.
155
+
156
+ If you want to create a new cluster with the configuration defined in your ECSFile, you can run the ` ecs-cli setup ` command (see reference below).
157
+
158
+ Otherwise, you can just validate that the ECSFile is correctly defined in a safe way.
159
+
160
+ There are a couple of commands that help you here:
161
+ * ` ecs-deploy validate ` : checks if the defined cluster and services exist on your AWS account. It also check for errors in your ECSFile.
162
+ * ` ecs-deploy diff ` computes the differences between your ECSFile configuration and your existing cluster configuration, printing them in STDOUT.
138
163
139
164
## CLI commands
140
165
141
166
You can find the full command list by running ` ecs-deploy help ` .
142
167
143
- Check if your ECSFile is valid
168
+ ### Validate
144
169
``` bash
145
170
$ ecs-deploy validate
146
171
```
147
172
148
- Create the cluster and the services
173
+ It checks if your ECSFile is valid and if the cluster/services you've defined exist in your account/region.
174
+
175
+ ### Setup
149
176
``` bash
150
177
$ ecs-deploy setup
151
178
```
152
179
153
- Deploy all services and scheduled tasks
180
+ It creates the cluster and the services as defined in your ECSFile
181
+
182
+ ### Deploy
154
183
``` bash
155
184
$ ecs-deploy deploy
156
185
```
186
+ It deploys (a.k.a. updates) all services and scheduled tasks
157
187
158
- Deploy just services
188
+ ### Deploy only services
159
189
``` bash
160
190
$ ecs-deploy deploy-services
161
191
```
192
+ It runs a deployment just on services
162
193
163
- Deploy just scheduled tasks
194
+ ### Deploy only scheduled tasks
164
195
``` bash
165
196
$ ecs-deploy deploy-scheduled-tasks
166
197
```
198
+ It runs a deployment just on scheduled tasks
167
199
168
- Prints the diff between your local task_definitions and the ones in your AWS account. Useful to debug what has to be updated using ` deploy ` .
200
+ ### Diff
169
201
``` bash
170
202
$ ecs-deploy diff
171
203
```
204
+ It prints the differences between your local task_definitions and the ones in your AWS account. Useful to debug what has to be updated using ` deploy ` .
172
205
173
- Starts a task in the cluster based on a task definition.
206
+ ### Run task
174
207
``` bash
175
- $ ecs-deploy run-task [task_name] --subnets subnet1,subnet2 --launch-type FARGATE| EC2 --security-groups sg-123,sg-234
208
+ $ ecs-deploy run-task [task_name] --subnets subnet1,subnet2 --launch-type [ FARGATE| EC2] --security-groups sg-123,sg-234
176
209
```
210
+ It starts a task in the cluster based on a task definition, given a launch type, a security group and/or subnets.
177
211
178
- Run SSH on a cluster container instance:
212
+ ### SSH
179
213
``` bash
180
214
$ ecs-deploy ssh
181
215
```
182
216
217
+ It connects with SSH to a cluster container instance. If there are more than one, it will prompt which one you want to connect.
218
+
219
+ You can also filter by task (` --task [YOUR-TASK] ` ) or by service (` --service [YOUR-SERVICE] ` )
220
+
221
+ * IMPORTANT* You have to open port 22 in your cluster security group to your IP.
222
+
183
223
## API
184
224
185
225
You can also use it as an API:
0 commit comments