나는 serverless 프레임 워크에 익숙하며 인스턴스의 상태를 가져 오려고합니다. 따라서 boto3 describe-instance-status()
을 사용했지만 관리자 권한이 있지만이 종류의 작업을 수행 할 권한이 없다는 오류가 계속 발생합니다. 모든 aws 서비스에; 도와주세요, 내가 여기 serverless를 사용하여 인스턴스의 상태를 얻으려면
import json
import boto3
import logging
import sys
#setup simple logging for INFO
logger = logging.getLogger()
logger.setLevel(logging.INFO)
from botocore.exceptions import ClientError
def instance_status(event, context):
"""Take an instance Id and return its status"""
#print "ttot"
body = {}
status_code = 200
client = boto3.client('ec2')
response = client.describe_instance_status(InstanceIds=['i-070ad071'])
return response
여기 내 serverless.yml 파일
service: ec2
provider:
name: aws
runtime: python2.7
timeout: 30
memorySize: 128
stage: dev
region: us-east-1
iamRoleStatements:
- Effect: "Allow"
Action:
- "ec2:DescribeInstanceStatus"
Resource: "*"
functions:
instance_status:
handler: handler.instance_status
description: Status ec2 instances
events:
- http:
path: ''
method: get
여기에있다 (Unautho를 "오류가 발생 : 오류 메시지 나는 점점 오전 :
는는"ERRORTYPE ":"ClientError ","ERRORMESSAGE는 " rizedOperation) DescribeInstanceStatus 호출 할 때 작업 :이 작업을 수행 할 수있는 권한이 없습니다. "
? 람다의 IAM 역할은 무엇입니까? 해당 IAM 역할은 EC2의 리소스를 수행 할 수있는 권한이 있습니까? 이 역할의 권한을 다시 확인하십시오. –
역할을 지정하지 않았는데 serverless.yml에서이 작업을 수행 할 수 있습니까? witch 역할은 boto3 라이브러리에서 가장 편리합니다. – ner
역할과 연결된 IAM 정책을 공유하십시오. –