diff --git a/.github/workflows/instance-deploy-prod.yml b/.github/workflows/instance-deploy-prod.yml index e0c7c26..fe99090 100644 --- a/.github/workflows/instance-deploy-prod.yml +++ b/.github/workflows/instance-deploy-prod.yml @@ -119,12 +119,12 @@ jobs: acrName: onlinestorecontainerregistry acrUsername: ${{ secrets.ACR_USERNAME }} acrPassword: ${{ secrets.ACR_TOKEN }} - containerAppName: onlinestore-api + containerAppName: prod-onlinestore-api imageToDeploy: onlinestorecontainerregistry.azurecr.io/onlinestore-api:${{ github.sha }} location: 'East US' resourceGroup: ${{ env.resource_group_name }} targetPort: 8080 - environmentVariables: OTEL_EXPORTER_OTLP_ENDPOINT=http://onlinestore-monitoring:18889 + environmentVariables: OTEL_EXPORTER_OTLP_ENDPOINT=http://prod-onlinestore-monitoring:18889 - name: Deploy website uses: azure/container-apps-deploy-action@v1 with: @@ -132,7 +132,7 @@ jobs: acrName: onlinestorecontainerregistry acrUsername: ${{ secrets.ACR_USERNAME }} acrPassword: ${{ secrets.ACR_TOKEN }} - containerAppName: onlinestore-website + containerAppName: prod-onlinestore-website imageToDeploy: onlinestorecontainerregistry.azurecr.io/onlinestore-website:${{ github.sha }} location: 'East US' resourceGroup: ${{ env.resource_group_name }} diff --git a/.github/workflows/instance-deploy-test.yml b/.github/workflows/instance-deploy-test.yml index ca52a24..07f37d7 100644 --- a/.github/workflows/instance-deploy-test.yml +++ b/.github/workflows/instance-deploy-test.yml @@ -60,7 +60,7 @@ jobs: TF_VAR_environment: ${{ github.head_ref }} TF_VAR_acr_username: ${{ secrets.ACR_USERNAME }} TF_VAR_acr_password: ${{ secrets.ACR_TOKEN }} - TF_VAR_website_dns_subdomain: ${{ github.head_ref }}-site + TF_VAR_website_dns_subdomain: ${{ github.head_ref }}-website TF_VAR_api_dns_subdomain: ${{ github.head_ref }}-api TF_VAR_monitoring_dns_subdomain: ${{ github.head_ref }}-monitoring - name: Terraform Apply @@ -71,9 +71,9 @@ jobs: TF_VAR_environment: ${{ github.head_ref }} TF_VAR_acr_username: ${{ secrets.ACR_USERNAME }} TF_VAR_acr_password: ${{ secrets.ACR_TOKEN }} - TF_VAR_website_dns_subdomain: ${{ github.head_ref }} - TF_VAR_api_dns_subdomain: api - TF_VAR_monitoring_dns_subdomain: monitoring + TF_VAR_website_dns_subdomain: ${{ github.head_ref }}-website + TF_VAR_api_dns_subdomain: ${{ github.head_ref }}-api + TF_VAR_monitoring_dns_subdomain: ${{ github.head_ref }}-monitoring - name: Save terraform outputs shell: bash run: | @@ -114,22 +114,24 @@ jobs: - name: Deploy api uses: azure/container-apps-deploy-action@v1 with: + yamlConfigPath: .github/workflows/config/container-environment-config.yaml acrName: onlinestorecontainerregistry acrUsername: ${{ secrets.ACR_USERNAME }} acrPassword: ${{ secrets.ACR_TOKEN }} - containerAppName: onlinestore-api + containerAppName: ${{ github.head_ref }}-onlinestore-api imageToDeploy: onlinestorecontainerregistry.azurecr.io/onlinestore-api:${{ github.sha }} location: 'East US' resourceGroup: ${{ env.resource_group_name }} targetPort: 8080 - environmentVariables: OTEL_EXPORTER_OTLP_ENDPOINT=http://onlinestore-monitoring:18889 + environmentVariables: OTEL_EXPORTER_OTLP_ENDPOINT=http://${{ github.head_ref }}-onlinestore-monitoring:18889 - name: Deploy website uses: azure/container-apps-deploy-action@v1 with: + yamlConfigPath: .github/workflows/config/container-environment-config.yaml acrName: onlinestorecontainerregistry acrUsername: ${{ secrets.ACR_USERNAME }} acrPassword: ${{ secrets.ACR_TOKEN }} - containerAppName: onlinestore-website + containerAppName: ${{ github.head_ref }}-onlinestore-website imageToDeploy: onlinestorecontainerregistry.azurecr.io/onlinestore-website:${{ github.sha }} location: 'East US' resourceGroup: ${{ env.resource_group_name }} diff --git a/terraform/instance/container_apps.tf b/terraform/instance/container_apps.tf index aec3ff8..c0bb36b 100644 --- a/terraform/instance/container_apps.tf +++ b/terraform/instance/container_apps.tf @@ -4,7 +4,7 @@ data "azurerm_container_app_environment" "apps" { } resource "azurerm_container_app" "api" { - name = "${var.name}-api" + name = "${lower(var.environment)}-${var.name}-api" container_app_environment_id = data.azurerm_container_app_environment.apps.id resource_group_name = azurerm_resource_group.instance.name revision_mode = "Single" @@ -39,7 +39,7 @@ resource "azurerm_container_app" "api" { } resource "azurerm_container_app" "website" { - name = "${var.name}-website" + name = "${lower(var.environment)}-${var.name}-website" container_app_environment_id = data.azurerm_container_app_environment.apps.id resource_group_name = azurerm_resource_group.instance.name revision_mode = "Single" @@ -74,7 +74,7 @@ resource "azurerm_container_app" "website" { } resource "azurerm_container_app" "monitoring" { - name = "${var.name}-monitoring" + name = "${lower(var.environment)}-${var.name}-monitoring" container_app_environment_id = data.azurerm_container_app_environment.apps.id resource_group_name = azurerm_resource_group.instance.name revision_mode = "Single" diff --git a/terraform/instance/dns.tf b/terraform/instance/dns.tf index d67b0a3..302517a 100644 --- a/terraform/instance/dns.tf +++ b/terraform/instance/dns.tf @@ -24,7 +24,6 @@ resource "azurerm_dns_txt_record" "api" { resource "azurerm_container_app_custom_domain" "api" { name = trimsuffix(trimprefix(azurerm_dns_txt_record.api.fqdn, "asuid."), ".") container_app_id = azurerm_container_app.api.id - certificate_binding_type = "SniEnabled" depends_on = [ azurerm_dns_txt_record.api, @@ -57,7 +56,6 @@ resource "azurerm_dns_txt_record" "website" { resource "azurerm_container_app_custom_domain" "website" { name = trimsuffix(trimprefix(azurerm_dns_txt_record.website.fqdn, "asuid."), ".") container_app_id = azurerm_container_app.website.id - certificate_binding_type = "SniEnabled" depends_on = [ azurerm_dns_txt_record.website, @@ -90,7 +88,6 @@ resource "azurerm_dns_txt_record" "monitoring" { resource "azurerm_container_app_custom_domain" "monitoring" { name = trimsuffix(trimprefix(azurerm_dns_txt_record.monitoring.fqdn, "asuid."), ".") container_app_id = azurerm_container_app.monitoring.id - certificate_binding_type = "SniEnabled" depends_on = [ azurerm_dns_txt_record.monitoring,