AWS C# Lambda
This example lives in the pulumi/examples repository. Check out just this directory to use it:
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examplesgit -C pulumi-examples sparse-checkout set aws-cs-lambdacd pulumi-examples/aws-cs-lambdaThis example creates an AWS Lambda function that does a simple .ToUpper on the string input and returns it.
Prerequisites#
Deploying the example#
-
Build and publish the Lambda function, making the output available to the Pulumi program:
Terminal window dotnet publish ./DotnetLambda/src/DotnetLambda/ -c Release -
Create a new stack and set the AWS region to deploy into:
Terminal window pulumi stack init dev -C ./pulumipulumi config set aws:region us-east-1 -C ./pulumi -
Deploy the stack to archive the published function output and create the Lambda:
Terminal window pulumi up -C ./pulumi -
Call the Lambda function from the AWS CLI with “foo” as the payload:
Terminal window aws lambda invoke \--function-name $(pulumi stack output Lambda -C ./pulumi) \--region $(pulumi config get aws:region -C ./pulumi) \--cli-binary-format raw-in-base64-out \--payload '"foo"' \output.jsoncat output.json # view the output file with your tool of choice# "FOO"
From there, feel free to experiment. Simply making edits, rebuilding your handler, and running pulumi up will update your function.
Cleaning up#
Once you’re finished experimenting, you can destroy your stack and remove it to avoid incurring any additional cost:
pulumi destroy -C ./pulumipulumi stack rm -C ./pulumi