https://pulumi.com logo
Title
r

rough-jewelry-40643

05/15/2023, 5:10 PM
Good morning everyone. I've been having trouble setting up an ECS service with CodeDeploy as the deployment controller using Pulumi. The problem arises when I try to run pulumi up. If I include both the taskDefinition and deploymentController in the ECS service definition, Pulumi throws an error saying Unable to update task definition on services with a CODE_DEPLOY deployment controller. Use AWS CodeDeploy to trigger a new deployment. Now, I understand that AWS doesn't allow direct task definition updates for services with CodeDeploy as the deployment controller, but I'm just trying to initially create the service. Here's where it gets even more confusing. If I remove the deploymentController section from my ECS service definition and try to run pulumi up, it still fails with the same error. On the other hand, if I remove both the deploymentController section and the taskDefinition, Pulumi complains that taskDefinition is required for the creation of the ECS service. I'm kind of stuck in a catch-22 situation here. I need to provide a taskDefinition to create the service but I can't include it if I want CodeDeploy to be the deployment controller. Could anyone help me figure out a way to correctly set up my ECS service with CodeDeploy as the deployment controller using Pulumi?
b

billowy-army-68599

05/15/2023, 5:41 PM
do you have code to share?
r

rough-jewelry-40643

05/15/2023, 5:46 PM
Here is the relevant code blocks. They appear one after the other
const service = new aws.ecs.Service("fake-backend-build", {
            cluster: ecsCluster.id,
            // taskDefinition: taskDefinition.arn,
            enableExecuteCommand: true,
            desiredCount: autoscaling_parsed.desired,
            launchType: "FARGATE",
            deploymentController: {
                type: "CODE_DEPLOY",
            },
            networkConfiguration: {
                subnets:[ subnetA, subnetB ],
                assignPublicIp: false,
                securityGroups: [ sg ],
            },
            // waitForSteadyState: true,
            loadBalancers: [{
                targetGroupArn: targetGroupA.arn,
                containerName: "backend-build-container", // Replace with your container name
                containerPort: 80 // Replace with the port your container is listening on
            }],
            tags: {
                "application" : "fake-backend-build",
                "service" : "backend"
            },
        });

        // Create the CodeDeploy Deployment Group with the Load Balancer.
    const deploymentGroup = new aws.codedeploy.DeploymentGroup("fake-backend-build", {
            appName: codedeployApplication.name,
            deploymentConfigName: "CodeDeployDefault.ECSAllAtOnce",
            deploymentGroupName: "fake-backend-build",
            serviceRoleArn: codedeployIamRole.arn, // replace with your actual service role ARN
            
            ////
            autoRollbackConfiguration: {
                enabled: true,
                events: ["DEPLOYMENT_FAILURE"],
            },
            blueGreenDeploymentConfig: {
                deploymentReadyOption: {
                    actionOnTimeout: "CONTINUE_DEPLOYMENT",
                },
                terminateBlueInstancesOnDeploymentSuccess: {
                    action: "TERMINATE",
                    terminationWaitTimeInMinutes: 5,
                },
            },
            deploymentStyle: {
                deploymentOption: "WITH_TRAFFIC_CONTROL",
                deploymentType: "BLUE_GREEN",
            },
            ecsService: {
                serviceName: service.name,
                clusterName: ecsCluster.name,
            },
            loadBalancerInfo: {
                targetGroupPairInfo: {
                    prodTrafficRoute: {
                        listenerArns: [listener.arn],
                    },
                    targetGroups: [
                        {
                            name: targetGroupA.name,
                        },
                        {
                            name: targetGroupB.name,
                        },
                    ],
                },
            },
            tags: {
                "application" : "fake-backend-build",
                "service" : "backend"
            },
        });
Happy to share the full file if needed
b

billowy-army-68599

05/15/2023, 5:52 PM
I have this working, but need to fish out the example 😅
r

rough-jewelry-40643

05/15/2023, 5:53 PM
Amazing, thank you thank you!
b

billowy-army-68599

05/15/2023, 5:56 PM
I’m just getting back from PTO so might be a day or so
r

rough-jewelry-40643

05/15/2023, 5:56 PM
No problem, the help is appriciated!
Thank you
b

breezy-lion-46435

05/15/2023, 6:02 PM
Just booked time for us to connect Wednesday! Thank you Lee and Greg
r

rough-jewelry-40643

05/15/2023, 6:07 PM
You may want to check with Lee. He may have a solution for my problem worked out already. If that's the case, I'm still happy to meet with you but we may not need the tech help
b

breezy-lion-46435

05/15/2023, 6:17 PM
Lee is invited to the call to address! Yes! And yes - we do need to chat about the teams account as well so its perfect timing
b

billowy-army-68599

05/16/2023, 3:21 PM
@rough-jewelry-40643 Unfortunately the code was committed to a customer repo, so I’ll have to rebuild the example. it’ll take a little while longer, I’m afraid
r

rough-jewelry-40643

05/17/2023, 9:21 AM
No worries, again thank you. Can you point me in a direction or a document I can look at to figure this out my self.