@@ -15,7 +15,7 @@ AWS CodeDeploy is a deployment service that automates application deployments to
15
15
Amazon EC2 instances, on-premises instances, serverless Lambda functions, or
16
16
Amazon ECS services.
17
17
18
- The CDK currently supports Amazon EC2, on-premise and AWS Lambda applications.
18
+ The CDK currently supports Amazon EC2, on-premise, AWS Lambda, and Amazon ECS applications.
19
19
20
20
## EC2/on-premise Applications
21
21
@@ -143,7 +143,7 @@ const deploymentGroup = new codedeploy.ServerDeploymentGroup(this, 'DeploymentGr
143
143
});
144
144
```
145
145
146
- ## Deployment Configurations
146
+ ## EC2/on-premise Deployment Configurations
147
147
148
148
You can also pass a Deployment Configuration when creating the Deployment Group:
149
149
@@ -226,41 +226,6 @@ In order to deploy a new version of this function:
226
226
2 . Re-deploy the stack (this will trigger a deployment).
227
227
3 . Monitor the CodeDeploy deployment as traffic shifts between the versions.
228
228
229
-
230
- ### Create a custom Deployment Config
231
-
232
- CodeDeploy for Lambda comes with built-in configurations for traffic shifting.
233
- If you want to specify your own strategy,
234
- you can do so with the CustomLambdaDeploymentConfig construct,
235
- letting you specify precisely how fast a new function version is deployed.
236
-
237
- ``` ts
238
- const config = new codedeploy .CustomLambdaDeploymentConfig (this , ' CustomConfig' , {
239
- type: codedeploy .CustomLambdaDeploymentConfigType .CANARY ,
240
- interval: Duration .minutes (1 ),
241
- percentage: 5 ,
242
- });
243
-
244
- declare const application: codedeploy .LambdaApplication ;
245
- declare const alias: lambda .Alias ;
246
- const deploymentGroup = new codedeploy .LambdaDeploymentGroup (this , ' BlueGreenDeployment' , {
247
- application ,
248
- alias ,
249
- deploymentConfig: config ,
250
- });
251
- ```
252
-
253
- You can specify a custom name for your deployment config, but if you do you will not be able to update the interval/percentage through CDK.
254
-
255
- ``` ts
256
- const config = new codedeploy .CustomLambdaDeploymentConfig (this , ' CustomConfig' , {
257
- type: codedeploy .CustomLambdaDeploymentConfigType .CANARY ,
258
- interval: Duration .minutes (1 ),
259
- percentage: 5 ,
260
- deploymentConfigName: ' MyDeploymentConfig' ,
261
- });
262
- ```
263
-
264
229
### Rollbacks and Alarms
265
230
266
231
CodeDeploy will roll back if the deployment fails. You can optionally trigger a rollback when one or more alarms are in a failed state:
@@ -327,3 +292,127 @@ const deploymentGroup = codedeploy.LambdaDeploymentGroup.fromLambdaDeploymentGro
327
292
deploymentGroupName: ' MyExistingDeploymentGroup' ,
328
293
});
329
294
```
295
+
296
+ ## Lambda Deployment Configurations
297
+
298
+ CodeDeploy for Lambda comes with predefined configurations for traffic shifting.
299
+ The predefined configurations are available as LambdaDeploymentConfig constants.
300
+
301
+ ``` ts
302
+ const config = codedeploy .LambdaDeploymentConfig .CANARY_10PERCENT_30MINUTES ;
303
+
304
+ declare const application: codedeploy .LambdaApplication ;
305
+ declare const alias: lambda .Alias ;
306
+ const deploymentGroup = new codedeploy .LambdaDeploymentGroup (this , ' BlueGreenDeployment' , {
307
+ application ,
308
+ alias ,
309
+ deploymentConfig: config ,
310
+ });
311
+ ```
312
+
313
+ If you want to specify your own strategy,
314
+ you can do so with the LambdaDeploymentConfig construct,
315
+ letting you specify precisely how fast a new function version is deployed.
316
+
317
+ ``` ts
318
+ const config = new codedeploy .LambdaDeploymentConfig (this , ' CustomConfig' , {
319
+ trafficRoutingConfig: new codedeploy .TimeBasedCanaryTrafficRoutingConfig ({
320
+ interval: cdk .Duration .minutes (15 ),
321
+ percentage: 5 ,
322
+ }),
323
+ });
324
+
325
+ declare const application: codedeploy .LambdaApplication ;
326
+ declare const alias: lambda .Alias ;
327
+ const deploymentGroup = new codedeploy .LambdaDeploymentGroup (this , ' BlueGreenDeployment' , {
328
+ application ,
329
+ alias ,
330
+ deploymentConfig: config ,
331
+ });
332
+ ```
333
+
334
+ You can specify a custom name for your deployment config, but if you do you will not be able to update the interval/percentage through CDK.
335
+
336
+ ``` ts
337
+ const config = new codedeploy .LambdaDeploymentConfig (this , ' CustomConfig' , {
338
+ trafficRoutingConfig: new codedeploy .TimeBasedCanaryTrafficRoutingConfig ({
339
+ interval: cdk .Duration .minutes (15 ),
340
+ percentage: 5 ,
341
+ }),
342
+ deploymentConfigName: ' MyDeploymentConfig' ,
343
+ });
344
+ ```
345
+
346
+ To import an already existing Deployment Config:
347
+
348
+ ``` ts
349
+ const deploymentConfig = codedeploy .LambdaDeploymentConfig .fromLambdaDeploymentConfigName (
350
+ this ,
351
+ ' ExistingDeploymentConfiguration' ,
352
+ ' MyExistingDeploymentConfiguration' ,
353
+ );
354
+ ```
355
+
356
+ ## ECS Applications
357
+
358
+ To create a new CodeDeploy Application that deploys an ECS service:
359
+
360
+ ``` ts
361
+ const application = new codedeploy .EcsApplication (this , ' CodeDeployApplication' , {
362
+ applicationName: ' MyApplication' , // optional property
363
+ });
364
+ ```
365
+
366
+ To import an already existing Application:
367
+
368
+ ``` ts
369
+ const application = codedeploy .EcsApplication .fromEcsApplicationName (
370
+ this ,
371
+ ' ExistingCodeDeployApplication' ,
372
+ ' MyExistingApplication' ,
373
+ );
374
+ ```
375
+
376
+ ## ECS Deployment Configurations
377
+
378
+ CodeDeploy for ECS comes with predefined configurations for traffic shifting.
379
+ The predefined configurations are available as LambdaDeploymentConfig constants.
380
+
381
+ ``` ts
382
+ const config = codedeploy .EcsDeploymentConfig .CANARY_10PERCENT_5MINUTES ;
383
+ ```
384
+
385
+ If you want to specify your own strategy,
386
+ you can do so with the EcsDeploymentConfig construct,
387
+ letting you specify precisely how fast an ECS service is deployed.
388
+
389
+ ``` ts
390
+ new codedeploy .EcsDeploymentConfig (this , ' CustomConfig' , {
391
+ trafficRoutingConfig: new codedeploy .TimeBasedCanaryTrafficRoutingConfig ({
392
+ interval: cdk .Duration .minutes (15 ),
393
+ percentage: 5 ,
394
+ }),
395
+ });
396
+ ```
397
+
398
+ You can specify a custom name for your deployment config, but if you do you will not be able to update the interval/percentage through CDK.
399
+
400
+ ``` ts
401
+ const config = new codedeploy .EcsDeploymentConfig (this , ' CustomConfig' , {
402
+ trafficRoutingConfig: new codedeploy .TimeBasedCanaryTrafficRoutingConfig ({
403
+ interval: cdk .Duration .minutes (15 ),
404
+ percentage: 5 ,
405
+ }),
406
+ deploymentConfigName: ' MyDeploymentConfig' ,
407
+ });
408
+ ```
409
+
410
+ Or import an existing one:
411
+
412
+ ``` ts
413
+ const deploymentConfig = codedeploy .EcsDeploymentConfig .fromEcsDeploymentConfigName (
414
+ this ,
415
+ ' ExistingDeploymentConfiguration' ,
416
+ ' MyExistingDeploymentConfiguration' ,
417
+ );
418
+ ```
0 commit comments