From d159c2e565521a669b4ee47427b2680ba9cd4f15 Mon Sep 17 00:00:00 2001 From: 2097 Date: Tue, 27 Aug 2024 02:27:51 +0900 Subject: [PATCH] chore: workflows --- azure.yaml | 10 --- infra/app/hg-good-tshirt.bicep | 127 --------------------------------- infra/main.bicep | 110 ---------------------------- infra/main.parameters.json | 37 ---------- 4 files changed, 284 deletions(-) delete mode 100644 azure.yaml delete mode 100644 infra/app/hg-good-tshirt.bicep delete mode 100644 infra/main.bicep delete mode 100644 infra/main.parameters.json diff --git a/azure.yaml b/azure.yaml deleted file mode 100644 index ee55e10..0000000 --- a/azure.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json - -name: rg-good-tshirt -metadata: - template: azd-init@1.9.6 -services: - hg-good-tshirt: - project: . - host: containerapp - language: java diff --git a/infra/app/hg-good-tshirt.bicep b/infra/app/hg-good-tshirt.bicep deleted file mode 100644 index a8e8874..0000000 --- a/infra/app/hg-good-tshirt.bicep +++ /dev/null @@ -1,127 +0,0 @@ -param name string -param location string = resourceGroup().location -param tags object = {} - -param identityName string -param containerRegistryName string -param containerAppsEnvironmentName string -param applicationInsightsName string -param exists bool -@secure() -param appDefinition object - -var appSettingsArray = filter(array(appDefinition.settings), i => i.name != '') -var secrets = map(filter(appSettingsArray, i => i.?secret != null), i => { - name: i.name - value: i.value - secretRef: i.?secretRef ?? take(replace(replace(toLower(i.name), '_', '-'), '.', '-'), 32) -}) -var env = map(filter(appSettingsArray, i => i.?secret == null), i => { - name: i.name - value: i.value -}) - -resource identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = { - name: identityName - location: location -} - -resource containerRegistry 'Microsoft.ContainerRegistry/registries@2023-01-01-preview' existing = { - name: containerRegistryName -} - -resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' existing = { - name: containerAppsEnvironmentName -} - -resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = { - name: applicationInsightsName -} - -resource acrPullRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = { - scope: containerRegistry - name: guid(subscription().id, resourceGroup().id, identity.id, 'acrPullRole') - properties: { - roleDefinitionId: subscriptionResourceId( - 'Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d') - principalType: 'ServicePrincipal' - principalId: identity.properties.principalId - } -} - -module fetchLatestImage '../modules/fetch-container-image.bicep' = { - name: '${name}-fetch-image' - params: { - exists: exists - name: name - } -} - -resource app 'Microsoft.App/containerApps@2023-05-02-preview' = { - name: name - location: location - tags: union(tags, {'azd-service-name': 'hg-good-tshirt' }) - dependsOn: [ acrPullRole ] - identity: { - type: 'UserAssigned' - userAssignedIdentities: { '${identity.id}': {} } - } - properties: { - managedEnvironmentId: containerAppsEnvironment.id - configuration: { - ingress: { - external: true - targetPort: 8080 - transport: 'auto' - } - registries: [ - { - server: '${containerRegistryName}.azurecr.io' - identity: identity.id - } - ] - secrets: union([ - ], - map(secrets, secret => { - name: secret.secretRef - value: secret.value - })) - } - template: { - containers: [ - { - image: fetchLatestImage.outputs.?containers[?0].?image ?? 'mcr.microsoft.com/azuredocs/containerapps-helloworld:latest' - name: 'main' - env: union([ - { - name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' - value: applicationInsights.properties.ConnectionString - } - { - name: 'PORT' - value: '8080' - } - ], - env, - map(secrets, secret => { - name: secret.name - secretRef: secret.secretRef - })) - resources: { - cpu: json('1.0') - memory: '2.0Gi' - } - } - ] - scale: { - minReplicas: 1 - maxReplicas: 10 - } - } - } -} - -output defaultDomain string = containerAppsEnvironment.properties.defaultDomain -output name string = app.name -output uri string = 'https://${app.properties.configuration.ingress.fqdn}' -output id string = app.id diff --git a/infra/main.bicep b/infra/main.bicep deleted file mode 100644 index fd035be..0000000 --- a/infra/main.bicep +++ /dev/null @@ -1,110 +0,0 @@ -targetScope = 'subscription' - -@minLength(1) -@maxLength(64) -@description('Name of the environment that can be used as part of naming resource convention') -param environmentName string - -@minLength(1) -@description('Primary location for all resources') -param location string - -param hgGoodTshirtExists bool -@secure() -param hgGoodTshirtDefinition object - -@description('Id of the user or app to assign application roles') -param principalId string - -// Tags that should be applied to all resources. -// -// Note that 'azd-service-name' tags should be applied separately to service host resources. -// Example usage: -// tags: union(tags, { 'azd-service-name': }) -var tags = { - 'azd-env-name': environmentName -} - -var abbrs = loadJsonContent('./abbreviations.json') -var resourceToken = toLower(uniqueString(subscription().id, environmentName, location)) - -resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = { - name: 'rg-${environmentName}' - location: location - tags: tags -} - -module monitoring './shared/monitoring.bicep' = { - name: 'monitoring' - params: { - location: location - tags: tags - logAnalyticsName: '${abbrs.operationalInsightsWorkspaces}${resourceToken}' - applicationInsightsName: '${abbrs.insightsComponents}${resourceToken}' - } - scope: rg -} - -module dashboard './shared/dashboard-web.bicep' = { - name: 'dashboard' - params: { - name: '${abbrs.portalDashboards}${resourceToken}' - applicationInsightsName: monitoring.outputs.applicationInsightsName - location: location - tags: tags - } - scope: rg -} - -module registry './shared/registry.bicep' = { - name: 'registry' - params: { - location: location - tags: tags - name: '${abbrs.containerRegistryRegistries}${resourceToken}' - } - scope: rg -} - -module keyVault './shared/keyvault.bicep' = { - name: 'keyvault' - params: { - location: location - tags: tags - name: '${abbrs.keyVaultVaults}${resourceToken}' - principalId: principalId - } - scope: rg -} - -module appsEnv './shared/apps-env.bicep' = { - name: 'apps-env' - params: { - name: '${abbrs.appManagedEnvironments}${resourceToken}' - location: location - tags: tags - applicationInsightsName: monitoring.outputs.applicationInsightsName - logAnalyticsWorkspaceName: monitoring.outputs.logAnalyticsWorkspaceName - } - scope: rg -} - -module hgGoodTshirt './app/hg-good-tshirt.bicep' = { - name: 'hg-good-tshirt' - params: { - name: '${abbrs.appContainerApps}hg-good-tshi-${resourceToken}' - location: location - tags: tags - identityName: '${abbrs.managedIdentityUserAssignedIdentities}hg-good-tshi-${resourceToken}' - applicationInsightsName: monitoring.outputs.applicationInsightsName - containerAppsEnvironmentName: appsEnv.outputs.name - containerRegistryName: registry.outputs.name - exists: hgGoodTshirtExists - appDefinition: hgGoodTshirtDefinition - } - scope: rg -} - -output AZURE_CONTAINER_REGISTRY_ENDPOINT string = registry.outputs.loginServer -output AZURE_KEY_VAULT_NAME string = keyVault.outputs.name -output AZURE_KEY_VAULT_ENDPOINT string = keyVault.outputs.endpoint diff --git a/infra/main.parameters.json b/infra/main.parameters.json deleted file mode 100644 index 7bc40fd..0000000 --- a/infra/main.parameters.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", - "contentVersion": "1.0.0.0", - "parameters": { - "environmentName": { - "value": "${AZURE_ENV_NAME}" - }, - "location": { - "value": "${AZURE_LOCATION}" - }, - "hgGoodTshirtExists": { - "value": "${SERVICE_HG_GOOD_TSHIRT_RESOURCE_EXISTS=false}" - }, - "hgGoodTshirtDefinition": { - "value": { - "settings": [ - { - "name": "", - "value": "${VAR}", - "_comment_name": "The name of the environment variable when running in Azure. If empty, ignored.", - "_comment_value": "The value to provide. This can be a fixed literal, or an expression like ${VAR} to use the value of 'VAR' from the current environment." - }, - { - "name": "", - "value": "${VAR_S}", - "secret": true, - "_comment_name": "The name of the environment variable when running in Azure. If empty, ignored.", - "_comment_value": "The value to provide. This can be a fixed literal, or an expression like ${VAR_S} to use the value of 'VAR_S' from the current environment." - } - ] - } - }, - "principalId": { - "value": "${AZURE_PRINCIPAL_ID}" - } - } -}