in cdk/ide/lambda_functions/c9InstanceProfile/lambda_function.py [0:0]
def create(event, context):
logger.debug("Got Create")
response = ec2_client.describe_instances(Filters=[{
'Name': 'tag:aws:cloud9:environment', 'Values': [event['ResourceProperties']['Cloud9Environment']]
}])
instance_id = response['Reservations'][0]['Instances'][0]['InstanceId']
ec2_client.associate_iam_instance_profile(
IamInstanceProfile={
'Name': event['ResourceProperties']['InstanceProfile']},
InstanceId=instance_id)
while not ssm_ready(instance_id):
if context.get_remaining_time_in_millis() < 20000:
raise Exception(
"Timed out waiting for instance to register with SSM")
sleep(15)
return instance_id