|
| 1 | +# Blank function (PowerShell) |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +The project source includes function code and supporting resources: |
| 6 | + |
| 7 | +- `function` - A PowerShell function. |
| 8 | +- `template.yml` - An AWS CloudFormation template that creates an application. |
| 9 | +- `1-create-bucket.sh`, `2-deploy.sh`, etc. - Shell scripts that use the AWS CLI to deploy and manage the application. |
| 10 | + |
| 11 | +Use the following instructions to deploy the sample application. |
| 12 | + |
| 13 | +# Requirements |
| 14 | +- [PowerShell Core 6.0 or newer](https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell#powershell-core) |
| 15 | +- [.NET Core 2.1](https://www.microsoft.com/net/download) |
| 16 | +- [AWSLambdaPSCore module](https://www.powershellgallery.com/packages/AWSLambdaPSCore/1.2.0.0) |
| 17 | +- The Bash shell. For Linux and macOS, this is included by default. In Windows 10, you can install the [Windows Subsystem for Linux](https://docs.microsoft.com/en-us/windows/wsl/install-win10) to get a Windows-integrated version of Ubuntu and Bash. |
| 18 | +- [The AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-install.html). |
| 19 | + |
| 20 | +# Setup |
| 21 | +Download or clone this repository. |
| 22 | + |
| 23 | + $ git clone [email protected]:awsdocs/aws-lambda-developer-guide.git |
| 24 | + $ cd aws-lambda-developer-guide/sample-apps/blank-powershell |
| 25 | + |
| 26 | +To create a new bucket for deployment artifacts, run `1-create-bucket.sh`. Or, if you already have a bucket, create a file named `bucket-name.txt` that contains the name of your bucket. |
| 27 | + |
| 28 | + blank-powershell$ ./1-create-bucket.sh |
| 29 | + make_bucket: lambda-artifacts-a5e491dbb5b22e0d |
| 30 | + |
| 31 | +# Deploy |
| 32 | +To deploy the application, run `2-deploy.sh`. |
| 33 | + |
| 34 | + blank-powershell$ ./2-deploy.sh |
| 35 | + Restoring .NET Lambda deployment tool |
| 36 | + Initiate packaging |
| 37 | + Uploading to e678bc216e6a0d510d661ca9ae2fd941 28800329 / 28800329.0 (100.00%) |
| 38 | + Successfully packaged artifacts and wrote output template to file out.yml. |
| 39 | + Waiting for changeset to be created.. |
| 40 | + Waiting for stack create/update to complete |
| 41 | + Successfully created/updated stack - blank-powershell |
| 42 | + |
| 43 | +This script uses AWS CloudFormation to deploy the Lambda functions and an IAM role. If the AWS CloudFormation stack that contains the resources already exists, the script updates it with any changes to the template or function code. |
| 44 | + |
| 45 | +# Test |
| 46 | +To invoke the function, run `3-invoke.sh`. |
| 47 | + |
| 48 | + blank-powershell$ ./3-invoke.sh |
| 49 | + { |
| 50 | + "StatusCode": 200, |
| 51 | + "ExecutedVersion": "$LATEST" |
| 52 | + } |
| 53 | + |
| 54 | +The application uses AWS X-Ray to trace requests. Open the [X-Ray console](https://console.aws.amazon.com/xray/home#/service-map) to view the service map. The following service map shows the function calling Amazon S3. |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | +Choose a node in the main function graph. Then choose **View traces** to see a list of traces. Choose any trace to view a timeline that breaks down the work done by the function. |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | +Finally, view the application in the Lambda console. |
| 63 | + |
| 64 | +*To view the output* |
| 65 | +1. Open the [applications page](https://console.aws.amazon.com/lambda/home#/applications) in the Lambda console. |
| 66 | +2. Choose **blank-powershell**. |
| 67 | + |
| 68 | +  |
| 69 | + |
| 70 | +# Cleanup |
| 71 | +To delete the application, run `4-cleanup.sh`. |
| 72 | + |
| 73 | + blank-powershell$ ./4-cleanup.sh |
0 commit comments