Skip to content

Commit

Permalink
Derive app_name from module path (#568)
Browse files Browse the repository at this point in the history
When changing the name of the application from the default of `app`,
such as when adding multiple applications to a monorepo, developers
often forget to modify the app_name config value in the app-config
module. This change removes the need for that manual step by obtaining
the app_name from the name of the folder containing the application's
infrastructure code.
  • Loading branch information
lorenyu authored Feb 28, 2024
1 parent c630716 commit 2ff0cc3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion infra/app/app-config/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
locals {
app_name = "app"
# app_name is the name of the application, which by convention should match the name of
# the folder under /infra that corresponds to the application
app_name = regex("/infra/([^/]+)/app-config$", abspath(path.module))[0]

environments = ["dev", "staging", "prod"]
project_name = module.project_config.project_name
image_repository_name = "${local.project_name}-${local.app_name}"
Expand Down

0 comments on commit 2ff0cc3

Please sign in to comment.