Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codedeploy: cannot configure blue/green deployment for ServerDeploymentGroup #30555

Open
daTobiGit opened this issue Jun 14, 2024 · 6 comments
Open
Labels
@aws-cdk/aws-codedeploy Related to AWS CodeDeploy effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p3

Comments

@daTobiGit
Copy link

Describe the bug

There are no options in CDK to set the deployment type from inplace to blue/green deployment. On the console, you can easily switch

Expected Behavior

i expected some configuration options in the class ServerDeploymentGroup, but there are none.

Current Behavior

only inplace deployments are possible

Reproduction Steps

this is all that can be configured:

`const vpc = new Vpc(this, "connect4-vpc-ec2", {
vpcName: "connect4-vpc-ec2",
maxAzs: 2,
subnetConfiguration: [
{
cidrMask: 24,
name: 'ingress',
subnetType: SubnetType.PUBLIC,
}]
})

    const asgC4Backend = new AutoScalingGroup(this, "asg", {
        vpc,
        instanceType: InstanceType.of(InstanceClass.BURSTABLE2, InstanceSize.MICRO),
        machineImage: MachineImage.latestAmazonLinux2023(),
        desiredCapacity: 2,
        minCapacity: 1,
        maxCapacity: 3
    })
    Tags.of(asgC4Backend).add("id", "backend-server")
    asgC4Backend.role.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName('AdministratorAccess'))

    const nlb = new NetworkLoadBalancer(this, 'C4-NLB', {
        vpc,
        internetFacing: true,
    });

    const listener = nlb.addListener('Listener', {
        port: 8001,
    });

    // Add the Auto Scaling Group as a target
    const nlbTargetGroup = listener.addTargets('Targets', {
        port: 8001,
        targets: [asgC4Backend],
    });

    const serverApplication = new ServerApplication(this, "serverApplication", {
        applicationName: "connect4-server-application-ec2"
    })

    const deploymentGroup = new ServerDeploymentGroup(this, 'deploymentGroupC4Backend', {
        application: serverApplication,
        deploymentGroupName: 'deploymentGroupC4Backend',
        autoScalingGroups: [asgC4Backend],
        installAgent: true,
        deploymentConfig: ServerDeploymentConfig.ALL_AT_ONCE,
        loadBalancers: [
            LoadBalancer.network(nlbTargetGroup),
        ],
        // auto-rollback configuration
        autoRollback: {
            failedDeployment: true, // default: true
        },
    });
    deploymentGroup.role?.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName('AdministratorAccess'))`

Possible Solution

include configuration options for blue/green deployment to the ServerDeploymentGroup

Additional Information/Context

No response

CDK CLI Version

2.144.0 (build 5fb15bc)

Framework Version

No response

Node.js Version

v20.13.1

OS

amazon linux 2023

Language

TypeScript

Language Version

Typescript (5.4.5)

Other information

No response

@daTobiGit daTobiGit added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Jun 14, 2024
@github-actions github-actions bot added the @aws-cdk/aws-codedeploy Related to AWS CodeDeploy label Jun 14, 2024
@daTobiGit
Copy link
Author

daTobiGit commented Jun 14, 2024

it seems the aws cli does support those parameters:

aws deploy create-deployment-group
--application-name MyCodeDeployApp
--deployment-group-name MyDeploymentGroup
--deployment-config-name CodeDeployDefault.AllAtOnce
--auto-scaling-groups MyAutoScalingGroup
--service-role-arn arn:aws:iam::123456789012:role/CodeDeployRole
--deployment-style deploymentType=BLUE_GREEN,deploymentOption=WITH_TRAFFIC_CONTROL
--blue-green-deployment-configuration file://blue-green-deployment-config.json
--load-balancer-info elbInfoList=[{name=MyLoadBalancer}]

@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Jun 14, 2024
@khushail khushail self-assigned this Jun 14, 2024
@khushail
Copy link
Contributor

Hi @daTobiGit , thanks for reaching out.

I see that cloudformation supports this blue/green deployment , can be seen here in L1 Construct -

https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_codedeploy.CfnDeploymentGroup.html#bluegreendeploymentconfiguration

Is this what you are looking for ??

@khushail khushail added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. feature-request A feature should be added or improved. and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. bug This issue is a bug. labels Jun 14, 2024
Copy link

This issue has not received a response in a while. If you want to keep this issue open, please leave a comment below and auto-close will be canceled.

@github-actions github-actions bot added the closing-soon This issue will automatically close in 4 days unless further comments are made. label Jun 16, 2024
@daTobiGit
Copy link
Author

daTobiGit commented Jun 17, 2024

Hi @khushail , thank you for your response.

i already tried it out with the cfn class, but unfortunately it also doesnt work

   `// const roleC4DeploymentApp = new Role(this, "roleC4DeploymentApp", {
    //     assumedBy: new ServicePrincipal('codedeploy.amazonaws.com'),
    //     managedPolicies: [
    //         ManagedPolicy.fromAwsManagedPolicyName('AdministratorAccess'),
    //     ],
    // });
    // const serverApplication2 = new ServerApplication(this, "serverApplicationEC2Deploy", {
    //     applicationName: "c4ec2deploymentApp"
    // })
    // const dg2 = new CfnDeploymentGroup( this, "dg2",{
    //     applicationName: serverApplication2.applicationName,
    //     deploymentGroupName: 'C4BackendDeployment',
    //     // deploymentConfigName: 'deploymentConfigName',
    //     serviceRoleArn: roleC4DeploymentApp.roleArn,

    //     autoRollbackConfiguration: {
    //         enabled: true,
    //         events: ['DEPLOYMENT_FAILURE'],
    //     },
    //     autoScalingGroups: [asgC4Backend.autoScalingGroupName],
    //     blueGreenDeploymentConfiguration: {
    //         deploymentReadyOption: {
    //             actionOnTimeout: 'CONTINUE_DEPLOYMENT',
    //             waitTimeInMinutes: 0, // Immediate switch
    //         },
    //         greenFleetProvisioningOption: {
    //             action: 'COPY_AUTO_SCALING_GROUP',
    //         },
    //         terminateBlueInstancesOnDeploymentSuccess: {
    //             action: 'TERMINATE',
    //             terminationWaitTimeInMinutes: 1,
    //         },
    //     },
        
    //     // loadBalancerInfo: {
    //     //     targetGroupPairInfoList: [{
    //     //         targetGroups: [{ name: nlbTargetGroup.targetGroupName }],
    //     //         prodTrafficRoute: {
    //     //             listenerArns: [listener.listenerArn],
    //     //         },
    //     //         testTrafficRoute: {
    //     //             listenerArns: [listener.listenerArn],
    //     //         },
    //     //     }],
    //     // },

    //     deploymentStyle: {
    //         deploymentOption: 'WITH_TRAFFIC_CONTROL',
    //         deploymentType: 'BLUE_GREEN',
    //     }
    // })
    // const deploymentGroup2 = ServerDeploymentGroup.fromServerDeploymentGroupAttributes( this, 'ExistingCodeDeployDeploymentGroup', {
    //     application : serverApplication2,
    //     deploymentGroupName: dg2.ref,
    // });`

when i configure the "deploymentStyle" attribute, i must not specify the AutoScalingGroups , LoadBalancerInfo , or Deployment properties. But CDK says: "one ASG has to be configured". This problem seems to be known: aws repost

@github-actions github-actions bot removed closing-soon This issue will automatically close in 4 days unless further comments are made. response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. labels Jun 17, 2024
@khushail
Copy link
Contributor

khushail commented Jun 17, 2024

My Bad, thanks for sharing the article. I see the CDK Docs also mention about this -

Amazon ECS blue/green deployments through CodeDeploy do not use the AWS::CodeDeploy::DeploymentGroup resource. To perform Amazon ECS blue/green deployments, use the AWS::CodeDeploy::BlueGreen hook. See [Perform Amazon ECS blue/green deployments through CodeDeploy using AWS CloudFormation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/blue-green.html) for more information.

In that case, you could file a FR with Cloudformation team ,by adding this on their Cloudformation coverage roadmap. .

let me know if you need any other help! Thanks!

@khushail khushail added needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p3 effort/medium Medium work item – several days of effort effort/large Large work item – several weeks of effort and removed effort/medium Medium work item – several days of effort labels Jun 17, 2024
@khushail khushail removed their assignment Jun 17, 2024
@daTobiGit
Copy link
Author

aws-cloudformation/cloudformation-coverage-roadmap#2071

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-codedeploy Related to AWS CodeDeploy effort/large Large work item – several weeks of effort feature-request A feature should be added or improved. needs-cfn This issue is waiting on changes to CloudFormation before it can be addressed. p3
Projects
None yet
Development

No branches or pull requests

2 participants