You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CloudFormation模板报错:VpcId应为String却得到JSONArray,求解决

CloudFormation TargetGroup VpcId 配置错误修复

问题出在VpcId的配置语法上,你用了列表符号-,导致传入的是JSON数组,但AWS::ElasticLoadBalancingV2::TargetGroup的VpcId参数要求是字符串类型的VPC ID,这就是报错的核心原因。

修正后的代码片段:

DevTG:
        Type: "AWS::ElasticLoadBalancingV2::TargetGroup"
        Condition: CreateDevResources
        Properties:
            HealthCheckIntervalSeconds: 30
            HealthCheckPath: "/api/healthcheck"
            Port: 80
            Protocol: "HTTP"
            HealthCheckPort: "traffic-port"
            HealthCheckProtocol: "HTTP"
            HealthCheckTimeoutSeconds: 5
            UnhealthyThresholdCount: 2
            TargetType: "ip"
            Matcher: 
                HttpCode: "200,302"
            HealthyThresholdCount: 5
            VpcId: !ImportValue "Deploy1-VPC"

你的Deploy1导出配置是正确的,!Ref EC2VPC返回的是字符串类型的VPC ID,只需要在导入时去掉多余的列表语法,直接使用!ImportValue即可。

内容的提问来源于stack exchange,提问作者user68288

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.17 19:52:02