AWS WAF 创建ACL和规则只允许访问一个国家访问API网关
AWS WAF Create an ACL and rule to allow access to only one country to access the API gateway
我想创建一个json格式的云形成模板,在WAF中创建一个ACL和规则,只允许美国用户访问API网关。到目前为止,我有以下代码,但它在 AWS 中给出了一个错误 ("Encountered unsupported property Action"):
"Type":"AWS::WAF::Rule",
"Properties":{
"Name":"APIGeoBlockRule",
"Priority":0,
"Action":{
"Block":{}
},
"VisibilityConfig":{
"SampledRequestsEnabled":true,
"CloudWatchMetricsEnabled":true,
"MetricName": "APIGeoBlockRule"
},
"Statement":{
"NotStatement":{
"Statement":{
"GeoMatchStatement":{
"CountryCodes":[
"US"
]
}
}
}
}
}
}
看了文档后,您正在尝试在经典 WAF 资源下执行 WAFv2 规则。您的资源类型AWS::WAF::Rule
是经典的WAF规则,而结构是WAFv2。
我自己还没有使用过 WAFv2,但看看 documentation,这应该是关于你想要的 yaml 格式的:
Description: Create WebACL example
Resources:
ExampleWebACL:
Type: AWS::WAFv2::WebACL
Properties:
Name: ExampleWebACL
Scope: REGIONAL
Description: This is an example WebACL
DefaultAction:
Allow: {}
Rules:
- Name: GeoRestrictExample
Priority: 0
Action:
Block: {}
Statement:
NotStatement:
Statement:
GeoMatchStatement:
CountryCodes:
- US
自 2020 年 1 月 13 日起,您无法使用 cloudformation 将 api 网关阶段等资源与 WAFv2 ACL 相关联。您可以使用控制台、SDK、自定义资源和 cli.
当 Cloudformation 实施 WAFv2(他们现在建议您使用)时,问题将得到解决。最终,我们需要 Cloudformation 来支持创建和关联(即到 API 网关或负载均衡器),以便其他变通办法不会到位,因为它们不是很容易转移。
GitHub 票是:https://github.com/aws-cloudformation/aws-cloudformation-coverage-roadmap/issues/344
我想创建一个json格式的云形成模板,在WAF中创建一个ACL和规则,只允许美国用户访问API网关。到目前为止,我有以下代码,但它在 AWS 中给出了一个错误 ("Encountered unsupported property Action"):
"Type":"AWS::WAF::Rule",
"Properties":{
"Name":"APIGeoBlockRule",
"Priority":0,
"Action":{
"Block":{}
},
"VisibilityConfig":{
"SampledRequestsEnabled":true,
"CloudWatchMetricsEnabled":true,
"MetricName": "APIGeoBlockRule"
},
"Statement":{
"NotStatement":{
"Statement":{
"GeoMatchStatement":{
"CountryCodes":[
"US"
]
}
}
}
}
}
}
看了文档后,您正在尝试在经典 WAF 资源下执行 WAFv2 规则。您的资源类型AWS::WAF::Rule
是经典的WAF规则,而结构是WAFv2。
我自己还没有使用过 WAFv2,但看看 documentation,这应该是关于你想要的 yaml 格式的:
Description: Create WebACL example
Resources:
ExampleWebACL:
Type: AWS::WAFv2::WebACL
Properties:
Name: ExampleWebACL
Scope: REGIONAL
Description: This is an example WebACL
DefaultAction:
Allow: {}
Rules:
- Name: GeoRestrictExample
Priority: 0
Action:
Block: {}
Statement:
NotStatement:
Statement:
GeoMatchStatement:
CountryCodes:
- US
自 2020 年 1 月 13 日起,您无法使用 cloudformation 将 api 网关阶段等资源与 WAFv2 ACL 相关联。您可以使用控制台、SDK、自定义资源和 cli.
当 Cloudformation 实施 WAFv2(他们现在建议您使用)时,问题将得到解决。最终,我们需要 Cloudformation 来支持创建和关联(即到 API 网关或负载均衡器),以便其他变通办法不会到位,因为它们不是很容易转移。
GitHub 票是:https://github.com/aws-cloudformation/aws-cloudformation-coverage-roadmap/issues/344