1

我找不到如何通过CloudFormation一个WAF与ALB相关联的任何实例或文档。据说其可能受此消息公布https://aws.amazon.com/about-aws/whats-new/2017/05/cloudformation-support-for-aws-waf-on-alb/去,但没有什么我发现了如何。使用CloudFront的代替ALB是有据可查的,但我还没有找到关于使用ALB(经由CloudFormation)的单个实例。如何AWS WAF添加到ALB通过CloudFormation

更新: 我不需要一个完整的示例,它所做的全部设置为我但至少指出WAF怎么会知道与ALB,反之亦然相关联的一个片段。链接是缺少的。

回答

4

为了解决这个问题我通过自己的版本历史浏览和发现被更新,以支持WAF & ALB http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/ReleaseHistory.html 从那里,我能够推导出联结部件是映射WAF和ALB一个WebACLAssociation的CloudFormation资源。但是,这也要求,而不是一个正常的WebACL必须使用WAFRegional。到目前为止,它似乎只意味着改变:: WAF为:: WAFRegional整个代码。

WAFRegional(AWS :: WAFRegional :: WebACL): http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafregional-webacl.html

"MyWebACL": { 
    "Type": "AWS::WAFRegional::WebACL", 
    "Properties": { 
    "Name": "WebACL to with three rules", 
    "DefaultAction": { 
     "Type": "ALLOW" 
    }, 
    "MetricName" : "MyWebACL", 
    "Rules": [ 
     { 
     "Action" : { 
      "Type" : "BLOCK" 
     }, 
     "Priority" : 1, 
     "RuleId" : { "Ref" : "MyRule" } 
     }, 
     { 
     "Action" : { 
      "Type" : "BLOCK" 
     }, 
     "Priority" : 2, 
     "RuleId" : { "Ref" : "BadReferersRule" } 
     }, 
     { 
     "Action" : { 
      "Type" : "BLOCK" 
     }, 
     "Priority" : 3, 
     "RuleId" : { "Ref" : "SqlInjRule" } 
     } 
    ] 
    }  
} 

WebACLAssociation(AWS :: WAFRegional :: WebACLAssociation)http://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-wafregional-webaclassociation.html

"MyWebACLAssociation": { 
    "Type": "AWS::WAFRegional::WebACLAssociation", 
    "Properties": { 
    "ResourceArn": { "Ref": "MyLoadBalancer" }, 
    "WebACLId": { "Ref": "MyWebACL" } 
    } 
}