forked from pulumi/examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
76 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,38 @@ | ||
# AWS C# Lambda Example | ||
Creates a lambda that does a simple `.toUpper` on the string input and returns it. | ||
# AWS C# Lambda | ||
This example creates a lambda that does a simple `.toUpper` on the string input and returns it. | ||
|
||
## Deploying the App | ||
|
||
## Instructions | ||
To deploy your infrastructure, follow the below steps. | ||
|
||
### Prerequisites | ||
|
||
1. [Install Pulumi](https://www.pulumi.com/docs/get-started/install/) | ||
2. [Configure AWS Credentials](https://www.pulumi.com/docs/intro/cloud-providers/aws/setup/) | ||
|
||
### Steps | ||
|
||
After cloning this repo, from this working directory, run these commands: | ||
|
||
1. Build and publish the lambda function, making the output available to our Pulumi program. | ||
|
||
From this directory: | ||
```bash | ||
# build publish the lambda function | ||
cd dotnetLambda/src/dotnetLambda/ && dotnet restore && dotnet build && dotnet publish && cd ../../../ | ||
``` | ||
|
||
2. Execute our Pulumi program to archive our published function output, and create our lambda. | ||
```bash | ||
# execute the pulumi program to deploy the lambda | ||
cd ./pulumi/ && pulumi up && cd ../ | ||
``` | ||
|
||
3. Call our lambda function from the aws cli. | ||
```bash | ||
aws lambda invoke \ | ||
--function-name $(pulumi stack output lambda) \ | ||
--region $(pulumi config get aws:region) \ | ||
--payload '"foo"' \ | ||
output.json | ||
|
||
cat output.json | ||
# "FOO" | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,19 @@ | ||
# AWS Lambda Empty Function Project | ||
# AWS Lambda Starter Function | ||
This starter function takes a string input, and returns the `toUpper` of it. | ||
|
||
This starter project consists of: | ||
* Function.cs - class file containing a class with a single function handler method | ||
* aws-lambda-tools-defaults.json - default argument settings for use with Visual Studio and command line deployment tools for AWS | ||
This project must be built and published prior to running `pulumi up` so that our pulumi program can create an [Archive](https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/asset/#Archive). | ||
|
||
You may also have a test project depending on the options selected. | ||
|
||
The generated function handler is a simple method accepting a string argument that returns the uppercase equivalent of the input string. Replace the body of this method, and parameters, to suit your needs. | ||
|
||
## Here are some steps to follow from Visual Studio: | ||
|
||
To deploy your function to AWS Lambda, right click the project in Solution Explorer and select *Publish to AWS Lambda*. | ||
|
||
To view your deployed function open its Function View window by double-clicking the function name shown beneath the AWS Lambda node in the AWS Explorer tree. | ||
|
||
To perform testing against your deployed function use the Test Invoke tab in the opened Function View window. | ||
|
||
To configure event sources for your deployed function, for example to have your function invoked when an object is created in an Amazon S3 bucket, use the Event Sources tab in the opened Function View window. | ||
|
||
To update the runtime configuration of your deployed function use the Configuration tab in the opened Function View window. | ||
|
||
To view execution logs of invocations of your function use the Logs tab in the opened Function View window. | ||
|
||
## Here are some steps to follow to get started from the command line: | ||
|
||
Once you have edited your template and code you can deploy your application using the [Amazon.Lambda.Tools Global Tool](https://github.com/aws/aws-extensions-for-dotnet-cli#aws-lambda-amazonlambdatools) from the command line. | ||
|
||
Install Amazon.Lambda.Tools Global Tools if not already installed. | ||
``` | ||
dotnet tool install -g Amazon.Lambda.Tools | ||
```bash | ||
dotnet build | ||
dotnet publish | ||
``` | ||
|
||
If already installed check if new version is available. | ||
``` | ||
dotnet tool update -g Amazon.Lambda.Tools | ||
``` | ||
See the [AWS .NET Lambda documentation](https://aws.amazon.com/blogs/compute/developing-net-core-aws-lambda-functions/) for more. | ||
|
||
Execute unit tests | ||
``` | ||
cd "BlueprintBaseName/test/BlueprintBaseName.Tests" | ||
dotnet test | ||
## About | ||
Generated with: | ||
```sh | ||
dotnet new lambda.EmptyFunction | ||
``` | ||
See the [AWS .NET Lambda documentation](https://aws.amazon.com/blogs/compute/developing-net-core-aws-lambda-functions/) for more C# templates. | ||
|
||
Deploy function to AWS Lambda | ||
``` | ||
cd "BlueprintBaseName/src/BlueprintBaseName" | ||
dotnet lambda deploy-function | ||
``` |
19 changes: 0 additions & 19 deletions
19
aws-cs-lambda/dotnetLambda/src/dotnetLambda/aws-lambda-tools-defaults.json
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
aws-cs-lambda/dotnetLambda/test/dotnetLambda.Tests/FunctionTest.cs
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
aws-cs-lambda/dotnetLambda/test/dotnetLambda.Tests/dotnetLambda.Tests.csproj
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
name: evanDotnetAws | ||
name: lambda | ||
runtime: dotnet | ||
description: A minimal AWS C# Pulumi program | ||
description: Basic example of an AWS lambda using C# |