> ## Documentation Index
> Fetch the complete documentation index at: https://docs.formae.io/llms.txt
> Use this file to discover all available pages before exploring further.

# ML platform

> An AWS infrastructure pattern, deployed with formae.

A complete machine learning platform built on Amazon SageMaker with its
supporting infrastructure. One forma provisions the VPC (with public and private
subnets, NAT, and VPC endpoints), security groups, a KMS key, an encrypted EFS
file system with access points, S3 buckets for training data and model
artifacts, an RDS feature store, IAM roles, CloudWatch logs, ECR repositories
with an ECS cluster, and the SageMaker domain with its user profiles and model
package group. The KMS key encrypts storage across the platform, and the
SageMaker domain sits on the private network with access to EFS and its
execution roles.

```mermaid theme={"languages":{"custom":["/languages/pkl.json"]}}
flowchart LR
  target["aws-target"]:::tgt

  subgraph stack["ml-platform"]
    direction LR
    vpc["VPC, subnets, NAT, endpoints"]:::res
    sgs["Security groups"]:::res
    kms["KMS key"]:::res
    efs["EFS + access points"]:::res
    buckets["S3 buckets"]:::res
    db["RDS feature store"]:::res
    roles["IAM roles"]:::res
    logs["CloudWatch logs"]:::res
    containers["ECR + ECS cluster"]:::res
    sagemaker["SageMaker domain, profiles, model group"]:::res

    vpc --> sgs
    kms --> efs
    kms --> buckets
    kms --> db
    kms --> logs
    kms --> containers
    vpc --> efs
    sgs --> efs
    vpc --> db
    sgs --> db
    vpc --> sagemaker
    sgs --> sagemaker
    efs --> sagemaker
    roles --> sagemaker
  end

  target --> stack

  classDef tgt fill:#FF8201,stroke:#B25900,color:#ffffff
  classDef res fill:#FFF3E6,stroke:#FF8201,color:#02024B
  style stack fill:#ffffff,stroke:#02024B,stroke-width:2px,stroke-dasharray:6 4,color:#02024B
```

**Deploy.** Apply the example forma. formae orders the platform by its
dependencies, so the KMS key and network come up before the storage, roles, and
SageMaker domain that depend on them:

```bash theme={"languages":{"custom":["/languages/pkl.json"]}}
formae apply --mode reconcile \
  /opt/pel/formae/examples/formae-plugin-aws/ml-platform/main.pkl
```

**Verify.** Once the command completes, the SageMaker domain is under
management:

```bash theme={"languages":{"custom":["/languages/pkl.json"]}}
formae inventory resources --query="type:AWS::SageMaker::Domain"
```

**Tear down.** Remove everything the forma created:

```bash theme={"languages":{"custom":["/languages/pkl.json"]}}
formae destroy \
  /opt/pel/formae/examples/formae-plugin-aws/ml-platform/main.pkl
```

The full forma is in the
[ml-platform example](https://github.com/platform-engineering-labs/formae-plugin-aws/tree/main/examples/ml-platform).
