# AWS Terraform Integration with Kloudfuse

Build the required infrastructure with Terraform to deploy Kloudfuse in AWS.

See the Terraform documentation for [Get Started — AWS](https://developer.hashicorp.com/terraform/tutorials/aws-get-started) for further details.

## Pre-Requisites

Enable these artifacts to configure S3 as a Terraform backend:

- **S3 bucket**: Create an S3 bucket with public access turned off, and remaining defaults enabled.
- **Dynamodb table**: Create a `dynamodb` table with partition `key = LockID`.

For details, see [Terraform Configuration](https://docs.kloudfuse.com/platform/3.2.5/cloud-service-aws-terraform/#backend).

- **Install Terraform**: Install the latest Terraform release, and export `terraform` to your executable `PATH`.
- **Terraform user**: Create an AWS user, or use a role that has enough permissions to access the S3 bucket and provision different resources on AWS.

1. Ensure to add the profile to your AWS credentials.
2. Export the AWS profile before running Terraform.

## Terraform Configuration

You must change the `backend.tf` file in each component folder, according to the created resources in S3 and `dynamodb`. Note that the state key is unique for each component; for a VPC, it can be `vpc.tfstate`.

**Example Terraform Configuration**

```yaml
terraform {
  backend "s3"{
    bucket                 = "bucket-name"
    region                 = "us-west-2"
    key                    = "<resource>.tfstate"
    dynamodb_table         = "dynamodb-table-name"
  }
}
```

## Terraform Variables

You must modify the variables in `variables.tf` for every deployed AWS component.

- **vpc_cidr**: The IPv4 CIDR block for the VPC. CIDR can be explicitly set, or it can be derived from IPAM using `ipv4_netmask_length` and `ipv4_ipam_pool_id`.
  - Example: `
