使用AWS re:Post即您表示您同意 AWS re:Post 使用条款

AWS CodeDeploy:STRING_VALUE can not be converted to an Integer

0

【以下的问题经过翻译处理】 使用AWS CodePipeline , 设置好Source、Build 并将taskdef.jsonappspec.yaml传给 CodePipeline,部署操作Amazon ECS (Blue/Green)将失败并显示以下错误:

STRING_VALUE can not be converted to an Integer

这个报错未指定出现错误的位置,因此很难定位问题。

这里是两个文件的参考内容:

# 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"
     }
   ]
}

有什么思路可以定位问题吗?

1 回答
0

【以下的回答经过翻译处理】 在“root level”上,CPU和memory应该是字符串,而您已经正确地处理了这一点。问题在于查看ECS容器定义时,容器部分的内存应该是一个整数。

       "name": "my-project",
       "memory": "512", << 应该是 "memory": 512
       "image": "01234567890.dkr.ecr.us-east-1.amazonaws.com/my-project:a09b7d81",

profile picture
专家
已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则