Thanks to visit codestin.com
Credit goes to github.com

Skip to content

PRO:Unable to trigger Lambda through SNS #2968

Closed
@ashameem123

Description

@ashameem123

Type of request: This is a ...

[ ] bug report

Detailed description

Trying to trigger an event from S3 to SNS which is connected to lambda. (Once SNS receives an event from S3, lambda should trigger)
...

Expected behavior

After uploading a file on S3, an event should be received by SNS topic and Lambda should trigger

...

Actual behavior

Lambda isn't triggering and getting an exception/failure
...

Steps to reproduce

docker-compose up -d

  1. Create Bucket->
    aws --endpoint-url=http://localhost:4566 s3 mb s3://test-bucket-sns

  2. Create Topic->
    aws sns create-topic --name putnotifications --endpoint-url=http://localhost:4575

  3. Subscribe to the topic-> (NOT NECESSARY)
    aws --endpoint-url=http://localhost:4575 sns subscribe --topic-arn arn:aws:sns:us-east-1:000000000000:putnotifications --protocol email --notification-endpoint [email protected]

  4. PUT Notification->
    aws s3api put-bucket-notification-configuration --bucket test-bucket-sns --notification-configuration file://snsTopicConfiguration.json --endpoint-url=http://localhost:4566

  5. Create Function->
    aws lambda create-function --endpoint-url=http://localhost:4574 --function-name SQSdemo --runtime java11 --handler com.aws.lamda.SQSdemo --zip-file fileb://C:/AWS/Localstack/aws-lambda-example/target/aws-labmda-example-1.0-SNAPSHOT.jar --role arn:aws:iam::1234567:role/anything --environment Variables="{PROFILE=LOCAL,AWS_REGION=us-east-1}"

  6. Subscribe lambda to Topic:
    aws sns subscribe --topic-arn arn:aws:sns:us-east-1:000000000000:putnotifications --protocol lambda --notification-endpoint arn:aws:lambda:us-east-1:000000000000:function:SQSdemo --endpoint-url=http://localhost:4575

  7. upload a file in s3:
    aws s3 cp s3-event.json s3://test-bucket-sns --endpoint-url=http://localhost:4566

snsTopicConfiguration.json -
{
"TopicConfigurations": [
{
"TopicArn": "arn:aws:sns:us-east-1:000000000000:putnotifications",
"Events": [
"s3:ObjectCreated:*"
]
}
]
}

Docker file:
version: '2.1'

services:
localstack:
container_name: "${LOCALSTACK_DOCKER_NAME-localstack_main111}"
image: localstack/localstack:latest
ports:
- "4566-4599:4566-4599"
- "${PORT_WEB_UI-8081}:${PORT_WEB_UI-8080}"
environment:
- SERVICES=${SERVICES- }
##- DEBUG=${DEBUG- }
- DEBUG=1
- DATA_DIR=${DATA_DIR- }
- PORT_WEB_UI=${PORT_WEB_UI- }
- LAMBDA_EXECUTOR=docker
- KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
- DOCKER_HOST=unix:///var/run/docker.sock
- LAMBDA_DOCKER_NETWORK=aws-lambda-example_default
- HOST_TMP_FOLDER=${TMPDIR}
volumes:
- "${TMPDIR:-/tmp/localstack}:/tmp/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"

Error i am receiving is:
LambdaException

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions