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

# Deploy Application

> Deploy your Fjall application to AWS with the CLI: prerequisites, progress tracking, deploy options, and rollback.

## Prerequisites

Complete these before deploying:

* [**Create an application**](/deployment/create-application) (an `infrastructure.ts` exists in your project)
* [**Authenticated with Fjall**](/cli/login) (run `fjall login`, or set `FJALL_API_KEY` for CI/CD)
* [**Connected an AWS account**](/cli/connect) (run `fjall connect`)

`fjall deploy` enforces both gates. An unauthenticated user sees `Authentication required. Run 'fjall login' first.`

***

## Deploy your application

Run from your project root:

```bash theme={null}
fjall deploy api
```

Replace `api` with your application name. The same command builds the container, synthesises infrastructure, and applies the changes.

***

## What happens during a deploy

The interactive deploy runs an automatic pipeline and streams live progress. There is no separate "preview then confirm" step for applications.

| Phase          | Activity                                                                     |
| -------------- | ---------------------------------------------------------------------------- |
| Auth gate      | Confirms Fjall login and AWS connection                                      |
| Build          | Builds and pushes the Docker image                                           |
| Infrastructure | Provisions network, storage, messaging, database, compute, and CDN resources |
| Service        | Starts the ECS service and reports the application URL                       |
| Complete       | Shows outputs, the website URL, and next steps                               |

Progress streams per phase with a live operation box for each resource group:

```bash theme={null}
Building image ............ done
Network ................... created
Database .................. created
Compute ................... created
Deployment complete
  Website: https://api.example.com
```

If nothing changed since the last deploy, Fjall reports `Already up to date — no changes since last deploy`.

### Confirmations

Fjall does not show an unconditional yes/no prompt for application deploys. Two prompts appear only when relevant:

* **Missing secrets**: if expected SSM secrets are absent, Fjall lists each one and asks `Deploy anyway?` (defaults to No).
* **Infrastructure changes**: when changes are detected, Fjall asks `Infrastructure changes detected. Deploy now?`.

Pass `--skip-confirmation` to bypass both.

***

## Deployment options

### Skip confirmations

```bash theme={null}
fjall deploy api --skip-confirmation
```

For CI/CD pipelines, force plain output:

```bash theme={null}
fjall deploy api --non-interactive
```

### Infrastructure only

Apply infrastructure changes without rebuilding the container:

```bash theme={null}
fjall deploy api --infra-only
```

### Code only

Rebuild and redeploy the container without touching infrastructure:

```bash theme={null}
fjall deploy api --deploy-only
```

### Skip the build

Reuse an already-pushed image (pair with `--deploy-only`):

```bash theme={null}
fjall deploy api --deploy-only --skip-build
```

### Roll forward or back to a known image

Deploy an existing image tag (skips build, implies `--deploy-only`):

```bash theme={null}
fjall deploy api --image-tag v1.4.2
```

### Pass a CI/CD environment label

The `-e, --environment` flag is a free-form label passed through to CDK synthesis as a context value. It does not select an AWS account or region.

```bash theme={null}
fjall deploy api -e production
```

To choose which AWS account a deploy lands in, set the active deployment target with `fjall target set <name>`, or override per deploy with `--target <name>`.

### Verbose output

```bash theme={null}
fjall deploy api --verbose
```

### All deploy options

| Option                    | Description                                                                 |
| ------------------------- | --------------------------------------------------------------------------- |
| `--infra-only`            | Deploy only infrastructure (skip code deployment)                           |
| `--deploy-only`           | Deploy only code (skip infrastructure)                                      |
| `--skip-build`            | Skip the Docker build (use with `--deploy-only`)                            |
| `--skip-migrations`       | Skip database migrations during this deployment                             |
| `--skip-confirmation`     | Skip deployment confirmation prompts                                        |
| `--non-interactive`       | Force plain CLI output (no UI)                                              |
| `-e, --environment <env>` | Free-form CI/CD label passed to CDK synthesis                               |
| `-f, --force`             | Redeploy all stacks even when no infrastructure changes are detected        |
| `-v, --verbose`           | Enable verbose logging                                                      |
| `--target <name>`         | Override the active deployment target for this deploy                       |
| `--region <region>`       | Deploy to a specific region within the target's account                     |
| `--all-regions`           | Deploy to all regions for the target's account                              |
| `--image-tag <tag>`       | Deploy an existing image tag (skips build, implies `--deploy-only`)         |
| `--deployment-id <id>`    | Deployment record ID for progress tracking                                  |
| `--no-cascade`            | Skip automatic platform and account deployment after an organisation deploy |

***

## After deployment

### Inspect your resources

List the resources declared in the application's `infrastructure.ts`:

```bash theme={null}
fjall list --app api
```

For an application and organisation overview, use `fjall apps` and `fjall status`.

### View logs

Stream logs from the AWS Console (ECS service, Logs tab), or find the log group and tail it:

```bash theme={null}
aws logs describe-log-groups --log-group-name-prefix fjall
aws logs tail <your-log-group> --follow
```

### Monitor costs

Track spending in the [AWS Cost Explorer](https://console.aws.amazon.com/cost-management/home), or query it from the CLI:

```bash theme={null}
aws ce get-cost-and-usage \
  --time-period Start=$(date -v-30d +%Y-%m-%d),End=$(date +%Y-%m-%d) \
  --granularity MONTHLY --metrics BlendedCost
```

***

## Updating applications

| Change                                             | Command                          |
| -------------------------------------------------- | -------------------------------- |
| Application code only                              | `fjall deploy api --deploy-only` |
| Infrastructure (after editing `infrastructure.ts`) | `fjall deploy api`               |

***

## Troubleshooting

When a deploy fails, Fjall rolls back automatically and CloudFormation reports the failing resource.

1. Read the error message. CloudFormation names the resource that failed.
2. Re-run with `--verbose` for detailed logs.
3. Fix the underlying issue and redeploy.

### Common issues

| Error                                               | Fix                                                                                                      |
| --------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| `User does not have permission to create IAM roles` | Confirm your AWS role has the required IAM permissions (the SSO `AdministratorAccess` role covers this). |
| `You have reached the maximum number of VPCs`       | Request a quota increase, or deploy to a different region with `--region`.                               |
| `Stack with name '...' already exists`              | Choose a different application name, or destroy the existing stack first.                                |

***

## Next Steps

<Note>
  A first deployment typically takes 10 to 15 minutes while AWS provisions resources. Later updates are faster.
</Note>

<CardGroup cols={3}>
  <Card title="Add Resources" icon="plus" href="/deployment/add-resources">
    Extend your application with databases, storage, and more
  </Card>

  <Card title="List Resources" icon="list" href="/cli/list">
    Inspect resources in your infrastructure.ts
  </Card>

  <Card title="Set Up CI/CD" icon="rotate" href="/deployment/ci-cd">
    Automate deployments from your pipeline
  </Card>
</CardGroup>
