Open benwaine opened 5 years ago
Hi @benwaine your alerting stack seems to be named sn-alerting-Alerting-1VKQQLE2KMQ26
not sn-alerting
. You can create a normal (not nested) CloudFormation stack based on cfn-modules/alerting, name it sn-alerting
and your idea should work.
Let me know if this works for you.
We reuse modules like this by creating exports. For example, this AlertingModule
is shared by all of our (dedicated-to-client) environments for our APEX application:
Resources:
AlertingModule:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
Email: 'team@org.com' # optional
HttpEndpoint: 'http://org.com/webhook' # optional
HttpsEndpoint: 'https://org.com/webhook' # optional
FallbackEmail: 'user@org.net' # optional
TemplateURL: './node_modules/@cfn-modules/alerting/module.yml'
Outputs:
AlertingModule:
Description: 'The stack name of the alerting module.'
Value: !GetAtt 'AlertingModule.Outputs.StackName'
Export:
Name: 'APEX-AlertingModule'
This lets us import the template elsewhere without having any relation between the two files:
AlbModule:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
AlertingModule: !ImportValue 'APEX-AlertingModule'
VpcModule: !GetAtt 'VpcModule.Outputs.StackName'
Scheme: 'internal'
TemplateURL: './node_modules/@cfn-modules/alb/module.yml'
Outputs:
EnvironmentAlbModule:
Description: 'Environment ALB module.'
Value: !GetAtt 'AlbModule.Outputs.StackName'
Export:
Name: !Sub 'APEX-${Environment}-AlbModule'
This example also exports the ALB in a narrower namespace since it's specific to a single client. When we want to build on that client's ALB, you need to use a slightly more verbose import...
NlbAlbForward443:
Type: 'AWS::CloudFormation::Stack'
Properties:
Parameters:
VpcModule: {'Fn::ImportValue': !Sub 'APEX-${Environment}-VpcModule'}
AlbModule: {'Fn::ImportValue': !Sub 'APEX-${Environment}-AlbModule'}
NlbModule: !GetAtt 'NlbModule.Outputs.StackName'
KmsKeyModule: {'Fn::ImportValue': !Sub 'APEX-${Environment}-KmsKeyModule'}
Port: '443'
TemplateURL: './apex-env-network-port.yaml'
As you can see, the VPC is also client-specific. The NLB is defined inline (in this same file). This particular template implements the lambda-based forwarding logic from an AWS Blog post.
These lines above from the VPC module README seem to imply that it's possible to create multiple stacks and feed the exports of one stack into the another.
I'm trying to do this with the idea that my vpc and alerting stacks will be referenced from multiple applications stacks.
After successfully creating the vpc and alerting stacks following the instructions in these docs, I attempt to create an application stack like so:
I get the following error when creating the application stack:
Looking at the alerting stack, there are no exports.
Looking at the nested stack created by my alerting stack I see exports including the expected ARN.
Is the design pattern I'm attempting possible? Have I missed something in terms of how to identify the stack in "child stacks"?