Why am I getting VpcId: expected type: String, found: JSONArray error with my CloudFormation Template?

huangapple go评论79阅读模式
英文:

Why am I getting VpcId: expected type: String, found: JSONArray error with my CloudFormation Template?

问题

I am using this exact logic all over the place in my cloud formation template but for some reason the VPC ID does not want to work.

以下是我在我的云形成模板中一直在使用的确切逻辑,但出于某种原因,VPC ID 无法正常工作。

Here is what I currently have for the export in the Deploy1 script.

以下是我当前在 Deploy1 脚本中用于导出的内容。

Finally this is what my output looks like inside of cloudformation. I cannot see any reason why this would result in a JSON object versus a string.

最后,这是我在云形成中的输出看起来像什么。我看不出为什么这会导致 JSON 对象而不是字符串。

英文:

I am using this exact logic all over the place in my cloud formation template but for some reason the VPC ID does not want to work.

Below is a snippet of where I am using the VPC import (where the error hits).

<!-- begin snippet: js hide: false console: true babel: false -->

<!-- language: lang-js -->

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

<!-- end snippet -->

Here is what I currently have for the export in the Deploy1 script.

Outputs:
    # VPC
    VPC:
        Value: !Ref EC2VPC
        Condition: CreateDevResources
        Export:
            Name: !Sub &quot;${AWS::StackName}-VPC&quot;

Finally this is what my output looks like inside of cloudformation. I cannot see any reason why this would result in a JSON object versus a string.

Why am I getting VpcId: expected type: String, found: JSONArray error with my CloudFormation Template?

答案1

得分: 1

这是因为您在这里将VpcId传递为一个数组:

            VpcId:  
              -  
                Fn::ImportValue: "Deploy1-VPC"

而您应该这样做:

            VpcId:  
                Fn::ImportValue: "Deploy1-VPC"
英文:

This is because you are passing VpcId as an array here:

            VpcId:  
              -  
                Fn::ImportValue: &quot;Deploy1-VPC&quot;

Instead you should do:

            VpcId:  
                Fn::ImportValue: &quot;Deploy1-VPC&quot;

huangapple
  • 本文由 发表于 2023年6月26日 20:52:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76556875.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定