我已经通过python2.7(使用boto3)编写了一个Lambda函数来启动EC2实例,然后将EC2实例连接到一个固定ELB(用于简单的故障转移)。在
当lambda关闭时,它启动EC2,但不将EC2连接到ELB。在
指导?在
为什么不起作用?在
#!/usr/bin/env python
import boto3
#True - Do nothing False - screw it all up
debugMode = False
#Declare
#Instance Status
#Hard Code InstanceIDs to script
if debugMode == False:
def lambda_handler(event, context):
client = boto3.client('ec2')
response = client.start_instances(InstanceIds=['i-someid',],
DryRun=False)
print ('[SPACE]:')
#Attach Instances to ELB once started.
#Hardcode Instance
def lamdba_hander(event, context):
client = boto3.client('elb')
response = client.register_instances_with_load_balancer(LoadBalancerName='someelb', Instances=[{'InstanceID': 'i-someid'},])
print('[SPACE]:')
目前没有回答
相关问题 更多 >
编程相关推荐