首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CDK得到WAF的webACLId

CDK得到WAF的webACLId
EN

Stack Overflow用户
提问于 2022-06-20 07:54:26
回答 1查看 305关注 0票数 0

如何获得WAF的webACLId

我正在尝试用WAF创建Cloudfront发行版。

我试图创建自定义资源来获取它,但是没有运气。

代码语言:javascript
复制
new cr.AwsCustomResource(this, 'GetParameter', {
            onUpdate: { // will also be called for a CREATE event
            service: 'WAF',
            action: 'ListWebACLs',
            // parameters: {
            //     Limit: 10,
            //     NextMarker: 'cloudfrontwebacl'
            // },
            physicalResourceId: cr.PhysicalResourceId.of('Date.now().toString()'), 
            },
            policy: cr.AwsCustomResourcePolicy.fromSdkCalls({
            resources: cr.AwsCustomResourcePolicy.ANY_RESOURCE,
            }),
        });
EN

回答 1

Stack Overflow用户

发布于 2022-06-21 07:52:29

哦哦。应该使用Ref提取webACLId

示例:

代码语言:javascript
复制
//  Create WAF Rule
const rule = new CfnRule(this,'rule',{
  metricName:'rule',
  name:'rule',
  predicates:[
    ...
  ]
})
...
//  Create WAF WebACL
const CloudfrontWebACL = new CfnWebACL(this, "cloudfrontwebacl", {
    name: "cloudfrontwebacl",
    defaultAction: { type: 'ALLOW' },
    metricName: 'cloudfrontwebacl',
    rules:[
      {
        priority: 0,
        ruleId: rule.ref,
        action:{
          type: 'BLOCK',
        }
      }
    ]
})
...
//  Create Cloudfront distribution for web
...
webAclId: CloudfrontWebACL.ref,
...

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-waf-webacl.html#aws-resource-waf-webacl-return-values

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/intrinsic-function-reference-ref.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72683835

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档