I'm trying to create an event source mapping with the AWS cli, but I keep getting a combination of errors that don't add up. Here's what I've tried:
aws lambda create-event-source-mapping --function-name someFunctionName --batch-size 100 --starting-position LATEST --event-source arn:aws:sqs:eu-central-1:someARN:SomeQueue.fifo
This results in: An error occurred (InvalidParameterValueException) when calling the CreateEventSourceMapping operation: StartingPosition
is not valid for SQS event sources.
Then I try without the starting position: aws lambda create-event-source-mapping --function-name someFunctionName --batch-size 100 --event-source arn:aws:sqs:eu-central-1:someARN:SomeQueue.fifo which results in: error: argument --starting-position is required
Am I missing something? How am I supposed to call this command?
aws -version tells me I'm running aws-cli/1.15.10 Python/2.7.9 Windows/2012Server botocore/1.10.10. Is this just an out of date version?
So, as I'm writing this question I upgrade the cli to 2.0.9 and option 2 works!!!
Upgraded the cli to 2.0.9 and option 2 works!!!
Related
I only keep the latest two versions of a lambda.
If I do:
$ aws lambda publish-version --function-name private-eye-converter-dev-pe-convert
I can see that the latest version is "Version": "27",.
But when I do:
$ aws lambda invoke --function-name my_lambda --cli-binary-format raw-in-base64-out \
--payload '{"key": "value"}' out --log-type Tail --query 'LogResult' \
--output text | base64 -d
START RequestId: f2bbdba7-c25b-460c-b72c-6c9afbf8afe0 Version: $LATEST
...
I got Version: $LATEST, which is helpless for me.
Is there a way of this $LATEST to show 27?
Sure
$ aws lambda invoke --function-name my_lambda:27
does, but I don't know which version is the latest a priori.
$LATEST is always the current, muttable version of the Lambda function. Sort of like a development version.
When you do Publish, you save all the current code and Lambda configuration to the function version, which you see as a version number.
The easiest way for you to always invoke the latest published version is to create an ALIAS for the Lambda function
When you do aws lambda publish in the response, you will receive the version number. You can use that to pass it in the second command
aws lambda update-alias (AWS CLI reference)and that way you automatically update the alias to the latest version. Then, when you invoke the lambda function with mylambda:myalias it will show the latest version number in logs.
I was able to run the create-cluster cli successfully and launched my EMR cluster, but when I tried to run below command to add a step:
aws emr add-steps --cluster-id j-your-cluster-id --steps Type=CUSTOM_JAR,Name=CustomJAR,ActionOnFailure=CONTINUE,Jar=s3://mybucket/mytest.jar,Args=arg1,arg2,arg3 Type=CUSTOM_JAR,Name=CustomJAR,ActionOnFailure=CONTINUE,Jar=s3://mybucket/mytest.jar,MainClass=mymainclass,Args=arg1,arg2,arg3 --profile my-test-account
it failed with this error:
An error occurred (InvalidRequestException) when calling the DescribeCluster operation: Cluster id 'j-your-cluster-id' is not valid.
and I've double checked j-your-cluster-id is matching my cluster-id exactly.
I feel like this is a permission issue, but how come the same profile could let me create a cluster, but cannot let me describe it?
How can I dig further and fix this please?
Based on the comments.
The issue was caused by execution AWS CLI in different region than intended. The solution was to use --region option to provide correct region for the CLI.
I am working with AWS SNS services and completed the initial setup as the AWS documentation. I just needed to test it using aws-cli. So I used the following command to publish a test message to SNS topic from my local PC.
aws sns publish --topic-arn "arn:aws:sns:us-east-1:xxxxxxxxxxx:test-notification-service" --message "Hello, from SNS"
However, I got stuck on the following generic error. It just says Invalid Parameter. I have configured the ~/.aws/credentials as needed.
An error occurred (InvalidParameter) when calling the Publish operation: Invalid parameter: TopicArn
The issue is due to cross-region. You AWS-CLI default region might be different to the region your SNS service location.
Check your AWS-CLI location and make sure you are in the same region as your SNS.
To check your region in AWS CLI use:
aws configure get region
To configure your AWS region you can use the command:
aws configure set region <region-name>
https://docs.aws.amazon.com/cli/latest/reference/configure/set.html
You can just add region parameter --region us-east-1 to your command:
aws sns publish --topic-arn "arn:aws:sns:us-east-1:xxxxxxxxxxx:test-notification-service" --message "Hello, from SNS" --region us-east-1
I am following an AWS lambda tutorial https://docs.aws.amazon.com/lambda/latest/dg/vpc-rds-create-rds-mysql.html and the first step is to create an RDS instance via the CLI but I am getting the following error...
Invalid endpoint: https://rds.us-east-2.amazonaws.com
I've tried specifying a couple other parameters such as --availability-zone, -vpc-security-group-ids, etc but it still is saying the endpoint doesn't exist?
Make sure you have the latest version of the AWS CLI tool installed. It sounds like you have an older version before us-east-2 was added. You can check the version you have installed by running aws --version.
I try to run my lambda function with localstack. I installed awscli-local and localstack
pip3 install awscli-local
pip3 install --user localstack --ignore-installed six
And then I started localstack
LAMDBA_EXECUTOR=docker localstack start --docker
When I now want to create my lambda function
aws lambda create-function --function-name Test --zip-file
fileb://myLambda.zip --handler index.handler --runtime
'nodejs6.10' --endpoint http://localhost:4574 --role admin
I get this error
An error occurred (ResourceConflictException) when calling the
CreateFunction operation: Function already exist: Test
Listing the functions returns nothing
aws lambda list-functions --endpoint http://localhost:4574
Does someone know why localstack thinks that the function is already there?
You can invoke lambdas directly in localstack from the Commandeer App. It installs localstack under the hood with docker.
There is a button on the lambda detail that allows you to specify the payload and then view the cloudwatch logs.
I'm also seeing this issue. Though it does not happen each time I try to create a lambda in localstack. What I have noticed is that lambda create seems to take a rather long time and cause a lot of CPU consumption on my mac while it is creating the lambda. My initial guess is that because of the time being take to create the ambda, something is timing out during the lambda creation and it's as if the creation is retried internally and it finds the lambda exits. If I query for the lambda after receiving this error message with awslocal, I see it exists.
I am running this on a MBP with 32Gb of memory and upped the allocation of resources to the Docker engine to 16Gb and 8 processors in hopes of solving this with additional resources, but that has not seemed to help. Suggestions welcome.