# Production Terraform Deployment

This guide covers deploying Fides using Terraform for automated infrastructure provisioning on AWS Elastic Container Service (ECS).

For Kubernetes deployments, see [Production Kubernetes Deployment](/content/docs/platform/installation/production/kubernetes/index.html). For Docker configuration options, see [Docker Installation](/content/docs/platform/installation/basic/docker/index.html).

## Overview [Permalink for this section](/content/docs/platform/installation/production/terraform#overview/index.html)

The Fides team maintains a [Terraform module (opens in a new tab)](https://github.com/ethyca/fides-terraform) to assist in deploying Fides to AWS ECS with all required infrastructure components.

The Terraform module provisions:

- AWS ECS cluster and task definitions
- Application Load Balancer
- RDS PostgreSQL database
- ElastiCache Redis cluster
- S3 bucket for storage
- VPC and networking resources
- IAM roles and security groups

## Prerequisites [Permalink for this section](/content/docs/platform/installation/production/terraform#prerequisites/index.html)

- [Terraform (opens in a new tab)](https://www.terraform.io/downloads) installed locally
- AWS account with appropriate permissions
- AWS credentials configured locally
- Basic understanding of Terraform and AWS services

## Installation [Permalink for this section](/content/docs/platform/installation/production/terraform#installation/index.html)

### 1. Reference the Terraform Module [Permalink for this section](/content/docs/platform/installation/production/terraform#1-reference-the-terraform-module/index.html)

Create a new Terraform configuration that references the Fides module:

```
module "fides" {
  source = "github.com/ethyca/fides-terraform//fides-aws-ecs"

# Required variables
  aws_region = "us-east-1"

# Add your configuration here
  # See module README for all available options
}
```

### 2. Configure Module Variables [Permalink for this section](/content/docs/platform/installation/production/terraform#2-configure-module-variables/index.html)

Customize the deployment by setting module variables. Common configuration options include:

```
module "fides" {
  source = "github.com/ethyca/fides-terraform//fides-aws-ecs"

aws_region          = "us-east-1"
  environment         = "production"
  fides_image_tag     = "latest"

# Database configuration
  db_instance_class   = "db.t3.medium"

# Redis configuration
  redis_node_type     = "cache.t3.micro"

# ECS configuration
  fides_cpu           = 1024
  fides_memory        = 2048
  fides_desired_count = 2
}
```

### 3. Initialize Terraform [Permalink for this section](/content/docs/platform/installation/production/terraform#3-initialize-terraform/index.html)

```
terraform init
```

### 4. Review the Plan [Permalink for this section](/content/docs/platform/installation/production/terraform#4-review-the-plan/index.html)

```
terraform plan
```

Review the resources that will be created to ensure they match your expectations.

### 5. Apply the Configuration [Permalink for this section](/content/docs/platform/installation/production/terraform#5-apply-the-configuration/index.html)

```
terraform apply
```

Type `yes` when prompted to confirm the deployment.

## Module Configuration [Permalink for this section](/content/docs/platform/installation/production/terraform#module-configuration/index.html)

For detailed configuration options and all available variables, refer to the [Terraform module README (opens in a new tab)](https://github.com/ethyca/fides-terraform/blob/main/fides-aws-ecs/README.md).

### Key Configuration Options [Permalink for this section](/content/docs/platform/installation/production/terraform#key-configuration-options/index.html)

**Infrastructure Sizing:**

- `db_instance_class` - RDS instance size
- `redis_node_type` - ElastiCache node type
- `fides_cpu` - ECS task CPU units
- `fides_memory` - ECS task memory (MB)
- `fides_desired_count` - Number of Fides task replicas

**Networking:**

- `vpc_id` - Existing VPC ID (or creates new VPC)
- `private_subnet_ids` - Subnets for private resources
- `public_subnet_ids` - Subnets for load balancer

**Security:**

- `app_encryption_key` - AES256 encryption key (32 characters)
- `oauth_root_client_id` - Root OAuth client ID
- `oauth_root_client_secret` - Root OAuth client secret

## Accessing Fides [Permalink for this section](/content/docs/platform/installation/production/terraform#accessing-fides/index.html)

After deployment completes, Terraform will output the application URL:

```
terraform output fides_url
```

Visit the URL to access the Fides Admin UI.

## Updating Fides [Permalink for this section](/content/docs/platform/installation/production/terraform#updating-fides/index.html)

To update Fides to a new version:

1. Update the `fides_image_tag` variable
2. Run `terraform apply`

The ECS service will perform a rolling update with zero downtime.

## Destroying Resources [Permalink for this section](/content/docs/platform/installation/production/terraform#destroying-resources/index.html)

To remove all Fides infrastructure:

```
terraform destroy
```

⚠️

**Warning:** This will permanently delete all resources including the database. Ensure you have backups before destroying.

## Next Steps [Permalink for this section](/content/docs/platform/installation/production/terraform#next-steps/index.html)

- Configure [storage destinations](/content/docs/privacy-requests/guides/storage-destinations/index.html) for privacy request exports
- Set up [integrations](/content/docs/integrations/index.html) to connect to your data systems
- Review [security best practices](/content/docs/platform/configuration/security-practices/index.html)
- Check the [Terraform module repository (opens in a new tab)](https://github.com/ethyca/fides-terraform) for updates

## Additional Resources [Permalink for this section](/content/docs/platform/installation/production/terraform#additional-resources/index.html)

- [Terraform Module Repository (opens in a new tab)](https://github.com/ethyca/fides-terraform)
- [Terraform Module README (opens in a new tab)](https://github.com/ethyca/fides-terraform/blob/main/fides-aws-ecs/README.md)
- [AWS ECS Documentation (opens in a new tab)](https://docs.aws.amazon.com/ecs/)
