AWS CodeDeploy: STRING_VALUE can not be converted to an Integer

Viewed 212

Using AWS CodePipeline and setting a Source, Build and passing taskdef.json and appspec.yaml as artifacts, the deployment action Amazon ECS (Blue/Green) will fail with the error:

STRING_VALUE can not be converted to an Integer

This error does not specify where this error happens and therefore it is not possible to fix.

For reference, the files look like this:

# appspec.yaml
version: 0.0
Resources:
  - TargetService:
      Type: AWS::ECS::Service
      Properties:
        TaskDefinition: <TASK_DEFINITION>
        LoadBalancerInfo:
          ContainerName: "my-project"
          ContainerPort: 3000
// taskdef.json
{
  "family": "my-project-web",
  "taskRoleArn": "arn:aws:iam::1234567890:role/ecsTaskRole-role",
  "executionRoleArn": "arn:aws:iam::1234567890:role/ecsTaskExecutionRole-web",
  "networkMode": "awsvpc",
  "cpu": "256",
  "memory": "512",
  "containerDefinitions":
  [
    {
       "name": "my-project",
       "memory": "512",
       "image": "01234567890.dkr.ecr.us-east-1.amazonaws.com/my-project:a09b7d81",
       "environment": [],
       "secrets":
       [
         {
           "name": "APP_ENV",
           "valueFrom": "arn:aws:secretsmanager:us-east-1:1234567890:secret:web/my-project-NBcsLj:APP_ENV::"
         },
         {
            "name": "PORT",
            "valueFrom": "arn:aws:secretsmanager:us-east-1:1234567890:secret:web/my-project-NBcsLj:PORT::"
         },
         {
           "name": "APP_NAME",
           "valueFrom": "arn:aws:secretsmanager:us-east-1:1234567890:secret:web/my-project-NBcsLj:APP_NAME::"
         },
         {
           "name": "LOG_CHANNEL",
           "valueFrom": "arn:aws:secretsmanager:us-east-1:1234567890:secret:web/my-project-NBcsLj:LOG_CHANNEL::"
         },
         {
           "name": "APP_KEY",
           "valueFrom": "arn:aws:secretsmanager:us-east-1:1234567890:secret:web/my-project-NBcsLj:APP_KEY::"
         },
         { 
           "name": "APP_DEBUG",
           "valueFrom": "arn:aws:secretsmanager:us-east-1:1234567890:secret:web/my-project-NBcsLj:APP_DEBUG::"
         }
       ],
       "essential": true,
       "logConfiguration":
       {
         "logDriver": "awslogs",
         "options":
         {
           "awslogs-group": "",
           "awslogs-region": "",
           "awslogs-stream-prefix": ""
         }
       },
       "portMappings":
       [
         {
           "hostPort": 3000,
           "protocol": "tcp",
           "containerPort": 3000
         }
       ],
       "entryPoint": [ "web" ], 
       "command": []
     }
   ],
   "requiresCompatibilities": [ "FARGATE", "EC2" ],
   "tags":
   [
     {
       "key": "project",
       "value": "my-project"
     }
   ]
}

Any insights on this issue are highly appreciated!

1 Answers

Please refer to the following guide that outlines the supported data type for each parameter: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html. It appears that you've provided a string where an integer is expected.

If I was to guess, looking at the above, the value for memory under containerDefinitions should be an integer not a string: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_memory

Related