def create_resource_tags()

in clone_mediaconvert_resources/clone_mediaconvert_resources.py [0:0]


def create_resource_tags(destination_client, account, resource_type):
    try:
        region = destination_client.meta.region_name
        resource_data = []
        item = []
        file_path = resource_type + "/resource.json"
        file_path_bool = os.path.isfile((os.path.exists(file_path)))
        if file_path_bool == True:

            with open(file_path) as resources:
                resource_data = json.load(resources)

            for item in resource_data:
                for resource in item:
                    arn = "arn:aws:mediaconvert:" + region + ":" + account + ":" + resource_type + "/" + resource
                    destination_client.tag_resource(
                        Arn=arn,
                        Tags=item[resource]
                    )

        # else nothing to do because we have no resources to tag
    except botocore.exceptions.ClientError as error:
        if error.response['Error']['Code'] == 'AccessDeniedException':
            print("No permissions to access the MediaConvert API and tag resources,"
                  " please check the AWS CLI credentials")
            exit(-1)