In the previous modules, you created a personalized, real-time movie title recommendation model. To build this, you used:

These tools helped you create user recommendations with machine learning.

In the following steps, you clean up the resources you created in this lab.

Time to Complete Module: 10 Minutes


  • Step 1. Delete the Amazon Personalize resources

    Run the following code to remove your Amazon Personalize resources:

    # Delete the campaign
    personalize.delete_campaign(campaignArn=campaign_arn)
    time.sleep(300)
    print("delete_campaign done")
    # Delete the solution
    personalize.delete_solution(solutionArn=solution_arn)
    time.sleep(60)
    print("delete_solution done")
    # Delete the interaction dataset
    personalize.delete_dataset(datasetArn=interactions_dataset_arn)
    time.sleep(60)
    print("delete_dataset done")
    # Delete the schema
    personalize.delete_schema(schemaArn=interaction_schema_arn)
    time.sleep(60)
    print("delete_schema done")
    # Delete the dataset group
    personalize.delete_dataset_group(datasetGroupArn = dataset_group_arn)
    time.sleep(60)
    print("delete_dataset_group done")

    You should see the following output in your terminal:

    delete_campaign done
    delete_solution done
    delete_dataset done
    delete_schema done
    delete_dataset_group done
  • Step 2. Delete Amazon S3 bucket and IAM policies

    Next, clean up the Amazon S3 bucket and IAM policies.

    # Empty S3 Bucket
    boto3.Session().resource('s3').Bucket(bucket_name).Object(interactions_filename).delete()
    # IAM policies should also be removed
    iam = boto3.client("iam")
    iam.detach_role_policy(PolicyArn="arn:aws:iam::aws:policy/AmazonS3FullAccess", RoleName=role_name)
    iam.detach_role_policy(PolicyArn="arn:aws:iam::aws:policy/service-role/AmazonPersonalizeFullAccess",RoleName=role_name)
    iam.detach_role_policy(PolicyArn="arn:aws:iam::aws:policy/service-role/IAMFullAccess",RoleName=role_name)
    iam.delete_role(RoleName=role_name)
  • Step 3. Delete SageMaker Notebook instance

    Next, stop and delete your Amazon SageMaker Notebook instance.

    1. Open the SageMaker console.
    2. Under Notebooks, choose Notebook instances.
    3. Choose the notebook instance that you created for this tutorial, then choose Actions, Stop. The notebook instance takes up to several minutes to stop. When Status changes to Stopped, move on to the next step.
    4. Choose Actions, then Delete.
    5. Choose Delete.