def lambda_handler()

in EC2 Auto Clean Room Forensics/Lambda-Functions/attachVolume.py [0:0]


def lambda_handler(event, context):
    # TODO Create volume from the Snapshot ID passed in the event
    volumeresponse = ec2client.create_volume(
        AvailabilityZone=event.get('availabilityZone'),
        # response['Instances'][0]['Placement']['AvailabilityZone'],
        Size=100,
        SnapshotId=event.get('snapshotID'),
        TagSpecifications=[
            {
                'ResourceType': 'volume',
                'Tags': [
                    {
                        'Key': 'Name',
                        'Value': 'Isolated VOLUME'
                    },
                ]
            },
        ]
    )
    waiter = ec2client.get_waiter('volume_available')

    waiter.wait(
        VolumeIds=[
         volumeresponse['VolumeId']
        ]
    )
    response = ec2client.attach_volume(
        InstanceId=event.get('ForensicInstanceId'),
        VolumeId=volumeresponse['VolumeId'],
        Device='/dev/sda2',

    )
    #Adds wait time for SSM
    event['wait_time'] = 60
    return event