# terraform-sagemaker-notebook

## Overview

Terraform module for managing a Sagemaker notebook module.

This allows the user to spin-up a Sagemaker notebook on AWS with out of the box support for the following:
* Feature Store - to explore existing datasets catalogued by others
* SecretManager - to only specific secrets related to the notebook (e.g. snowflake service account password)
* S3 (default: dev-cucumbers) - to load and explore data in S3 buckets assuming you using COPY INTO from snowflake.


### Variables

There are mandatory variables that must be provided for the module to function properly:
```
* service_name - Name of service that will benefit from this notebook instance
* application_family - Name of application family that is related to this notebook instance
* instance_name - The name of the notebook instance (must be unique)
* instance_type - The name of ML compute instance type
```

There are optional variables:
```
* volume_size - The size, in GB, of the ML storage volume to attach to the notebook instance (defaults to 5)
* default_code_repository - The Git repository associated with the notebook instance as its default code repository
* lifecycle_config_enabled - If lifecycle configuration will be associated with the notebook instance
* platform identifier - The platform identifier of the notebook instance runtime environment
```

## Usage

```
module "notebook" {
  source = "git@github.com:theorchard/terraform-sagemaker-notebook.git?ref=X.X.X"
  
  service_name = "my-service"
  application_family = "my-application"
  instance_name = "my-notebook"
  instance_type = "ml.t3.medium"
  code_repository_url = "ml.t3.medium"
  lifecycle_config_enabled = true
}
```

## Notes
* Currently, Sagemaker notebook instance will be created in the DEV AWS environment.

* If using Sagemaker code repository then related secret must be filled:
*The Amazon Resource Name (ARN) of the AWS Secrets Manager secret that contains 
the credentials used to access the git repository. The secret must have a staging 
label of AWSCURRENT and must be in the following format: {"username": UserName, "password": Password}*
### Resources

#### The module manages the following: 

* Sagemaker Notebook Instance
* KMS keys that are created specifically for notebook instance
* Notebook instance lifecycle configuration
* Sagemaker code repository
* terraform-secrets-manager in order to create secret used by code repository
* AWS IAM Role
