Good morning everyone. I've been having trouble se...
# aws
r
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
do you have code to share?
r
Here is the relevant code blocks. They appear one after the other
Copy code
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
I have this working, but need to fish out the example 😅
r
Amazing, thank you thank you!
b
I’m just getting back from PTO so might be a day or so
r
No problem, the help is appriciated!
Thank you
b
Just booked time for us to connect Wednesday! Thank you Lee and Greg
r
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
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
@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
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.
163 Views