Skip to content

Commit

Permalink
docs: add RFC-005 Terraform to mono-repository (#19)
Browse files Browse the repository at this point in the history
* docs: add RFC-005 Terraform to mono-repository

* docs: add `backend.tf` example

* docs: grammar

* docs: add batch jobs to the scope

* docs: move the scope section higher and improve clarity
  • Loading branch information
JoshuaLicense authored Mar 13, 2024
1 parent 3e341a8 commit 689f208
Showing 1 changed file with 98 additions and 0 deletions.
98 changes: 98 additions & 0 deletions docs/rfc/rfc-005-add-terraform-to-mono-repository.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# RFC-005: Add Terraform to Mono-repository

## Summary

This RFC proposes incorporating Terraform into the mono repository to manage infrastructure as code, initially focusing on container-related AWS resources.

## Problem

Historically, Terraform has been managed in a separate repository, leading to several challenges:

### Rollback

The Terraform repository lacks automated versioning alignment with application code, complicating understanding of infrastructure state at specific points in time. This creates challenges during rollbacks or deploying older application versions for testing, as it necessitates running two independent workflows in a specific sequence, contradicting the principles of continuous delivery (CD).

### Duplication & Maintenance

Maintaining separate repositories necessitates duplicating GitHub Action workflows across them to apply changes to both application and infrastructure. Each repository must also check out code from the other, typically requiring the application code to utilize a Personal Access Token (PAT) for accessing private infrastructure code, adding to maintenance overhead.

## Proposal

Building on the proposal from RFC-001, Terraform, limited to the scope below, will be integrated into the mono repository to manage infrastructure as code.

### Scope

This RFC will cover resources created with the following Terraform modules:

- https://github.com/terraform-aws-modules/terraform-aws-ecr
- https://github.com/terraform-aws-modules/terraform-aws-ecs
- https://github.com/terraform-aws-modules/terraform-aws-batch

Any resources that support the above work can be included without requiring a new RFC. Subsequent RFCs should be created for larger collections of resources, such as networking or databases.

### Terraform Directory Structure

Terraform files will reside in the `infra/terraform` directory, organized as follows:

```js
|-- `terraform/`
| |-- `accounts/`
| | |-- `nonprod/`
| | | |-- `backend.tf`
| | | |-- `main.tf`
| | | |-- `outputs.tf`
| | | |-- `provider.tf`
| | | |-- `variables.tf`
| | | |-- ...
| | |-- `prod/`
| | | |-- `backend.tf`
| | | |-- `main.tf`
| | | |-- `outputs.tf`
| | | |-- `provider.tf`
| | | |-- `variables.tf`
| | | |-- ...
| |-- `environments/`
| | |-- `dev/`
| | | |-- `backend.tf`
| | | |-- `main.tf`
| | | |-- `outputs.tf`
| | | |-- `provider.tf`
| | | |-- `variables.tf`
| | | |-- ...
| | |-- `int/`
| | | |-- `backend.tf`
| | | |-- `main.tf`
| | | |-- `outputs.tf`
| | | |-- `provider.tf`
| | | |-- `variables.tf`
| | | |-- ...
| | |-- `prep/`
| | | |-- `backend.tf`
| | | |-- `main.tf`
| | | |-- `outputs.tf`
| | | |-- `provider.tf`
| | | |-- `variables.tf`
| | | |-- ...
| | |-- `prod/`
| | | |-- `backend.tf`
| | | |-- `main.tf`
| | | |-- `outputs.tf`
| | | |-- `provider.tf`
| | | |-- `variables.tf`
| | | |-- ...
| | |-- ...
| |-- `modules/`
| | |-- `account/`
| | | |-- `main.tf`
| | | |-- `outputs.tf`
| | | |-- `provider.tf`
| | | |-- `variables.tf`
| | | |-- ...
| | |-- `service/`
| | | |-- `main.tf`
| | | |-- `outputs.tf`
| | | |-- `provider.tf`
| | | |-- `variables.tf`
| | | |-- ...
| | |-- ...
```

0 comments on commit 689f208

Please sign in to comment.