aws-cloudformation-fargate
aws-cloudformation-fargate copied to clipboard
Template for importing in outputs
Do you have a way to import values from the VPC as stated
VPCId:
Description: The ID of the VPC that this stack is deployed in
Value: !Ref 'VPC'
Export:
Name: !Join [ ':', [ !Ref 'AWS::StackName', 'VPCId' ] ]
How do I import VPC Id from the above export?
You are not importing values from the vpc itself. Instead you are importing things about the vpc. You would have to use the name of the CloudFormation stack and suffix VPCId to it. I have not tried this specifically but it would be something like the following. The name that is being constructed is the CloudFormation stackname and VPCId concatenated and separated by a colon.
Fn::ImportValue:
!Sub "${StackName}:VPCId"
That should return the vpcid.
ok so the ${StackName} is the parameter of the stack? or is it something you have to hard code in?
Sorry, I should have included that. If you are creating a new CloudFormation stack and need it to get that vpcid you would need to pass in the name of the stack that created it as a StackName parameter. Then the statement above would know the name of the exported vpcid value to use.