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).
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"
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.
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"