1. 程式人生 > >Amazon API Gateway adds support for AWS WAF

Amazon API Gateway adds support for AWS WAF

This post courtesy of Heitor Lessa, AWS Specialist Solutions Architect – Serverless

Today, I’m excited to tell you about the Amazon API Gateway native integration with AWS WAF. Previously, if you wanted to secure your API in Amazon API Gateway with AWS WAF, you had to deploy a Regional API endpoint and use your own Amazon CloudFront distribution. This new feature now enables you to provision any­­ API Gateway endpoint and secure it with AWS WAF without having to configure your own CloudFront distribution to add that capability.

In Part 1 of this series, I described how to protect your API provided by API Gateway using AWS WAF.

In Part 2 of this series, I described how to use API keys as a shared secret between a CloudFront distribution and API Gateway to secure public access to your API in API Gateway. This new AWS WAF integration means that the method described in Part 2 is no longer necessary.

The following image describes methods to secure your API in API Gateway before and after this feature was made available.

Where:

  1. AWS WAF securing CloudFront endpoint only.
  2. AWS WAF securing Amazon API Gateway endpoints natively.

Enabling AWS WAF for an API managed by Amazon API Gateway

For this walkthrough, you can use an existing Pet Store API or any API in API Gateway that you may already have deployed. You create a new AWS WAF web ACL that is later associated with your API Gateway stage.

Follow these steps to create a web ACL:

  1. Choose Create web ACL.
  2. For Web ACL Name, enter ApiGateway-HTTP-Flood-Sample.
  3. For Region, choose US East (N. Virginia).
  4. Choose Next until you reach Step 3: Create rules.
  5. Choose Create rule and enter HTTP Flood Sample.
  6. For Rule type, choose Rate-based rule.
  7. For Rate limit, enter 2000 and choose Create.
  8. For Default action, choose Allow all requests that don’t match any rules.
  9. Choose Review and create.
  10. Confirm that your options look similar to the following image and choose Confirm and create next.

You can now follow the steps to enable the AWS WAF web ACL for an existing API in API Gateway:

  1. Choose Stages, prod.
  2. Under Web Application Firewall (WAF), choose ApiGateway-HTTP-Flood-Sample (or the web ACL that you just created).
  3. Choose Save Changes.

Testing your API in API Gateway now secured by AWS WAF

AWS WAF provides HTTP flood protection that is a rate-based rule. The rate-based rule is automatically triggered when web requests from a client exceed a configurable threshold. The threshold is defined by the maximum number of incoming requests allowed from a single IP address within a five-minute period.

After this threshold is breached, additional requests from the IP address are blocked until the request rate falls below the threshold. For this example, you defined 2000 requests as a threshold for the HTTP flood rate–based rule.

Artillery, an open source modern load testing toolkit, is used to send a large number of requests directly to the API Gateway Invoke URL to test whether your AWS WAF native integration is working correctly.

Firstly, follow these steps to retrieve the correct Invoke URL of your Pet Store API:

  1. In the left navigation pane, open the PetStore API.
  2. Choose Stages, select prod, and copy the Invoke URL value.

Secondly, use cURL to query your distribution and see the API output before the rate limit rule is triggered:

$ curl -s INVOKE_URL/pets

[
  {
    "id": 1,
    "type": "dog",
    "price": 249.99
  },
  {
    "id": 2,
    "type": "cat",
    "price": 124.99
  },
  {
    "id": 3,
    "type": "fish",
    "price": 0.99
  }
] 

Then, use Artillery to send a large number of requests in a short period of time to trigger your rate limit rule:

$ artillery quick -n 2000 --count 10 INVOKE_URL/pets

With this command, Artillery sends 2000 requests to your PetStore API from 10 concurrent users. By doing so, you trigger the rate limit rule in less than the 5-minute threshold. For brevity, I am not posting the Artillery output here.

After Artillery finishes its execution, try re-running the cURL command. You should no longer see a list of pets:

{“message”:”Forbidden”}

As you can see from the output, the request was blocked by AWS WAF. Your IP address is removed from the blocked list after it falls below the request limit rate.

Conclusion

As you can see, with the AWS WAF native integration with Amazon API Gateway, you no longer have to manage your own Amazon CloudFront distribution in order to secure your API with AWS WAF. The AWS WAF native integration makes this process seamless.

I hope that you found the information in this post helpful. Remember that you can use this integration today with all Amazon API Gateway endpoints (Edge, Regional, and Private). It is available in the following Regions:

  • US East (N. Virginia)
  • US East (Ohio)
  • US West (Oregon)
  • US West (N. California)
  • EU (Ireland)
  • EU (Frankfurt)
  • Asia Pacific (Sydney)
  • Asia Pacific (Tokyo)

相關推薦

Amazon API Gateway adds support for AWS WAF

This post courtesy of Heitor Lessa, AWS Specialist Solutions Architect – Serverless Today, I’m excited to tell you about the Amazon API Ga

AWS Amplify Adds Support for Securely Embedding Amazon Sumerian AR/VR Scenes in Web Applications

AWS Amplify offers this functionality via a new XR category in the JavaScript library that makes it easy for developers to embed Amazon Sumeria

Support for multi-value parameters in Amazon API Gateway

This post is courtesy of Akash Jain, Partner Solutions Architect – AWS The new multi-value parameter support feature for Amazon API Gatewa

Pass Custom Headers Through Amazon API Gateway to an AWS Lambda Function

By default, a Lambda function only ingests the request body received by an API created in the API Gateway. To pass custom headers f

Amazon API Gateway | AWS

Amazon API Gateway API コール料金 = 333 萬回 * 3.50 USD / 100 萬回 = 1,165.50 USD                                                        

AWS Marketplace: Fortinet Managed Rules for AWS WAF

AWS Marketplace is hiring! Amazon Web Services (AWS) is a dynamic, growing business unit within Am

AWS Marketplace: Trustwave Managed Rules for AWS WAF

AWS Marketplace is hiring! Amazon Web Services (AWS) is a dynamic, growing business unit within Am

Managed Rules for AWS WAF

Select Trustwave SpiderLabs ModSecurity virtual patches to provide additional support for your web applications running AWS WAF. As

AWS Marketplace: Trend Micro Managed Rules for AWS WAF

AWS Marketplace is hiring! Amazon Web Services (AWS) is a dynamic, growing business unit within Am

Amazon API Gateway

The AWS Serverless Application Repository is a collection of serverless applications published by developers, companies, and partners. Quickly

FAQ sur Amazon API Gateway

Q : Comment commencer à utiliser Amazon API Gateway ? Amazon API Gateway vous permet de créer rapidement et facilement une API pe

使用 Amazon API Gateway 為 SAP 部署 API

本文由Amazon Web Services (AWS)的SAP數字顧問KK Ramamoorthy撰寫。 您的客戶,合作伙伴和員工希望通過各種渠道獲得一種無縫,安全的使用者體驗。 例如,使用像亞馬遜Alexa等支援語音功能的裝置下訂單的客戶,也應該在移動裝置上得到相同的體驗

Amazon API Gateway雲網關_API閘道器託管服務

Amazon API Gateway 是一種完全託管的服務,可以幫助開發者輕鬆建立、釋出、維護、監控和保護任意規模的 API。只需在 AWS 管理控制檯中點選幾下,您便可以建立可充當應用程式“前門”的 API,從後端服務訪問資料、業務邏輯或功能,例如基於 Amazon Elastic Co

Amazon API Gateway雲網關價格_API閘道器託管服務

Amazon API Gateway API 呼叫費用 = 3.33 億 * 3.50 USD/100 萬 = 1165.50 USD                                                            

Amazon API Gateway雲網關常見問題_API閘道器託管服務

問:如何開始使用 Amazon API Gateway? 使用 Amazon API Gateway,您可以快速輕鬆地建立自定義 API。對於簡單的“Hello World”示例,請遵循以下步驟: 1.轉至 Amazon API Ga

Tutorial for building a Web Application with Amazon S3, Lambda, DynamoDB and API Gateway

Tutorial for building a Web Application with Amazon S3, Lambda, DynamoDB and API GatewayI recently attended Serverless Day at the AWS Loft in downtown San

Introducing support for Amazon S3 Select in the AWS SDK for PHP

We’re excited to announce support for the Amazon Simple Storage Service (Amazon S3) SelectObjectContent API with event streams in the AWS SDK for

AWS Marketplace: SecureSphere WAF AV1000 Gateway for AWS (On

Imperva SecureSphere WAF for AWS extends all of the security and management capabilities of the world's most-trusted web application firewall to A

Amazon Comprehend introduces new Region availability and language support for French, German, Italian, and Portuguese

Amazon Comprehend is a natural language processing (NLP) service that uses machine learning to find insights and relationships in text. The servic