英文:
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: "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:
-
Fn::ImportValue: "Deploy1-VPC"
<!-- 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 "${AWS::StackName}-VPC"
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.
答案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: "Deploy1-VPC"
Instead you should do:
VpcId:
Fn::ImportValue: "Deploy1-VPC"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论