Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nest network and within service & database modules #161

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

coilysiren
Copy link
Contributor

@coilysiren coilysiren commented Jan 21, 2025

Motivation and Context

The motivation of this PR is in this diff:

image

Nesting the network module within the service/database modules has the following impact:

  • reduces the networking-related API surface of those modules
  • abstract the remaining networking API surface away from AWS

This makes the modules more flexible and resilient!

Testing

~/projects/platform-test/infra/app/service/

$ terraform plan -var environment_name=dev

> No changes. Your infrastructure matches the configuration.
~/projects/platform-test/infra/app/database/

$ terraform plan -var environment_name=dev

> No changes. Your infrastructure matches the configuration.

Preview environment for app

Preview environment for app-rails

Copy link
Collaborator

@lorenyu lorenyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@@ -3,30 +3,34 @@ module "interface" {
name = var.name
}

module "project_config" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we discussed in our 1:1 don't introduce dependencies on config modules in reusable modules

Copy link
Contributor Author

@coilysiren coilysiren Jan 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can definitely make that change! I just don't totally remember the motivation there. Like, what's the conceptual difference between nesting the network model and nesting the project config module?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

infra/modules/ are reusable modules. they should have no dependencies on anything project specific.
Longer term once these modules are stable we may decided to publish them to the terraform registry, so we should have no dependencies on any local project configuration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah! So infra/modules are truly meant to be as flexible as terraform modules you would find on the registry. Gotcha.

That changes my point of view here a bit... but I'm going to continue on with nesting the VPC module

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's also why I was on the fence about nesting the network module, because by nesting the network module it means that database and service modules now have a dependency on the network module, meaning that in order for someone to use the database and service modules they would also need to use the network module, or at least adhere to the same interface for the network module. But after seeing how it cleans up the interface I think maybe the benefit is worth the tradeoff.

Comment on lines -66 to -69
vpc_id = module.network.vpc_id
public_subnet_ids = module.network.public_subnet_ids
private_subnet_ids = module.network.private_subnet_ids
aws_services_security_group_id = module.network.aws_services_security_group_id
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😎

@coilysiren coilysiren changed the title Nest network and project module within service module Nest network and within service module Jan 28, 2025
@coilysiren coilysiren changed the title Nest network and within service module Nest network and within service & database modules Jan 28, 2025
@coilysiren coilysiren marked this pull request as ready for review January 28, 2025 00:53
@@ -33,6 +33,10 @@ locals {
)
}

module "project_config" {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clean this up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants