AWS code-library documentation change
Summary
Added PowerShell V5 examples for creating Lambda functions with environment variables and S3 deployment
Security assessment
The examples demonstrate standard Lambda creation patterns with environment variables and IAM roles, but don't address specific vulnerabilities or introduce new security controls
Diff
diff --git a/code-library/latest/ug/lambda_example_lambda_CreateFunction_section.md b/code-library/latest/ug/lambda_example_lambda_CreateFunction_section.md index 39eb3c919..8fc104950 100644 --- a//code-library/latest/ug/lambda_example_lambda_CreateFunction_section.md +++ b//code-library/latest/ug/lambda_example_lambda_CreateFunction_section.md @@ -542,0 +543,54 @@ PowerShell +**Tools for PowerShell V5** + + +**Example 1: This example creates a new C# (dotnetcore1.0 runtime) function named MyFunction in AWS Lambda, providing the compiled binaries for the function from a zip file on the local file system (relative or absolute paths may be used). C# Lambda functions specify the handler for the function using the designation AssemblyName::Namespace.ClassName::MethodName. You should replace the assembly name (without .dll suffix), namespace, class name and method name parts of the handler spec appropriately. The new function will have environment variables 'envvar1' and 'envvar2' set up from the provided values.** + + + Publish-LMFunction -Description "My C# Lambda Function" ` + -FunctionName MyFunction ` + -ZipFilename .\MyFunctionBinaries.zip ` + -Handler "AssemblyName::Namespace.ClassName::MethodName" ` + -Role "arn:aws:iam::123456789012:role/LambdaFullExecRole" ` + -Runtime dotnetcore1.0 ` + -Environment_Variable @{ "envvar1"="value";"envvar2"="value" } + + +**Output:** + + + CodeSha256 : /NgBMd...gq71I= + CodeSize : 214784 + DeadLetterConfig : + Description : My C# Lambda Function + Environment : Amazon.Lambda.Model.EnvironmentResponse + FunctionArn : arn:aws:lambda:us-west-2:123456789012:function:ToUpper + FunctionName : MyFunction + Handler : AssemblyName::Namespace.ClassName::MethodName + KMSKeyArn : + LastModified : 2016-12-29T23:50:14.207+0000 + MemorySize : 128 + Role : arn:aws:iam::123456789012:role/LambdaFullExecRole + Runtime : dotnetcore1.0 + Timeout : 3 + Version : $LATEST + VpcConfig : + +**Example 2: This example is similar to the previous one except the function binaries are first uploaded to an Amazon S3 bucket (which must be in the same region as the intended Lambda function) and the resulting S3 object is then referenced when creating the function.** + + + Write-S3Object -BucketName amzn-s3-demo-bucket -Key MyFunctionBinaries.zip -File .\MyFunctionBinaries.zip + Publish-LMFunction -Description "My C# Lambda Function" ` + -FunctionName MyFunction ` + -BucketName amzn-s3-demo-bucket ` + -Key MyFunctionBinaries.zip ` + -Handler "AssemblyName::Namespace.ClassName::MethodName" ` + -Role "arn:aws:iam::123456789012:role/LambdaFullExecRole" ` + -Runtime dotnetcore1.0 ` + -Environment_Variable @{ "envvar1"="value";"envvar2"="value" } + + + * For API details, see [CreateFunction](https://docs.aws.amazon.com/powershell/v5/reference) in _AWS Tools for PowerShell Cmdlet Reference (V5)_. + + + +