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

# ACM Upgrade

> Background service that upgrades to ACM-native certificates

# Internal Service: \_background\_acm\_upgrade

Upgrades from Let's Encrypt certificate to ACM-native certificate for automatic renewal.

## Purpose

Let's Encrypt certificates expire after 90 days and require manual renewal. ACM certificates auto-renew indefinitely. This background task upgrades to ACM after the proxy is deployed.

## Function Signature

```python theme={null}
async def _background_acm_upgrade(
    domain: str,
    distribution_id: str,
    old_certificate_arn: str,
    entity_id: str,
    org_id: str
)
```

## Parameters

| Parameter             | Type | Description                                                           |
| --------------------- | ---- | --------------------------------------------------------------------- |
| `domain`              | str  | The custom domain (e.g., "[www.example.com](http://www.example.com)") |
| `distribution_id`     | str  | CloudFront distribution ID                                            |
| `old_certificate_arn` | str  | Current Let's Encrypt certificate ARN                                 |
| `entity_id`           | str  | Database entity ID                                                    |
| `org_id`              | str  | Clerk organization ID                                                 |

## Execution Flow

```mermaid theme={null}
flowchart TD
    A[Task Started] --> B[Wait 60 seconds]
    B --> C[Call upgrade_to_acm_native]
    C --> D[Request ACM Certificate]
    D --> E[DNS Validation via Route53]
    E --> F[Wait for Validation]
    F --> G[Update CloudFront]
    G --> H[Update Database]
    H --> I[Log Success/Failure]
```

## Timing

* **Delay:** 60 seconds after Step 2 completes
* **Duration:** 2-10 minutes (ACM validation time)
* **Non-blocking:** User doesn't wait for this

## Dependencies

* `src/app/apis/domain/shared/acm_upgrade.py` - `upgrade_to_acm_native()`

## Code Location

```
src/app/apis/domain/mark_step_complete/routes.py
```
