diff --git a/infrastructure/README.md b/infrastructure/README.md new file mode 100644 index 0000000..54f0707 --- /dev/null +++ b/infrastructure/README.md @@ -0,0 +1,44 @@ +# Terraform Module + + +## Requirements + +| Name | Version | +|------|---------| +| [aws](#requirement\_aws) | ~> 5.0 | +| [github](#requirement\_github) | ~> 6.0 | +| [infisical](#requirement\_infisical) | ~> 0.8 | + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws](#module\_aws) | ./aws | n/a | +| [github](#module\_github) | ./github | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_region](#input\_aws\_region) | AWS region | `string` | `"us-east-1"` | no | +| [github\_token](#input\_github\_token) | GitHub personal access token | `string` | n/a | yes | +| [infisical\_client\_id](#input\_infisical\_client\_id) | Infisical client ID | `string` | n/a | yes | +| [infisical\_client\_secret](#input\_infisical\_client\_secret) | Infisical client secret | `string` | n/a | yes | +| [infisical\_workspace\_id](#input\_infisical\_workspace\_id) | Infisical workspace ID | `string` | `"d1ee8b80-118c-4daf-ae84-31da43261b76"` | no | +| [repository\_collaborators](#input\_repository\_collaborators) | List of GitHub users to add as collaborators |
list(object({
username = string
permission = string
}))
| `[]` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [github\_repository\_name](#output\_github\_repository\_name) | GitHub repository name | +| [rds\_endpoint](#output\_rds\_endpoint) | RDS instance endpoint | + diff --git a/infrastructure/aws/.terraform-version b/infrastructure/aws/.terraform-version new file mode 100644 index 0000000..feaae22 --- /dev/null +++ b/infrastructure/aws/.terraform-version @@ -0,0 +1 @@ +1.13.0 diff --git a/infrastructure/aws/README.md b/infrastructure/aws/README.md new file mode 100644 index 0000000..163d22c --- /dev/null +++ b/infrastructure/aws/README.md @@ -0,0 +1,39 @@ +# Terraform Module + + +## Requirements + +| Name | Version | +|------|---------| +| [aws](#requirement\_aws) | 6.14.1 | + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | 6.14.1 | +| [infisical](#provider\_infisical) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_db_instance.branch_rds](https://registry.terraform.io/providers/hashicorp/aws/6.14.1/docs/resources/db_instance) | resource | +| [infisical_secrets.rds_folder](https://registry.terraform.io/providers/infisical/infisical/latest/docs/data-sources/secrets) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [infisical\_client\_id](#input\_infisical\_client\_id) | n/a | `string` | n/a | yes | +| [infisical\_client\_secret](#input\_infisical\_client\_secret) | n/a | `string` | n/a | yes | +| [infisical\_workspace\_id](#input\_infisical\_workspace\_id) | n/a | `string` | `"d1ee8b80-118c-4daf-ae84-31da43261b76"` | no | + +## Outputs + +No outputs. + diff --git a/infrastructure/aws/backend.tf b/infrastructure/aws/backend.tf new file mode 100644 index 0000000..6a28c27 --- /dev/null +++ b/infrastructure/aws/backend.tf @@ -0,0 +1,9 @@ +terraform { + backend "s3" { + bucket = "c4c-neu-terraform-state-files" + key = "aws/terraform.tfstate" + region = "us-east-2" + dynamodb_table = "terraform-state-lock" + encrypt = true + } +} \ No newline at end of file diff --git a/infrastructure/aws/main.tf b/infrastructure/aws/main.tf new file mode 100644 index 0000000..e649ee1 --- /dev/null +++ b/infrastructure/aws/main.tf @@ -0,0 +1,11 @@ +resource "aws_db_instance" "branch_rds" { + allocated_storage = 10 + db_name = "branch_rds" + engine = "postgres" + engine_version = "18.0" + instance_class = "db.t3.micro" + username = data.infisical_secrets.rds_folder.secrets["username"].value + password = data.infisical_secrets.rds_folder.secrets["password"].value + parameter_group_name = "default.postgres18.0" + skip_final_snapshot = true +} \ No newline at end of file diff --git a/infrastructure/aws/providers.tf b/infrastructure/aws/providers.tf new file mode 100644 index 0000000..b73dae3 --- /dev/null +++ b/infrastructure/aws/providers.tf @@ -0,0 +1,25 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "6.14.1" + } + infisical = { + source = "infisical/infisical" + } + } +} + +provider "aws" { + region = "us-east-2" +} + +provider "infisical" { + host = "https://app.infisical.com" + auth = { + universal = { + client_id = var.infisical_client_id + client_secret = var.infisical_client_secret + } + } +} \ No newline at end of file diff --git a/infrastructure/aws/secrets.tf b/infrastructure/aws/secrets.tf new file mode 100644 index 0000000..9ac70cf --- /dev/null +++ b/infrastructure/aws/secrets.tf @@ -0,0 +1,13 @@ +variable "infisical_client_id" { + type = string +} + +variable "infisical_client_secret" { + type = string +} + +data "infisical_secrets" "rds_folder" { + env_slug = "dev" + workspace_id = var.infisical_workspace_id + folder_path = "/aws/rds" +} \ No newline at end of file diff --git a/infrastructure/aws/variables.tf b/infrastructure/aws/variables.tf new file mode 100644 index 0000000..07d2fd5 --- /dev/null +++ b/infrastructure/aws/variables.tf @@ -0,0 +1,4 @@ +variable "infisical_workspace_id" { + type = string + default = "d1ee8b80-118c-4daf-ae84-31da43261b76" +} \ No newline at end of file diff --git a/infrastructure/github/secrets.tf b/infrastructure/github/secrets.tf index 3b03076..36fada5 100644 --- a/infrastructure/github/secrets.tf +++ b/infrastructure/github/secrets.tf @@ -55,3 +55,4 @@ variable "infisical_workspace_id" { type = string default = "d1ee8b80-118c-4daf-ae84-31da43261b76" } + diff --git a/infrastructure/github/variables.tf b/infrastructure/github/variables.tf index 5bdb931..e17d6a6 100644 --- a/infrastructure/github/variables.tf +++ b/infrastructure/github/variables.tf @@ -10,4 +10,4 @@ variable "repository_collaborators" { # permission = "push" # } ] -} +} \ No newline at end of file