Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from FIAP-3SOAT-G15/change-instance-class
Browse files Browse the repository at this point in the history
Update IaC
  • Loading branch information
wellyfrs authored Mar 16, 2024
2 parents 66de750 + af27ebf commit 3efc70b
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 22 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/rds.yml → .github/workflows/provisioning.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
name: "RDS"
name: "Provisioning"

on:
push:
branches:
- main
paths:
- .github/workflows/rds.yml
- .github/workflows/provisioning.yml
- 'terraform/**'
pull_request:
branches:
- main
paths:
- .github/workflows/rds.yml
- .github/workflows/provisioning.yml
- 'terraform/**'

jobs:
rds:
provisioning:
runs-on: ubuntu-latest
defaults:
run:
Expand Down Expand Up @@ -62,5 +62,5 @@ jobs:
run: exit 1

- name: Terraform Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
#if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terraform apply -auto-approve -input=false
62 changes: 62 additions & 0 deletions terraform/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
locals {
name = "selfordermanagementdb"
}

data "terraform_remote_state" "tech-challenge" {
backend = "s3"

config = {
bucket = "fiap-3soat-g15-infra-tech-challenge-state"
key = "live/terraform.tfstate"
region = var.region
}
}

module "db" {
source = "terraform-aws-modules/rds/aws"
version = "6.5.2"

identifier = local.name

engine = "postgres"
engine_version = "15"
family = "postgres15"
major_engine_version = "15"
instance_class = "db.t3.micro"

allocated_storage = 10
max_allocated_storage = 20

storage_encrypted = false

db_name = local.name
username = "master"
port = 5432

manage_master_user_password = true

multi_az = false
db_subnet_group_name = data.terraform_remote_state.tech-challenge.outputs.database_subnet_group_name
vpc_security_group_ids = [module.security_group.security_group_id]

backup_retention_period = 0
skip_final_snapshot = true
deletion_protection = false
}

module "security_group" {
source = "terraform-aws-modules/security-group/aws"
version = "~> 5.0"

name = local.name
vpc_id = data.terraform_remote_state.tech-challenge.outputs.vpc_id

ingress_with_cidr_blocks = [
{
from_port = 5432
to_port = 5432
protocol = "tcp"
cidr_blocks = data.terraform_remote_state.tech-challenge.outputs.vpc_cidr_block
},
]
}
2 changes: 1 addition & 1 deletion terraform/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0.0"
version = ">= 5.36"
}
}

Expand Down
16 changes: 0 additions & 16 deletions terraform/rds.tf

This file was deleted.

0 comments on commit 3efc70b

Please sign in to comment.