Как вызвать лямбда-функцию AWS, используя sam CLI - PullRequest
0 голосов
/ 03 июля 2019

Я создал лямбда-функцию Python myTestPython и хочу вызывать с помощью sam CLI mac или windows.

Я выполняю:

sudo aws lambda invoke --function-name "myLambdaPython" --endpoint-url "https://XXXXXX.execute-api.us-east-1.amazonaws.com/Prod" --no-verify-ssl out.txt

Но я получаю ошибку ниже:

/usr/local/aws/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)

An error occurred (InvalidSignatureException) when calling the Invoke operation: Credential should be scoped to a valid region, not 's3.amazonaws.com'. Credential should be scoped to correct service: 'execute-api'
sudo aws lambda invoke --function-name "myLambdaPython" --endpoint-url "https://XXXXXX.execute-api.us-east-1.amazonaws.com/Prod" --no-verify-ssl out.txt

Но я получаю ошибку ниже

/usr/local/aws/lib/python3.7/site-packages/urllib3/connectionpool.py:851: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)


def lambda_handler(event, context):
    # TODO implement
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }

Ожидаемый результат - вывод функции

...