import json import boto3 def lambda_handler(event, context): sm_client = boto3.client("sagemaker") # The name of the model created in the Pipeline CreateModelStep model_name = event["model_name"] model_package_arn = event["model_package_arn"] endpoint_config_name = event["endpoint_config_name"] endpoint_name = event["endpoint_name"] endpoint_instance_type = event["endpoint_instance_type"] role = event["role"] container = {"ModelPackageName": model_package_arn} create_model_respose = sm_client.create_model(ModelName=model_name, ExecutionRoleArn=role, Containers=[container]) create_endpoint_config_response = sm_client.create_endpoint_config( EndpointConfigName=endpoint_config_name, ProductionVariants=[ { "InstanceType": endpoint_instance_type, "InitialVariantWeight": 1, "InitialInstanceCount": 1, "ModelName": model_name, "VariantName": "AllTraffic", } ], ) create_endpoint_response = sm_client.create_endpoint( EndpointName=endpoint_name, EndpointConfigName=endpoint_config_name ) return { "statusCode": 200, "body": json.dumps("Created Endpoint!"), "other_key": "example_value", }