Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does the AWS cli reject my IAM ARN for not matching the regex/pattern?

I'm trying in a number of different ways to push my .zip to AWS Lambda. All of the methods I've tried (grunt, gulp, and cli) are throwing an error despite having copied my ARN straight from the IAM console.

I'm running the following in the CLI

aws lambda create-function --function-name myFunctionName --runtime nodejs4.3 --role="arn:aws:iam::848602986150:user/lambda" --handler index.handler --zip-file fileb://./path/to/my.zip

and receiving this error:

A client error (ValidationException) occurred when calling the CreateFunction operation: 1 validation error detected: Value 'arn:aws:iam::848602986150:user/lambda' at 'role' failed to satisfy constraint: Member must satisfy regular expression pattern: arn:aws:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@\-_/]+

Anyone know what I'm doing wrong?

like image 875
Bryce York Avatar asked Apr 20 '16 11:04

Bryce York


1 Answers

You have to create and pass IAM Role not IAM User

From the docs:

--role :

Services (AWS) resources. The Amazon Resource Name (ARN) of the IAM role that Lambda assumes when it executes your function to access any other Amazon Web

like image 166
Vor Avatar answered Sep 20 '22 18:09

Vor