Skip to content

Commit

Permalink
Terraform cleanup [Part 1] (#4106)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoacierno authored Oct 6, 2024
1 parent 61bffdf commit 8442737
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 178 deletions.
60 changes: 30 additions & 30 deletions infrastructure/applications/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions infrastructure/applications/applications.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
locals {
is_prod = terraform.workspace == "production"
deploy_pretix = local.is_prod
enable_proxy = local.is_prod ? false : false

# AMI
# Built from https://github.com/aws/amazon-ecs-ami
# Using 8GB as storage.
ecs_x86_ami = "ami-04467750a630d1f7c" # make al2023
ecs_arm_ami = "ami-0bd650c1ca04cc1a4" # make al2023arm
}

Expand All @@ -15,14 +13,11 @@ locals {
module "pretix" {
source = "./pretix"
count = local.deploy_pretix ? 1 : 0
enable_proxy = local.enable_proxy
ecs_x86_ami = local.ecs_x86_ami
ecs_arm_ami = local.ecs_arm_ami
}

module "pycon_backend" {
source = "./pycon_backend"
enable_proxy = local.enable_proxy
ecs_arm_ami = local.ecs_arm_ami

providers = {
Expand All @@ -35,7 +30,6 @@ module "pycon_backend" {

module "database" {
source = "./database"
enable_proxy = local.enable_proxy
}

module "emails" {
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/applications/config.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.64.0"
version = "5.70.0"
configuration_aliases = [aws.us]
}
}
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/applications/database/db.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "aws_db_instance" "database" {
identifier = "pythonit-${terraform.workspace}"
allow_major_version_upgrade = true
engine_version = "14.12"
instance_class = local.is_prod ? "db.t4g.micro" : "db.t4g.micro"
instance_class = "db.t4g.micro"
db_name = "${local.normalized_workspace}backend"
username = "root"
password = module.common_secrets.value.database_password
Expand Down
92 changes: 0 additions & 92 deletions infrastructure/applications/database/proxy.tf

This file was deleted.

1 change: 0 additions & 1 deletion infrastructure/applications/database/variable.tf

This file was deleted.

5 changes: 0 additions & 5 deletions infrastructure/applications/pretix/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ resource "aws_eip" "ip" {
}
}

data "aws_db_proxy" "proxy" {
count = var.enable_proxy ? 1 : 0
name = "pythonit-${terraform.workspace}-database-proxy"
}

resource "aws_ebs_volume" "data" {
availability_zone = "eu-central-1a"
size = 20
Expand Down
2 changes: 0 additions & 2 deletions infrastructure/applications/pretix/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
variable "enable_proxy" {}
variable "ecs_x86_ami" {}
variable "ecs_arm_ami" {}
7 changes: 1 addition & 6 deletions infrastructure/applications/pycon_backend/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ locals {
is_prod = terraform.workspace == "production"
admin_domain = "admin"
full_admin_domain = local.is_prod ? "${local.admin_domain}.pycon.it" : "${terraform.workspace}-${local.admin_domain}.pycon.it"
db_connection = var.enable_proxy ? "postgres://${data.aws_db_instance.database.master_username}:${module.common_secrets.value.database_password}@${data.aws_db_proxy.proxy[0].endpoint}:${data.aws_db_instance.database.port}/pycon" : "postgres://${data.aws_db_instance.database.master_username}:${module.common_secrets.value.database_password}@${data.aws_db_instance.database.address}:${data.aws_db_instance.database.port}/pycon"
db_connection = "postgres://${data.aws_db_instance.database.master_username}:${module.common_secrets.value.database_password}@${data.aws_db_instance.database.address}:${data.aws_db_instance.database.port}/pycon"
cdn_url = local.is_prod ? "cdn.pycon.it" : "${terraform.workspace}-cdn.pycon.it"
}

Expand Down Expand Up @@ -40,11 +40,6 @@ data "aws_db_instance" "database" {
db_instance_identifier = "pythonit-${terraform.workspace}"
}

data "aws_db_proxy" "proxy" {
count = var.enable_proxy ? 1 : 0
name = "pythonit-${terraform.workspace}-database-proxy"
}

data "aws_acm_certificate" "cert" {
domain = "*.pycon.it"
statuses = ["ISSUED"]
Expand Down
1 change: 0 additions & 1 deletion infrastructure/applications/pycon_backend/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.64.0"
configuration_aliases = [aws.us]
}
}
Expand Down
14 changes: 0 additions & 14 deletions infrastructure/applications/pycon_backend/queue.tf

This file was deleted.

20 changes: 7 additions & 13 deletions infrastructure/applications/pycon_backend/s3.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
resource "aws_s3_bucket" "backend_media" {
bucket = "${terraform.workspace}-pycon-backend-media"
force_destroy = !local.is_prod
}

cors_rule {
allowed_headers = ["*"]
allowed_methods = ["PUT", "POST"]
allowed_origins = ["*"]
expose_headers = ["ETag"]
max_age_seconds = 3000
}
resource "aws_s3_bucket_server_side_encryption_configuration" "backend_media" {
bucket = aws_s3_bucket.backend_media.id

server_side_encryption_configuration {
rule {
bucket_key_enabled = false
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
rule {
bucket_key_enabled = false
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
1 change: 0 additions & 1 deletion infrastructure/applications/pycon_backend/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ locals {
local_path = "backend"
}

variable "enable_proxy" {}
variable "ecs_arm_ami" {}
5 changes: 0 additions & 5 deletions infrastructure/applications/pycon_backend/worker_repo.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ data "aws_ecr_repository" "be_repo" {
name = "pythonit/pycon-backend"
}

data "aws_ecr_image" "be_image" {
repository_name = data.aws_ecr_repository.be_repo.name
image_tag = data.external.githash.result.githash
}

data "aws_ecr_image" "be_arm_image" {
repository_name = data.aws_ecr_repository.be_repo.name
image_tag = "arm-${data.external.githash.result.githash}"
Expand Down

0 comments on commit 8442737

Please sign in to comment.