EcsDeploymentGroup L2 construct
A CodeDeploy deployment group that orchestrates ECS blue-green deployments.
Example
declare const myApplication: codedeploy.EcsApplication;
declare const cluster: ecs.Cluster;
declare const taskDefinition: ecs.FargateTaskDefinition;
declare const blueTargetGroup: elbv2.ITargetGroup;
declare const greenTargetGroup: elbv2.ITargetGroup;
declare const listener: elbv2.IApplicationListener;
const service = new ecs.FargateService(this, 'Service', {
cluster,
taskDefinition,
deploymentController: {
type: ecs.DeploymentControllerType.CODE_DEPLOY,
},
});
new codedeploy.EcsDeploymentGroup(this, 'BlueGreenDG', {
service,
blueGreenDeploymentConfig: {
blueTargetGroup,
greenTargetGroup,
listener,
},
deploymentConfig: codedeploy.EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES,
});
# my_application: codedeploy.EcsApplication
# cluster: ecs.Cluster
# task_definition: ecs.FargateTaskDefinition
# blue_target_group: elbv2.ITargetGroup
# green_target_group: elbv2.ITargetGroup
# listener: elbv2.IApplicationListener
service = ecs.FargateService(self, "Service",
cluster=cluster,
task_definition=task_definition,
deployment_controller=ecs.DeploymentController(
type=ecs.DeploymentControllerType.CODE_DEPLOY
)
)
codedeploy.EcsDeploymentGroup(self, "BlueGreenDG",
service=service,
blue_green_deployment_config=codedeploy.EcsBlueGreenDeploymentConfig(
blue_target_group=blue_target_group,
green_target_group=green_target_group,
listener=listener
),
deployment_config=codedeploy.EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES
)
EcsApplication myApplication;
Cluster cluster;
FargateTaskDefinition taskDefinition;
ITargetGroup blueTargetGroup;
ITargetGroup greenTargetGroup;
IApplicationListener listener;
FargateService service = FargateService.Builder.create(this, "Service")
.cluster(cluster)
.taskDefinition(taskDefinition)
.deploymentController(DeploymentController.builder()
.type(DeploymentControllerType.CODE_DEPLOY)
.build())
.build();
EcsDeploymentGroup.Builder.create(this, "BlueGreenDG")
.service(service)
.blueGreenDeploymentConfig(EcsBlueGreenDeploymentConfig.builder()
.blueTargetGroup(blueTargetGroup)
.greenTargetGroup(greenTargetGroup)
.listener(listener)
.build())
.deploymentConfig(EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES)
.build();
// Install: dotnet add package Amazon.CDK.Lib
EcsApplication myApplication;
Cluster cluster;
FargateTaskDefinition taskDefinition;
ITargetGroup blueTargetGroup;
ITargetGroup greenTargetGroup;
IApplicationListener listener;
var service = new FargateService(this, "Service", new FargateServiceProps {
Cluster = cluster,
TaskDefinition = taskDefinition,
DeploymentController = new DeploymentController {
Type = DeploymentControllerType.CODE_DEPLOY
}
});
new EcsDeploymentGroup(this, "BlueGreenDG", new EcsDeploymentGroupProps {
Service = service,
BlueGreenDeploymentConfig = new EcsBlueGreenDeploymentConfig {
BlueTargetGroup = blueTargetGroup,
GreenTargetGroup = greenTargetGroup,
Listener = listener
},
DeploymentConfig = EcsDeploymentConfig.CANARY_10PERCENT_5MINUTES
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var myApplication EcsApplication
var cluster Cluster
var taskDefinition FargateTaskDefinition
var blueTargetGroup ITargetGroup
var greenTargetGroup ITargetGroup
var listener IApplicationListener
service := ecs.NewFargateService(this, jsii.String("Service"), &FargateServiceProps{
Cluster: Cluster,
TaskDefinition: TaskDefinition,
DeploymentController: &DeploymentController{
Type: ecs.DeploymentControllerType_CODE_DEPLOY,
},
})
codedeploy.NewEcsDeploymentGroup(this, jsii.String("BlueGreenDG"), &EcsDeploymentGroupProps{
Service: Service,
BlueGreenDeploymentConfig: &EcsBlueGreenDeploymentConfig{
BlueTargetGroup: *BlueTargetGroup,
GreenTargetGroup: *GreenTargetGroup,
Listener: *Listener,
},
DeploymentConfig: codedeploy.EcsDeploymentConfig_CANARY_10PERCENT_5MINUTES(),
})
Initializer
new EcsDeploymentGroup(scope: Construct, id: string, props: EcsDeploymentGroupProps)
EcsDeploymentGroup(scope: Construct, id: str, props: EcsDeploymentGroupProps)
new EcsDeploymentGroup(Construct scope, String id, EcsDeploymentGroupProps props)
new EcsDeploymentGroup(Construct scope, string id, EcsDeploymentGroupProps props)
NewEcsDeploymentGroup(Scope Construct, Id *string, Props EcsDeploymentGroupProps)
Construct Props
alarmsoptionalIAlarmRef[]alarmsoptionaltyping.List[IAlarmRef]alarmsoptionalList<IAlarmRef>AlarmsoptionalIAlarmRef[]Alarmsoptional*[]IAlarmRef= []#CodeDeploy will stop (and optionally roll back) a deployment if during it any of the alarms trigger.
Alarms can also be added after the Deployment Group is created using the #addAlarm method.
applicationoptionalIApplicationRefapplicationoptionalIApplicationRefapplicationoptionalIApplicationRefApplicationoptionalIApplicationRefApplicationoptionalIApplicationRef#Default: One will be created for you.
autoRollbackoptionalAutoRollbackConfigauto_rollbackoptionalAutoRollbackConfigautoRollbackoptionalAutoRollbackConfigAutoRollbackoptionalAutoRollbackConfigAutoRollbackoptionalAutoRollbackConfig#Default: default AutoRollbackConfig.
blueGreenDeploymentConfigEcsBlueGreenDeploymentConfigblue_green_deployment_configEcsBlueGreenDeploymentConfigblueGreenDeploymentConfigEcsBlueGreenDeploymentConfigBlueGreenDeploymentConfigEcsBlueGreenDeploymentConfigBlueGreenDeploymentConfigEcsBlueGreenDeploymentConfigrequired#deploymentConfigoptionalIDeploymentConfigRefdeployment_configoptionalIDeploymentConfigRefdeploymentConfigoptionalIDeploymentConfigRefDeploymentConfigoptionalIDeploymentConfigRefDeploymentConfigoptionalIDeploymentConfigRef= EcsDeploymentConfig.ALL_AT_ONCE#deploymentGroupNameoptionalstringdeployment_group_nameoptionalstrdeploymentGroupNameoptionalStringDeploymentGroupNameoptionalstringDeploymentGroupNameoptional*string#Default: An auto-generated name will be used.
ignoreAlarmConfigurationoptionalbooleanignore_alarm_configurationoptionalboolignoreAlarmConfigurationoptionalBooleanIgnoreAlarmConfigurationoptionalboolIgnoreAlarmConfigurationoptional*bool= false#ignorePollAlarmsFailureoptionalbooleanignore_poll_alarms_failureoptionalboolignorePollAlarmsFailureoptionalBooleanIgnorePollAlarmsFailureoptionalboolIgnorePollAlarmsFailureoptional*bool= false#Default: A new Role will be created.
serviceIBaseServiceserviceIBaseServiceserviceIBaseServiceServiceIBaseServiceServiceIBaseServicerequired#Properties
applicationIEcsApplicationapplicationIEcsApplicationapplicationIEcsApplicationApplicationIEcsApplicationApplicationIEcsApplicationrequired#applicationNamestringapplication_namestrapplicationNameStringApplicationNamestringApplicationName*stringrequired#deploymentConfigIEcsDeploymentConfigdeployment_configIEcsDeploymentConfigdeploymentConfigIEcsDeploymentConfigDeploymentConfigIEcsDeploymentConfigDeploymentConfigIEcsDeploymentConfigrequired#deploymentGroupArnstringdeployment_group_arnstrdeploymentGroupArnStringDeploymentGroupArnstringDeploymentGroupArn*stringrequired#deploymentGroupNamestringdeployment_group_namestrdeploymentGroupNameStringDeploymentGroupNamestringDeploymentGroupName*stringrequired#deploymentGroupRefDeploymentGroupReferencedeployment_group_refDeploymentGroupReferencedeploymentGroupRefDeploymentGroupReferenceDeploymentGroupRefDeploymentGroupReferenceDeploymentGroupRefDeploymentGroupReferencerequired#envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
For resources that are created and managed in a Stack (those created by creating new class instances like new Role(), new Bucket(), etc.), this is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be different than the stack they were imported into.
PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#Methods
addAlarm(alarm: IAlarmRef): voiddef add_alarm(self, alarm: IAlarmRef) -> Nonepublic void addAlarm(IAlarmRef alarm)public void AddAlarm(IAlarmRef alarm)func AddAlarm(Alarm IAlarmRef)#1 parameter
Parameters
alarmalarmalarmalarmAlarm— the alarm to associate with this Deployment Group.
applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
When set, any cross-stack reference to this resource will use the specified mechanism instead of the global default determined by the @aws-cdk/core:defaultCrossStackReferences context key. This is useful for selectively weakening specific references to avoid the "deadly embrace" problem without changing the app-wide default.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS account for data recovery and cleanup later (RemovalPolicy.RETAIN).
fromEcsDeploymentGroupAttributes(scope: Construct, id: string, attrs: EcsDeploymentGroupAttributes): IEcsDeploymentGroup@staticmethod def from_ecs_deployment_group_attributes(scope: Construct, id: str, attrs: EcsDeploymentGroupAttributes) -> IEcsDeploymentGrouppublic static IEcsDeploymentGroup fromEcsDeploymentGroupAttributes(Construct scope, String id, EcsDeploymentGroupAttributes attrs)public static IEcsDeploymentGroup FromEcsDeploymentGroupAttributes(Construct scope, string id, EcsDeploymentGroupAttributes attrs)func FromEcsDeploymentGroupAttributes(Scope Construct, Id *string, Attrs EcsDeploymentGroupAttributes) IEcsDeploymentGroupstatic#Account and region for the DeploymentGroup are taken from the application.
3 parameters · returns
Parameters
scopescopescopescopeScope— the parent Construct for this new Construct.ididididId— the logical ID of this new Construct.attrsattrsattrsattrsAttrs— the properties of the referenced Deployment Group.
Returns: a Construct representing a reference to an existing Deployment Group
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#Mixins are applied in order. The list of constructs is captured at the start of the call, so constructs added by a mixin will not be visited. Use multiple with() calls if subsequent mixins should apply to added constructs.