4개 답변
- 최신
- 최다 투표
- 가장 많은 댓글
2
Hello, your script looks correct.
I just tested your script myself and it works.
It seems something else is wrong, maybe your testevent itself?
I used the default testevent:
{
"key1": "value1",
"key2": "value2",
"key3": "value3"
}
See also: https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-eventbridge/
0
HeikoMR, thanks for the link. It helped to remind me about the roles and how I forgot to apply the correct one to the Lambda function.
답변함 일 년 전
0
Hello,
You are just missing a double quote. The code should look as below. I tested this in my environment and it works fine.
import boto3
region = 'us-east-1'
instances = ["i-xxxxxxxxxxx"]
ec2 = boto3.client('ec2', region_name=region)
def lambda_handler(event, context):
ec2.stop_instances(InstanceIds=instances)
print('stopped your instances: ' + str(instances))
답변함 일 년 전
관련 콘텐츠
- AWS 공식업데이트됨 일 년 전