AWS Lambda Function for API Gateway Testing

Prepare API Gateway URL

Prev Question Next Question

Question

You have recently developed an AWS Lambda function to be used as a backend technology for an API gateway instance.

You need to give the API gateway URL to a set of users for testing.

What must be done before the users can test the API?

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

Answer - A.

This is also mentioned in the AWS Documentation.

In API Gateway, a deployment is represented by a Deployment resource.

It is like an executable of an API represented by a RestApi resource.

For the client to call your API, you must create a deployment and associate a stage to it.

A stage is represented by a Stage resource and represents a snapshot of the API, including methods, integrations, models, mapping templates, Lambda authorizers (formerly known as custom authorizers), etc.

Option B is incorrect since this is only required for cross-domain requests.

Option C is incorrect since this is only required when you want to use your code to call the API gateway, and there is no mention of that requirement in the question.

Option D is incorrect since this is only required if the request is not text-based.

There is no mention of the type of payload in the question.

For more information on setting up deployments, please refer to the below URL-

https://docs.aws.amazon.com/apigateway/latest/developerguide/set-up-deployments.html

The correct answer is A. Ensure that a deployment is created in the API gateway.

Explanation: AWS Lambda function is an event-driven compute service, where you can upload and run code without worrying about the infrastructure behind it. AWS API Gateway is a fully managed service that makes it easy for developers to create, publish, maintain, monitor, and secure APIs at any scale. You can use AWS API Gateway as a front end to an AWS Lambda function, which means that API Gateway proxies requests to the Lambda function, and the Lambda function executes the business logic.

When you create an API in AWS API Gateway, you can define resources and methods, which correspond to the HTTP methods (GET, POST, PUT, DELETE, etc.) that you want to support. You can also define integration types, which specify how the API Gateway should forward requests to the backend service, in this case, AWS Lambda.

Before you can give the API gateway URL to the set of users for testing, you need to ensure that a deployment is created in the API gateway. A deployment is a snapshot of an API that you can make available to users. Deploying an API makes it available for clients to call. When you deploy an API, API Gateway creates a new deployment resource, which represents a snapshot of the API at a moment in time. The deployment resource is associated with a stage, which is a named reference to a deployment, like a version number.

CORS (Cross-Origin Resource Sharing) is a mechanism that allows many resources (e.g., fonts, JavaScript, etc.) on a web page to be requested from another domain outside the domain from which the resource originated. CORS is not required to be enabled to test the API.

Generating the SDK for the API is not required to test the API. However, generating an SDK is a useful feature provided by API Gateway that enables you to generate SDKs for your API in several programming languages, which makes it easier for your clients to integrate your API into their applications.

Enabling support for binary payloads is not required to test the API. However, if your API is going to support binary payloads like images, videos, or other non-text data, you need to enable support for binary payloads in API Gateway.

In conclusion, the correct answer is A. Ensure that a deployment is created in the API gateway.