Pon*_*spe 5 sam amazon-web-services amazon-waf
我们正在尝试在 SAM 模板中创建 AWS::WAFv2::IPSet。
WhitelistedIPAddressesIPSet:
Type: AWS::WAFv2::IPSet
Properties:
Description: 'Merchant IPs'
Scope: REGIONAL
IPAddressVersion: IPV4
Addresses: [0.0.0.0/32, 0.0.10.0/32]
Run Code Online (Sandbox Code Playgroud)
IP 集的创建已成功完成。创建 AWS::WAFv2::WebACLAssociation 后。
WAFApiAssociation:
Type: AWS::WAFv2::WebACLAssociation
DependsOn:
- ApiGateway
- WAFWebAcl
Properties:
ResourceArn: !Sub 'arn:aws:apigateway:${AWS::Region}::/restapis/${ApiGateway}/stages/${EnvType}'
WebACLArn: !GetAtt WAFWebAcl.Arn
Run Code Online (Sandbox Code Playgroud)
CloudFormation 失败并进行回滚。显示错误如下:
Resource handler returned
ion message: "AWS WAF couldn?t
perform the operation
because your resource
doesn?t exist. (Service:
Wafv2, Status Code: 400,
Request ID: e337720a-e32c-
4c29-acde-1896855405c9,
Extended Request ID:
null)" (RequestToken: f24d
0488-3016-4030-3a3b-bbb246
66f130, HandlerErrorCode:
NotFound)
Run Code Online (Sandbox Code Playgroud)
我们尝试了 IP 集的 SAM 模板的不同格式,以查看是否会导致问题,但没有成功。
有人可以分享一些对此问题有用的见解吗?
DependsOnA)如果您的资源已经直接依赖于其他资源,则不需要。在这种情况下确实如此,因此您可以删除此属性。
B) 您需要在此处共享整个堆栈,而不仅仅是共享的内容,因为您的 APIGW 配置可能存在问题。由于创建失败,您可能会出现后续问题。
创建 APIGW 还不够,您需要确保在创建 APIGW阶段后实际附加 WAF ,而不仅仅是 APIGW。在这种情况下,将 替换ResourceArn为引用 的值APIGW Stage。(此外,您可能需要等待阶段部署完成。)
关联的 CFN 示例:
WAFv2Assocation:
Type: AWS::WAFv2::WebACLAssociation
Properties:
ResourceArn: !Sub "arn:aws:apigateway:${AWS::Region}::/restapis/${ApiGatewayApi}/stages/${Stage}"
Stage: !Ref ApiGatewayApi.Stage
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7243 次 |
| 最近记录: |