style: minor changes

This commit is contained in:
xpk
2025-11-24 15:40:40 +08:00
parent 3e5bb0547a
commit 6c01a4f55c
3 changed files with 85 additions and 14 deletions
+8 -7
View File
@@ -4,13 +4,14 @@ import json
# reference: https://aws.amazon.com/premiumsupport/knowledge-center/start-stop-lambda-eventbridge/
ec2 = boto3.client('ec2', region_name=os.environ['region_name'])
def lambda_handler(event, context):
if (event['action'] == 'start'):
resp = ec2.start_instances(InstanceIds=json.loads(os.environ['instances']))
elif (event['action'] == 'stop'):
resp = ec2.stop_instances(InstanceIds=json.loads(os.environ['instances']))
ec2 = boto3.client('ec2', region_name=os.environ['region_name'])
instances = json.loads(os.environ['instances'])
if event['action'] == 'start':
resp = ec2.start_instances(InstanceIds=instances)
elif event['action'] == 'stop':
resp = ec2.stop_instances(InstanceIds=instances)
else:
resp = "Event action not provided"
raise ValueError("Invalid event action")
return resp