![](/img/trans.png)
[英]AWS Cloudfront (with WAF) + API Gateway: how to force access through Cloudfront?
[英]How can I implement a AWS WAF rule to restrict access of api gateway to the users of other accounts?
我需要编写一个 WAF 规则,以便其他 AWS 账户的用户无法访问 API 网关。
现在,我正在探索 WAF 的实现,但我已经成功地创建了 CfnWebCl,规则语句为 ipSetReferenceStatement,这样我就创建了一个允许 ips 的 IP 集,但这不是我想要的,我想要用户其他 aws 帐户的示例代码。
this.commserviceAllowedIpSet = new CfnIPSet(this, 'commservice-allowedIps', {
name: 'allowed ips',
ipAddressVersion: 'IPV4',
addresses: [],
scope: 'REGIONAL',
});
this.commserviceWebAcl = new CfnWebACL(this, 'commservice-webacl', {
defaultAction: {
block: {},
},
visibilityConfig: {
cloudWatchMetricsEnabled: true,
metricName: 'commservice-webacl',
sampledRequestsEnabled: true,
},
scope: 'REGIONAL',
rules: [
{
statement: {
ipSetReferenceStatement: {
arn: this.commserviceAllowedIpSet.attrArn,
},
},
name: 'abc',
priority: 0,
visibilityConfig: {
cloudWatchMetricsEnabled: true,
metricName: 'allowed-requests',
sampledRequestsEnabled: true,
},
},
],
});
除了 ipSetReferencesStatement 之外,还有其他规则语句可以使用吗? 如果问题不清楚,请见谅。
你不能用 WAF 做到这一点。 正确的做法是使用API Gateway 资源策略。 通过编写这样的策略,您可以将 API 的访问权限限制为您自己的帐户。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.