gkrizek / bash-lambda-layer

Run Bash scripts in AWS Lambda via Layers
MIT License
428 stars 89 forks source link

Lambda executes in loop #24

Closed rjain07 closed 5 years ago

rjain07 commented 5 years ago

Hello, I enabled layer using the method discussed on this git and am trying to execute bunch of shell scripts (.sh files) that are stored in s3 bucket. I am first copying file from s3 into /tmp folder in Lambda and then trying to execute script using /bin/bash command. I am able to get the results but lambda seems to execute in loop for complete 5 minutes and running command multiple times. That is not the behavior when I use Python Boto3. How do we stop processing and come out once all commands are executed. Following is what my script looks like.

handler () { set -e

aws s3 cp s3://my-bucket/my-folder/download-from-other.sh /tmp/download-from-other.sh aws s3 cp s3://my-bucket/my-folder/upload-to-s3.sh /tmp/upload-to-s3.sh aws s3 cp s3://my-bucket/my-folder/create-emr-stack.sh /tmp/create-emr-stack.sh

cd /tmp ls -l

/bin/bash download-from-other.sh
/bin/bash upload-to-s3.sh /bin/bash create-emr-stack.sh

echo "{"success": true}" >&2

}

gkrizek commented 5 years ago

That's odd it loops. I'm not sure what could be causing that. Have you tried simply exiting manually after it's done. For example:

  echo "{"success": true}" >&2
  exit 0
}

Also do you think there's anything inside your scripts that could cause that?

rjain07 commented 5 years ago

I tried exit, quit, etc., without any luck. I also don't have anything that should run scrip in loop. Like I removed everything and ran simple aws s3 copy command inside my handler, but it still loops through.

gkrizek commented 5 years ago

This is still a mystery to me. I can't reproduce it. What are you setting on your Lambda?

rjain07 commented 5 years ago

I had regular settings on lambda. In fact I removed everything from handler and just had couple of S3 copy functions. But it was still going in loop and taking full 5 minutes before terminated.

I would say if you are not able to reproduce then please don’t spend much time on this. I have changed my approach little bit and using serverless to deploy my lambda now.

Thanks for looking in to this issue.

-Ritesh

On Aug 6, 2019, at 11:17 PM, Graham Krizek notifications@github.com<mailto:notifications@github.com> wrote:

This is still a mystery to me. I can't reproduce it. What are you setting on your Lambda?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/gkrizek/bash-lambda-layer/issues/24?email_source=notifications&email_token=AMBJMUJP37XAWFSJVRFEHYTQDI5FHA5CNFSM4HMTCAQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3XCHVQ#issuecomment-518923222, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMBJMUO3SP7I5JSY5DGMJOTQDI5FHANCNFSM4HMTCAQQ.

gkrizek commented 5 years ago

Closing this as it's stale and can't reproduce. If we have more details or context we can revisit.