AWS ApiGateway RestApi is created from the DuploCloud Portal which will take care of creating the security policies to make the API Gateway accessible to other resources (like Lambda functions) within the Tenant. Creating the RestApi is the only configuration done from within the DuploCloud portal. All other configurations for the API (like defining methods, resources, and pointing to lambda functions) should be done in the AWS console. The API console can be reached by navigating to Cloud Services -> Networking, selecting the API Gateway tab, and then clicking on the Console button under the Actions menu.
The steps below use DuploCloud's API Gateway/Lambda integration to create a web API with an HTTP endpoint for your Lambda function (in this case, it returns a simple "Hello!
" response).
The example API deployed is not secure. Anyone on the internet can access the endpoint (in this example, "Hello!
"). When creating your own Lambda, you will need to configure CORS, authentication, and other security details.
Create a lambda_function.py
with this code:
For more information about formatting your Lambda response, the AWS documentation.
Run zip my_deployment_package.zip lambda_function.py
Upload my_deployment_package.zip
to an S3 bucket.
Create a Lambda Function in DuploCloud and point it to that Zip with handler lambda_function.lambda_handler
.
Create an API Gateway and select the Lambda you just created.
Then you can "Deploy API" from the new gateway that's created in AWS Console and you can curl the endpoint that shows up under Stages -> Stage details -> Invoke URL (again in AWS Console).