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

(@aws-cdk/aws-ecs): CreateService error: NetworkConfiguration must be null #16981

Closed
saishandilya opened this issue Oct 14, 2021 · 2 comments
Closed
Assignees
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.

Comments

@saishandilya
Copy link

What is the problem?

Trying to achieve Perform ECS blue/green deployments through CodeDeploy using AWS CloudFormation via CDK.

Reference: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/blue-green.html

Using the above link trying to create the Cloudformation template via CDK, as Cloudformation now supports ECS blue/green deployment.

  1. I am using FARGATE to achieve the above, "FargetService" Construct to create the CDK code for the template and the code is clean during the "cdk synth".
    I am not passing any NetworkConfiguration, but CDK is assuming by itself while creating the template, I had a session with the CDK support team in AWS, even they confirmed that the creation of NetworkConfiguration inside the "ECS Service" by itself during the synth process. When I try to deploy, it is throwing the below error's :

Resource handler returned message: "Invalid request provided: CreateService error: NetworkConfiguration must be null. (Service: AmazonECS; Status Code: 400; Error Code: InvalidParameterException; Request ID: f3d3b359-32f3-4dad-bf56-abd2552af518; Proxy: null)" (RequestToken: 73935952-e726-0020-a399-c6518da2c124, HandlerErrorCode: InvalidRequest)

  1. I have tried another method using cfnService, I am facing another error, I am not passing any value for LaunchType it is taking "EC2" instead of "Fargate" for Fargate Service. When I am passing launchType value as "Fargate" it is throwing the below error:

Resource handler returned message: "Invalid request provided: CreateService error: LaunchType must be blank. (Service: AmazonECS; Status Code: 400; Error Code: InvalidParameterException; Request ID: 0e1f6d38-d0e8-4438-af67-68e0bf5caa48; Proxy: null)" (RequestToken: 3aab09c2-6cfa-3674-8ea0-300d2be1c4e3, HandlerErrorCode: InvalidRequest)

My End goal is to achieve Blue/Green Deployment but unable to achieve it in both cases there are errors, my primary focus is on using the "FargateService" Construct. I need an assist on how to rectify the error and also wanted to know whether it is a potential bug.

Reproduction Steps

Implementation 1 :

const Service = new FargateService(this, "Service", {
  cluster: cluster,
  taskDefinition: taskDefinition,
  healthCheckGracePeriod: cdk.Duration.seconds(10),
  minHealthyPercent: 50,
  maxHealthyPercent: 200,
  // assignPublicIp: false,
  desiredCount: props.desiredContainersCount,
  deploymentController: {
    type: DeploymentControllerType.EXTERNAL
  },
  // vpcSubnets: selection,
  // securityGroup: serviceSG,
});

// enable EnableExecuteCommand for the service
// https://github.com/pahud/ecs-exec-cdk-demo
const cfnService = Service.node.findChild('Service') as CfnService;
cfnService.addPropertyOverride('EnableExecuteCommand', true);

I tried to remove the assignPublicIp,  vpcSubnets, securityGroup and see if that is causing the NetworkConfiguration in the Service but the result is still the same.

Implementation 2 :
const Service = new CfnService(this, 'Service', {
cluster: cluster.clusterName,
desiredCount: 3,
launchType: "FARGATE",
deploymentController: { type: DeploymentControllerType.EXTERNAL },
propagateTags: PropagatedTagSource.SERVICE,
});

Here it is throwing the error for launchType must be blank , if passed nothing it is assuming as EC2.

What did you expect to happen?

Implementation 1:

Expected to create an ECS Service Resource inside CloudFormation without NetworkConfiguration and create an ECS Service on console during deployment, but it is creating the template with NetworkConfiguration inside Service Resource Part and during the deployment of the stack it is throwing error and stack failed.

Implementation 2:

Expected to create an ECS Service on console during deployment with FARGATE Service but instead, it is creating with EC2 when the launchType property is not passed, but if passed as FARGATE in CDK it is throwing the error.

What actually happened?

Implementation 1 Error :
Resource handler returned message: "Invalid request provided: CreateService error: NetworkConfiguration must be null. (Service: AmazonECS; Status Code: 400; Error Code: InvalidParameterException; Request ID: f3d3b359-32f3-4dad-bf56-abd2552af518; Proxy: null)" (RequestToken: 73935952-e726-0020-a399-c6518da2c124, HandlerErrorCode: InvalidRequest)

Implementation 2 Error:
Resource handler returned message: "Invalid request provided: CreateService error: LaunchType must be blank. (Service: AmazonECS; Status Code: 400; Error Code: InvalidParameterException; Request ID: 0e1f6d38-d0e8-4438-af67-68e0bf5caa48; Proxy: null)" (RequestToken: 3aab09c2-6cfa-3674-8ea0-300d2be1c4e3, HandlerErrorCode: InvalidRequest)

CDK CLI Version

1.127.0

Framework Version

No response

Node.js Version

v16.8.0

OS

Linux

Language

Typescript

Language Version

4.4.3

Other information

No response

@saishandilya saishandilya added bug This issue is a bug. needs-triage This issue or PR still needs to be triaged. labels Oct 14, 2021
@github-actions github-actions bot added the @aws-cdk/aws-ecs Related to Amazon Elastic Container label Oct 14, 2021
@peterwoodworth
Copy link
Contributor

Hey @saishandilya,

ECS blue/green deployments provided by CloudFormation are pretty limited. Please see #1559 for more information and help on this topic. I encourage you to post your experience in that thread :)

@github-actions
Copy link

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ecs Related to Amazon Elastic Container bug This issue is a bug. needs-triage This issue or PR still needs to be triaged.
Projects
None yet
Development

No branches or pull requests

3 participants