# Deploy to the cloud

> This lesson runs the same project on AWS: EKS for Kubernetes, ECR for images, S3 for storage, RDS PostgreSQL for service state and AWS Glue as the Iceberg…

Source: https://openlakeforge.dev/docs/tutorial/10-deploy-to-the-cloud/

This lesson runs the same project on AWS: EKS for Kubernetes, ECR for images,
S3 for storage, RDS PostgreSQL for service state and AWS Glue as the Iceberg
catalog.

**You will** deploy the project you built to your own AWS account and
validate it, in about 60 minutes plus the time AWS needs to create the
cluster.

**Start from** the project of [lesson 9](https://openlakeforge.dev/docs/tutorial/09-add-prod-and-promote/), and an
AWS account that meets the
[prerequisites of the AWS guide](https://openlakeforge.dev/docs/guides/cloud/deploy-to-aws/#prerequisites).
Your `lakehouse_code/` does not change: only the Deployment Profile does.

:::caution
This creates billable AWS resources and is not production-hardened. Run the
teardown step when you are done. The limits are listed in
[Deploy to AWS](https://openlakeforge.dev/docs/guides/cloud/deploy-to-aws/#limitations-and-costs).
:::

## 1. Point the profile at AWS

In `openlakeforge.yaml`, set the provider and the region, keep only the DEV
stage, and remove the `access:` and `identity:` blocks:

```yaml
spec:
  provider:
    type: aws
    region: eu-west-1
  stages:
    dev:
      enabled: true
```

The cloud deployment is validated with one stage, so the DEV-to-PROD promotion
of lesson 9 stays on your local platform. The cloud deployment publishes no
routes, so there is no sign-in: you reach its services with `olf infra forward`, and
an `access:` block would require `identity:`.

```bash
olf profile validate --project .
```

## 2. Authenticate

```bash
olf infra auth login --provider aws
```

It reuses your `default` AWS profile, or asks for your IAM Identity Center
start URL and region. The other sign-in options are in
[Deploy to AWS](https://openlakeforge.dev/docs/guides/cloud/deploy-to-aws/#1-authenticate). The cloud
pushes your image to its own ECR registry, so clear the registry settings of
lesson 9:

```bash
unset PROJECT_CODE_IMAGE_REPOSITORY PROJECT_CODE_IMAGE_TAG
```

## 3. Deploy

The same phases you used locally:

```bash
olf infra deploy --provider aws --phase foundation   # VPC, EKS, ECR, IAM
olf infra deploy --provider aws --phase platform     # S3, Glue, RDS, Trino, Dagster, Superset, OpenMetadata
olf infra deploy --provider aws --phase artifacts    # build and push images, load your code
```

The cloud has no public endpoint. To open the services, port-forward them to
your machine, then stop with Ctrl-C; Dagster is at `http://localhost:3000`:

```bash
olf infra forward --provider aws
```

## Check it worked

Stop `olf infra forward` first: run one `olf` command at a time.

```bash
olf infra e2e run --env aws
```

It launches every product's job on EKS and verifies the Silver and Gold
tables, the dashboards and OpenMetadata. It ends with a line of the form
`<Env> OpenLakeForge <suite> e2e validation passed.`

## Tear down

```bash
olf infra destroy --provider aws
```

On Azure the steps are the same with `--provider azure`, plus a variables file
for the resource group and node size; see
[Deploy to Azure](https://openlakeforge.dev/docs/guides/cloud/deploy-to-azure/).

## What you learned

- The project does not change between local, AWS and Azure; the profile's
  provider does.
- A cloud deploy is the same foundation, platform and artifacts phases.
- Cloud services are reached with `olf infra forward`, and `olf infra e2e run --env aws`
  validates them.

## Next

- [Deploy to AWS](https://openlakeforge.dev/docs/guides/cloud/deploy-to-aws/): every option, the
  limitations and the costs.
- [CI/CD and environment promotion](https://openlakeforge.dev/docs/guides/promote-dev-to-prod/): build
  and deploy revisions from CI.
- [Architecture](https://openlakeforge.dev/docs/architecture/overview/): how the same project runs on
  each provider.

---

<small>Synced from openlakeforge @ `v0.6.0-alpha.3` (`882b426`), [docs/tutorial/10-deploy-to-the-cloud.md](https://github.com/OpenLakeForge/openlakeforge/blob/882b426992381ef277f7c0830f36c0d6fa348644/docs/tutorial/10-deploy-to-the-cloud.md).</small>
