# AWS Terraform deployment

Information specific to CiviForm Terraform deploy scripts for AWS.

For general information, see [Terraform deploy system](/it-manual/sre-playbook/initial-deployment/terraform-deploy-system.md).

## Infrastructure

![AWS System Diagram](https://user-images.githubusercontent.com/1741747/184951252-1a33c8c8-8a86-44ea-b39a-cebea71e7495.png)

Created for CiviForm app:

* VPC
* Load balancer
* Internet Gateway
* NAT Gateway
* Fargate ECS cluster
* RDS with Postgres
* S3 bucket

Connected services

* SES
* Secrets Manager

Supporting Infrastructure:

* S3 bucket for Terraform backend state
* CloudWatch export for logs

## Code and examples (AWS)

The code that manages deployment can be found [here](https://github.com/civiform/cloud-deploy-infra/tree/main/cloud/aws).

Our staging environment is at [staging-aws.civiform.dev](https://staging-aws.civiform.dev).

Config for the staging environment is [here](https://github.com/civiform/civiform-staging-deploy/blob/main/aws_staging_civiform_config.sh).

## Troubleshooting

After running the `setup` or `deploy` script, you can login to the [AWS ECS console](https://console.aws.amazon.com/ecs/v2/clusters) to check the status of CiviForm. Make sure to select correct region in the top right corner.

You should see Cluster with app\_prefix-civiform name. Click on it and go to Tasks tab. If everything is going well you should see a task in the Running state.

![Screen Shot 2022-08-15 at 5 18 55 PM](https://user-images.githubusercontent.com/1741747/184758808-c1081316-7baf-45dc-9c76-a64594a9de5e.png)

### Inspecting task config

You can see the task configuration by clicking on the Task definition tab, finding the latest revision, and opening the JSON tab.

![Screen Shot 2022-08-15 at 5 21 53 PM](https://user-images.githubusercontent.com/1741747/184758833-fce81bec-9f2c-49be-a102-2d5b38aa58dd.png)

### Inspecting logs

You can see the logs on the task page by clicking into the specific task and selecting Logs.

![Screen Shot 2022-08-15 at 5 23 27 PM](https://user-images.githubusercontent.com/1741747/184758931-a8374a7a-d1dc-4308-8676-7617d4237d7a.png)

Logs are also available in CloudWatch. Search for app\_prefix-civiformlogs group.

![Screen Shot 2022-08-15 at 5 26 42 PM](https://user-images.githubusercontent.com/1741747/184758880-f92b064b-658c-401e-ad71-175f64fde305.png)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.civiform.us/it-manual/sre-playbook/initial-deployment/terraform-deploy-system/terraform-aws-deployment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
