cloudcomponents / cdk-constructs

A collection of higher-level reusable cdk constructs
MIT License
625 stars 104 forks source link

feat(cdk-blue-green-container-deployment): support DeploymentConfig creation #114

Closed kimisme9386 closed 3 years ago

kimisme9386 commented 3 years ago

Reference issue https://github.com/cloudcomponents/cdk-constructs/issues/115

fix https://github.com/cloudcomponents/cdk-constructs/issues/115

hupe1980 commented 3 years ago

DeploymentConfig is directly supported by Cloudformation. Let's build our own construct from this (-> Wrapper over CfnDeploymentConfig) and pass it to the DeploymentGroup Construct? This is cleaner than a createDeploymentConfigInput parameter.

import { EcsDeploymentGroup, EcsDeploymentConfiguration, /**...**/ } from '@cloudcomponents/cdk-blue-green-container-deployment';

const deploymentConfigurattion =new EcsDeploymentConfiguration(this, 'DeploymentConfiguration', {
  deploymentConfigName: 'blue-green-config',
  trafficRoutingConfig: {
    type: "TimeBasedCanary",
    timeBasedCanary: {
      canaryInterval: 5,
      canaryPercentage: 20,
    },
  },
}

const deploymentGroup = new EcsDeploymentGroup(this, 'DeploymentGroup', {
  applicationName: 'blue-green-application',
  deploymentGroupName: 'blue-green-deployment-group',
  deploymentConfiguration,
  //...
});

How do you find that?

kimisme9386 commented 3 years ago

Although DeploymentConfig is directly supported by Cloudformation, but in the Construct EcsDeploymentGroup class which leverage CustomResource to create DeploymentGroup by AWS SDK in Lambda.

For consistency purposes, the PR use AWS SDK to create DeploymentConfig as well. The createDeploymentConfigInput props refer to AWS SDK naming which document is in here. The content of createDeploymentConfigInput props is equal to content of CfnDeploymentConfigProps.

Perhaps the createDeploymentConfigInput naming is not good enough. Do you prefer deploymentConfiguration props naming to createDeploymentConfigInput ? @hupe1980

hupe1980 commented 3 years ago

I only implemented the DeploymentGroup with a custom resource because the ecs bluegreeen usecase is not directly supported by Cloudformation. As far as I know, this does not apply to the DeploymentConfiguration. The DeploymentConfiguration is also an independent object. So why not as a separate construct?

kimisme9386 commented 3 years ago

After chewing on independent object for DeploymentConfiguration, it's better way to decouple dependency. Thank you for your suggestions.

I have pushed some commitments. Please review it, thanks. @hupe1980