为什么 AWS cli 会因为不匹配 regex/pattern 而拒绝我的 IAM ARN?

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

我正在尝试通过多种不同的方式将我的 .zip 推送到 AWS Lambda。尽管我直接从 IAM 控制台复制了我的 ARN,但我尝试过的所有方法(grunt、gulp 和 cli)都会引发错误。

我是 运行 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

并收到此错误:

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+=,.@\-_/]+

有人知道我做错了什么吗?

您必须创建并传递 IAM Role 而不是 IAM User

来自文档:

--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