Giter Site home page Giter Site logo

awsdocs / aws-lambda-developer-guide Goto Github PK

View Code? Open in Web Editor NEW
2.5K 90.0 1.7K 8.56 MB

Supplementary resources for the AWS Lambda Developer Guide

License: MIT No Attribution

Shell 33.74% JavaScript 3.30% C# 11.15% PowerShell 0.69% Python 1.59% Ruby 0.88% Java 46.73% Go 1.92%

aws-lambda-developer-guide's Introduction

AWS Lambda Developer Guide

This repository contains additional resources for the AWS Lambda developer guide.

  • iam-policies - Sample permissions policies for cross-service use cases.
  • sample-apps - Sample applications that demonstrate features and use cases for the AWS Lambda service and managed runtimes.
  • templates - AWS CloudFormation templates for creating functions and VPC network resources.

License Summary

The sample code within this repo is made available under a modified MIT license. See the LICENSE file.

aws-lambda-developer-guide's People

Contributors

adamchainz avatar alivest avatar awsben avatar awstimrtrev avatar benbridts avatar coraxster avatar daeltan avatar dependabot[bot] avatar devlinbd2 avatar dulac avatar eanbyrne avatar eriboo avatar finalfantasia avatar gytisrepecka avatar jogold avatar juankb1024 avatar kennyk65 avatar klmz avatar ksami avatar mark-hirayama avatar mwunderl avatar praveensripati avatar romankydybets avatar ryapric avatar spaethp avatar talianassi921 avatar teknogeek0 avatar timoschilling avatar willarmiros avatar yualexan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-lambda-developer-guide's Issues

Question about the `blank-nodejs` example

In your blank-nodejs example, you create an S3 bucket for deployment artifacts but some things aren't clear.

  1. I can't find anywhere in the code you're actually writing to that bucket. Where does this happen?
  2. What are the build artifacts for? What would be the result if I removed the bucket?

Maybe the documentation could be updated to make this more clear.

Go deployment page has inaccurate information

There is some bad information here. "Note that your function-name must match the name of your Lambda handler name." This is not true, the name of the function can be anything. This can be seen, for example, here: https://github.com/aws-samples/lambda-go-samples/blob/master/template.yml where the function name will be set by CloudFormation to something related to "HelloFunction" but Handler is set to "main", which is the name of the executable built from this file https://github.com/aws-samples/lambda-go-samples/blob/master/main.go

AddPermission's SourceArn Parameter Doesn't Specify Supported Event Sources

According to the CloudFormation AWS::Lambda::Permission docs, "This property [SourceArn] is not supported by all event sources. For more information, see the SourceArn parameter for the AddPermission action in the AWS Lambda Developer Guide." However, SourceArn doesn't specify which even sources are supported.

I could see this being an issue with the CloudFormation docs, but SourceAccount does document the supported event sources, so it seems like SourceArn should as well.

Thanks!

Issues in Logging AWS Lambda Application with Log4j2

I have an AWS Lambda Function, when executed gives errors related to reading Log4j2 file on cloudWatch.
I have log4j2 configuration related to AWS Lambda Logging

@spaethp Could you please help me resolve the below error

2019-10-01 14:39:54,029 main ERROR Error processing element Lambda: CLASS_NOT_FOUND
2019-10-01 14:39:54,031 main ERROR Unable to locate plugin type for Lambda
2019-10-01 14:39:54,054 main ERROR Unable to locate plugin for Lambda
2019-10-01 14:39:54,056 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.config.AppendersPlugin for element Appenders: java.lang.NullPointerException java.lang.NullPointerException
.
.
.
.
2019-10-01 14:39:55,839 main ERROR AppenderRef contains an invalid element or attribute "_ref"
2019-10-01 14:39:55,840 main ERROR Appender references must contain a reference
2019-10-01 14:39:55,893 main ERROR Null object returned for AppenderRef in Root.
2019-10-01 14:39:55,894 main ERROR Root contains an invalid element or attribute "_level"
2019-10-01 14:39:59,837 main ERROR Error processing element Lambda: CLASS_NOT_FOUND

Here is my Log4j2.YAML Configuration

Configuration:
 Appenders:
  Lambda:
   PatternLayout:
    pattern: "%d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1}:%L - %m%n"
   _name: Lambda
 Loggers:
  Root:
   AppenderRef:
    _ref: Lambda
   _level: info
 _packages: "com.amazonaws.services.lambda.runtime.log4j2.LambdaAppender"

Here is my Maven POM for Logging Dependencies

<dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-lambda-java-log4j2</artifactId>
            <version>1.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>2.12.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.12.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.12.0</version>
        </dependency>

        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>1.25</version>
        </dependency>
        
       <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-yaml</artifactId>
            <version>2.9.9</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.9</version>
        </dependency>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>**/Log4j2Plugins.dat</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Context object to include memory used.

Would it be possible to include the memory used by the function in the context object ?
https://github.com/awsdocs/aws-lambda-developer-guide/tree/master/doc_source/nodejs-context.md

This is ultimately outputted in the cloudwatch log; but having a getter for the current usage similar to ( getRemainingTimeInMillis ) would be of great value. Today there is process.memoryUsage() that does not appear to have a 1 to 1 mapping of what AWS assesses in the end:

For example:

     const used = process.memoryUsage();
      let totalUsed = 0;
      for (let key in used) {
        const mb = Math.round(used[key] / 1024 / 1024 * 100) / 100;
        totalUsed+=mb;
        console.log(`${key} ${mb} MB`);
      }
      console.log("total: ", totalUsed)
      callback(null, response.ok(result) );

log:

2020-08-01T18:46:02.291Z	*	INFO	rss 47.01 MB
2020-08-01T18:46:02.291Z	*	INFO	heapTotal 15.92 MB
2020-08-01T18:46:02.292Z	*	INFO	heapUsed 7.58 MB
2020-08-01T18:46:02.292Z	*	INFO	external 1.52 MB
2020-08-01T18:46:02.292Z	*	INFO	arrayBuffers 0.24 MB
2020-08-01T18:46:02.292Z	*	INFO	total:  72.27
END RequestId: *
REPORT RequestId:*Duration: 1188.30 ms	Billed Duration: 1200 ms	Memory Size: 128 MB	Max Memory Used: 81 MB	Init Duration: 236.17 ms	

Lambda Consumer with KPL Producer needs more explanation

I followed the guide here - https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/doc_source/with-kinesis-create-package.md - for making a function to process messages from a Kinesis stream.

This worked fine for messages that were produced individually, but when several messages were produced in a short time-frame, the latter messages were prefixed by extra characters, including the partitionKey and some pipe characters.

After some research, I realised that I needed to either disable the Kinesis Aggregation using the producer library (which I chose) or I needed to use https://github.com/awslabs/kinesis-aggregation

It would be enormously helpful if there were some warnings in the documentation about creating a Kinesis function on the subject of aggregation.

light nit: correct style for js

In js, the name are camelCase, and there is no space between function names and parens:

exports.myHandler = function(event, context, callback) {
	var foo = event.foo;
	var bar = event.bar;
	var result = myLambdaFunction(foo, bar);
 
	callback(null, result);
}
 
function myLambdaFunction(foo, bar) {
	// myLambdaFunction logic here
}

I am not sure if this is standard throughout the docs, so did not push a PR, but would be nice to keep it similar.

Improve doc for Python dependencies with C++/DLL components

The Working with Python > Deployment Package page section on "Updating a function with additional dependencies" misses an important point that can confuse users:

Following the instructions to pip install --target ./package on your build environment only works if either...

  • Your target libraries are pure Python (or any bundled native dependencies are cross-platform), or
  • Your build environment architecture is similar to the Lambda runtime.

For example (a typical request), I cannot pip install --target ./package Pillow on my Mac, bundle that to a Lambda deployment package and upload it. My Lambda function will give an error message something like:

{
    "errorMessage": "Unable to import module 'lambda_function': Cannot import name '_imaging' from 'PIL' (/var/task/PIL/__init__.py)",
    "errorType": "Runtime.ImportModuleError"
}

...If I'm deep on Python packaging, I might trace that this is because the line from . import _imaging as core buried in the PIL source code will work on my machine (where it resolves _imaging.cpython-38-darwin.so installed in the bundle) but fail on Amazon Linux (because the architecture doesn't match).

If I'm not, it will probably take me a long time to debug as I'll be looking for solutions specific to my library & runtimes!

Please consider adding a caution on this (perhaps mentioning some popular libraries like PIL/Pillow which bundle architecture-specific components), and some discussion on workarounds such as:

  • Creating the bundle (or at least the packaging part) on a compatible environment e.g. an EC2 instance, Cloud9, a SageMaker Notebook, etc)
  • Using the AWS SAM CLI on your local machine with the --container option, so that SAM sets up a Docker container with a Lambda-like environment for you and simplifies the process.

Thanks!

Does the `nodejs12.x` runtime include full-icu?

I don't see this documented anywhere, but a quick test makes me think that AWS Lambda is using a custom build of Node.js with full icu.

console.log(new Intl.DateTimeFormat('en-GB').format(new Date('2015-05-30')));
// prints the expected "30/05/2015"

Can this feature be relied upon?

Node.js Docs: https://nodejs.org/docs/latest-v12.x/api/intl.html#intl_embed_the_entire_icu_full_icu
AWS Lambda Docs: https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html

Max concurrent lambda per SQS queue

Documentation states "whichever is lower" of 1000, the account limit, or the function limit. This implies that 1000 is the maximum concurrent lambda off of a SQS queue, is this true?

text from doco https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/doc_source/scaling.md
As the influx of messages to a queue increases, AWS Lambda automatically scales up polling activity until the number of concurrent function executions reaches 1000, the account concurrency limit, or the (optional) function concurrency limit, whichever is lower.
end text

"blank-python" aws example may contain incorrect template.yml

Going through this example I've stopped on Deploy step. Following exection from aws is returned after 3-deploy.sh execution:

Uploading to c1badd00616f4d13770cb5a1b6d9dfc8 1169 / 1169.0 (100.00%)
Successfully packaged artifacts and wrote output template to file out.yml.
Execute the following command to deploy the packaged template
aws cloudformation deploy --template-file //aws-lambda-developer-guide/sample-apps/blank-python/out.yml --stack-name

Waiting for changeset to be created..

Failed to create the changeset: Waiter ChangeSetCreateComplete failed: Waiter encountered a terminal failure state Status: FAILED. Reason: Transform AWS::Serverless-2016-10-31 failed with: Invalid Serverless Application Specification document. Number of errors found: 1. Resource with id [libsec98e4a2a4] is invalid. 'ContentUri' is not a valid S3 Uri of the form 's3://bucket/key' with optional versionId query parameter.

out.yml contains:

AWSTemplateFormatVersion: '2010-09-09'
Description: An AWS Lambda application that calls the Lambda API.
Resources:
  function:
    Properties:
      CodeUri: s3://lambda-artifacts-26c3674062aa40ab/c1badd00616f4d13770cb5a1b6d9dfc8
      Description: Call the AWS Lambda API
      Handler: lambda_function.lambda_handler
      Layers:
      - Ref: libs
      Policies:
      - AWSLambdaBasicExecutionRole
      - AWSLambdaReadOnlyAccess
      - AWSXrayWriteOnlyAccess
      Runtime: python3.8
      Timeout: 10
      Tracing: Active
    Type: AWS::Serverless::Function
  libs:
    Properties:
      CompatibleRuntimes:
      - python3.8
      ContentUri: package/.
      Description: Dependencies for the blank-python sample app.
      LayerName: blank-python-lib
    Type: AWS::Serverless::LayerVersion
Transform: AWS::Serverless-2016-10-31

template.yml contains(native from repository):

AWSTemplateFormatVersion: '2010-09-09'
Transform: 'AWS::Serverless-2016-10-31'
Description: An AWS Lambda application that calls the Lambda API.
Resources:
  function:
    Type: AWS::Serverless::Function
    Properties:
      Handler: lambda_function.lambda_handler
      Runtime: python3.8
      CodeUri: function/.
      Description: Call the AWS Lambda API
      Timeout: 10
      # Function's execution role
      Policies:
        - AWSLambdaBasicExecutionRole
        - AWSLambdaReadOnlyAccess
        - AWSXrayWriteOnlyAccess
      Tracing: Active
      Layers:
        - !Ref libs
  libs:
    Type: AWS::Serverless::LayerVersion
    Properties:
      LayerName: blank-python-lib
      Description: Dependencies for the blank-python sample app.
      ContentUri: package/.
      CompatibleRuntimes:
        - python3.8

bucket-name.txt file, which was created on step with ./1-create-bucket.sh contains: lambda-artifacts-26c3674062aa40ab. Correcponding bucket was created on S3 service with script above.

My concern is: something is wrong with out.yml and template.yml

What must to contain the activate.bat file

I have been following the documentation here So, once I get my virtual environment done. I would like to know what should I set in the file activate.bat

path\to\my\virtual-env\Scripts\activate.bat

Or should I just create the file with that name and that's it? thanks. I don't know if here is the right place to really post this question.

Warning when using the policy with wildcard in Resource

Dear Colleagues,

when I use the following policy for example:

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublishLayers",
"Effect": "Allow",
"Action": [
"lambda:PublishLayerVersion"
],
"Resource": "arn:aws:lambda:::layer:test-"
},
{
"Sid": "ManageLayerVersions",
"Effect": "Allow",
"Action": [
"lambda:GetLayerVersion",
"lambda:DeleteLayerVersion"
],
"Resource": "arn:aws:lambda:
::layer:test-:*"
}
]
}

copied from the article -
https://docs.aws.amazon.com/lambda/latest/dg/access-control-identity-based.html

I receive a warning in AWS Console:

"This policy defines some actions, resources, or conditions that do not provide permissions. To grant access, policies must have an action that has an applicable resource or condition. For details, choose Show remaining Learn more"

When I inspect the warning i can see:

GetLayerVersion(No access)
This action does not have an applicable resource.

DeleteLayerVersion(No access)
This action does not have an applicable resource.

PublishLayerVersion(No access)
This action does not have an applicable resource.

where we can clearly see that we have a Resource specified;

When I place a Resource name that does not contains * the warning Disappears;

.Net Sample links incorrect

The links for the .Net SDK in the blank-csharp and ec2-spot projects are incorrectly pointing to the NodeJS release page. Will be providing a PR directly

Need to be clearer about installing Python packages with C++/DLL components

The Working with Python > Deployment Package page section on "Updating a function with additional dependencies" misses an important point that can confuse users:

Following these instructions to pip install --target ./package on your build environment only works if either:

  • Your target libraries are pure Python (or any bundled native dependencies are cross-platform), or
  • Your build environment architecture is similar to the Lambda runtime.

For example (a typical request), I cannot pip install --target ./package Pillow on my Mac, bundle that to a Lambda deployment package upload it. My Lambda will give an error message something like:

{
    "errorMessage": "Unable to import module 'lambda_function': Cannot import name '_imaging' from 'PIL' (/var/task/PIL/__init__.py)",
    "errorType": "Runtime.ImportModuleError"
}

...If I'm deep on Python packaging, I might trace that this is because the line from . import _imaging as core buried in the PIL source code will work on my machine (where it resolves _imaging.cpython-38-darwin.so included in the bundle) but fail on Amazon Linux (because the architecture doesn't match).

If I'm not, it will probably take me a long time to debug as I'll be looking for solutions specific to my library & runtimes!

Please consider adding a caution on this (perhaps mentioning some popular libraries like PIL/Pillow which bundle architecture-specific components), and some discussion on workarounds such as:

  • Creating the bundle (or at least the packaging part) on a compatible environment e.g. an EC2 instance, a SageMaker Notebook, etc)
  • Using the AWS SAM CLI on your local machine with the --container option, so that SAM sets up a Docker container with a Lambda-like environment for you and simplifies the process.

Thanks!

Document that certain APIs don't work across accounts

The documentation says this:

You can grant cross-account access for any API action that operates on an existing function. For example, you could grant access to lambda:ListAliases to let an account get a list of aliases, or lambda:GetFunction to let them download your function code. Add each permission separately, or use lambda:* to grant access to all actions for the specified function.

That would suggest that all actions on this page that operate on the function resource, except for CreateFunction, can work across accounts.

From my testing, in practice that list appears to be more restrictive. AddPermission, DeletePermission, and UpdateFunctionConfiguration at least also don't seem to allow me to use them across accounts.

.NET 5 - Unable to start Kestrel - System.Net.Sockets.SocketException (13): Permission denied

Hi I can't start net 5 function, detail error in cloudwatch like below:

==========================================

2021-01-02T15:32:01.708+08:00 - ๏ฟฝ[41m๏ฟฝ[1m๏ฟฝ[37mcrit๏ฟฝ[39m๏ฟฝ[22m๏ฟฝ[49m: Microsoft.AspNetCore.Server.Kestrel[0]
-- - --
ย  - 2021-01-02T15:32:01.708+08:00 - Unable to start Kestrel.
ย  - 2021-01-02T15:32:01.708+08:00 - System.Net.Sockets.SocketException (13): Permission denied
ย  - 2021-01-02T15:32:01.708+08:00 - at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
ย  - 2021-01-02T15:32:01.708+08:00 - at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
ย  - 2021-01-02T15:32:01.708+08:00 - at System.Net.Sockets.Socket.Bind(EndPoint localEP)
ย  - 2021-01-02T15:32:01.708+08:00 - at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.<Bind>g__BindSocket\|13_0(<>c__DisplayClass13_0& )
ย  - 2021-01-02T15:32:01.708+08:00 - at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
ย  - 2021-01-02T15:32:01.708+08:00 - at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
ย  - 2021-01-02T15:32:01.708+08:00 - at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.TransportManager.BindAsync(EndPoint endPoint, ConnectionDelegate connectionDelegate, EndpointConfig endpointConfig)
ย  - 2021-01-02T15:32:01.708+08:00 - at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.<>c__DisplayClass29_0`1.<<StartAsync>g__OnBind\|0>d.MoveNext()

==========================================

I use docker container to build the app, docker configuration like below:

`FROM public.ecr.aws/lambda/dotnet:5.0 AS base
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:5.0-buster-slim AS build

WORKDIR /src
COPY StaviStudentRegistration.sln ./

COPY Stavi.Student.Registration.API/*.csproj ./Stavi.Student.Registration.API/

RUN dotnet clean
RUN dotnet restore

COPY . .

WORKDIR /src/Stavi.Student.Registration.API
RUN dotnet build -c Release -o /app/publish

FROM build AS publish
RUN dotnet publish \
    --configuration Release \ 
    --runtime linux-x64 \
    --output /app/publish \
    -p:PublishReadyToRun=true 

FROM base AS final
WORKDIR /usr/secret
COPY Secret/secret.json .

#for security reason, I hide the env name
ENV XXX=/usr/secret/secret.json

WORKDIR /var/task
COPY --from=publish /app/publish .

ENTRYPOINT ["/var/lang/bin/dotnet", "Stavi.Student.Registration.API.dll"]`

Here my program.cs :

public class Program
    {
        public static void Main(string[] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string[] args) =>
            Host.CreateDefaultBuilder(args)
                .ConfigureWebHostDefaults(webBuilder =>
                {
                    webBuilder.ConfigureKestrel(option =>
                    {
                        option.ListenAnyIP(80);
                    });

                    webBuilder.UseStartup<Startup>();
                });
    }

Here my startup.cs:

public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new OpenApiInfo { Title = "Stavi.StudentRegistration.API", Version = "v1" });
            });

            services.InitiateThirdParty();
            services.AddDependency();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "Stavi.StudentRegistration.API v1"));
            }

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }

I don't have any idea how to fix this, can someone help me? thank you..

Go runtime on Amazon Linux 2 is not documented

Hi,
Recently, Go runtime on Amazon Linux 2 is announced.
https://aws.amazon.com/about-aws/whats-new/2020/08/aws-lambda-supports-go-amazon-linux-2/

But, I can't find Amazon Linux 2 in the Go runtimes section.

https://github.com/awsdocs/aws-lambda-developer-guide/blame/0168ba0ea389592df2e41f9666850c4fa79ac6f1/doc_source/lambda-golang.md#L8-L10

The announce says that select provided.al2 ("provide your own bootstrap on Amazon Linux 2 runtime") to use Go runtime on Amazon Linux 2, but the example of deployment package still uses the go1.x runtime that is on Amazon Linux.

https://github.com/awsdocs/aws-lambda-developer-guide/blame/main/doc_source/golang-package.md#L21-L26

Where can I found the documents about Go runtime on Amazon Linux 2?

Lambda is given additional permissions than required

Lambda is given the permissions via the AWSLambdaExecute Policy which gives access to all the S3 buckets in the current AWS Account. The Lambda simply needs s3:GetObject permissions on the input S3 bucket and the s3:PutObject permissions on the output S3 bucket.

I have given this page as a reference to a lot many and they might be blindly following the documentation to give the unnecessary permissions to the Lambda. So, is this Issue.

Go Runtime does not support extension API

I saw the release of AppConfig, and jumped on it to use it on my go lambdas to replace my environment variables.
I followed the tutorial on https://docs.aws.amazon.com/appconfig/latest/userguide/appconfig-integration-lambda-extensions.html.
I pushed my Go lambda with the new layer, just to realise that my AppConfig extension was never called ... ( I tested with python it works great)

Then I read the list of supported runtime, and go seems to be not included.

It seems that all language are supported even CustomRuntime, so I don't get why go is not supported.
Would it mean I have to run my go lambda on a CustomRuntime (provided.al2)?

Also if you can share why go is left alone, that would be great !

Thks a lot,
Thomas.

issues with blank-nodejs

I had trouble doing the tutorial for blank-nodejs.

First, it didn't work with AWS CLI v1. Step 3 (./3-deploy.sh) failed as the command aws cloudformation wasn't supported. So I updated to CLI v2.

Then on the Invoke step (./4-invoke.sh), I got the following response, which doesn't match the results listed in the tutorial:

Invalid base64: "{
  "Records": [
    {
      "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
      "receiptHandle": "MessageReceiptHandle",
      "body": "Hello from SQS!",
      "attributes": {
        "ApproximateReceiveCount": "1",
        "SentTimestamp": "1523232000000",
        "SenderId": "123456789012",
        "ApproximateFirstReceiveTimestamp": "1523232000001"
      },
      "messageAttributes": {},
      "md5OfBody": "7b270e59b47ff90a553787216d55d91d",
      "eventSource": "aws:sqs",
      "eventSourceARN": "arn:aws:sqs:us-west-2:123456789012:MyQueue",
      "awsRegion": "us-west-2"
    }
  ]
}
"

So then I ran the tests:

./0-run-tests.sh
Installing libraries...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 539 packages from 416 contributors and audited 540 packages in 11.206s

12 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


> [email protected] test /development/aws-lambda-developer-guide/sample-apps/blank-nodejs
> jest

 PASS  function/index.test.js
  โœ“ Runs function handler (97ms)

  console.log
    Hello from SQS!

      at forEach (function/index.js:10:13)
          at Array.forEach (<anonymous>)

  console.log
    ## ENVIRONMENT VARIABLES: {
      "LESSOPEN": "| /usr/bin/lesspipe %s",
      "npm_package_devDependencies_aws_sdk": "2.631.0",
      "npm_package_dependencies_aws_xray_sdk_core": "1.1.2",
      "npm_config_cache_lock_stale": "60000",
      "npm_config_ham_it_up": "",
      "CURL_CA_BUNDLE": "/opt/bitnami/common/openssl/certs/curl-ca-bundle.crt",
      "npm_config_legacy_bundling": "",
      "npm_config_sign_git_tag": "",
      "MAIL": "/var/mail/scott",
      "SSH_CLIENT": "97.118.111.213 51125 22",
      "USER": "scott",
      "BITNAMI_ROOT": "/opt/bitnami",
      "LANGUAGE": "en_US.UTF-8",
      "GIT_TEMPLATE_DIR": "/opt/bitnami/git/share/git-core/templates",
      "SASL_CONF_PATH": "/opt/bitnami/common/etc",
      "npm_package_devDependencies_jest": "25.4.0",
      "npm_config_user_agent": "npm/6.14.5 node/v12.14.1 linux x64",
      "npm_config_always_auth": "",
      "FONTCONFIG_PATH": "/opt/bitnami/common/etc/fonts",
      "GIT_EXEC_PATH": "/opt/bitnami/git/libexec/git-core/",
      "SASL_PATH": "/opt/bitnami/common/lib/sasl2",
      "CXXFLAGS": "-I/opt/bitnami/common/include -I/opt/bitnami/common/include ",
      "npm_config_bin_links": "true",
      "npm_config_key": "",
      "npm_config_allow_same_version": "",
      "npm_config_description": "true",
      "npm_config_fetch_retries": "2",
      "npm_config_heading": "npm",
      "npm_config_if_present": "",
      "npm_config_init_version": "1.0.0",
      "npm_config_user": "",
      "npm_node_execpath": "/opt/bitnami/nodejs/bin/.node.bin",
      "SHLVL": "2",
      "LD_LIBRARY_PATH": "/opt/bitnami/redis/lib:/opt/bitnami/python/lib:/opt/bitnami/git/lib:/opt/bitnami/apache2/lib:/opt/bitnami/common/lib:/opt/bitnami/common/lib64",
      "GIT_SSL_CAINFO": "/opt/bitnami/common/openssl/certs/curl-ca-bundle.crt",
      "LDAPCONF": "/opt/bitnami/common/etc/openldap/ldap.conf",
      "npm_config_prefer_online": "",
      "npm_config_noproxy": "",
      "HOME": "/home/scott",
      "TERMINFO": "/opt/bitnami/common/share/terminfo",
      "npm_config_force": "",
      "SSH_TTY": "/dev/pts/0",
      "npm_config_only": "",
      "npm_config_read_only": "",
      "npm_config_cache_min": "10",
      "npm_config_init_license": "ISC",
      "LDFLAGS": "-L/opt/bitnami/common/lib -L/opt/bitnami/common/lib ",
      "npm_config_editor": "vi",
      "npm_config_rollback": "true",
      "npm_config_tag_version_prefix": "v",
      "SSL_CERT_FILE": "/opt/bitnami/common/openssl/certs/curl-ca-bundle.crt",
      "OPENSSL_ENGINES": "/opt/bitnami/common/lib/engines",
      "npm_config_cache_max": "Infinity",
      "npm_config_timing": "",
      "npm_config_userconfig": "/home/scott/.npmrc",
      "npm_config_engine_strict": "",
      "npm_config_init_author_name": "",
      "npm_config_init_author_url": "",
      "npm_config_preid": "",
      "npm_config_tmp": "/tmp",
      "npm_package_description": "This sample application is a Lambda function that calls the Lambda API. It shows the use of logging, environment variables, AWS X-Ray tracing, layers, unit tests and the AWS SDK. You can use it to learn about Lambda features or use it as a starting point for your own projects.",
      "npm_config_depth": "Infinity",
      "npm_config_package_lock_only": "",
      "npm_config_save_dev": "",
      "npm_config_usage": "",
      "npm_package_readmeFilename": "README.md",
      "npm_config_metrics_registry": "https://registry.npmjs.org/",
      "npm_config_cafile": "",
      "npm_config_otp": "",
      "npm_config_package_lock": "true",
      "npm_config_progress": "true",
      "npm_config_https_proxy": "",
      "npm_config_save_prod": "",
      "npm_config_audit": "true",
      "npm_config_cidr": "",
      "npm_config_onload_script": "",
      "npm_config_sso_type": "oauth",
      "LOGNAME": "scott",
      "npm_config_rebuild_bundle": "true",
      "npm_config_save_bundle": "",
      "npm_config_shell": "/bin/bash",
      "_": "/opt/bitnami/nodejs/bin/npm",
      "npm_package_private": "true",
      "npm_config_dry_run": "",
      "npm_config_format_package_lock": "true",
      "npm_config_prefix": "/opt/bitnami/nodejs",
      "MAGICK_CONFIGURE_PATH": "/opt/bitnami/common/lib/ImageMagick-6.9.8/config-Q16:/opt/bitnami/common/",
      "OPENSSL_CONF": "/opt/bitnami/common/openssl/openssl.cnf",
      "PKG_CONFIG_PATH": "/opt/bitnami/common/lib64/pkgconfig:/opt/bitnami/common/lib/pkgconfig",
      "npm_config_scope": "",
      "npm_config_browser": "",
      "npm_config_cache_lock_wait": "10000",
      "npm_config_ignore_prepublish": "",
      "npm_config_registry": "https://registry.npmjs.org/",
      "npm_config_save_optional": "",
      "npm_config_searchopts": "",
      "npm_config_versions": "",
      "XDG_SESSION_ID": "195",
      "TERM": "xterm",
      "npm_config_cache": "/home/scott/.npm",
      "npm_config_proxy": "",
      "npm_config_send_metrics": "",
      "npm_config_global_style": "",
      "npm_config_ignore_scripts": "",
      "npm_config_version": "",
      "npm_config_local_address": "",
      "npm_config_viewer": "man",
      "npm_config_node_gyp": "/opt/bitnami/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",
      "PATH": "/opt/bitnami/nodejs/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/development/aws-lambda-developer-guide/sample-apps/blank-nodejs/node_modules/.bin:/home/scott/bin:/home/scott/.local/bin:/opt/bitnami/redis/bin:/opt/bitnami/python/bin:/opt/bitnami/nodejs/bin:/opt/bitnami/git/bin:/opt/bitnami/letsencrypt/:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:/opt/bitnami/redis/bin:/opt/bitnami/python/bin:/opt/bitnami/nodejs/bin:/opt/bitnami/git/bin:/opt/bitnami/letsencrypt/:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
      "npm_package_name": "blank-nodejs",
      "npm_config_audit_level": "low",
      "npm_config_prefer_offline": "",
      "NODE": "/opt/bitnami/nodejs/bin/.node.bin",
      "XDG_RUNTIME_DIR": "/run/user/1001",
      "CFLAGS": "-I/opt/bitnami/common/include/ImageMagick -I/opt/bitnami/common/include -I/opt/bitnami/common/include/ImageMagick -I/opt/bitnami/common/include ",
      "npm_config_color": "true",
      "npm_config_sign_git_commit": "",
      "MAGICK_CODER_MODULE_PATH": "/opt/bitnami/common/lib/ImageMagick-6.9.8/modules-Q16/coders",
      "npm_config_fetch_retry_mintimeout": "10000",
      "npm_config_maxsockets": "50",
      "npm_config_offline": "",
      "npm_config_sso_poll_frequency": "500",
      "LANG": "en_US.UTF-8",
      "MAGICK_HOME": "/opt/bitnami/common",
      "npm_config_umask": "0002",
      "LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:",
      "npm_config_fund": "true",
      "npm_config_fetch_retry_maxtimeout": "60000",
      "npm_config_loglevel": "notice",
      "npm_config_logs_max": "10",
      "npm_config_message": "%s",
      "npm_lifecycle_script": "jest",
      "npm_package_scripts_test": "jest",
      "npm_config_ca": "",
      "npm_config_cert": "",
      "npm_config_global": "",
      "npm_config_link": "",
      "SHELL": "/bin/bash",
      "NODE_PATH": "/opt/bitnami/nodejs/lib/node_modules",
      "npm_package_version": "1.0.0",
      "npm_config_access": "",
      "npm_config_also": "",
      "npm_config_save": "true",
      "npm_config_unicode": "true",
      "npm_lifecycle_event": "test",
      "AWS_REGION": "us-east-2",
      "npm_config_argv": "{\"remain\":[],\"cooked\":[\"run\",\"test\"],\"original\":[\"run\",\"test\"]}",
      "npm_config_before": "",
      "npm_config_long": "",
      "npm_config_production": "",
      "npm_config_searchlimit": "20",
      "npm_config_unsafe_perm": "true",
      "npm_config_update_notifier": "true",
      "LESSCLOSE": "/usr/bin/lesspipe %s %s",
      "npm_config_auth_type": "legacy",
      "npm_config_node_version": "12.14.1",
      "npm_config_tag": "latest",
      "npm_config_git_tag_version": "true",
      "npm_config_commit_hooks": "true",
      "npm_config_script_shell": "",
      "npm_config_shrinkwrap": "true",
      "npm_config_fetch_retry_factor": "10",
      "npm_config_save_exact": "",
      "npm_config_strict_ssl": "true",
      "npm_config_dev": "",
      "npm_config_globalconfig": "/opt/bitnami/nodejs/etc/npmrc",
      "npm_config_init_module": "/home/scott/.npm-init.js",
      "npm_config_parseable": "",
      "LC_ALL": "en_US.UTF-8",
      "PWD": "/development/aws-lambda-developer-guide/sample-apps/blank-nodejs",
      "npm_config_globalignorefile": "/opt/bitnami/nodejs/etc/npmignore",
      "npm_execpath": "/opt/bitnami/nodejs/lib/node_modules/npm/bin/npm-cli.js",
      "SSH_CONNECTION": "97.118.111.213 51125 172.31.20.187 22",
      "XDG_DATA_DIRS": "/usr/local/share:/usr/share:/var/lib/snapd/desktop",
      "npm_config_cache_lock_retries": "10",
      "npm_config_searchstaleness": "900",
      "npm_config_node_options": "",
      "npm_config_save_prefix": "^",
      "npm_config_scripts_prepend_node_path": "warn-only",
      "npm_config_group": "1003",
      "npm_config_init_author_email": "",
      "npm_config_searchexclude": "",
      "npm_config_git": "git",
      "npm_config_optional": "true",
      "npm_config_json": "",
      "INIT_CWD": "/development/aws-lambda-developer-guide/sample-apps/blank-nodejs",
      "NODE_ENV": "test",
      "JEST_WORKER_ID": "1"
    }

      at Object.handler (function/index.js:12:11)

  console.log
    ## CONTEXT: null

      at Object.handler (function/index.js:13:11)

  console.log
    ## EVENT: {
      "Records": [
        {
          "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
          "receiptHandle": "MessageReceiptHandle",
          "body": "Hello from SQS!",
          "attributes": {
            "ApproximateReceiveCount": "1",
            "SentTimestamp": "1523232000000",
            "SenderId": "123456789012",
            "ApproximateFirstReceiveTimestamp": "1523232000001"
          },
          "messageAttributes": {},
          "md5OfBody": "7b270e59b47ff90a553787216d55d91d",
          "eventSource": "aws:sqs",
          "eventSourceARN": "arn:aws:sqs:us-west-2:123456789012:MyQueue",
          "awsRegion": "us-west-2"
        }
      ]
    }

      at Object.handler (function/index.js:14:11)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.895s
Ran all test suites.

Upload multiple functions

How would I deploy multiple functions using cloudformation? I tried changing the name of the function but it just updated the old lambda function instead of creating a new one

managing the stages

How can I manage multiple stages with this CICD-guide. I want to have one development-part and one production-part (production-stage should execute only after manual approval). Please throw some light on this.

Bug in s3-java example

S3-java example to rename file uses incorrect destination bucket name here: https://github.com/awsdocs/aws-lambda-developer-guide/blob/master/sample-apps/s3-java/src/main/java/example/Handler.java#L54

It should be:
String dstBucket = srcBucket + "-resized";

Otherwise it ends up using srcBucket as desBucket and Lambda function runs in loop causing below error:
If your Lambda function uses the same bucket that triggers it, it could cause the function to execute in a loop. For example, if the bucket triggers a function each time an object is uploaded, and the function uploads an object to the bucket, then the function indirectly triggers itself. To avoid this, use two buckets, or configure the trigger to only apply to a prefix used for incoming objects.

dynamodb:ListShard permission is missing from the lambda Execution Role

Request:
Update the permissions required on the lambda execution role in the documentaion here to include dynamodb:ListShards action.

Issue:

Currently, the documentation related to lambda Execution Role Permissions to manage resources related to DynamoDB streams stream mentions the following permissions:

dynamodb:DescribeStream
dynamodb:GetRecords
dynamodb:GetShardIterator
dynamodb:ListStreams

However, when using these permissions itself, the creation of AWS::Lambda::EventSourceMapping resource is failing with the following error: Invalid request provided: Cannot access stream <Stream ARN>. Please ensure the role can perform the GetRecords, GetShardIterator, DescribeStream, ListShards, and ListStreams Actions on your stream in IAM. (Service: Lambda, Status Code: 400)

From the above error message, it is clear that the dynamodb:ListShards permission is also required to create EventSourceMapping resource. Providing this permission on the lambda execution role has fixed the error.

I would request to update the documentation to include the dynamodb:ListShards permission in order to avoid confusion.

AWS Lambda and Log4j2

I have an AWS Lambda Function, when executed gives errors related to reading Log4j2 file on cloudWatch.
I have log4j2 configuration related to AWS Lambda Logging

@mwunderl Could you please help me resolve the below error

2019-10-01 14:39:54,029 main ERROR Error processing element Lambda: CLASS_NOT_FOUND
2019-10-01 14:39:54,031 main ERROR Unable to locate plugin type for Lambda
2019-10-01 14:39:54,054 main ERROR Unable to locate plugin for Lambda
2019-10-01 14:39:54,056 main ERROR Unable to invoke factory method in class org.apache.logging.log4j.core.config.AppendersPlugin for element Appenders: java.lang.NullPointerException java.lang.NullPointerException
.
.
.
.
2019-10-01 14:39:55,839 main ERROR AppenderRef contains an invalid element or attribute "_ref"
2019-10-01 14:39:55,840 main ERROR Appender references must contain a reference
2019-10-01 14:39:55,893 main ERROR Null object returned for AppenderRef in Root.
2019-10-01 14:39:55,894 main ERROR Root contains an invalid element or attribute "_level"
2019-10-01 14:39:59,837 main ERROR Error processing element Lambda: CLASS_NOT_FOUND

Here is my Log4j2.YAML Configuration

Configuration:
 Appenders:
  Lambda:
   PatternLayout:
    pattern: "%d{yyyy-MM-dd HH:mm:ss} %X{AWSRequestId} %-5p %c{1}:%L - %m%n"
   _name: Lambda
 Loggers:
  Root:
   AppenderRef:
    _ref: Lambda
   _level: info
 _packages: "com.amazonaws.services.lambda.runtime.log4j2"

Here is my Maven POM for Logging Dependencies

        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-lambda-java-log4j2</artifactId>
            <version>1.0.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
            <version>2.12.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-api</artifactId>
            <version>2.12.0</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.12.0</version>
        </dependency>

        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>1.25</version>
        </dependency>
        
       <dependency>
            <groupId>com.fasterxml.jackson.dataformat</groupId>
            <artifactId>jackson-dataformat-yaml</artifactId>
            <version>2.9.9</version>
        </dependency>

        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.9.9</version>
        </dependency>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.1</version>
                <configuration>
                    <createDependencyReducedPom>false</createDependencyReducedPom>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>**/Log4j2Plugins.dat</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Java Logging with Lambda and Log4j2 appender has a bug

The Bug is that if you follow the instructions logging does not work instead you get

2018-04-23 14:04:19,908 main ERROR Error processing element Lambda ([Appenders: null]): CLASS_NOT_FOUND
2018-04-23 14:04:19,926 main ERROR Unable to locate appender "Lambda" for logger config "root"

Many requests on Stackoverflow suggest that people are having trouble with this.

I have fixed the issue in a Pull request here:- PR #27 please merge it. thanks

in sample-apps/blank-java/ slf4j logger is not working with current configuration when building using Gradle

Hi,
The Gradle file included in the project is not adequate for the code to compile.
The error lies in the following line:

runtimeOnly 'org.apache.logging.log4j:log4j-slf4j18-impl:2.13.0'

When this line is changed to

implemenation 'org.apache.logging.log4j:log4j-slf4j18-impl:2.13.0'
then the code compiles but then I get the following logs in CloudWacth:

START RequestId: 8096f26f-13be-4c90-9a79-41d5b46f5f4b Version: $LATEST
WARNING: sun.reflect.Reflection.getCallerClass is not supported. This will impact performance.
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [d]
ERROR StatusLogger Unrecognized conversion specifier [d] starting at position 16 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [thread]
ERROR StatusLogger Unrecognized conversion specifier [thread] starting at position 25 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [level]
ERROR StatusLogger Unrecognized conversion specifier [level] starting at position 35 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [logger]
ERROR StatusLogger Unrecognized conversion specifier [logger] starting at position 47 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [msg]
ERROR StatusLogger Unrecognized conversion specifier [msg] starting at position 54 in conversion pattern.
ERROR StatusLogger Unrecognized format specifier [n]
ERROR StatusLogger Unrecognized conversion specifier [n] starting at position 56 in conversion pattern.
END RequestId: 8096f26f-13be-4c90-9a79-41d5b46f5f4b
REPORT RequestId: 8096f26f-13be-4c90-9a79-41d5b46f5f4b	Duration: 274.86 ms	Billed Duration: 300 ms	Memory Size: 1400 MB	Max Memory Used: 123 MB	Init Duration: 1375.39 ms	

The configuration file (src/main/resources/log4j2.xml) is the following:

<Configuration status="info">
  <Appenders>
    <Lambda name="Lambda">
      <PatternLayout>
        <pattern>%%m%n</pattern>
      </PatternLayout>
    </Lambda>
  </Appenders>
  <Loggers>
    <Root level="INFO">
      <AppenderRef ref="Lambda"/>
    </Root>
    <Logger name="software.amazon.awssdk" level="INFO" />
    <Logger name="software.amazon.awssdk.request" level="INFO" />
  </Loggers>
</Configuration>

issue with blank-java

there is no policy name 'AWSXrayWriteOnlyAccess' so that run deply.sh will be failed

sample-apps - CLI v2 Invalid base64 error on lambda invoke

The AWS CLI v2 has a breaking change in which it treats a file:// CLI option as base64-encoded text.
https://docs.aws.amazon.com/cli/latest/userguide/cliv2-migration.html#cliv2-migration-binaryparam

This breaks the 4-invoke.sh script lambda invoke call.

aws lambda invoke --function-name $FUNCTION --payload file://event.json out.json

One fix is to add the argument --cli-binary-format raw-in-base64-out which reverts the call back to CLI v1 behavior.

Node.js 8.xx update deprecation clarification

I believe it's possible to at least update a node.js 8.xx RUNTIME past it's update deprecation date.

So customers won't need to re-create a new lambda, just simply go in and update the runtime.

Runtime OS references out of date?

Printing os.uname() in a new Python 3.6 Lambda function in ap-southeast-1 today, I got output of:

os.uname(): posix.uname_result(sysname='Linux', nodename='169.254.252.45', release='4.14.165-102.205.amzn2.x86_64', version='#1 SMP Fri Feb 14 22:46:57 UTC 2020', machine='x86_64')

As I understood the amzn2 in the release meant it's an AL2 system right? Not AL1 as documented on the Lambda Runtimes page

Fix python package steps

In the creating a package for function with dependencies (ref), the command series to create the package do not work

Steps to reproduce

Following the same steps as the current docs

  • pip install --target ./package requests
  • zip -r my-deployment-package.zip ./package/

Produce a zip file with the "package" folder containing the dependencies

unzip -l my-deployment-package.zip
Archive:  my-deployment-package.zip
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2020-12-30 08:06   package/
        0  2020-12-30 08:06   package/chardet/
...
        4  2020-12-30 08:06   package/requests-2.25.1.dist-info/INSTALLER
     2330  2020-12-30 08:06   package/requests-2.25.1.dist-info/RECORD
    10142  2020-12-30 08:06   package/requests-2.25.1.dist-info/LICENSE
        0  2020-12-30 08:06   package/idna-2.10.dist-info/
     9104  2020-12-30 08:06   package/idna-2.10.dist-info/METADATA
      110  2020-12-30 08:06   package/idna-2.10.dist-info/WHEEL
        5  2020-12-30 08:06   package/idna-2.10.dist-info/top_level.txt
        4  2020-12-30 08:06   package/idna-2.10.dist-info/INSTALLER
     1565  2020-12-30 08:06   package/idna-2.10.dist-info/LICENSE.rst
     1212  2020-12-30 08:06   package/idna-2.10.dist-info/RECORD
---------                     -------
  3753712                     273 files

Therefore the following python module lambda_function.py is unable to do import requests once loaded to lambda.

import requests

def lambda_handler(event, context):
    print("Test")

Testing produces

[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'requests'

Fix

  • As per man zip the only option to discard paths (-j) discards all and is not proper
  • The same steps are proposed as for virtualenv to fix this (ref)

permission denied PathError

I'm getting the following error on Windows running 3-invoke.sh in the blank-go sample :

{
    "StatusCode": 200,
    "FunctionError": "Unhandled",
    "ExecutedVersion": "$LATEST"
}
{"errorMessage":"fork/exec /var/task/main: permission denied","errorType":"PathError"}

CLI version: aws-cli/2.0.51 Python/3.7.7 Windows/10 exe/AMD64

The only non-standard thing I've done is added the following to my ~/.aws.config file:

cli_binary_format=raw-in-base64-out

Python 3.7 is missing PYTHONPATH

We recently discovered that in the python3.7 runtime, PYTHONPATH is missing. Not sure if this is a gap in the doc or a bug on the lambda side. Anyone has any idea?

Contradiction on SQS event source.

The first link specifies that the SQS event source is Poll based and is invoked synchronously (like kinesis streams event sources), however the second link says that SQS is async based for the purposes of error handling (like the sns event source). These appear to contradict each other.
This should ideally be clarified before the SQS event source is launched.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.