【发布时间】:2021-08-28 22:19:35
【问题描述】:
我使用 CfnInclude 将 cloudformation 模板导入我的 cdk 代码:
template= _cfn_include.CfnInclude(self,
'template',
template_file = "aws-waf-security-automations.yaml")
之后我使用 get_resource() 从这个模板中获取资源之一:
waf = template.get_resource("WebACLStack")
问题在于该资源不是 WafWebACL 类型,而是 CfnStack 类型。在模板中,这个资源是这样描述的:
WebACLStack:
Type: 'AWS::CloudFormation::Stack'
DependsOn: CheckRequirements
Properties:
TemplateURL: !Sub
- 'https://${S3Bucket}.s3.amazonaws.com/${KeyPrefix}/aws-waf-security-automations-webacl.template'
-
S3Bucket: !FindInMap ["SourceCode", "General", "TemplateBucket"]
KeyPrefix: !FindInMap ["SourceCode", "General", "KeyPrefix"]
Parameters:
ActivateAWSManagedRulesParam: !Ref ActivateAWSManagedRulesParam ...
如何从 CfnStack 中获取 WAFWebACL? 据我了解,WAFWebACL 是 CfnStack 内的嵌套堆栈。
Obs.:我从这个 url 得到这个模板:https://docs.aws.amazon.com/solutions/latest/aws-waf-security-automations/template.html
Obs2:模板输出如下:
WAFWebACL:
Description: AWS WAF WebACL
Value: !GetAtt WebACLStack.Outputs.WAFWebACL
那么我可以从输入中获取 WAFWebACL 资源吗?
【问题讨论】:
标签: amazon-web-services amazon-cloudformation aws-cdk