Skip to content

Commit

Permalink
feat(tfmodules): make deploymentConfigName configurable
Browse files Browse the repository at this point in the history
Enable different traffic patterns for deployment
(defaults to All at Once)
  • Loading branch information
kschelonka committed Jan 13, 2025
1 parent d32ee5c commit db7709a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions infrastructure/client-api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,9 @@ class ClientAPI extends TerraformStack {
useCodeDeploy: true,
useCodePipeline: false,
useTerraformBasedCodeDeploy: false,
// Shifts 10 percent of traffic in the first increment.
// The remaining 90 percent is deployed five minutes later.
deploymentConfigName: 'CodeDeployDefault.ECSCanary10Percent5Minutes',
generateAppSpec: false,
snsNotificationTopicArn: snsTopic.arn,
successTerminationWaitTimeInMinutes: 5,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export interface ApplicationECSAlbCodeDeployProps
targetGroupNames: string[];
tags?: { [key: string]: string };
dependsOn?: TerraformResource[];
// Docs at Terraform Registry: CodedeployDeploymentGroup#deployment_config_name
deploymentConfigName?: string | undefined;
successTerminationWaitTimeInMinutes?: number;
notifications?: {
notifyOnStarted?: boolean;
Expand Down Expand Up @@ -66,7 +68,9 @@ export class ApplicationECSAlbCodeDeploy extends Construct {
{
dependsOn: config.dependsOn,
appName: codeDeployApp.name,
deploymentConfigName: 'CodeDeployDefault.ECSAllAtOnce',
deploymentConfigName:
this.config.deploymentConfigName ??
'CodeDeployDefault.ECSAllAtOnce',
deploymentGroupName: `${this.config.prefix}-ECS`,
serviceRoleArn: ecsCodeDeployRole.arn,
autoRollbackConfiguration: {
Expand Down
3 changes: 3 additions & 0 deletions packages/terraform-modules/src/base/ApplicationECSService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export interface ApplicationECSServiceProps extends TerraformMetaArguments {
useCodePipeline?: boolean;
generateAppSpec?: boolean;
successTerminationWaitTimeInMinutes?: number;
// Docs at Terraform Registry: CodedeployDeploymentGroup#deployment_config_name
deploymentConfigName?: string | undefined;
codeDeployNotifications?: {
notifyOnStarted?: boolean; //defaults to true
notifyOnSucceeded?: boolean; //defaults to true
Expand Down Expand Up @@ -205,6 +207,7 @@ export class ApplicationECSService extends Construct {
clusterName: this.config.ecsClusterName,
targetGroupNames: targetGroupNames,
listenerArn: this.config.albConfig.listenerArn,
deploymentConfigName: this.config.deploymentConfigName,
snsNotificationTopicArn:
this.config.codeDeploySnsNotificationTopicArn,
tags: this.config.tags,
Expand Down
7 changes: 7 additions & 0 deletions packages/terraform-modules/src/pocket/PocketALBApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ export interface PocketALBApplicationProps extends TerraformMetaArguments {
* Option to create a CodeDeploy application.
*/
useCodeDeploy: boolean;
/**
* How to do the blue/green deployment
* Docs at Terraform Registry: CodedeployDeploymentGroup#deployment_config_name
* See also: https://docs.aws.amazon.com/codedeploy/latest/userguide/deployment-configurations.html
*/
deploymentConfigName?: string | undefined;
/**
* Option to deploy a new version using terraform, instead of externally
*/
Expand Down Expand Up @@ -644,6 +650,7 @@ export class PocketALBApplication extends Construct {
ecsClusterArn: ecsCluster.cluster.arn,
ecsClusterName: ecsCluster.cluster.name,
useCodeDeploy: this.config.codeDeploy.useCodeDeploy,
deploymentConfigName: this.config.codeDeploy.deploymentConfigName,
codeDeployNotifications: this.config.codeDeploy.notifications,
useCodePipeline: this.config.codeDeploy.useCodePipeline,
useTerraformBasedCodeDeploy:
Expand Down

0 comments on commit db7709a

Please sign in to comment.