AWS lambda应用
使用lambda定时启动一个EC2。
""" Lambda to launch ec2-instances """
import boto3
REGION = 'cn-north-1' # region to launch instance.
EC2 = boto3.client('ec2', region_name=REGION)
def lambda_to_ec2(event, context):
""" Lambda handler taking [message] and creating a httpd instance with an echo. """
message = event['message']
instance = EC2.run_instances(
ImageId='ami-c333edae',
InstanceType='t2.medium',
MinCount=1,
MaxCount=1,
SecurityGroups='prod-rds-backup',
SubnetId='subnet-d45208b1',
PrivateIpAddress='10.184.12.240',
InstanceInitiatedShutdownBehavior='stop'
)
print "New instance created."
instance_id = instance['Instances'][0]['InstanceId']
print instance_id
return instance_id创建Lambda函数
创建Cloudwatch event
创建trigger
相关推荐
XuYongshi0 2018-06-04
meylovezn 2020-09-21
mmmjyjy 2020-07-16
typhoonpython 2020-06-11
x青年欢乐多 2020-06-06
Stranger 2020-05-16
PythonMaker 2020-04-22
QianYanDai 2020-04-18
千锋 2020-04-11
SDUTACM 2020-03-05
fly00love 2020-03-05
f = lambda x, y, z: x + y + z # returns a function that can optionally be assigned a name. def func:
sschencn 2020-02-21
wklken的笔记 2020-01-30
GhostLWB 2020-01-30
sulindong0 2020-01-19
chinademon 2020-01-12