Feature/1 add projects and about pages (#2)

* adding api

* adding projects page

* adding project page

* updating terraform

* updating terraform

* adding github workflows
This commit was merged in pull request #2.
This commit is contained in:
2025-02-23 20:45:04 +00:00
committed by GitHub
parent 2d9cd07358
commit 6deca4c7ea
95 changed files with 14643 additions and 1500 deletions

4
infrastructure/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
# Terraform
.terraform/*
*.tfstate
*.tfstate.*

View File

@@ -1,47 +0,0 @@
data "azurerm_client_config" "current" {}
data "azurerm_user_assigned_identity" "user_assigned_identity" {
name = "noahspanflyingdevuser"
resource_group_name = azurerm_resource_group.resource_group.name
}
resource "azurerm_app_configuration" "app_configuration" {
name = "noahspan-appconfig"
resource_group_name = azurerm_resource_group.resource_group.name
location = azurerm_resource_group.resource_group.location
identity {
type = "UserAssigned"
identity_ids = [
data.azurerm_user_assigned_identity.user_assigned_identity.id
]
}
}
resource "azurerm_role_assignment" "role_assignment" {
scope = azurerm_app_configuration.app_configuration.id
role_definition_name = "App Configuration Data Owner"
principal_id = data.azurerm_client_config.current.object_id
}
# resource "azurerm_app_configuration_feature" "flying-pilots" {
# configuration_store_id = azurerm_app_configuration.app_configuration.id
# description = "Feature flag for pilots page in flying app"
# name = "flying-pilots"
# label = "flying-pilots-label"
# enabled = false
# depends_on = [ azurerm_role_assignment.role_assignment ]
# }
# resource "azurerm_app_configuration_feature" "flying-logbook" {
# configuration_store_id = azurerm_app_configuration.app_configuration.id
# description = "Feature flag for logbook page in flying app"
# name = "flying-logbook"
# label = "flying-logbook-label"
# enabled = false
# depends_on = [ azurerm_role_assignment.role_assignment ]
# }

4
infrastructure/config.tf Normal file
View File

@@ -0,0 +1,4 @@
module "environment" {
source = "./config"
environment = var.WORKSPACE
}

View File

@@ -0,0 +1,61 @@
locals {
container_app_app_name = {
test = "root-app-test"
prod = "root-app-prod"
}
container_app_app_container_image = {
test = "noahspan/root-app:v0.0.1"
prod = "noahspan/root-app:v0.0.1"
}
container_app_app_container_name = {
test = "root-app-test"
prod = "root-app-prod"
}
container_app_api_name = {
test = "root-api-test"
prod = "root-api-prod"
}
container_app_api_container_image = {
test = "noahspan/root-api:v0.0.1"
prod = "noahspan/root-api:v0.0.1"
}
container_app_api_container_name = {
test = "root-api-test"
prod = "root-api-prod"
}
container_app_api_dapr_app_id = {
test = "rootapitest"
prod = "rootpapiprod"
}
container_app_environment_name = {
test = "root-test"
prod = "root-prod"
}
custom_domain_count = {
test = 0
prod = 1
}
log_analytics_workspace_name = {
test = "root-log-analytics-workspace-test"
prod = "root-log-analytics-workspace-prod"
}
storage_account_name = {
test = "noahspanroottest"
prod = "noahspanrootprod"
}
storage_tables = {
test = ["projects"]
prod = ["projects"]
}
}

View File

@@ -0,0 +1,47 @@
output "container_app_app_name" {
value = local.container_app_app_name[var.environment]
}
output "container_app_app_container_image" {
value = local.container_app_app_container_image[var.environment]
}
output "container_app_app_container_name" {
value = local.container_app_app_container_name[var.environment]
}
output "container_app_api_name" {
value = local.container_app_api_name[var.environment]
}
output "container_app_api_container_image" {
value = local.container_app_api_container_image[var.environment]
}
output "container_app_api_container_name" {
value = local.container_app_api_container_name[var.environment]
}
output "container_app_api_dapr_app_id" {
value = local.container_app_api_dapr_app_id[var.environment]
}
output "container_app_environment_name" {
value = local.container_app_environment_name[var.environment]
}
output "custom_domain_count" {
value = local.custom_domain_count[var.environment]
}
output "log_analytics_workspace_name" {
value = local.log_analytics_workspace_name[var.environment]
}
output "storage_account_name" {
value = local.storage_account_name[var.environment]
}
output "storage_tables" {
value = local.storage_tables[var.environment]
}

View File

@@ -0,0 +1 @@
variable "environment" {}

View File

@@ -1,49 +0,0 @@
# resource "azurerm_static_web_app_custom_domain" "static_web_app_custom_domain_txt" {
# static_web_app_id = module.static_web_app.id
# domain_name = var.DOMAIN_NAME
# validation_type = "dns-txt-token"
# }
resource "azurerm_dns_zone" "dns_zone" {
name = var.DOMAIN_NAME
resource_group_name = azurerm_resource_group.resource_group.name
}
resource "azurerm_dns_txt_record" "dns_txt_record" {
name = var.WEBSITE_NAME == var.DOMAIN_NAME ? "@" : split(".", var.WEBSITE_NAME)[0]
zone_name = azurerm_dns_zone.dns_zone.name
resource_group_name = azurerm_resource_group.resource_group.name
ttl = 14400
record {
value = azurerm_static_web_app_custom_domain.static_web_app_custom_domain.validation_token == "" ? "validated" : azurerm_static_web_app_custom_domain.static_web_app_custom_domain.validation_token
}
# email
record {
value = var.EMAIL_TXT_VALUE == "" ? "validated" : var.EMAIL_TXT_VALUE
}
record {
value = var.EMAIL_SPF_VALUE == "" ? "validated" : var.EMAIL_SPF_VALUE
}
}
# email
resource "azurerm_dns_mx_record" "dns_mx_record" {
name = "@"
zone_name = azurerm_dns_zone.dns_zone.name
resource_group_name = azurerm_resource_group.resource_group.name
ttl = 14400
record {
preference = 10
exchange = "mx01.mail.icloud.com."
}
record {
preference = 10
exchange = "mx02.mail.icloud.com."
}
}

View File

@@ -1,45 +1,23 @@
# module "static_web_app" {
# source = "./modules/static_web_app"
# region = var.REGION
# resource_group_name = azurerm_resource_group.resource_group.name
# static_web_app_name = var.STATIC_WEB_APP_NAME
# custom_domain_name_count = var.CUSTOM_DOMAIN_NAME_COUNT
# domain_name = var.DOMAIN_NAME
# subdomain_name = var.SUBDOMAIN_NAME
# }
resource "azurerm_static_web_app" "static_web_app" {
name = var.STATIC_WEB_APP_NAME
resource_group_name = azurerm_resource_group.resource_group.name
location = var.REGION
}
resource "azurerm_static_web_app_custom_domain" "static_web_app_custom_domain" {
static_web_app_id = azurerm_static_web_app.static_web_app.id
domain_name = var.WEBSITE_NAME
validation_type = "dns-txt-token"
}
resource "azurerm_dns_a_record" "dns_a_record" {
name = var.WEBSITE_NAME == var.DOMAIN_NAME ? "@" : split(".", var.WEBSITE_NAME)[0]
zone_name = azurerm_dns_zone.dns_zone.name
resource_group_name = azurerm_resource_group.resource_group.name
ttl = 14400
target_resource_id = azurerm_static_web_app.static_web_app.id
}
resource "azurerm_dns_cname_record" "dns_cname_record" {
name = "www"
zone_name = azurerm_dns_zone.dns_zone.name
resource_group_name = azurerm_resource_group.resource_group.name
ttl = 14400
record = azurerm_static_web_app.static_web_app.default_host_name
}
resource "azurerm_static_web_app_custom_domain" "static_web_app_custom_domain_www" {
static_web_app_id = azurerm_static_web_app.static_web_app.id
domain_name = "www.${var.DOMAIN_NAME}"
validation_type = "cname-delegation"
depends_on = [ azurerm_dns_cname_record.dns_cname_record ]
module "container_app" {
source = "github.com/noahspannbauer/noahspan-terraform/modules/container_app"
app_subdomain_name = var.APP_SUBDOMAIN_NAME
client_id = var.CLIENT_ID
client_secret = var.CLIENT_SECRET
container_app_app_name = module.environment.container_app_app_name
container_app_app_container_image = module.environment.container_app_api_container_image
container_app_app_container_name = module.environment.container_app_api_container_name
container_app_api_name = module.environment.container_app_api_name
container_app_api_container_image = module.environment.container_app_api_container_image
container_app_api_container_name = module.environment.container_app_api_container_name
container_app_environment_name = module.environment.container_app_environment_name
custom_domain_count = module.environment.custom_domain_count
dns_zone_resource_group = var.DNS_ZONE_RESOURCE_GROUP
docker_io_password = var.DOCKER_IO_PASSWORD
docker_io_username = var.DOCKER_IO_USERNAME
domain_name = var.DOMAIN_NAME
log_analytics_workspace_name = module.environment.log_analytics_workspace_name
resource_group_name = var.RESOURCE_GROUP_NAME
storage_account_name = module.environment.storage_account_name
storage_tables = module.environment.storage_tables
tenant_id = var.TENANT_ID
}

View File

@@ -1,12 +0,0 @@
# resource "azurerm_static_web_app" "static_web_app" {
# name = var.static_web_app_name
# resource_group_name = var.resource_group_name
# location = var.region
# }
# resource "azurerm_static_web_app_custom_domain" "static_web_app_custom_domain" {
# count = var.custom_domain_name_count
# static_web_app_id = azurerm_static_web_app.static_web_app.id
# domain_name = "${var.subdomain_name}.${var.domain_name}"
# validation_type = "cname-delegation"
# }

View File

@@ -1,11 +0,0 @@
output "id" {
value = azurerm_static_web_app.static_web_app.id
}
output "api_key" {
value = azurerm_static_web_app.static_web_app.api_key
}
output "default_host_name" {
value = azurerm_static_web_app.static_web_app.default_host_name
}

View File

@@ -1,24 +0,0 @@
variable "region" {
}
variable "resource_group_name" {
}
variable "static_web_app_name" {
}
variable "custom_domain_name_count" {
}
variable "domain_name" {
}
variable "subdomain_name" {
}

View File

@@ -1,17 +0,0 @@
output "api_key" {
value = azurerm_static_web_app.static_web_app.api_key
sensitive = true
}
# output "default_host_name" {
# value = azurerm_static_web_app.static_web_app.default_host_name
# }
# output "validation_token" {
# value = azurerm_static_web_app_custom_domain.static_web_app_custom_domain_txt.validation_token
# sensitive = false
# }
output "name_servers" {
value = azurerm_dns_zone.dns_zone.name_servers
}

View File

@@ -1,4 +0,0 @@
resource "azurerm_resource_group" "resource_group" {
name = var.RESOURCE_GROUP_NAME
location = var.REGION
}

View File

@@ -1,31 +1,42 @@
variable "EMAIL_TXT_VALUE" {
variable "APP_SUBDOMAIN_NAME" {
type = string
}
variable "EMAIL_SPF_VALUE" {
variable "CLIENT_ID" {
type = string
}
variable "REGION" {
variable "CLIENT_SECRET" {
type = string
sensitive = true
}
variable "DNS_ZONE_RESOURCE_GROUP" {
type = string
}
variable "DOCKER_IO_PASSWORD" {
type = string
sensitive = true
}
variable "DOCKER_IO_USERNAME" {
type = string
}
variable "DOMAIN_NAME" {
type = string
}
variable "RESOURCE_GROUP_NAME" {
type = string
}
variable "STATIC_WEB_APP_NAME" {
variable "TENANT_ID" {
type = string
}
variable "CUSTOM_DOMAIN_NAME_COUNT" {
type = number
}
variable "DOMAIN_NAME" {
variable "WORKSPACE" {
type = string
}
variable "WEBSITE_NAME" {
type = string
}