Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template for importing in outputs #17

Open
mosesliao opened this issue Apr 24, 2020 · 3 comments
Open

Template for importing in outputs #17

mosesliao opened this issue Apr 24, 2020 · 3 comments

Comments

@mosesliao
Copy link

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?

@dougtoppin
Copy link

dougtoppin commented Apr 24, 2020

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.

@mosesliao
Copy link
Author

ok so the ${StackName} is the parameter of the stack? or is it something you have to hard code in?

@dougtoppin
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants