Giter VIP home page Giter VIP logo

aws_lambda_function's People

Contributors

prabhakar2020 avatar

Stargazers

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

Watchers

 avatar  avatar

aws_lambda_function's Issues

error

error message
Test Event Name
deploy

Response
{
"errorMessage": "An error occurred (404) when calling the HeadObject operation: Not Found",
"errorType": "ClientError",
"requestId": "9c60ff97-5c61-4046-a240-f84677271370",
"stackTrace": [
" File "/var/task/lambda_function.py", line 16, in lambda_handler\n s3.meta.client.copy(copy_source, tgt_bucket_path, tgt_file_name)\n",
" File "/var/runtime/boto3/s3/inject.py", line 380, in copy\n return future.result()\n",
" File "/var/runtime/s3transfer/futures.py", line 103, in result\n return self._coordinator.result()\n",
" File "/var/runtime/s3transfer/futures.py", line 266, in result\n raise self._exception\n",
" File "/var/runtime/s3transfer/tasks.py", line 269, in _main\n self._submit(transfer_future=transfer_future, **kwargs)\n",
" File "/var/runtime/s3transfer/copies.py", line 118, in _submit\n response = call_args.source_client.head_object(\n",
" File "/var/runtime/botocore/client.py", line 391, in _api_call\n return self._make_api_call(operation_name, kwargs)\n",
" File "/var/runtime/botocore/client.py", line 719, in _make_api_call\n raise error_class(parsed_response, operation_name)\n"
]
}

Function Logs
START RequestId: 9c60ff97-5c61-4046-a240-f84677271370 Version: $LATEST
[ERROR] ClientError: An error occurred (404) when calling the HeadObject operation: Not Found
Traceback (most recent call last):
  File "/var/task/lambda_function.py", line 16, in lambda_handler
    s3.meta.client.copy(copy_source, tgt_bucket_path, tgt_file_name)
  File "/var/runtime/boto3/s3/inject.py", line 380, in copy
    return future.result()
  File "/var/runtime/s3transfer/futures.py", line 103, in result
    return self._coordinator.result()
  File "/var/runtime/s3transfer/futures.py", line 266, in result
    raise self._exception
  File "/var/runtime/s3transfer/tasks.py", line 269, in _main
    self._submit(transfer_future=transfer_future, **kwargs)
  File "/var/runtime/s3transfer/copies.py", line 118, in _submit
    response = call_args.source_client.head_object(
  File "/var/runtime/botocore/client.py", line 391, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/var/runtime/botocore/client.py", line 719, in _make_api_call
    raise error_class(parsed_response, operation_name)END RequestId: 9c60ff97-5c61-4046-a240-f84677271370
REPORT RequestId: 9c60ff97-5c61-4046-a240-f84677271370 Duration: 2095.08 ms Billed Duration: 2096 ms Memory Size: 128 MB Max Memory Used: 73 MB Init Duration: 269.78 ms

Request ID
9c60ff97-5c61-4046-a240-f84677271370

code
from future import print_function
import boto3
import time, urllib
import json
"""Code snippet for copying the objects from AWS source S3 bucket to target S3 bucket as soon as objects uploaded on source S3 bucket
@author: Prabhakar G
"""
print ("*"80)
print ("Initializing..")
print ("
"*80)

s3 = boto3.client('s3')

def lambda_handler(event, context):
# TODO implement
source_bucket = event['Records'][0]['s3']['bucket']['name']
object_key = urllib.unquote_plus(event['Records'][0]['s3']['object']['key'])
target_bucket = 'lambda-output-1'
copy_source = {'Bucket': source_bucket, 'Key': object_key}
print ("Source bucket : ", source_bucket)
print ("Target bucket : ", target_bucket)
print ("Log Stream name: ", context.log_stream_name)
print ("Log Group name: ", context.log_group_name)
print ("Request ID: ", context.aws_request_id)
print ("Mem. limits(MB): ", context.memory_limit_in_mb)
try:
print ("Using waiter to waiting for object to persist through s3 service")
waiter = s3.get_waiter('object_exists')
waiter.wait(Bucket=source_bucket, Key=object_key)
s3.copy_object(Bucket=target_bucket, Key=object_key, CopySource=copy_source)
return response['ContentType']
except Exception as err:
print ("Error -"+str(err))
return e

please help me out on this.

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.