4 Respostas
- Mais recentes
- Mais votos
- Mais comentários
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.
respondido há um ano
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))
respondido há um ano
Conteúdo relevante
- AWS OFICIALAtualizada há 3 anos
- AWS OFICIALAtualizada há 2 meses
- AWS OFICIALAtualizada há 6 meses