Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. AWSTemplateFormatVersion: '2010-09-09'
  2. Description: 'Template for WAF Configuration'
  3. Parameters:
  4. CamerasApi:
  5. Description: "Arn of the Cameras Api"
  6. Type: String
  7. Default: cameras-api-dev
  8. StageName:
  9. Description: "Stage name of the Cameras Api"
  10. Type: String
  11. Default: v
  12. Blocking:
  13. Description: "Number of calls per 5 minutes for WAF IP blocking."
  14. Type: Number
  15. Default: 2000
  16. EnvironmentType:
  17. Type: String
  18. Default: "dev"
  19. Description: "Type of environment: dev, staging or prod."
  20.  
  21.  
  22. Resources:
  23. WAFCamerasWebACL:
  24. Type: AWS::WAFRegional::WebACL
  25. DependsOn: CamerasRateRule
  26. Properties:
  27. DefaultAction:
  28. Type: ALLOW
  29. MetricName: !Join ['', ['IPBlockingMetric', !Ref EnvironmentType]]
  30. Name: !Join ['', ['IPBlockingACL', !Ref EnvironmentType]]
  31. Rules:
  32. -
  33. Action:
  34. Type: "BLOCK"
  35. Priority: 1
  36. RuleId: !Ref CamerasRateRule
  37.  
  38. CamerasRateRule:
  39. Type: AWS::WAFRegional::RateBasedRule
  40. Properties:
  41. MetricName: UnallowedAccessCount
  42. Name: FiveMinuteRule
  43. RateKey: IP
  44. RateLimit: !Ref Blocking
  45. MatchPredicates:
  46. -
  47. DataId: !Ref CamerasIpSet
  48. Negated: false
  49. Type: "IPMatch"
  50.  
  51. CamerasIpSet:
  52. Type: AWS::WAFRegional::IPSet
  53. Properties:
  54. Name: !Join ['-', ['IpBlacklist', !Ref EnvironmentType]]
  55.  
  56.  
  57. MyWebACLAssociation:
  58. Type: AWS::WAFRegional::WebACLAssociation
  59. Properties:
  60. ResourceArn: !Sub arn:aws:apigateway:${AWS::Region}::/restapis/${CamerasApi}/stages/${StageName}
  61. WebACLId: !Ref WAFCamerasWebACL
  62.  
  63. Outputs:
  64. WebACL:
  65. Description: Name of the web ACL
  66. Value: !Ref WAFCamerasWebACL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement