in cdk/ide/lambda_functions/c9DiskResize/lambda_function.py [0:0]
def create(event, context):
logger.debug("Got Create")
instance_id = event['ResourceProperties']['InstanceId']
instance = ec2_client.describe_instances(Filters=[{'Name': 'instance-id', 'Values': [instance_id]}])['Reservations'][0]['Instances'][0]
block_volume_id = instance['BlockDeviceMappings'][0]['Ebs']['VolumeId']
size = event['ResourceProperties']['EBSVolumeSize']
ec2_client.modify_volume(VolumeId=block_volume_id,Size=int(size))
while True:
commands = ['sudo growpart /dev/xvda 1']
send_response = send_command(instance_id, commands)
if send_response:
helper.Data["CommandId"] = send_response['Command']['CommandId']
break
if context.get_remaining_time_in_millis() < 20000:
raise Exception("Timed out attempting to send command to SSM")
sleep(15)
stop_instance(instance_id)
start_instance(instance_id)