def create()

in functions/source/FargateProfile/lambda_function.py [0:0]


def create(event, _):
    pid = "{}-{}".format(
        event['LogicalResourceId'],
        ''.join(random.choice(string.ascii_lowercase) for i in range(8))
    )
    kwargs = {
        "fargateProfileName": pid,
        "clusterName": event['ResourceProperties']['ClusterName'],
        "podExecutionRoleArn": event['ResourceProperties']['IamRole'],
        "subnets": event['ResourceProperties']['Subnets'],
        "selectors": []
    }
    labels = {s.split("=")[0]: s.split("=")[1] for s in event['ResourceProperties'].get('Labels', [])}
    for ns in event['ResourceProperties']['Namespaces']:
        selector = {'namespace': ns}
        if labels:
            selector['labels'] = labels
        kwargs['selectors'].append(selector)
    eks.create_fargate_profile(**kwargs)
    status = stabilize(pid, event['ResourceProperties']['ClusterName'])
    if status != 'ACTIVE':
        raise Exception(f"Fargate profile {pid} status is {status}")
    return pid