Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Failed to parse the task definition file: invalid JSON provided. Fix?

Andrew Duncan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 3, 2020

I can't seem to make the ECS deploy image run properly. Even when using you example code.

Here's the last few lines of the pipeline output. I had DEBUG turned on:

5b3de3e43369: Pull complete6fa0d3662c46: Pull completeDigest: sha256:1aa9f89c0c38960914214a2b71cdd11ebb7d39c0dde4d8f934541453ff1e1555Status: Downloaded newer image for bitbucketpipelines/aws-ecs-deploy:1.0.0INFO: Updating the task definition...DEBUG: Changing event name from creating-client-class.iot-data to creating-client-class.iot-data-planeDEBUG: Changing event name from before-call.apigateway to before-call.api-gatewayDEBUG: Changing event name from request-created.machinelearning.Predict to request-created.machine-learning.PredictDEBUG: Changing event name from before-parameter-build.autoscaling.CreateLaunchConfiguration to before-parameter-build.auto-scaling.CreateLaunchConfigurationDEBUG: Changing event name from before-parameter-build.route53 to before-parameter-build.route-53DEBUG: Changing event name from request-created.cloudsearchdomain.Search to request-created.cloudsearch-domain.SearchDEBUG: Changing event name from docs.*.autoscaling.CreateLaunchConfiguration.complete-section to docs.*.auto-scaling.CreateLaunchConfiguration.complete-sectionDEBUG: Changing event name from before-parameter-build.logs.CreateExportTask to before-parameter-build.cloudwatch-logs.CreateExportTaskDEBUG: Changing event name from docs.*.logs.CreateExportTask.complete-section to docs.*.cloudwatch-logs.CreateExportTask.complete-sectionDEBUG: Changing event name from before-parameter-build.cloudsearchdomain.Search to before-parameter-build.cloudsearch-domain.SearchDEBUG: Changing event name from docs.*.cloudsearchdomain.Search.complete-section to docs.*.cloudsearch-domain.Search.complete-sectionDEBUG: Looking for credentials via: envINFO: Found credentials in environment variables.DEBUG: Loading JSON file: /usr/local/lib/python3.7/site-packages/botocore/data/endpoints.jsonDEBUG: Event choose-service-name: calling handler <function handle_service_name_alias at 0x7f759adc44d0>DEBUG: Loading JSON file: /usr/local/lib/python3.7/site-packages/botocore/data/ecs/2014-11-13/service-2.jsonDEBUG: Event creating-client-class.ecs: calling handler <function add_generate_presigned_url at 0x7f759adfd290>DEBUG: The s3 config key is not a dictionary type, ignoring its value of: NoneDEBUG: Setting ecs timeout as (60, 60)DEBUG: Loading JSON file: /usr/local/lib/python3.7/site-packages/botocore/data/_retry.jsonDEBUG: Registering retry handlers for service: ecs✖ Failed to parse the task definition file: invalid JSON provided.
Here is my task-definition-template.json file:
{
"family": "",
"executionRoleArn": "arn:aws:iam::#########:role/ecsTaskExecutionRole",
"containerDefinitions": [
{
"name": "aft-cms-api",
"image": "${IMAGE_NAME}",
"portMappings": [
{
"hostPort": 80,
"protocol": "tcp",
"containerPort": 80
}
],
"secrets": [
{
"valueFrom": "arn:aws:ssm:us-east-1:#########:parameter/CMS-APP-SECRET-DEV",
"name": "AppSettings__Secret"
},
{
"valueFrom": "arn:aws:ssm:us-east-1:###########:parameter/CMS-DB-CONN-INFO-DEV",
"name": "ConnectionStrings__AFTDataContext"
}
]
}
],
"memory": "512",
"taskRoleArn": "arn:aws:iam::###########:role/ecsTaskExecutionRole",
"compatibilities": [
"EC2",
"FARGATE"
],
"requiresCompatibilities": [
"FARGATE"
],
"networkMode": "awsvpc",
"cpu": "256"

1 answer

0 votes
Andy Huang
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 29, 2020

How are you running envsubst? I was noticed that when I tried to use the docker command for it (which I might have been using incorrectly), it would spit out an empty JSON file. So now I'm using this.

- apk add gettext
- export IMAGE_NAME="asdf"
- envsubst < task-definition-template.json > task-definition.json

 

The first line of my bitbucket-pipelines.yml file is:

image: python:3.7.4-alpine3.10

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events