Search code examples
amazon-web-servicesamazon-ecs

AWS ecs create-service "Invalid JSON received" error even with file:// syntax


I'm trying to create a service using the AWS CLI from JSON, but I keep getting Invalid JSON received even with the file:// syntax. I generated the skeleton for the JSON with --generate-cli-skeleton.

aws ecs create-service --cli-input-json file://test-app.json

test-app.json is in the current working directory. Here is the content:

{
  "cluster": "wf-development",
  "serviceName": "test-app-2",
  "taskDefinition": "xxxxxxxxx",
  "loadBalancers": [
    {
      "targetGroupArn": "xxxxxxxxx",
      "containerName": "test-app",
      "containerPort": 80
    }
  ],
  "serviceRegistries": [],
  "desiredCount": 1,
  "launchType": "EC2",
  "role": "AWSServiceRoleForECS",
  "deploymentConfiguration": {
    "maximumPercent": 200,
    "minimumHealthyPercent": 100
  },
  "placementConstraints": [],
  "placementStrategy": [],
  "healthCheckGracePeriodSeconds": 10,
  "schedulingStrategy": "REPLICA",
  "enableECSManagedTags": true,
  "propagateTags": "NONE",
  "enableExecuteCommand": true
}

I'm new to AWS and just figuring this out, but I did this yesterday on a different PC and it worked just fine.

Edit: I'm using Windows and Powershell.


Solution

  • Okay, very strange. I just copied the contents of my JSON file into a new file without changing anything and it works now.