


Use CloudFormation to build this environment and check the actual behavior. So to meet the above requirements, we use the built-in function Fn::Sub to embed and configure the API’s ID and stage name. The following is a description of how to specify the WAFįor an Amazon API Gateway REST API: arn:aws:apigateway:region::/restapis/api-id/stages/stage-name AWS::WAFv2::WebACLAssociation In the ResourceArn property, specify the API Gateway to which WAF is to be applied. Resource for applying WAF to API Gateway. Resources: RestApi: Type: AWS::ApiGateway::RestApi Properties: EndpointConfiguration: Types: - EDGE Name: !Ref Prefix Deployment: Type: AWS::ApiGateway::Deployment DependsOn: - Method Properties: RestApiId: !Ref RestApi Resource: Type: AWS::ApiGateway::Resource Properties: ParentId: !GetAtt RestApi.RootResourceId PathPart: !Sub "$" WebACLArn: !GetAtt WebACL.Arn Code language: YAML ( yaml )
