'How to call S3 using aws cli commands in Lambda Function(Bash Script)

Am using custom environment to run bash script in a lambda function. I have included a layer to support AWS CLI functions. But am not successful calling a s3 bucket. Here is the sample I tried inside hello.sh file. The line I have commented works providing function arn but the aws s3 list buckets did not work.

function handler () {
    EVENT_DATA=$1
    echo $EVENT_DATA
   #DATA=`/opt/awscli/aws lambda get-function --function-name testshellinlambda --query 'Configuration.FunctionArn' --output text`
    DATA =`/opt/awscli/aws aws s3api list-buckets --query 'Buckets[].Name'`
    RESPONSE="{\"statusCode\": 200, \"body\": \"$DATA\"}"
    echo $RESPONSE
}

Do any one has similar experience?Any suggestions will be helpful.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source