# © 2023 Amazon Web Services, Inc. or its affiliates. All Rights Reserved. # This AWS Content is provided subject to the terms of the AWS Customer Agreement available at # http: // aws.amazon.com/agreement or other written agreement between Customer and either # Amazon Web Services, Inc. or Amazon Web Services EMEA SARL or both. import json import boto3 from botocore.exceptions import ClientError client = boto3.client('organizations') def handler(event, context): id = event["arguments"]["id"] print(event) print(id) try: response = client.list_parents( ChildId=id ) return response["Parents"][0] except ClientError as e: print(e.response['Error']['Message'])