VPC Standalone Usage

Hi,

Referring to this on the vpc module:

Once the stack is created, you can use the stack name (in this case vpc ) as the value for the VpcModule parameter in other cfn-modules .

When referring to the created VPC in a separate stack to create fargate services I am faced with an error:

Embedded stack arn:aws:cloudformation:eu-west-2:203623385273:stack/anprstream-apps-Service-KWK53IZHDXBA/d5ef85e0-8acb-11ea-a9af-02317fefc7aa was not successfully created: No export named anprstream-vpc-SubnetIdsPrivate found

Sure enough when I check the vpc stack there are no exports listed (however the underlying template does set the outputs/exports:

SubnetIdsPrivate:
Value: !If
- HasAvailabilityZoneC
- !Sub ‘{SubnetAPrivate.Outputs.Id},{SubnetBPrivate.Outputs.Id},{SubnetCPrivate.Outputs.Id}' - !Sub '{SubnetAPrivate.Outputs.Id},{SubnetBPrivate.Outputs.Id}' Export: Name: !Sub '{AWS::StackName}-SubnetIdsPrivate’

Do these need to be somehow redeclared in my own template yaml file?

Many thanks

Hi Nick,

can you post a screenshot of the outputs of stack anprstream-vpc ?

Thanks
Michael

Hi,

I defined all of the ones you see on this page to get it working. Before I did this the page was empty.

But the export column is empty.

Can you share the template that you use? It looks like that you wrap the vpc module inside another template? If you don’t want to duplicate all the outputs you could deploy ./node_modules/@cfn-modules/vpc/module.yml (path is out of my head, please double check :)) directly?


AWSTemplateFormatVersion: ‘2010-09-09’
Resources:
Vpc:
Type: AWS::CloudFormation::Stack
Properties:
Parameters:
NumberOfAvailabilityZones: 2
S3Endpoint: ‘false’
DynamoDBEndpoint: ‘false’
FlowLog: ‘false’
NatGateways: ‘false’
TemplateURL: ‘./node_modules/@cfn-modules/vpc/module.yml’
Outputs:
StackRef:
Value: !Ref Vpc
SubnetIdAPublic:
Value: !GetAtt Vpc.Outputs.SubnetIdAPublic
SubnetIdBPublic:
Value: !GetAtt Vpc.Outputs.SubnetIdBPublic
SubnetIdAPrivate:
Value: !GetAtt Vpc.Outputs.SubnetIdAPrivate
SubnetIdBPrivate:
Value: !GetAtt Vpc.Outputs.SubnetIdBPrivate
Id:
Value: !GetAtt Vpc.Outputs.Id
Export:
Name: !Sub ‘{AWS::StackName}-Id' StackName: Value: !GetAtt Vpc.Outputs.StackName Export: Name: !Sub '{AWS::StackName}’

If you replace your template with ./node_modules/@cfn-modules/vpc/module.yml you should be fine.

If you want to keep your template make sure the duplicate the Outputs including the Export section

Ah ok - that explains it. I didn’t realise I would need to duplicate the exports.
Thanks for clarifying!

I see. You are welcome!