The CDK stack creates an Amazon API Gateway REST API endpoint with AWS Lambda function proxy integration.
Proxy integration creates a proxy resource with the greedy path {proxy+}
and the method ANY
.
This means that the REST API endpoint accepts any method and any path by default.
The Lambda used in this pattern is an ASP.NET Core Web API application that has been configured to allow Lambda and API Gateway to act as the web server instead of Kestrel.
Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/apigw-lambda-cdk-dotnet
Important: this application uses various AWS services and there are costs associated with these services after the Free Tier usage - please see the AWS Pricing page for details. You are responsible for any AWS costs incurred. No warranty is implied in this example.
- Create an AWS account if you do not already have one and log in. The IAM user that you use must have sufficient permissions to make necessary AWS service calls and manage AWS resources.
- AWS CLI installed and configured
- Git Installed
- .NET 6 installed
- AWS Cloud Development Kit (AWS CDK) installed
- Clone the project to your local working directory
git clone https://github.com/aws-samples/serverless-patterns
- Change the working directory to this pattern's directory
cd apigw-lambda-cdk-dotnet/src/cdk/src
- Build the application
dotnet build
- Return one level back to the path
apigw-lambda-cdk-dotnet/src/cdk
cd..
- Deploy the stack to your default AWS account and region. The output of this command should give you the REST API URL.
cdk deploy
- After deployment, the output shows the API Gateway URL with the Lambda integration, for example:
CdkStack.RESTAPIUrl = https://<random-id>.execute-api.ap-south-1.amazonaws.com/prod/
- Copy this URL and append
WeatherForecast
, the URL will look like this:https://<random-id>.execute-api.ap-south-1.amazonaws.com/prod/WeatherForecast
- Enter this URL into your browser, you should receive a JSON response with weather information.
Run the given command to delete the resources that were created. It might take some time for the CloudFormation stack to get deleted.
cdk destroy
Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0