【问题标题】:AWS CodeDeploy: STRING_VALUE can not be converted to an IntegerAWS CodeDeploy:STRING_VALUE 无法转换为整数
【发布时间】:2022-01-31 09:33:41
【问题描述】:

使用 AWS CodePipeline 并设置源、构建并将 taskdef.jsonappspec.yaml 作为工件传递,部署操作 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"
     }
   ]
}

非常感谢您对此问题的任何见解!

【问题讨论】:

    标签: amazon-web-services amazon-ecs aws-codepipeline aws-codebuild aws-code-deploy


    【解决方案1】:

    请参阅以下指南,其中概述了每个参数支持的数据类型:https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html。您似乎提供了一个字符串,其中需要一个整数。

    如果我猜的话,看看上面,containerDefinitions 下的memory 的值应该是整数而不是字符串:https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task_definition_parameters.html#container_definition_memory

    【讨论】:

    • 感谢@norman 指出!有趣的是,AWS 在同一文件之外的另一个部分中将相同的内存设置为字符串,这误导了我。继续摇摆!
    • 不客气!
    猜你喜欢
    • 1970-01-01
    • 2014-04-13
    • 2018-10-19
    • 2016-05-02
    • 2011-03-19
    • 2012-03-03
    • 2019-11-25
    • 2011-08-30
    相关资源
    最近更新 更多