我需要使用Lambda函数启动EC2机器。 lambda函数具有环境变量集中的所有参数,如AMIID,IM_ROLE_NAME等。当它运行lambda函数时,它会给出错误:
2018-01-24T06:04:42.189Z 76289722-00cc-11e8-af1d-0bdcfbd45ab7 { InvalidParameterValue: Value (cloudwatchlogs) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name
at Request.extractError (/var/task/node_modules/aws-sdk/lib/services/ec2.js:50:35)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14)
at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:685:12)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
message: 'Value (cloudwatchlogs) for parameter iamInstanceProfile.name is invalid. Invalid IAM Instance Profile name',
code: 'InvalidParameterValue',
time: 2018-01-24T06:04:42.151Z,
requestId: '4c1e3cae-ba71-45b9-8332-23d6d11b4971',
statusCode: 400,
retryable: false,
retryDelay: 43.681361140256826 } null
我无法解决上述问题&#39;参数iamInstanceProfile.name的值(cloudwatchlogs)无效。无效的IAM实例配置文件名称&#39;, 代码:&#39; InvalidParameterValue&#39; ,.请指导。
答案 0 :(得分:0)
从错误中可以清楚地看出,您正在为EC2实例指定无效角色。
在您的IAM控制台中,在角色下
cloudwatchlogs
是否存在验证您的lambda角色是否可以访问您尝试为EC2提供的角色。一个示例代码段 -
"Effect": "Allow"
"Action": "iam:PassRole"
"Resource": "arn:aws:iam::<Account-id>:role/cloudwatchlogs" or "Resource": "*"