> ## 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.

# Bookstore on EKS

> An AWS infrastructure pattern, deployed with formae.

A full-stack bookstore application running on a managed EKS cluster. This example
lives in the formae Kubernetes plugin, and the AWS entry file provisions the
cluster itself (a VPC with public subnets, an internet gateway and routing,
cluster and node IAM roles, security groups, and an EKS AutoMode cluster) and
then deploys the workload onto it: a namespace, ConfigMaps and a secret, a
backend service account, an nginx frontend deployment behind a LoadBalancer
service, and a Node.js API backend behind a ClusterIP service. formae orders the
whole graph, so the cluster is ready before the Kubernetes resources land on it.

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

  subgraph stack["k8s-bookstore-aws"]
    direction LR
    vpc["VPC + subnets + IGW + routing"]:::res
    roles["IAM roles (cluster, node)"]:::res
    sgs["Security groups (cluster, node)"]:::res
    eks["EKS AutoMode cluster"]:::res
    sc["EBS storage class"]:::res
    ns["Namespace"]:::res
    config["ConfigMaps + secret"]:::res
    sa["Backend service account"]:::res
    frontend["Frontend deployment (nginx)"]:::res
    backend["Backend deployment (Node API)"]:::res
    feSvc["Frontend service (LoadBalancer)"]:::res
    beSvc["Backend service (ClusterIP)"]:::res

    vpc --> eks
    roles --> eks
    sgs --> eks
    eks --> sc
    ns --> config
    ns --> sa
    config --> frontend
    config --> backend
    sa --> backend
    frontend --> feSvc
    backend --> beSvc
  end

  target --> stack
  eks --> k8sTgt
  k8sTgt --> ns

  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 AWS entry file. The cloud is chosen by which entry file you
apply, so `aws.pkl` provisions the EKS cluster and then the workload on top of
it:

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

**Verify.** Once the command completes, the EKS cluster is under management:

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

**Tear down.** Remove everything the forma created. Because the workload depends
on the cluster, cascade the destroy to its dependents:

```bash theme={"languages":{"custom":["/languages/pkl.json"]}}
formae destroy --on-dependents=cascade \
  /opt/pel/formae/examples/formae-plugin-kubernetes/bookstore/aws.pkl
```

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