From 528f9adf17f7e4aae1bcedf6063cd72962139bc0 Mon Sep 17 00:00:00 2001 From: Hattan Shobokshi Date: Wed, 3 Aug 2022 12:09:46 -0700 Subject: [PATCH 01/30] adding in cse fork changes --- eng/pipelines/repoman.yml | 20 +++++++++++++------ .../todo/projects/csharp-cosmos-sql/repo.yaml | 2 +- .../todo/projects/csharp-mongo/repo.yaml | 2 +- templates/todo/projects/csharp-sql/repo.yaml | 2 +- .../todo/projects/nodejs-mongo-aca/repo.yaml | 2 +- .../projects/nodejs-mongo-swa-func/repo.yaml | 2 +- .../todo/projects/nodejs-mongo/repo.yaml | 2 +- .../todo/projects/python-mongo-aca/repo.yaml | 2 +- .../projects/python-mongo-swa-func/repo.yaml | 2 +- .../todo/projects/python-mongo/repo.yaml | 2 +- 10 files changed, 23 insertions(+), 15 deletions(-) diff --git a/eng/pipelines/repoman.yml b/eng/pipelines/repoman.yml index ca4a44a1344..1fcd1c83264 100644 --- a/eng/pipelines/repoman.yml +++ b/eng/pipelines/repoman.yml @@ -1,4 +1,12 @@ -trigger: none +trigger: + branches: + include: + - cse_main + paths: + include: + - generators/ + - templates/ + - eng/pipelines/repoman.yml pr: paths: @@ -14,7 +22,7 @@ jobs: - job: Generate_Repos pool: name: azsdk-pool-mms-ubuntu-2004-general - vmImage: MMSUbuntu20.04 + #vmImage: MMSUbuntu20.04 steps: - checkout: self @@ -24,10 +32,10 @@ jobs: versionSpec: 16 - pwsh: | - git config --global user.name "azure-sdk" - git config --global user.email "azuresdk@microsoft.com" + git config --global user.name "$(azuresdk-github-user)" + git config --global user.email "$(azuresdk-github-email)" Set-Content ` - -Value "https://azure-sdk:$(azuresdk-github-pat)@github.com" ` + -Value "https://$(azuresdk-github-user):$(azuresdk-github-pat)@github.com" ` -Path ~/.git-credentials git config --global credential.helper "store" displayName: Set git credentials @@ -118,7 +126,7 @@ jobs: targetType: filePath filePath: ./eng/scripts/Update-PRComment.ps1 arguments: >- - -Repo 'azure/azure-dev' + -Repo 'kaizentm/azure-dev' -PRNumber '$(PRNumber)' -BodyFile '$(CommentBodyFile)' -Tag '' diff --git a/templates/todo/projects/csharp-cosmos-sql/repo.yaml b/templates/todo/projects/csharp-cosmos-sql/repo.yaml index 2d59da1536b..480c390a96d 100644 --- a/templates/todo/projects/csharp-cosmos-sql/repo.yaml +++ b/templates/todo/projects/csharp-cosmos-sql/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:Azure-Samples/todo-csharp-cosmos-sql.git + url: git@github.com:kaizentm/todo-csharp-cosmos-sql.git rewrite: patterns: diff --git a/templates/todo/projects/csharp-mongo/repo.yaml b/templates/todo/projects/csharp-mongo/repo.yaml index 818006cc318..ef4c410dc23 100644 --- a/templates/todo/projects/csharp-mongo/repo.yaml +++ b/templates/todo/projects/csharp-mongo/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:Azure-Samples/todo-csharp-mongo.git + url: git@github.com:kaizentm/todo-csharp-mongo.git rewrite: patterns: diff --git a/templates/todo/projects/csharp-sql/repo.yaml b/templates/todo/projects/csharp-sql/repo.yaml index 0d32ba98a90..aaf8f51e120 100644 --- a/templates/todo/projects/csharp-sql/repo.yaml +++ b/templates/todo/projects/csharp-sql/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:Azure-Samples/todo-csharp-sql.git + url: git@github.com:kaizentm/todo-csharp-sql.git rewrite: patterns: diff --git a/templates/todo/projects/nodejs-mongo-aca/repo.yaml b/templates/todo/projects/nodejs-mongo-aca/repo.yaml index 28f5aa8a160..0994ffac357 100644 --- a/templates/todo/projects/nodejs-mongo-aca/repo.yaml +++ b/templates/todo/projects/nodejs-mongo-aca/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:Azure-Samples/todo-nodejs-mongo-aca.git + url: git@github.com:kaizentm/todo-nodejs-mongo-aca.git rewrite: patterns: diff --git a/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml b/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml index 2467acb1036..1f7a58b319c 100644 --- a/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml +++ b/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:Azure-Samples/todo-nodejs-mongo-swa-func.git + url: git@github.com:kaizentm/todo-nodejs-mongo-swa-func.git rewrite: patterns: diff --git a/templates/todo/projects/nodejs-mongo/repo.yaml b/templates/todo/projects/nodejs-mongo/repo.yaml index 972bf0968f8..f1e403e4bcc 100644 --- a/templates/todo/projects/nodejs-mongo/repo.yaml +++ b/templates/todo/projects/nodejs-mongo/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:Azure-Samples/todo-nodejs-mongo.git + url: git@github.com:kaizentm/todo-nodejs-mongo.git rewrite: patterns: diff --git a/templates/todo/projects/python-mongo-aca/repo.yaml b/templates/todo/projects/python-mongo-aca/repo.yaml index d3e1ab58bcd..05a344e0c3f 100644 --- a/templates/todo/projects/python-mongo-aca/repo.yaml +++ b/templates/todo/projects/python-mongo-aca/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:Azure-Samples/todo-python-mongo-aca.git + url: git@github.com:kaizentm/todo-python-mongo-aca.git rewrite: patterns: diff --git a/templates/todo/projects/python-mongo-swa-func/repo.yaml b/templates/todo/projects/python-mongo-swa-func/repo.yaml index b8d20b3fbf6..50ca1664472 100644 --- a/templates/todo/projects/python-mongo-swa-func/repo.yaml +++ b/templates/todo/projects/python-mongo-swa-func/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:Azure-Samples/todo-python-mongo-swa-func.git + url: git@github.com:kaizentm/todo-python-mongo-swa-func.git rewrite: patterns: diff --git a/templates/todo/projects/python-mongo/repo.yaml b/templates/todo/projects/python-mongo/repo.yaml index 3e4823fc14c..b4c12e8a5a3 100644 --- a/templates/todo/projects/python-mongo/repo.yaml +++ b/templates/todo/projects/python-mongo/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:Azure-Samples/todo-python-mongo.git + url: git@github.com:kaizentm/todo-python-mongo.git rewrite: patterns: From 60a463bae9339847ef0d5b3daf4e5417cc21d34d Mon Sep 17 00:00:00 2001 From: Hattan Shobokshi Date: Wed, 3 Aug 2022 13:15:39 -0700 Subject: [PATCH 02/30] adding vscode debugging support --- .vscode/launch.json | 50 +++++++++++++++++++++++++++++++++++++++++++++ .vscode/tasks.json | 14 +++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000000..feab252240a --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,50 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Repoman Generate - Python Mongo", + "program": "${workspaceFolder}/generators/repo/src/index.ts", + "preLaunchTask": "tsc: build", + "outFiles": ["${workspaceFolder}/generators/repo/dist/**/*.js"], + "args" : [ + "generate", + "-s", + "${workspaceFolder}/templates/todo/projects/python-mongo", + "-o", + "${workspaceFolder}/.tmp/python-mongo", + "--branch", + "pr-debug-test", + "--https", + "--fail-on-update-error", + "--resultsFile", + "--update" + ] + }, + { + "type": "node", + "request": "launch", + "name": "Repoman Generate - NodeJs Mongo", + "program": "${workspaceFolder}/generators/repo/src/index.ts", + "preLaunchTask": "tsc: build", + "outFiles": ["${workspaceFolder}/generators/repo/dist/**/*.js"], + "args" : [ + "generate", + "-s", + "${workspaceFolder}/templates/todo/projects/nodejs-mongo", + "-o", + "${workspaceFolder}/.tmp/nodejs-mongo", + "--branch", + "pr-debug-test", + "--https", + "--fail-on-update-error", + "--resultsFile", + "--update" + ] + }, + ] +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000000..34149fbcc0e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,14 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "typescript", + "tsconfig": "generators/repo/tsconfig.json", + "problemMatcher": [ + "$tsc" + ], + "group": "build", + "label": "tsc: build" + } + ] +} \ No newline at end of file From 68e6947f6ba5116106aca14c0f98e08ed97a74a7 Mon Sep 17 00:00:00 2001 From: Hattan Shobokshi Date: Wed, 3 Aug 2022 13:15:59 -0700 Subject: [PATCH 03/30] adding .tmp folder to gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 600d787dbb2..de411ef5f65 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ *.so *.dylib +# Temp path for testing repoman generation +/.tmp + # Test binary, built with `go test -c` *.test From 362572c67c80a2953166e6acdcef579f869530b0 Mon Sep 17 00:00:00 2001 From: Hattan Shobokshi Date: Wed, 3 Aug 2022 13:16:11 -0700 Subject: [PATCH 04/30] refator to support bicep in folder structure --- templates/todo/projects/python-mongo/infra/{ => bicep}/main.bicep | 0 .../projects/python-mongo/infra/{ => bicep}/main.parameters.json | 0 .../todo/projects/python-mongo/infra/{ => bicep}/resources.bicep | 0 .../todo/projects/python-mongo/{repo.yaml => repo-bicep.yaml} | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename templates/todo/projects/python-mongo/infra/{ => bicep}/main.bicep (100%) rename templates/todo/projects/python-mongo/infra/{ => bicep}/main.parameters.json (100%) rename templates/todo/projects/python-mongo/infra/{ => bicep}/resources.bicep (100%) rename templates/todo/projects/python-mongo/{repo.yaml => repo-bicep.yaml} (100%) diff --git a/templates/todo/projects/python-mongo/infra/main.bicep b/templates/todo/projects/python-mongo/infra/bicep/main.bicep similarity index 100% rename from templates/todo/projects/python-mongo/infra/main.bicep rename to templates/todo/projects/python-mongo/infra/bicep/main.bicep diff --git a/templates/todo/projects/python-mongo/infra/main.parameters.json b/templates/todo/projects/python-mongo/infra/bicep/main.parameters.json similarity index 100% rename from templates/todo/projects/python-mongo/infra/main.parameters.json rename to templates/todo/projects/python-mongo/infra/bicep/main.parameters.json diff --git a/templates/todo/projects/python-mongo/infra/resources.bicep b/templates/todo/projects/python-mongo/infra/bicep/resources.bicep similarity index 100% rename from templates/todo/projects/python-mongo/infra/resources.bicep rename to templates/todo/projects/python-mongo/infra/bicep/resources.bicep diff --git a/templates/todo/projects/python-mongo/repo.yaml b/templates/todo/projects/python-mongo/repo-bicep.yaml similarity index 100% rename from templates/todo/projects/python-mongo/repo.yaml rename to templates/todo/projects/python-mongo/repo-bicep.yaml From 3d1827312d9c67cc59247ed00e49eefc5c89aa97 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Wed, 3 Aug 2022 17:01:20 -0700 Subject: [PATCH 05/30] update repoman to add new rule to copy specific files, update repoman list to match wider pattern repo*.yaml, refactor infra to infra/bicep in common, and common/projects --- .vscode/launch.json | 15 ++++ generators/repo/src/commands/generate.ts | 11 ++- generators/repo/src/commands/list.ts | 2 +- generators/repo/src/common/util.ts | 10 +++ .../infra/{ => bicep}/abbreviations.json | 0 .../{ => bicep}/applicationinsights.bicep | 0 .../{azure.yaml => azure-bicep.yaml} | 1 + .../python-mongo/azure-terraform.yaml | 16 +++++ .../python-mongo/infra/terraform/main.tf | 0 .../projects/python-mongo/repo-bicep.yaml | 21 +++++- .../projects/python-mongo/repo-terraform.yaml | 69 +++++++++++++++++++ 11 files changed, 140 insertions(+), 5 deletions(-) rename templates/common/infra/{ => bicep}/abbreviations.json (100%) rename templates/common/infra/{ => bicep}/applicationinsights.bicep (100%) rename templates/todo/projects/python-mongo/{azure.yaml => azure-bicep.yaml} (98%) create mode 100644 templates/todo/projects/python-mongo/azure-terraform.yaml create mode 100644 templates/todo/projects/python-mongo/infra/terraform/main.tf create mode 100644 templates/todo/projects/python-mongo/repo-terraform.yaml diff --git a/.vscode/launch.json b/.vscode/launch.json index feab252240a..f831d9a466d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -13,6 +13,8 @@ "outFiles": ["${workspaceFolder}/generators/repo/dist/**/*.js"], "args" : [ "generate", + "-t", + "repo-terraform.yaml", "-s", "${workspaceFolder}/templates/todo/projects/python-mongo", "-o", @@ -46,5 +48,18 @@ "--update" ] }, + { + "type": "node", + "request": "launch", + "name": "Repoman List", + "program": "${workspaceFolder}/generators/repo/src/index.ts", + "preLaunchTask": "tsc: build", + "outFiles": ["${workspaceFolder}/generators/repo/dist/**/*.js"], + "args" : [ + "list", + "--format", + "json", + ] + }, ] } \ No newline at end of file diff --git a/generators/repo/src/commands/generate.ts b/generators/repo/src/commands/generate.ts index 0ffa120b8b3..483d4b770ae 100644 --- a/generators/repo/src/commands/generate.ts +++ b/generators/repo/src/commands/generate.ts @@ -5,7 +5,7 @@ import os from "os"; import fs from "fs/promises"; import ansiEscapes from "ansi-escapes"; import chalk from "chalk"; -import { cleanDirectoryPath, copyFile, createRepoUrlFromRemote, ensureDirectoryPath, getGlobFiles, getRepoPropsFromRemote, isStringNullOrEmpty, RepoProps, writeHeader } from "../common/util"; +import { cleanDirectoryPath, copyFile, createRepoUrlFromRemote, ensureDirectoryPath, getGlobFiles, getRepoPropsFromRemote, isStringNullOrEmpty, RepoProps, writeHeader,ensureFilePath } from "../common/util"; import { AssetRule, GitRemote, RepomanCommand, RepomanCommandOptions, RepoManifest } from "../models"; import { GitRepo } from "../tools/git"; @@ -338,8 +338,13 @@ export class GenerateCommand implements RepomanCommand { private processAssetRule = async (rule: AssetRule) => { const absoluteSourcePath = path.resolve(this.sourcePath, rule.from); const absoluteDestPath = path.join(this.generatePath, rule.to); - console.info(chalk.white(`Copying assets from ${chalk.cyan(rule.from)} to ${chalk.cyan(rule.to)}...`)); - + console.info(chalk.white(`Copying asset(s) from ${chalk.cyan(rule.from)} to ${chalk.cyan(rule.to)}...`)); + // check if this is filepath + if (await ensureFilePath(absoluteSourcePath)) { + await copyFile(absoluteSourcePath, absoluteDestPath); + return; + } + // Default to all files if no patterns defined const patterns = rule.patterns ?? ["**/*"]; const globOptions: IOptions = { diff --git a/generators/repo/src/commands/list.ts b/generators/repo/src/commands/list.ts index 83b3a4befc7..f2da920d431 100644 --- a/generators/repo/src/commands/list.ts +++ b/generators/repo/src/commands/list.ts @@ -30,7 +30,7 @@ export class ListCommand implements RepomanCommand { console.info(); } - const files = await getGlobFiles("**/repo.yaml", { cwd: this.sourcePath }); + const files = await getGlobFiles("**/repo*.yaml", { cwd: this.sourcePath }); if (!isJsonFormat) { console.info(chalk.cyan(`Found ${files.length} templates within search path`)); diff --git a/generators/repo/src/common/util.ts b/generators/repo/src/common/util.ts index 4a9a5be4ead..52c2e70b2c2 100644 --- a/generators/repo/src/common/util.ts +++ b/generators/repo/src/common/util.ts @@ -47,6 +47,16 @@ export const ensureDirectoryPath = async (directoryPath: string) => { } } +export const ensureFilePath = async (filePath: string) => { + try { + const link = await fs.lstat(filePath); + return link.isFile() + } + catch (err) { + console.error(chalk.red(`- ${err}`)); + } +} + export const cleanDirectoryPath = async (directoryPath: string, cleanGit: boolean = true) => { if (isDebug()) { console.debug(chalk.yellow(`Cleaning output directory: ${directoryPath}`)); diff --git a/templates/common/infra/abbreviations.json b/templates/common/infra/bicep/abbreviations.json similarity index 100% rename from templates/common/infra/abbreviations.json rename to templates/common/infra/bicep/abbreviations.json diff --git a/templates/common/infra/applicationinsights.bicep b/templates/common/infra/bicep/applicationinsights.bicep similarity index 100% rename from templates/common/infra/applicationinsights.bicep rename to templates/common/infra/bicep/applicationinsights.bicep diff --git a/templates/todo/projects/python-mongo/azure.yaml b/templates/todo/projects/python-mongo/azure-bicep.yaml similarity index 98% rename from templates/todo/projects/python-mongo/azure.yaml rename to templates/todo/projects/python-mongo/azure-bicep.yaml index ad99d4beefb..de3864a0f4f 100644 --- a/templates/todo/projects/python-mongo/azure.yaml +++ b/templates/todo/projects/python-mongo/azure-bicep.yaml @@ -13,3 +13,4 @@ services: project: ../../api/python language: py host: appservice + \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/azure-terraform.yaml b/templates/todo/projects/python-mongo/azure-terraform.yaml new file mode 100644 index 00000000000..de3864a0f4f --- /dev/null +++ b/templates/todo/projects/python-mongo/azure-terraform.yaml @@ -0,0 +1,16 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +name: todo-python-mongo +metadata: + template: todo-python-mongo@0.0.1-beta +services: + web: + project: ../../web/react-fluent + dist: build + language: js + host: appservice + api: + project: ../../api/python + language: py + host: appservice + \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/infra/terraform/main.tf b/templates/todo/projects/python-mongo/infra/terraform/main.tf new file mode 100644 index 00000000000..e69de29bb2d diff --git a/templates/todo/projects/python-mongo/repo-bicep.yaml b/templates/todo/projects/python-mongo/repo-bicep.yaml index b4c12e8a5a3..200edb07585 100644 --- a/templates/todo/projects/python-mongo/repo-bicep.yaml +++ b/templates/todo/projects/python-mongo/repo-bicep.yaml @@ -5,7 +5,7 @@ metadata: description: ToDo Application with a Python API and Azure Cosmos DB API for MongoDB repo: - includeProjectAssets: true + includeProjectAssets: false remotes: - name: azure-samples @@ -18,6 +18,12 @@ repo: assets: # Common assets + - from: ./ + to: ./ + ignore: + - "repo-*.y[a]ml" + - "infra/**/*" + - "azure-*.y[a]ml" # openapi.yaml to root - from: ../../api/common @@ -34,6 +40,11 @@ repo: # Template common - from: ../../../common to: ./ + ignore: + - "infra/**/*" + + - from: ../../../common/infra/bicep + to: ./infra # Assets common - from: ../../common/assets @@ -56,3 +67,11 @@ repo: ignore: - "build/**/*" - "node_modules/**/*" + + # Infra + - from: ./infra/bicep + to: ./infra + + # Azure.yml + - from: ./azure-bicep.yaml + to: ./azure.yaml \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/repo-terraform.yaml b/templates/todo/projects/python-mongo/repo-terraform.yaml new file mode 100644 index 00000000000..10cca277d6e --- /dev/null +++ b/templates/todo/projects/python-mongo/repo-terraform.yaml @@ -0,0 +1,69 @@ +templateApi: 1.0.0 +metadata: + type: repo + name: todo-python-mongo + description: ToDo Application with a Python API and Azure Cosmos DB API for MongoDB + +repo: + includeProjectAssets: false + + remotes: + - name: azure-samples + url: git@github.com:kaizentm/todo-python-mongo-terraform.git + + rewrite: + patterns: + - "**/azure.@(yml|yaml)" + - "**/*.bicep" + + assets: + # Common assets + - from: ./ + to: ./ + ignore: + - "repo-*.y[a]ml" + - "infra/**/*" + + # openapi.yaml to root + - from: ../../api/common + to: ./ + patterns: + - openapi.yaml + + # openapi.yaml to api root + - from: ../../api/common + to: ./src/api + patterns: + - openapi.yaml + + # Template common + - from: ../../../common + to: ./ + ignore: + - "infra/**/*" + + # Assets common + - from: ../../common/assets + to: ./assets + + # Tests common + - from: ../../common/tests + to: ./tests + + # Python API + - from: ../../api/python + to: ./src/api + ignore: + - "**/__pycache__/**" + - "**/@(venv|.venv)/**" + + # React Frontend + - from: ../../web/react-fluent + to: ./src/web + ignore: + - "build/**/*" + - "node_modules/**/*" + + # Infra + - from: ./infra/terraform + to: ./infra \ No newline at end of file From f2152c38a43506d0a7b5b431e4bd440d679b1987 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Thu, 4 Aug 2022 14:22:53 -0700 Subject: [PATCH 06/30] add aca/bicep layer in common infra folders Co-authored-by: Hattan Shobokshi --- .vscode/launch.json | 46 +++++++++++++++++++ .../common/infra/aca/{ => bicep}/api.bicep | 0 .../infra/aca/{ => bicep}/api.parameters.json | 0 .../common/infra/aca/{ => bicep}/main.bicep | 0 .../aca/{ => bicep}/main.parameters.json | 0 .../infra/aca/{ => bicep}/resources.bicep | 0 .../common/infra/aca/{ => bicep}/web.bicep | 0 .../infra/aca/{ => bicep}/web.parameters.json | 0 .../todo/projects/nodejs-mongo-aca/repo.yaml | 2 +- .../todo/projects/python-mongo-aca/repo.yaml | 2 +- 10 files changed, 48 insertions(+), 2 deletions(-) rename templates/todo/common/infra/aca/{ => bicep}/api.bicep (100%) rename templates/todo/common/infra/aca/{ => bicep}/api.parameters.json (100%) rename templates/todo/common/infra/aca/{ => bicep}/main.bicep (100%) rename templates/todo/common/infra/aca/{ => bicep}/main.parameters.json (100%) rename templates/todo/common/infra/aca/{ => bicep}/resources.bicep (100%) rename templates/todo/common/infra/aca/{ => bicep}/web.bicep (100%) rename templates/todo/common/infra/aca/{ => bicep}/web.parameters.json (100%) diff --git a/.vscode/launch.json b/.vscode/launch.json index f831d9a466d..3b55a247133 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -48,6 +48,52 @@ "--update" ] }, + { + "type": "node", + "request": "launch", + "name": "Repoman Generate - Python Mongo-aca", + "program": "${workspaceFolder}/generators/repo/src/index.ts", + "preLaunchTask": "tsc: build", + "outFiles": ["${workspaceFolder}/generators/repo/dist/**/*.js"], + "args" : [ + "generate", + "-t", + "repo.yaml", + "-s", + "${workspaceFolder}/templates/todo/projects/python-mongo-aca", + "-o", + "${workspaceFolder}/.tmp/python-mongo-aca", + "--branch", + "pr-debug-test", + "--https", + "--fail-on-update-error", + "--resultsFile", + "--update" + ] + }, + { + "type": "node", + "request": "launch", + "name": "Repoman Generate - NodeJs Mongo-aca", + "program": "${workspaceFolder}/generators/repo/src/index.ts", + "preLaunchTask": "tsc: build", + "outFiles": ["${workspaceFolder}/generators/repo/dist/**/*.js"], + "args" : [ + "generate", + "-s", + "${workspaceFolder}/templates/todo/projects/nodejs-mongo-aca", + "-t", + "repo.yaml", + "-o", + "${workspaceFolder}/.tmp/nodejs-mongo-aca", + "--branch", + "pr-debug-test", + "--https", + "--fail-on-update-error", + "--resultsFile", + "--update" + ] + }, { "type": "node", "request": "launch", diff --git a/templates/todo/common/infra/aca/api.bicep b/templates/todo/common/infra/aca/bicep/api.bicep similarity index 100% rename from templates/todo/common/infra/aca/api.bicep rename to templates/todo/common/infra/aca/bicep/api.bicep diff --git a/templates/todo/common/infra/aca/api.parameters.json b/templates/todo/common/infra/aca/bicep/api.parameters.json similarity index 100% rename from templates/todo/common/infra/aca/api.parameters.json rename to templates/todo/common/infra/aca/bicep/api.parameters.json diff --git a/templates/todo/common/infra/aca/main.bicep b/templates/todo/common/infra/aca/bicep/main.bicep similarity index 100% rename from templates/todo/common/infra/aca/main.bicep rename to templates/todo/common/infra/aca/bicep/main.bicep diff --git a/templates/todo/common/infra/aca/main.parameters.json b/templates/todo/common/infra/aca/bicep/main.parameters.json similarity index 100% rename from templates/todo/common/infra/aca/main.parameters.json rename to templates/todo/common/infra/aca/bicep/main.parameters.json diff --git a/templates/todo/common/infra/aca/resources.bicep b/templates/todo/common/infra/aca/bicep/resources.bicep similarity index 100% rename from templates/todo/common/infra/aca/resources.bicep rename to templates/todo/common/infra/aca/bicep/resources.bicep diff --git a/templates/todo/common/infra/aca/web.bicep b/templates/todo/common/infra/aca/bicep/web.bicep similarity index 100% rename from templates/todo/common/infra/aca/web.bicep rename to templates/todo/common/infra/aca/bicep/web.bicep diff --git a/templates/todo/common/infra/aca/web.parameters.json b/templates/todo/common/infra/aca/bicep/web.parameters.json similarity index 100% rename from templates/todo/common/infra/aca/web.parameters.json rename to templates/todo/common/infra/aca/bicep/web.parameters.json diff --git a/templates/todo/projects/nodejs-mongo-aca/repo.yaml b/templates/todo/projects/nodejs-mongo-aca/repo.yaml index 0994ffac357..5ae1ec26aa4 100644 --- a/templates/todo/projects/nodejs-mongo-aca/repo.yaml +++ b/templates/todo/projects/nodejs-mongo-aca/repo.yaml @@ -44,7 +44,7 @@ repo: to: ./tests # ACA infra common - - from: ../../common/infra/aca + - from: ../../common/infra/aca/bicep to: ./infra # Node JS API diff --git a/templates/todo/projects/python-mongo-aca/repo.yaml b/templates/todo/projects/python-mongo-aca/repo.yaml index 05a344e0c3f..24bfd277940 100644 --- a/templates/todo/projects/python-mongo-aca/repo.yaml +++ b/templates/todo/projects/python-mongo-aca/repo.yaml @@ -44,7 +44,7 @@ repo: to: ./tests # ACA infra common - - from: ../../common/infra/aca + - from: ../../common/infra/aca/bicep to: ./infra # Python API From bb37d8aaed45fc4a9d5519eb953810d4c2fbabd0 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Thu, 4 Aug 2022 15:13:22 -0700 Subject: [PATCH 07/30] update to set -t to the project template Co-authored-by: Hattan Shobokshi --- eng/scripts/Invoke-RepomanGenerate.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/eng/scripts/Invoke-RepomanGenerate.ps1 b/eng/scripts/Invoke-RepomanGenerate.ps1 index a85e90fa5d4..3fa92b280ef 100644 --- a/eng/scripts/Invoke-RepomanGenerate.ps1 +++ b/eng/scripts/Invoke-RepomanGenerate.ps1 @@ -8,18 +8,20 @@ param( $projectsJson = repoman list --format json | Out-String $projects = ConvertFrom-Json $projectsJson -$projectPaths = $projects.projectPath - -foreach ($projectPath in $projectPaths) { +foreach ($project in $projects) { $additionalParameters = '--update' if ($WhatIf) { $additionalParameters = '' } + $projectPath = $project.projectPath + $templatePath = $project.templatePath.Replace($projectPath, "") + Write-Host @" repoman generate ` -s $projectPath ` -o $RunnerTemp ` + -t $templatePath ` --branch "$TargetBranchName" ` --https ` --fail-on-update-error ` @@ -30,6 +32,7 @@ repoman generate ` repoman generate ` -s $projectPath ` -o $RunnerTemp ` + -t $templatePath ` --branch `"$TargetBranchName`" ` --https ` --fail-on-update-error ` From 6e115b0c407a49f37e706f09ce7e7197b99d8af1 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Thu, 4 Aug 2022 16:08:14 -0700 Subject: [PATCH 08/30] update node-js-mongo project Co-authored-by: Hattan Shobokshi --- .../{azure.yaml => azure-bicep.yaml} | 0 .../nodejs-mongo/infra/{ => bicep}/main.bicep | 0 .../infra/{ => bicep}/main.parameters.json | 0 .../infra/{ => bicep}/resources.bicep | 0 .../{repo.yaml => repo-bicep.yaml} | 21 ++++++++++++++++++- 5 files changed, 20 insertions(+), 1 deletion(-) rename templates/todo/projects/nodejs-mongo/{azure.yaml => azure-bicep.yaml} (100%) rename templates/todo/projects/nodejs-mongo/infra/{ => bicep}/main.bicep (100%) rename templates/todo/projects/nodejs-mongo/infra/{ => bicep}/main.parameters.json (100%) rename templates/todo/projects/nodejs-mongo/infra/{ => bicep}/resources.bicep (100%) rename templates/todo/projects/nodejs-mongo/{repo.yaml => repo-bicep.yaml} (75%) diff --git a/templates/todo/projects/nodejs-mongo/azure.yaml b/templates/todo/projects/nodejs-mongo/azure-bicep.yaml similarity index 100% rename from templates/todo/projects/nodejs-mongo/azure.yaml rename to templates/todo/projects/nodejs-mongo/azure-bicep.yaml diff --git a/templates/todo/projects/nodejs-mongo/infra/main.bicep b/templates/todo/projects/nodejs-mongo/infra/bicep/main.bicep similarity index 100% rename from templates/todo/projects/nodejs-mongo/infra/main.bicep rename to templates/todo/projects/nodejs-mongo/infra/bicep/main.bicep diff --git a/templates/todo/projects/nodejs-mongo/infra/main.parameters.json b/templates/todo/projects/nodejs-mongo/infra/bicep/main.parameters.json similarity index 100% rename from templates/todo/projects/nodejs-mongo/infra/main.parameters.json rename to templates/todo/projects/nodejs-mongo/infra/bicep/main.parameters.json diff --git a/templates/todo/projects/nodejs-mongo/infra/resources.bicep b/templates/todo/projects/nodejs-mongo/infra/bicep/resources.bicep similarity index 100% rename from templates/todo/projects/nodejs-mongo/infra/resources.bicep rename to templates/todo/projects/nodejs-mongo/infra/bicep/resources.bicep diff --git a/templates/todo/projects/nodejs-mongo/repo.yaml b/templates/todo/projects/nodejs-mongo/repo-bicep.yaml similarity index 75% rename from templates/todo/projects/nodejs-mongo/repo.yaml rename to templates/todo/projects/nodejs-mongo/repo-bicep.yaml index f1e403e4bcc..89ec6094f15 100644 --- a/templates/todo/projects/nodejs-mongo/repo.yaml +++ b/templates/todo/projects/nodejs-mongo/repo-bicep.yaml @@ -5,7 +5,7 @@ metadata: description: ToDo Application with a Node.js API and Azure Cosmos DB API for MongoDB repo: - includeProjectAssets: true + includeProjectAssets: false remotes: - name: azure-samples @@ -18,6 +18,12 @@ repo: assets: # Common assets + - from: ./ + to: ./ + ignore: + - "repo-*.y[a]ml" + - "infra/**/*" + - "azure-*.y[a]ml" # openapi.yaml to root - from: ../../api/common @@ -34,6 +40,11 @@ repo: # Template common - from: ../../../common to: ./ + ignore: + - "infra/**/*" + + - from: ../../../common/infra/bicep + to: ./infra # Assets common - from: ../../common/assets @@ -58,3 +69,11 @@ repo: ignore: - "build/**/*" - "node_modules/**/*" + + # Infra + - from: ./infra/bicep + to: ./infra + + # Azure.yml + - from: ./azure-bicep.yaml + to: ./azure.yaml \ No newline at end of file From 222007bfaa178c9449f5df6581783fa5255f0def Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Thu, 4 Aug 2022 16:25:44 -0700 Subject: [PATCH 09/30] update repo.yaml files to reference common/infra/bicep Co-authored-by: Hattan Shobokshi --- templates/todo/projects/csharp-cosmos-sql/repo.yaml | 5 +++++ templates/todo/projects/csharp-mongo/repo.yaml | 5 +++++ templates/todo/projects/csharp-sql/repo.yaml | 5 +++++ templates/todo/projects/nodejs-mongo-aca/repo.yaml | 5 +++++ templates/todo/projects/nodejs-mongo-swa-func/repo.yaml | 5 +++++ templates/todo/projects/python-mongo-aca/repo.yaml | 5 +++++ templates/todo/projects/python-mongo-swa-func/repo.yaml | 5 +++++ 7 files changed, 35 insertions(+) diff --git a/templates/todo/projects/csharp-cosmos-sql/repo.yaml b/templates/todo/projects/csharp-cosmos-sql/repo.yaml index 480c390a96d..ead8b643dae 100644 --- a/templates/todo/projects/csharp-cosmos-sql/repo.yaml +++ b/templates/todo/projects/csharp-cosmos-sql/repo.yaml @@ -34,6 +34,11 @@ repo: # Template common - from: ../../../common to: ./ + ignore: + - "infra/**/*" + + - from: ../../../common/infra/bicep + to: ./infra # Assets common - from: ../../common/assets diff --git a/templates/todo/projects/csharp-mongo/repo.yaml b/templates/todo/projects/csharp-mongo/repo.yaml index ef4c410dc23..bd65058eccb 100644 --- a/templates/todo/projects/csharp-mongo/repo.yaml +++ b/templates/todo/projects/csharp-mongo/repo.yaml @@ -34,6 +34,11 @@ repo: # Template common - from: ../../../common to: ./ + ignore: + - "infra/**/*" + + - from: ../../../common/infra/bicep + to: ./infra # Assets common - from: ../../common/assets diff --git a/templates/todo/projects/csharp-sql/repo.yaml b/templates/todo/projects/csharp-sql/repo.yaml index aaf8f51e120..1ac65ed6702 100644 --- a/templates/todo/projects/csharp-sql/repo.yaml +++ b/templates/todo/projects/csharp-sql/repo.yaml @@ -34,6 +34,11 @@ repo: # Template common - from: ../../../common to: ./ + ignore: + - "infra/**/*" + + - from: ../../../common/infra/bicep + to: ./infra # Assets common - from: ../../common/assets diff --git a/templates/todo/projects/nodejs-mongo-aca/repo.yaml b/templates/todo/projects/nodejs-mongo-aca/repo.yaml index 5ae1ec26aa4..c3ad4d2af48 100644 --- a/templates/todo/projects/nodejs-mongo-aca/repo.yaml +++ b/templates/todo/projects/nodejs-mongo-aca/repo.yaml @@ -34,6 +34,11 @@ repo: # Template common - from: ../../../common to: ./ + ignore: + - "infra/**/*" + + - from: ../../../common/infra/bicep + to: ./infra # Assets common - from: ../../common/assets diff --git a/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml b/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml index 1f7a58b319c..703856d744f 100644 --- a/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml +++ b/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml @@ -34,6 +34,11 @@ repo: # Template common - from: ../../../common to: ./ + ignore: + - "infra/**/*" + + - from: ../../../common/infra/bicep + to: ./infra # Assets common - from: ../../common/assets diff --git a/templates/todo/projects/python-mongo-aca/repo.yaml b/templates/todo/projects/python-mongo-aca/repo.yaml index 24bfd277940..0c5773e9fce 100644 --- a/templates/todo/projects/python-mongo-aca/repo.yaml +++ b/templates/todo/projects/python-mongo-aca/repo.yaml @@ -34,6 +34,11 @@ repo: # Template common - from: ../../../common to: ./ + ignore: + - "infra/**/*" + + - from: ../../../common/infra/bicep + to: ./infra # Assets common - from: ../../common/assets diff --git a/templates/todo/projects/python-mongo-swa-func/repo.yaml b/templates/todo/projects/python-mongo-swa-func/repo.yaml index 50ca1664472..925fe4dd8bf 100644 --- a/templates/todo/projects/python-mongo-swa-func/repo.yaml +++ b/templates/todo/projects/python-mongo-swa-func/repo.yaml @@ -34,6 +34,11 @@ repo: # Template common - from: ../../../common to: ./ + ignore: + - "infra/**/*" + + - from: ../../../common/infra/bicep + to: ./infra # Assets common - from: ../../common/assets From de0f308c7f62baed6e073ddb17d60ae6e5cfae9d Mon Sep 17 00:00:00 2001 From: Hattan Shobokshi Date: Thu, 4 Aug 2022 16:51:18 -0700 Subject: [PATCH 10/30] Removing extra lines in python-mongo azure*.yaml files. Co-authored-by: Hadwa Gaber --- templates/todo/projects/python-mongo/azure-bicep.yaml | 3 +-- templates/todo/projects/python-mongo/azure-terraform.yaml | 3 +-- templates/todo/projects/python-mongo/repo-terraform.yaml | 7 ++++++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/templates/todo/projects/python-mongo/azure-bicep.yaml b/templates/todo/projects/python-mongo/azure-bicep.yaml index de3864a0f4f..43d3fdf040e 100644 --- a/templates/todo/projects/python-mongo/azure-bicep.yaml +++ b/templates/todo/projects/python-mongo/azure-bicep.yaml @@ -12,5 +12,4 @@ services: api: project: ../../api/python language: py - host: appservice - \ No newline at end of file + host: appservice \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/azure-terraform.yaml b/templates/todo/projects/python-mongo/azure-terraform.yaml index de3864a0f4f..43d3fdf040e 100644 --- a/templates/todo/projects/python-mongo/azure-terraform.yaml +++ b/templates/todo/projects/python-mongo/azure-terraform.yaml @@ -12,5 +12,4 @@ services: api: project: ../../api/python language: py - host: appservice - \ No newline at end of file + host: appservice \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/repo-terraform.yaml b/templates/todo/projects/python-mongo/repo-terraform.yaml index 10cca277d6e..c2fdda5f715 100644 --- a/templates/todo/projects/python-mongo/repo-terraform.yaml +++ b/templates/todo/projects/python-mongo/repo-terraform.yaml @@ -23,6 +23,7 @@ repo: ignore: - "repo-*.y[a]ml" - "infra/**/*" + - "azure-*.y[a]ml" # openapi.yaml to root - from: ../../api/common @@ -66,4 +67,8 @@ repo: # Infra - from: ./infra/terraform - to: ./infra \ No newline at end of file + to: ./infra + + # Azure.yml + - from: ./azure-bicep.yaml + to: ./azure.yaml \ No newline at end of file From c1b9754e6eae806df5bfcdfffa0a55ad8bd5708f Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Fri, 5 Aug 2022 11:16:53 -0700 Subject: [PATCH 11/30] Code Cleanup Co-authored-by: Hattan Shobokshi --- .gitignore | 4 +- .vscode/launch.json | 65 +--------------- .../projects/python-mongo/azure-bicep.yaml | 3 +- .../python-mongo/azure-terraform.yaml | 15 ---- .../python-mongo/infra/terraform/main.tf | 0 .../projects/python-mongo/repo-terraform.yaml | 74 ------------------- 6 files changed, 7 insertions(+), 154 deletions(-) delete mode 100644 templates/todo/projects/python-mongo/azure-terraform.yaml delete mode 100644 templates/todo/projects/python-mongo/infra/terraform/main.tf delete mode 100644 templates/todo/projects/python-mongo/repo-terraform.yaml diff --git a/.gitignore b/.gitignore index de411ef5f65..c0678016c6b 100644 --- a/.gitignore +++ b/.gitignore @@ -5,8 +5,8 @@ *.so *.dylib -# Temp path for testing repoman generation -/.tmp +# Output path for local repoman generation +/.output # Test binary, built with `go test -c` *.test diff --git a/.vscode/launch.json b/.vscode/launch.json index 3b55a247133..622b6fa5ca0 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -14,11 +14,11 @@ "args" : [ "generate", "-t", - "repo-terraform.yaml", + "repo-bicep.yaml", "-s", "${workspaceFolder}/templates/todo/projects/python-mongo", "-o", - "${workspaceFolder}/.tmp/python-mongo", + "${workspaceFolder}/.output/python-mongo", "--branch", "pr-debug-test", "--https", @@ -39,7 +39,7 @@ "-s", "${workspaceFolder}/templates/todo/projects/nodejs-mongo", "-o", - "${workspaceFolder}/.tmp/nodejs-mongo", + "${workspaceFolder}/.output/nodejs-mongo", "--branch", "pr-debug-test", "--https", @@ -48,64 +48,5 @@ "--update" ] }, - { - "type": "node", - "request": "launch", - "name": "Repoman Generate - Python Mongo-aca", - "program": "${workspaceFolder}/generators/repo/src/index.ts", - "preLaunchTask": "tsc: build", - "outFiles": ["${workspaceFolder}/generators/repo/dist/**/*.js"], - "args" : [ - "generate", - "-t", - "repo.yaml", - "-s", - "${workspaceFolder}/templates/todo/projects/python-mongo-aca", - "-o", - "${workspaceFolder}/.tmp/python-mongo-aca", - "--branch", - "pr-debug-test", - "--https", - "--fail-on-update-error", - "--resultsFile", - "--update" - ] - }, - { - "type": "node", - "request": "launch", - "name": "Repoman Generate - NodeJs Mongo-aca", - "program": "${workspaceFolder}/generators/repo/src/index.ts", - "preLaunchTask": "tsc: build", - "outFiles": ["${workspaceFolder}/generators/repo/dist/**/*.js"], - "args" : [ - "generate", - "-s", - "${workspaceFolder}/templates/todo/projects/nodejs-mongo-aca", - "-t", - "repo.yaml", - "-o", - "${workspaceFolder}/.tmp/nodejs-mongo-aca", - "--branch", - "pr-debug-test", - "--https", - "--fail-on-update-error", - "--resultsFile", - "--update" - ] - }, - { - "type": "node", - "request": "launch", - "name": "Repoman List", - "program": "${workspaceFolder}/generators/repo/src/index.ts", - "preLaunchTask": "tsc: build", - "outFiles": ["${workspaceFolder}/generators/repo/dist/**/*.js"], - "args" : [ - "list", - "--format", - "json", - ] - }, ] } \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/azure-bicep.yaml b/templates/todo/projects/python-mongo/azure-bicep.yaml index 43d3fdf040e..de3864a0f4f 100644 --- a/templates/todo/projects/python-mongo/azure-bicep.yaml +++ b/templates/todo/projects/python-mongo/azure-bicep.yaml @@ -12,4 +12,5 @@ services: api: project: ../../api/python language: py - host: appservice \ No newline at end of file + host: appservice + \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/azure-terraform.yaml b/templates/todo/projects/python-mongo/azure-terraform.yaml deleted file mode 100644 index 43d3fdf040e..00000000000 --- a/templates/todo/projects/python-mongo/azure-terraform.yaml +++ /dev/null @@ -1,15 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json - -name: todo-python-mongo -metadata: - template: todo-python-mongo@0.0.1-beta -services: - web: - project: ../../web/react-fluent - dist: build - language: js - host: appservice - api: - project: ../../api/python - language: py - host: appservice \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/infra/terraform/main.tf b/templates/todo/projects/python-mongo/infra/terraform/main.tf deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/templates/todo/projects/python-mongo/repo-terraform.yaml b/templates/todo/projects/python-mongo/repo-terraform.yaml deleted file mode 100644 index c2fdda5f715..00000000000 --- a/templates/todo/projects/python-mongo/repo-terraform.yaml +++ /dev/null @@ -1,74 +0,0 @@ -templateApi: 1.0.0 -metadata: - type: repo - name: todo-python-mongo - description: ToDo Application with a Python API and Azure Cosmos DB API for MongoDB - -repo: - includeProjectAssets: false - - remotes: - - name: azure-samples - url: git@github.com:kaizentm/todo-python-mongo-terraform.git - - rewrite: - patterns: - - "**/azure.@(yml|yaml)" - - "**/*.bicep" - - assets: - # Common assets - - from: ./ - to: ./ - ignore: - - "repo-*.y[a]ml" - - "infra/**/*" - - "azure-*.y[a]ml" - - # openapi.yaml to root - - from: ../../api/common - to: ./ - patterns: - - openapi.yaml - - # openapi.yaml to api root - - from: ../../api/common - to: ./src/api - patterns: - - openapi.yaml - - # Template common - - from: ../../../common - to: ./ - ignore: - - "infra/**/*" - - # Assets common - - from: ../../common/assets - to: ./assets - - # Tests common - - from: ../../common/tests - to: ./tests - - # Python API - - from: ../../api/python - to: ./src/api - ignore: - - "**/__pycache__/**" - - "**/@(venv|.venv)/**" - - # React Frontend - - from: ../../web/react-fluent - to: ./src/web - ignore: - - "build/**/*" - - "node_modules/**/*" - - # Infra - - from: ./infra/terraform - to: ./infra - - # Azure.yml - - from: ./azure-bicep.yaml - to: ./azure.yaml \ No newline at end of file From d3fb35d0620fcde11476e01d31eb8af9277b1f57 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Fri, 5 Aug 2022 11:45:14 -0700 Subject: [PATCH 12/30] redirect configurations to upstream azure/azure-dev Co-authored-by: Hattan Shobokshi --- eng/pipelines/repoman.yml | 20 ++++++------------- .../todo/projects/csharp-cosmos-sql/repo.yaml | 2 +- .../todo/projects/csharp-mongo/repo.yaml | 2 +- templates/todo/projects/csharp-sql/repo.yaml | 2 +- .../todo/projects/nodejs-mongo-aca/repo.yaml | 2 +- .../projects/nodejs-mongo-swa-func/repo.yaml | 2 +- .../projects/nodejs-mongo/repo-bicep.yaml | 2 +- .../todo/projects/python-mongo-aca/repo.yaml | 2 +- .../projects/python-mongo-swa-func/repo.yaml | 2 +- .../projects/python-mongo/azure-bicep.yaml | 1 - .../projects/python-mongo/repo-bicep.yaml | 2 +- 11 files changed, 15 insertions(+), 24 deletions(-) diff --git a/eng/pipelines/repoman.yml b/eng/pipelines/repoman.yml index 1fcd1c83264..ca4a44a1344 100644 --- a/eng/pipelines/repoman.yml +++ b/eng/pipelines/repoman.yml @@ -1,12 +1,4 @@ -trigger: - branches: - include: - - cse_main - paths: - include: - - generators/ - - templates/ - - eng/pipelines/repoman.yml +trigger: none pr: paths: @@ -22,7 +14,7 @@ jobs: - job: Generate_Repos pool: name: azsdk-pool-mms-ubuntu-2004-general - #vmImage: MMSUbuntu20.04 + vmImage: MMSUbuntu20.04 steps: - checkout: self @@ -32,10 +24,10 @@ jobs: versionSpec: 16 - pwsh: | - git config --global user.name "$(azuresdk-github-user)" - git config --global user.email "$(azuresdk-github-email)" + git config --global user.name "azure-sdk" + git config --global user.email "azuresdk@microsoft.com" Set-Content ` - -Value "https://$(azuresdk-github-user):$(azuresdk-github-pat)@github.com" ` + -Value "https://azure-sdk:$(azuresdk-github-pat)@github.com" ` -Path ~/.git-credentials git config --global credential.helper "store" displayName: Set git credentials @@ -126,7 +118,7 @@ jobs: targetType: filePath filePath: ./eng/scripts/Update-PRComment.ps1 arguments: >- - -Repo 'kaizentm/azure-dev' + -Repo 'azure/azure-dev' -PRNumber '$(PRNumber)' -BodyFile '$(CommentBodyFile)' -Tag '' diff --git a/templates/todo/projects/csharp-cosmos-sql/repo.yaml b/templates/todo/projects/csharp-cosmos-sql/repo.yaml index ead8b643dae..9606307481d 100644 --- a/templates/todo/projects/csharp-cosmos-sql/repo.yaml +++ b/templates/todo/projects/csharp-cosmos-sql/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:kaizentm/todo-csharp-cosmos-sql.git + url: git@github.com:Azure-Samples/todo-csharp-cosmos-sql.git rewrite: patterns: diff --git a/templates/todo/projects/csharp-mongo/repo.yaml b/templates/todo/projects/csharp-mongo/repo.yaml index bd65058eccb..b8c19441390 100644 --- a/templates/todo/projects/csharp-mongo/repo.yaml +++ b/templates/todo/projects/csharp-mongo/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:kaizentm/todo-csharp-mongo.git + url: git@github.com:Azure-Samples/todo-csharp-mongo.git rewrite: patterns: diff --git a/templates/todo/projects/csharp-sql/repo.yaml b/templates/todo/projects/csharp-sql/repo.yaml index 1ac65ed6702..8847e07a965 100644 --- a/templates/todo/projects/csharp-sql/repo.yaml +++ b/templates/todo/projects/csharp-sql/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:kaizentm/todo-csharp-sql.git + url: git@github.com:Azure-Samples/todo-csharp-sql.git rewrite: patterns: diff --git a/templates/todo/projects/nodejs-mongo-aca/repo.yaml b/templates/todo/projects/nodejs-mongo-aca/repo.yaml index c3ad4d2af48..a813e1f4a77 100644 --- a/templates/todo/projects/nodejs-mongo-aca/repo.yaml +++ b/templates/todo/projects/nodejs-mongo-aca/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:kaizentm/todo-nodejs-mongo-aca.git + url: git@github.com:Azure-Samples/todo-nodejs-mongo-aca.git rewrite: patterns: diff --git a/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml b/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml index 703856d744f..f958baea59c 100644 --- a/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml +++ b/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:kaizentm/todo-nodejs-mongo-swa-func.git + url: git@github.com:Azure-Samples/todo-nodejs-mongo-swa-func.git rewrite: patterns: diff --git a/templates/todo/projects/nodejs-mongo/repo-bicep.yaml b/templates/todo/projects/nodejs-mongo/repo-bicep.yaml index 89ec6094f15..fed28af9b14 100644 --- a/templates/todo/projects/nodejs-mongo/repo-bicep.yaml +++ b/templates/todo/projects/nodejs-mongo/repo-bicep.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:kaizentm/todo-nodejs-mongo.git + url: git@github.com:Azure-Samples/todo-nodejs-mongo.git rewrite: patterns: diff --git a/templates/todo/projects/python-mongo-aca/repo.yaml b/templates/todo/projects/python-mongo-aca/repo.yaml index 0c5773e9fce..b3320688fdc 100644 --- a/templates/todo/projects/python-mongo-aca/repo.yaml +++ b/templates/todo/projects/python-mongo-aca/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:kaizentm/todo-python-mongo-aca.git + url: git@github.com:Azure-Samples/todo-python-mongo-aca.git rewrite: patterns: diff --git a/templates/todo/projects/python-mongo-swa-func/repo.yaml b/templates/todo/projects/python-mongo-swa-func/repo.yaml index 925fe4dd8bf..f4b934edbbe 100644 --- a/templates/todo/projects/python-mongo-swa-func/repo.yaml +++ b/templates/todo/projects/python-mongo-swa-func/repo.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:kaizentm/todo-python-mongo-swa-func.git + url: git@github.com:Azure-Samples/todo-python-mongo-swa-func.git rewrite: patterns: diff --git a/templates/todo/projects/python-mongo/azure-bicep.yaml b/templates/todo/projects/python-mongo/azure-bicep.yaml index de3864a0f4f..ad99d4beefb 100644 --- a/templates/todo/projects/python-mongo/azure-bicep.yaml +++ b/templates/todo/projects/python-mongo/azure-bicep.yaml @@ -13,4 +13,3 @@ services: project: ../../api/python language: py host: appservice - \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/repo-bicep.yaml b/templates/todo/projects/python-mongo/repo-bicep.yaml index 200edb07585..43749682543 100644 --- a/templates/todo/projects/python-mongo/repo-bicep.yaml +++ b/templates/todo/projects/python-mongo/repo-bicep.yaml @@ -9,7 +9,7 @@ repo: remotes: - name: azure-samples - url: git@github.com:kaizentm/todo-python-mongo.git + url: git@github.com:Azure-Samples/todo-python-mongo.git rewrite: patterns: From ec30798409a7fa0bc7cf234ef2c1933516b69c89 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Fri, 5 Aug 2022 15:50:43 -0700 Subject: [PATCH 13/30] address bicep lint failures Co-authored-by: Hattan Shobokshi --- .../test/samples/storage/infra/resources.json | 45 +++++++++++++++++++ .../todo/common/infra/aca/bicep/api.bicep | 2 +- .../todo/common/infra/aca/bicep/main.bicep | 2 +- .../common/infra/aca/bicep/resources.bicep | 4 +- .../todo/common/infra/aca/bicep/web.bicep | 2 +- .../csharp-cosmos-sql/infra/main.bicep | 2 +- .../csharp-cosmos-sql/infra/resources.bicep | 4 +- .../projects/csharp-mongo/infra/main.bicep | 2 +- .../csharp-mongo/infra/resources.bicep | 4 +- .../todo/projects/csharp-sql/infra/main.bicep | 2 +- .../projects/csharp-sql/infra/resources.bicep | 4 +- .../nodejs-mongo-swa-func/infra/main.bicep | 2 +- .../infra/resources.bicep | 4 +- .../nodejs-mongo/infra/bicep/main.bicep | 2 +- .../nodejs-mongo/infra/bicep/resources.bicep | 4 +- .../python-mongo-swa-func/infra/main.bicep | 2 +- .../infra/resources.bicep | 4 +- .../python-mongo/infra/bicep/main.bicep | 2 +- .../python-mongo/infra/bicep/resources.bicep | 4 +- 19 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 cli/azd/test/samples/storage/infra/resources.json diff --git a/cli/azd/test/samples/storage/infra/resources.json b/cli/azd/test/samples/storage/infra/resources.json new file mode 100644 index 00000000000..9baf97a5386 --- /dev/null +++ b/cli/azd/test/samples/storage/infra/resources.json @@ -0,0 +1,45 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "metadata": { + "_generator": { + "name": "bicep", + "version": "0.4.1318.3566", + "templateHash": "11825518782068023226" + } + }, + "parameters": { + "location": { + "type": "string" + }, + "resourceToken": { + "type": "string" + }, + "tags": { + "type": "object" + } + }, + "resources": [ + { + "type": "Microsoft.Storage/storageAccounts", + "apiVersion": "2021-09-01", + "name": "[format('st{0}', parameters('resourceToken'))]", + "location": "[parameters('location')]", + "tags": "[parameters('tags')]", + "kind": "StorageV2", + "sku": { + "name": "Standard_LRS" + } + } + ], + "outputs": { + "AZURE_STORAGE_ACCOUNT_ID": { + "type": "string", + "value": "[resourceId('Microsoft.Storage/storageAccounts', format('st{0}', parameters('resourceToken')))]" + }, + "AZURE_STORAGE_ACCOUNT_NAME": { + "type": "string", + "value": "[format('st{0}', parameters('resourceToken'))]" + } + } +} \ No newline at end of file diff --git a/templates/todo/common/infra/aca/bicep/api.bicep b/templates/todo/common/infra/aca/bicep/api.bicep index 5773b70df5a..1972eab6b0d 100644 --- a/templates/todo/common/infra/aca/bicep/api.bicep +++ b/templates/todo/common/infra/aca/bicep/api.bicep @@ -11,7 +11,7 @@ param imageName string var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' existing = { name: '${abbrs.appManagedEnvironments}${resourceToken}' diff --git a/templates/todo/common/infra/aca/bicep/main.bicep b/templates/todo/common/infra/aca/bicep/main.bicep index 9e0d79f6fe4..142f6bb7eea 100644 --- a/templates/todo/common/infra/aca/bicep/main.bicep +++ b/templates/todo/common/infra/aca/bicep/main.bicep @@ -20,7 +20,7 @@ param webImageName string = '' var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: '${abbrs.resourcesResourceGroups}${name}' diff --git a/templates/todo/common/infra/aca/bicep/resources.bicep b/templates/todo/common/infra/aca/bicep/resources.bicep index 0c566c92363..c42ecf3b7ba 100644 --- a/templates/todo/common/infra/aca/bicep/resources.bicep +++ b/templates/todo/common/infra/aca/bicep/resources.bicep @@ -6,7 +6,7 @@ param tags object param apiImageName string = '' param webImageName string = '' -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' = { name: '${abbrs.appManagedEnvironments}${resourceToken}' @@ -83,7 +83,7 @@ resource keyVaultAccessPolicies 'Microsoft.KeyVault/vaults/accessPolicies@2021-1 } } -module applicationInsightsResources '../../../../common/infra/applicationinsights.bicep' = { +module applicationInsightsResources '../../../../../common/infra/bicep/applicationinsights.bicep' = { name: 'applicationinsights-resources' params: { resourceToken: resourceToken diff --git a/templates/todo/common/infra/aca/bicep/web.bicep b/templates/todo/common/infra/aca/bicep/web.bicep index 5cd6e1c222b..6a5db362ed5 100644 --- a/templates/todo/common/infra/aca/bicep/web.bicep +++ b/templates/todo/common/infra/aca/bicep/web.bicep @@ -11,7 +11,7 @@ param imageName string var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' existing = { name: '${abbrs.appManagedEnvironments}${resourceToken}' diff --git a/templates/todo/projects/csharp-cosmos-sql/infra/main.bicep b/templates/todo/projects/csharp-cosmos-sql/infra/main.bicep index 52e33a264c7..c3be8b14659 100644 --- a/templates/todo/projects/csharp-cosmos-sql/infra/main.bicep +++ b/templates/todo/projects/csharp-cosmos-sql/infra/main.bicep @@ -14,7 +14,7 @@ param principalId string = '' var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../common/infra/bicep/abbreviations.json') resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: '${abbrs.resourcesResourceGroups}${name}' diff --git a/templates/todo/projects/csharp-cosmos-sql/infra/resources.bicep b/templates/todo/projects/csharp-cosmos-sql/infra/resources.bicep index a3a9da58a99..6d9ba4d3da9 100644 --- a/templates/todo/projects/csharp-cosmos-sql/infra/resources.bicep +++ b/templates/todo/projects/csharp-cosmos-sql/infra/resources.bicep @@ -3,7 +3,7 @@ param principalId string = '' param resourceToken string param tags object -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../common/infra/bicep/abbreviations.json') resource web 'Microsoft.Web/sites@2021-03-01' = { name: '${abbrs.webSitesAppService}web-${resourceToken}' @@ -127,7 +127,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03 }) } -module applicationInsightsResources '../../../../common/infra/applicationinsights.bicep' = { +module applicationInsightsResources '../../../../common/infra/bicep/applicationinsights.bicep' = { name: 'applicationinsights-resources' params: { resourceToken: resourceToken diff --git a/templates/todo/projects/csharp-mongo/infra/main.bicep b/templates/todo/projects/csharp-mongo/infra/main.bicep index e39ec4b399b..ff72de41f2c 100644 --- a/templates/todo/projects/csharp-mongo/infra/main.bicep +++ b/templates/todo/projects/csharp-mongo/infra/main.bicep @@ -14,7 +14,7 @@ param principalId string = '' var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../common/infra/bicep/abbreviations.json') resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: '${abbrs.resourcesResourceGroups}${name}' diff --git a/templates/todo/projects/csharp-mongo/infra/resources.bicep b/templates/todo/projects/csharp-mongo/infra/resources.bicep index 5b06c8229d8..0c2e525d01c 100644 --- a/templates/todo/projects/csharp-mongo/infra/resources.bicep +++ b/templates/todo/projects/csharp-mongo/infra/resources.bicep @@ -3,7 +3,7 @@ param principalId string = '' param resourceToken string param tags object -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../common/infra/bicep/abbreviations.json') resource web 'Microsoft.Web/sites@2021-03-01' = { name: '${abbrs.webSitesAppService}web-${resourceToken}' @@ -171,7 +171,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03 }) } -module applicationInsightsResources '../../../../common/infra/applicationinsights.bicep' = { +module applicationInsightsResources '../../../../common/infra/bicep/applicationinsights.bicep' = { name: 'applicationinsights-resources' params: { resourceToken: resourceToken diff --git a/templates/todo/projects/csharp-sql/infra/main.bicep b/templates/todo/projects/csharp-sql/infra/main.bicep index ec9050ea8cb..45614f110e0 100644 --- a/templates/todo/projects/csharp-sql/infra/main.bicep +++ b/templates/todo/projects/csharp-sql/infra/main.bicep @@ -11,7 +11,7 @@ param location string var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../common/infra/bicep/abbreviations.json') resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: '${abbrs.resourcesResourceGroups}${name}' diff --git a/templates/todo/projects/csharp-sql/infra/resources.bicep b/templates/todo/projects/csharp-sql/infra/resources.bicep index 580cbf6ea5c..92df8c5f3ca 100644 --- a/templates/todo/projects/csharp-sql/infra/resources.bicep +++ b/templates/todo/projects/csharp-sql/infra/resources.bicep @@ -2,7 +2,7 @@ param location string param resourceToken string param tags object -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../common/infra/bicep/abbreviations.json') resource web 'Microsoft.Web/sites@2021-03-01' = { name: '${abbrs.webSitesAppService}web-${resourceToken}' @@ -125,7 +125,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03 }) } -module applicationInsightsResources '../../../../common/infra/applicationinsights.bicep' = { +module applicationInsightsResources '../../../../common/infra/bicep/applicationinsights.bicep' = { name: 'applicationinsights-resources' params: { resourceToken: resourceToken diff --git a/templates/todo/projects/nodejs-mongo-swa-func/infra/main.bicep b/templates/todo/projects/nodejs-mongo-swa-func/infra/main.bicep index 27aff2379de..7694ad69705 100644 --- a/templates/todo/projects/nodejs-mongo-swa-func/infra/main.bicep +++ b/templates/todo/projects/nodejs-mongo-swa-func/infra/main.bicep @@ -14,7 +14,7 @@ param principalId string = '' var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../common/infra/bicep/abbreviations.json') resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: '${abbrs.resourcesResourceGroups}${name}' diff --git a/templates/todo/projects/nodejs-mongo-swa-func/infra/resources.bicep b/templates/todo/projects/nodejs-mongo-swa-func/infra/resources.bicep index 6e108084db5..510e69b5a10 100644 --- a/templates/todo/projects/nodejs-mongo-swa-func/infra/resources.bicep +++ b/templates/todo/projects/nodejs-mongo-swa-func/infra/resources.bicep @@ -3,7 +3,7 @@ param principalId string = '' param resourceToken string param tags object -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../common/infra/bicep/abbreviations.json') resource web 'Microsoft.Web/staticSites@2021-03-01' = { name: '${abbrs.webStaticSites}${resourceToken}' @@ -161,7 +161,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03 }) } -module applicationInsightsResources '../../../../common/infra/applicationinsights.bicep' = { +module applicationInsightsResources '../../../../common/infra/bicep/applicationinsights.bicep' = { name: 'applicationinsights-resources' params: { resourceToken: resourceToken diff --git a/templates/todo/projects/nodejs-mongo/infra/bicep/main.bicep b/templates/todo/projects/nodejs-mongo/infra/bicep/main.bicep index e39ec4b399b..29939fdd5a7 100644 --- a/templates/todo/projects/nodejs-mongo/infra/bicep/main.bicep +++ b/templates/todo/projects/nodejs-mongo/infra/bicep/main.bicep @@ -14,7 +14,7 @@ param principalId string = '' var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: '${abbrs.resourcesResourceGroups}${name}' diff --git a/templates/todo/projects/nodejs-mongo/infra/bicep/resources.bicep b/templates/todo/projects/nodejs-mongo/infra/bicep/resources.bicep index c0365015078..83396a6b645 100644 --- a/templates/todo/projects/nodejs-mongo/infra/bicep/resources.bicep +++ b/templates/todo/projects/nodejs-mongo/infra/bicep/resources.bicep @@ -3,7 +3,7 @@ param principalId string = '' param resourceToken string param tags object -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') resource web 'Microsoft.Web/sites@2021-03-01' = { name: '${abbrs.webSitesAppService}web-${resourceToken}' @@ -179,7 +179,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03 }) } -module applicationInsightsResources '../../../../common/infra/applicationinsights.bicep' = { +module applicationInsightsResources '../../../../../common/infra/bicep/applicationinsights.bicep' = { name: 'applicationinsights-resources' params: { resourceToken: resourceToken diff --git a/templates/todo/projects/python-mongo-swa-func/infra/main.bicep b/templates/todo/projects/python-mongo-swa-func/infra/main.bicep index 27aff2379de..7694ad69705 100644 --- a/templates/todo/projects/python-mongo-swa-func/infra/main.bicep +++ b/templates/todo/projects/python-mongo-swa-func/infra/main.bicep @@ -14,7 +14,7 @@ param principalId string = '' var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../common/infra/bicep/abbreviations.json') resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: '${abbrs.resourcesResourceGroups}${name}' diff --git a/templates/todo/projects/python-mongo-swa-func/infra/resources.bicep b/templates/todo/projects/python-mongo-swa-func/infra/resources.bicep index 386e14955ea..b2a53b44b4c 100644 --- a/templates/todo/projects/python-mongo-swa-func/infra/resources.bicep +++ b/templates/todo/projects/python-mongo-swa-func/infra/resources.bicep @@ -3,7 +3,7 @@ param principalId string = '' param resourceToken string param tags object -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../common/infra/bicep/abbreviations.json') resource web 'Microsoft.Web/staticSites@2021-03-01' = { name: '${abbrs.webStaticSites}web-${resourceToken}' @@ -158,7 +158,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03 }) } -module applicationInsightsResources '../../../../common/infra/applicationinsights.bicep' = { +module applicationInsightsResources '../../../../common/infra/bicep/applicationinsights.bicep' = { name: 'applicationinsights-resources' params: { resourceToken: resourceToken diff --git a/templates/todo/projects/python-mongo/infra/bicep/main.bicep b/templates/todo/projects/python-mongo/infra/bicep/main.bicep index e39ec4b399b..29939fdd5a7 100644 --- a/templates/todo/projects/python-mongo/infra/bicep/main.bicep +++ b/templates/todo/projects/python-mongo/infra/bicep/main.bicep @@ -14,7 +14,7 @@ param principalId string = '' var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: '${abbrs.resourcesResourceGroups}${name}' diff --git a/templates/todo/projects/python-mongo/infra/bicep/resources.bicep b/templates/todo/projects/python-mongo/infra/bicep/resources.bicep index ecdb499bfe7..5b77e836065 100644 --- a/templates/todo/projects/python-mongo/infra/bicep/resources.bicep +++ b/templates/todo/projects/python-mongo/infra/bicep/resources.bicep @@ -3,7 +3,7 @@ param principalId string = '' param resourceToken string param tags object -var abbrs = loadJsonContent('../../../../common/infra/abbreviations.json') +var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') resource web 'Microsoft.Web/sites@2021-03-01' = { name: '${abbrs.webSitesAppService}web-${resourceToken}' @@ -180,7 +180,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03 }) } -module applicationInsightsResources '../../../../common/infra/applicationinsights.bicep' = { +module applicationInsightsResources '../../../../../common/infra/bicep/applicationinsights.bicep' = { name: 'applicationinsights-resources' params: { resourceToken: resourceToken From dd99040b58e760ff8ae13b5a6090a667f1beee27 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Mon, 22 Aug 2022 12:09:32 -0700 Subject: [PATCH 14/30] Update todo-project template. Co-authored-by: Hattan Shobokshi --- .vscode/launch.json | 52 ------------------- .vscode/tasks.json | 14 ----- .../test/samples/storage/infra/resources.json | 45 ---------------- generators/repo/src/commands/generate.ts | 4 +- generators/repo/src/commands/list.ts | 3 +- generators/repo/src/common/util.ts | 7 +-- .../todo/projects/csharp-cosmos-sql/repo.yaml | 5 ++ .../todo/projects/csharp-mongo/repo.yaml | 5 ++ templates/todo/projects/csharp-sql/repo.yaml | 5 ++ .../todo/projects/nodejs-mongo-aca/repo.yaml | 5 ++ .../projects/nodejs-mongo-swa-func/repo.yaml | 5 ++ .../bicep/azure.yaml} | 0 .../.repo/bicep/infra}/main.bicep | 2 +- .../bicep/infra}/main.parameters.json | 0 .../bicep/infra}/resources.bicep | 4 +- .../bicep/repo.yaml} | 34 +++++++----- .../todo/projects/python-mongo-aca/repo.yaml | 5 ++ .../projects/python-mongo-swa-func/repo.yaml | 5 ++ .../bicep/azure.yaml} | 0 .../.repo/bicep/infra}/main.bicep | 2 +- .../bicep/infra}/main.parameters.json | 0 .../bicep/infra}/resources.bicep | 4 +- .../bicep/repo.yaml} | 30 ++++++----- 23 files changed, 85 insertions(+), 151 deletions(-) delete mode 100644 .vscode/launch.json delete mode 100644 .vscode/tasks.json delete mode 100644 cli/azd/test/samples/storage/infra/resources.json rename templates/todo/projects/nodejs-mongo/{azure-bicep.yaml => .repo/bicep/azure.yaml} (100%) rename templates/todo/projects/{python-mongo/infra/bicep => nodejs-mongo/.repo/bicep/infra}/main.bicep (94%) rename templates/todo/projects/nodejs-mongo/{infra/bicep => .repo/bicep/infra}/main.parameters.json (100%) rename templates/todo/projects/nodejs-mongo/{infra/bicep => .repo/bicep/infra}/resources.bicep (97%) rename templates/todo/projects/nodejs-mongo/{repo-bicep.yaml => .repo/bicep/repo.yaml} (67%) rename templates/todo/projects/python-mongo/{azure-bicep.yaml => .repo/bicep/azure.yaml} (100%) rename templates/todo/projects/{nodejs-mongo/infra/bicep => python-mongo/.repo/bicep/infra}/main.bicep (94%) rename templates/todo/projects/python-mongo/{infra/bicep => .repo/bicep/infra}/main.parameters.json (100%) rename templates/todo/projects/python-mongo/{infra/bicep => .repo/bicep/infra}/resources.bicep (97%) rename templates/todo/projects/python-mongo/{repo-bicep.yaml => .repo/bicep/repo.yaml} (68%) diff --git a/.vscode/launch.json b/.vscode/launch.json deleted file mode 100644 index 622b6fa5ca0..00000000000 --- a/.vscode/launch.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - // Use IntelliSense to learn about possible attributes. - // Hover to view descriptions of existing attributes. - // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 - "version": "0.2.0", - "configurations": [ - { - "type": "node", - "request": "launch", - "name": "Repoman Generate - Python Mongo", - "program": "${workspaceFolder}/generators/repo/src/index.ts", - "preLaunchTask": "tsc: build", - "outFiles": ["${workspaceFolder}/generators/repo/dist/**/*.js"], - "args" : [ - "generate", - "-t", - "repo-bicep.yaml", - "-s", - "${workspaceFolder}/templates/todo/projects/python-mongo", - "-o", - "${workspaceFolder}/.output/python-mongo", - "--branch", - "pr-debug-test", - "--https", - "--fail-on-update-error", - "--resultsFile", - "--update" - ] - }, - { - "type": "node", - "request": "launch", - "name": "Repoman Generate - NodeJs Mongo", - "program": "${workspaceFolder}/generators/repo/src/index.ts", - "preLaunchTask": "tsc: build", - "outFiles": ["${workspaceFolder}/generators/repo/dist/**/*.js"], - "args" : [ - "generate", - "-s", - "${workspaceFolder}/templates/todo/projects/nodejs-mongo", - "-o", - "${workspaceFolder}/.output/nodejs-mongo", - "--branch", - "pr-debug-test", - "--https", - "--fail-on-update-error", - "--resultsFile", - "--update" - ] - }, - ] -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json deleted file mode 100644 index 34149fbcc0e..00000000000 --- a/.vscode/tasks.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "version": "2.0.0", - "tasks": [ - { - "type": "typescript", - "tsconfig": "generators/repo/tsconfig.json", - "problemMatcher": [ - "$tsc" - ], - "group": "build", - "label": "tsc: build" - } - ] -} \ No newline at end of file diff --git a/cli/azd/test/samples/storage/infra/resources.json b/cli/azd/test/samples/storage/infra/resources.json deleted file mode 100644 index 9baf97a5386..00000000000 --- a/cli/azd/test/samples/storage/infra/resources.json +++ /dev/null @@ -1,45 +0,0 @@ -{ - "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", - "contentVersion": "1.0.0.0", - "metadata": { - "_generator": { - "name": "bicep", - "version": "0.4.1318.3566", - "templateHash": "11825518782068023226" - } - }, - "parameters": { - "location": { - "type": "string" - }, - "resourceToken": { - "type": "string" - }, - "tags": { - "type": "object" - } - }, - "resources": [ - { - "type": "Microsoft.Storage/storageAccounts", - "apiVersion": "2021-09-01", - "name": "[format('st{0}', parameters('resourceToken'))]", - "location": "[parameters('location')]", - "tags": "[parameters('tags')]", - "kind": "StorageV2", - "sku": { - "name": "Standard_LRS" - } - } - ], - "outputs": { - "AZURE_STORAGE_ACCOUNT_ID": { - "type": "string", - "value": "[resourceId('Microsoft.Storage/storageAccounts', format('st{0}', parameters('resourceToken')))]" - }, - "AZURE_STORAGE_ACCOUNT_NAME": { - "type": "string", - "value": "[format('st{0}', parameters('resourceToken'))]" - } - } -} \ No newline at end of file diff --git a/generators/repo/src/commands/generate.ts b/generators/repo/src/commands/generate.ts index 483d4b770ae..107c01fa96f 100644 --- a/generators/repo/src/commands/generate.ts +++ b/generators/repo/src/commands/generate.ts @@ -5,7 +5,7 @@ import os from "os"; import fs from "fs/promises"; import ansiEscapes from "ansi-escapes"; import chalk from "chalk"; -import { cleanDirectoryPath, copyFile, createRepoUrlFromRemote, ensureDirectoryPath, getGlobFiles, getRepoPropsFromRemote, isStringNullOrEmpty, RepoProps, writeHeader,ensureFilePath } from "../common/util"; +import { cleanDirectoryPath, copyFile, createRepoUrlFromRemote, ensureDirectoryPath, getGlobFiles, getRepoPropsFromRemote, isStringNullOrEmpty, RepoProps, writeHeader,isFilePath } from "../common/util"; import { AssetRule, GitRemote, RepomanCommand, RepomanCommandOptions, RepoManifest } from "../models"; import { GitRepo } from "../tools/git"; @@ -340,7 +340,7 @@ export class GenerateCommand implements RepomanCommand { const absoluteDestPath = path.join(this.generatePath, rule.to); console.info(chalk.white(`Copying asset(s) from ${chalk.cyan(rule.from)} to ${chalk.cyan(rule.to)}...`)); // check if this is filepath - if (await ensureFilePath(absoluteSourcePath)) { + if (await isFilePath(absoluteSourcePath)) { await copyFile(absoluteSourcePath, absoluteDestPath); return; } diff --git a/generators/repo/src/commands/list.ts b/generators/repo/src/commands/list.ts index f2da920d431..2219d8653fe 100644 --- a/generators/repo/src/commands/list.ts +++ b/generators/repo/src/commands/list.ts @@ -29,8 +29,7 @@ export class ListCommand implements RepomanCommand { console.info(chalk.green(`Searching for repo templates within path ${this.sourcePath}`)); console.info(); } - - const files = await getGlobFiles("**/repo*.yaml", { cwd: this.sourcePath }); + const files = await getGlobFiles("**/repo.yaml", { cwd: this.sourcePath, dot:true }); if (!isJsonFormat) { console.info(chalk.cyan(`Found ${files.length} templates within search path`)); diff --git a/generators/repo/src/common/util.ts b/generators/repo/src/common/util.ts index 52c2e70b2c2..42554da9005 100644 --- a/generators/repo/src/common/util.ts +++ b/generators/repo/src/common/util.ts @@ -47,13 +47,14 @@ export const ensureDirectoryPath = async (directoryPath: string) => { } } -export const ensureFilePath = async (filePath: string) => { +export const isFilePath = async (filePath: string) => { try { const link = await fs.lstat(filePath); return link.isFile() } - catch (err) { - console.error(chalk.red(`- ${err}`)); + catch (err: any) + { + console.warn(chalk.yellowBright(`- ${err.message}`)); } } diff --git a/templates/todo/projects/csharp-cosmos-sql/repo.yaml b/templates/todo/projects/csharp-cosmos-sql/repo.yaml index 9606307481d..894b2ef215e 100644 --- a/templates/todo/projects/csharp-cosmos-sql/repo.yaml +++ b/templates/todo/projects/csharp-cosmos-sql/repo.yaml @@ -18,6 +18,11 @@ repo: assets: # Common assets + # Rule for Path Rewrite Only + - from: ../../../../common/infra/bicep + to: ./ + ignore: + - "**/*" # openapi.yaml to root - from: ../../api/common diff --git a/templates/todo/projects/csharp-mongo/repo.yaml b/templates/todo/projects/csharp-mongo/repo.yaml index b8c19441390..b330bacb66d 100644 --- a/templates/todo/projects/csharp-mongo/repo.yaml +++ b/templates/todo/projects/csharp-mongo/repo.yaml @@ -18,6 +18,11 @@ repo: assets: # Common assets + # Rule for Path Rewrite Only + - from: ../../../../common/infra/bicep + to: ./ + ignore: + - "**/*" # openapi.yaml to root - from: ../../api/common diff --git a/templates/todo/projects/csharp-sql/repo.yaml b/templates/todo/projects/csharp-sql/repo.yaml index 8847e07a965..298e37fc04b 100644 --- a/templates/todo/projects/csharp-sql/repo.yaml +++ b/templates/todo/projects/csharp-sql/repo.yaml @@ -18,6 +18,11 @@ repo: assets: # Common assets + # Rule for Path Rewrite Only + - from: ../../../../common/infra/bicep + to: ./ + ignore: + - "**/*" # openapi.yaml to root - from: ../../api/common diff --git a/templates/todo/projects/nodejs-mongo-aca/repo.yaml b/templates/todo/projects/nodejs-mongo-aca/repo.yaml index a813e1f4a77..4542114bfa3 100644 --- a/templates/todo/projects/nodejs-mongo-aca/repo.yaml +++ b/templates/todo/projects/nodejs-mongo-aca/repo.yaml @@ -18,6 +18,11 @@ repo: assets: # Common assets + # Rule for Path Rewrite Only + - from: ../../../../../common/infra/bicep + to: ./ + ignore: + - "**/*" # openapi.yaml to root - from: ../../api/common diff --git a/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml b/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml index f958baea59c..7ed890f26bf 100644 --- a/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml +++ b/templates/todo/projects/nodejs-mongo-swa-func/repo.yaml @@ -18,6 +18,11 @@ repo: assets: # Common assets + # Rule for Path Rewrite Only + - from: ../../../../common/infra/bicep + to: ./ + ignore: + - "**/*" # openapi.yaml to root - from: ../../api/common diff --git a/templates/todo/projects/nodejs-mongo/azure-bicep.yaml b/templates/todo/projects/nodejs-mongo/.repo/bicep/azure.yaml similarity index 100% rename from templates/todo/projects/nodejs-mongo/azure-bicep.yaml rename to templates/todo/projects/nodejs-mongo/.repo/bicep/azure.yaml diff --git a/templates/todo/projects/python-mongo/infra/bicep/main.bicep b/templates/todo/projects/nodejs-mongo/.repo/bicep/infra/main.bicep similarity index 94% rename from templates/todo/projects/python-mongo/infra/bicep/main.bicep rename to templates/todo/projects/nodejs-mongo/.repo/bicep/infra/main.bicep index 29939fdd5a7..8b9a4ffba1b 100644 --- a/templates/todo/projects/python-mongo/infra/bicep/main.bicep +++ b/templates/todo/projects/nodejs-mongo/.repo/bicep/infra/main.bicep @@ -14,7 +14,7 @@ param principalId string = '' var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') +var abbrs = loadJsonContent('../../../../../../common/infra/bicep/abbreviations.json') resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: '${abbrs.resourcesResourceGroups}${name}' diff --git a/templates/todo/projects/nodejs-mongo/infra/bicep/main.parameters.json b/templates/todo/projects/nodejs-mongo/.repo/bicep/infra/main.parameters.json similarity index 100% rename from templates/todo/projects/nodejs-mongo/infra/bicep/main.parameters.json rename to templates/todo/projects/nodejs-mongo/.repo/bicep/infra/main.parameters.json diff --git a/templates/todo/projects/nodejs-mongo/infra/bicep/resources.bicep b/templates/todo/projects/nodejs-mongo/.repo/bicep/infra/resources.bicep similarity index 97% rename from templates/todo/projects/nodejs-mongo/infra/bicep/resources.bicep rename to templates/todo/projects/nodejs-mongo/.repo/bicep/infra/resources.bicep index 83396a6b645..f94a0bdba11 100644 --- a/templates/todo/projects/nodejs-mongo/infra/bicep/resources.bicep +++ b/templates/todo/projects/nodejs-mongo/.repo/bicep/infra/resources.bicep @@ -3,7 +3,7 @@ param principalId string = '' param resourceToken string param tags object -var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') +var abbrs = loadJsonContent('../../../../../../common/infra/bicep/abbreviations.json') resource web 'Microsoft.Web/sites@2021-03-01' = { name: '${abbrs.webSitesAppService}web-${resourceToken}' @@ -179,7 +179,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03 }) } -module applicationInsightsResources '../../../../../common/infra/bicep/applicationinsights.bicep' = { +module applicationInsightsResources '../../../../../../common/infra/bicep/applicationinsights.bicep' = { name: 'applicationinsights-resources' params: { resourceToken: resourceToken diff --git a/templates/todo/projects/nodejs-mongo/repo-bicep.yaml b/templates/todo/projects/nodejs-mongo/.repo/bicep/repo.yaml similarity index 67% rename from templates/todo/projects/nodejs-mongo/repo-bicep.yaml rename to templates/todo/projects/nodejs-mongo/.repo/bicep/repo.yaml index fed28af9b14..770a6574208 100644 --- a/templates/todo/projects/nodejs-mongo/repo-bicep.yaml +++ b/templates/todo/projects/nodejs-mongo/.repo/bicep/repo.yaml @@ -21,41 +21,45 @@ repo: - from: ./ to: ./ ignore: - - "repo-*.y[a]ml" - - "infra/**/*" - - "azure-*.y[a]ml" + - ".repo/**/*" + + # Rule for Path Rewrite Only + - from: ../../../../../../common/infra/bicep + to: ./ + ignore: + - ".repo/**/*" # openapi.yaml to root - - from: ../../api/common + - from: ../../../../api/common to: ./ patterns: - openapi.yaml # openapi.yaml to api root - - from: ../../api/common + - from: ../../../../api/common to: ./src/api patterns: - openapi.yaml # Template common - - from: ../../../common + - from: ../../../../../common to: ./ ignore: - "infra/**/*" - - from: ../../../common/infra/bicep + - from: ../../../../../common/infra/bicep to: ./infra # Assets common - - from: ../../common/assets + - from: ../../../../common/assets to: ./assets # Tests common - - from: ../../common/tests + - from: ../../../../common/tests to: ./tests # Node JS API - - from: ../../api/js + - from: ../../../../api/js to: ./src/api ignore: - "dist/**/*" @@ -64,16 +68,18 @@ repo: - "**/*.log" # React Frontend - - from: ../../web/react-fluent + - from: ../../../../web/react-fluent to: ./src/web ignore: - "build/**/*" - "node_modules/**/*" # Infra - - from: ./infra/bicep + - from: ./infra/ to: ./infra # Azure.yml - - from: ./azure-bicep.yaml - to: ./azure.yaml \ No newline at end of file + - from: ./azure.yaml + to: ./azure.yaml + + \ No newline at end of file diff --git a/templates/todo/projects/python-mongo-aca/repo.yaml b/templates/todo/projects/python-mongo-aca/repo.yaml index b3320688fdc..9a4c7547a9d 100644 --- a/templates/todo/projects/python-mongo-aca/repo.yaml +++ b/templates/todo/projects/python-mongo-aca/repo.yaml @@ -18,6 +18,11 @@ repo: assets: # Common assets + # Rule for Path Rewrite Only + - from: ../../../../../common/infra/bicep + to: ./ + ignore: + - "**/*" # openapi.yaml to root - from: ../../api/common diff --git a/templates/todo/projects/python-mongo-swa-func/repo.yaml b/templates/todo/projects/python-mongo-swa-func/repo.yaml index f4b934edbbe..8f879d1d675 100644 --- a/templates/todo/projects/python-mongo-swa-func/repo.yaml +++ b/templates/todo/projects/python-mongo-swa-func/repo.yaml @@ -18,6 +18,11 @@ repo: assets: # Common assets + # Rule for Path Rewrite Only + - from: ../../../../common/infra/bicep + to: ./ + ignore: + - "**/*" # openapi.yaml to root - from: ../../api/common diff --git a/templates/todo/projects/python-mongo/azure-bicep.yaml b/templates/todo/projects/python-mongo/.repo/bicep/azure.yaml similarity index 100% rename from templates/todo/projects/python-mongo/azure-bicep.yaml rename to templates/todo/projects/python-mongo/.repo/bicep/azure.yaml diff --git a/templates/todo/projects/nodejs-mongo/infra/bicep/main.bicep b/templates/todo/projects/python-mongo/.repo/bicep/infra/main.bicep similarity index 94% rename from templates/todo/projects/nodejs-mongo/infra/bicep/main.bicep rename to templates/todo/projects/python-mongo/.repo/bicep/infra/main.bicep index 29939fdd5a7..8b9a4ffba1b 100644 --- a/templates/todo/projects/nodejs-mongo/infra/bicep/main.bicep +++ b/templates/todo/projects/python-mongo/.repo/bicep/infra/main.bicep @@ -14,7 +14,7 @@ param principalId string = '' var resourceToken = toLower(uniqueString(subscription().id, name, location)) var tags = { 'azd-env-name': name } -var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') +var abbrs = loadJsonContent('../../../../../../common/infra/bicep/abbreviations.json') resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = { name: '${abbrs.resourcesResourceGroups}${name}' diff --git a/templates/todo/projects/python-mongo/infra/bicep/main.parameters.json b/templates/todo/projects/python-mongo/.repo/bicep/infra/main.parameters.json similarity index 100% rename from templates/todo/projects/python-mongo/infra/bicep/main.parameters.json rename to templates/todo/projects/python-mongo/.repo/bicep/infra/main.parameters.json diff --git a/templates/todo/projects/python-mongo/infra/bicep/resources.bicep b/templates/todo/projects/python-mongo/.repo/bicep/infra/resources.bicep similarity index 97% rename from templates/todo/projects/python-mongo/infra/bicep/resources.bicep rename to templates/todo/projects/python-mongo/.repo/bicep/infra/resources.bicep index 5b77e836065..28dfee3495d 100644 --- a/templates/todo/projects/python-mongo/infra/bicep/resources.bicep +++ b/templates/todo/projects/python-mongo/.repo/bicep/infra/resources.bicep @@ -3,7 +3,7 @@ param principalId string = '' param resourceToken string param tags object -var abbrs = loadJsonContent('../../../../../common/infra/bicep/abbreviations.json') +var abbrs = loadJsonContent('../../../../../../common/infra/bicep/abbreviations.json') resource web 'Microsoft.Web/sites@2021-03-01' = { name: '${abbrs.webSitesAppService}web-${resourceToken}' @@ -180,7 +180,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03 }) } -module applicationInsightsResources '../../../../../common/infra/bicep/applicationinsights.bicep' = { +module applicationInsightsResources '../../../../../../common/infra/bicep/applicationinsights.bicep' = { name: 'applicationinsights-resources' params: { resourceToken: resourceToken diff --git a/templates/todo/projects/python-mongo/repo-bicep.yaml b/templates/todo/projects/python-mongo/.repo/bicep/repo.yaml similarity index 68% rename from templates/todo/projects/python-mongo/repo-bicep.yaml rename to templates/todo/projects/python-mongo/.repo/bicep/repo.yaml index 43749682543..9afce959020 100644 --- a/templates/todo/projects/python-mongo/repo-bicep.yaml +++ b/templates/todo/projects/python-mongo/.repo/bicep/repo.yaml @@ -21,57 +21,61 @@ repo: - from: ./ to: ./ ignore: - - "repo-*.y[a]ml" - - "infra/**/*" - - "azure-*.y[a]ml" + - ".repo/**/*" + # Rule for Path Rewrite Only + - from: ../../../../../../common/infra/bicep + to: ./ + ignore: + - ".repo/**/*" + # openapi.yaml to root - - from: ../../api/common + - from: ../../../../api/common to: ./ patterns: - openapi.yaml # openapi.yaml to api root - - from: ../../api/common + - from: ../../../../api/common to: ./src/api patterns: - openapi.yaml # Template common - - from: ../../../common + - from: ../../../../../common to: ./ ignore: - "infra/**/*" - - from: ../../../common/infra/bicep + - from: ../../../../../common/infra/bicep to: ./infra # Assets common - - from: ../../common/assets + - from: ../../../../common/assets to: ./assets # Tests common - - from: ../../common/tests + - from: ../../../../common/tests to: ./tests # Python API - - from: ../../api/python + - from: ../../../../api/python to: ./src/api ignore: - "**/__pycache__/**" - "**/@(venv|.venv)/**" # React Frontend - - from: ../../web/react-fluent + - from: ../../../../web/react-fluent to: ./src/web ignore: - "build/**/*" - "node_modules/**/*" # Infra - - from: ./infra/bicep + - from: ./infra/ to: ./infra # Azure.yml - - from: ./azure-bicep.yaml + - from: ./azure.yaml to: ./azure.yaml \ No newline at end of file From 861e34af59bf301f22e786bab140d736645d4889 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Mon, 22 Aug 2022 16:29:58 -0700 Subject: [PATCH 15/30] fix asset rules for path rewitre Co-authored-by: Hattan Shobokshi --- .../todo/projects/nodejs-mongo/.repo/bicep/repo.yaml | 8 +++++--- .../todo/projects/python-mongo/.repo/bicep/repo.yaml | 9 ++++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/templates/todo/projects/nodejs-mongo/.repo/bicep/repo.yaml b/templates/todo/projects/nodejs-mongo/.repo/bicep/repo.yaml index f1e04af47ba..aa7bc655f72 100644 --- a/templates/todo/projects/nodejs-mongo/.repo/bicep/repo.yaml +++ b/templates/todo/projects/nodejs-mongo/.repo/bicep/repo.yaml @@ -21,16 +21,18 @@ repo: assets: # Common assets - - from: ./ + # Rule for Path Rewrite Only + - from: ../../../../../../common/infra/bicep to: ./ ignore: - ".repo/**/*" - # Rule for Path Rewrite Only - - from: ../../../../../../common/infra/bicep + - from: ./../../ to: ./ ignore: - ".repo/**/*" + - "repo.y[a]ml" + - "azure.y[a]ml" # openapi.yaml to root - from: ../../../../api/common diff --git a/templates/todo/projects/python-mongo/.repo/bicep/repo.yaml b/templates/todo/projects/python-mongo/.repo/bicep/repo.yaml index 2eb28515538..675702c4574 100644 --- a/templates/todo/projects/python-mongo/.repo/bicep/repo.yaml +++ b/templates/todo/projects/python-mongo/.repo/bicep/repo.yaml @@ -21,16 +21,19 @@ repo: assets: # Common assets - - from: ./ + + # Rule for Path Rewrite Only + - from: ../../../../../../common/infra/bicep to: ./ ignore: - ".repo/**/*" - # Rule for Path Rewrite Only - - from: ../../../../../../common/infra/bicep + - from: ./../../ to: ./ ignore: - ".repo/**/*" + - "repo.y[a]ml" + - "azure.y[a]ml" # openapi.yaml to root - from: ../../../../api/common From 9e1fa5a8c0bb306bda2e3e4d2644689a02bd68e9 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Mon, 22 Aug 2022 18:20:27 -0700 Subject: [PATCH 16/30] Add rewrite path rules tmp fix Co-authored-by: Hattan Shobokshi --- .../projects/nodejs-mongo/.repo/bicep/repo.yaml | 13 ++++++++++++- .../projects/python-mongo/.repo/bicep/repo.yaml | 13 ++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/templates/todo/projects/nodejs-mongo/.repo/bicep/repo.yaml b/templates/todo/projects/nodejs-mongo/.repo/bicep/repo.yaml index aa7bc655f72..fb750fbefd2 100644 --- a/templates/todo/projects/nodejs-mongo/.repo/bicep/repo.yaml +++ b/templates/todo/projects/nodejs-mongo/.repo/bicep/repo.yaml @@ -21,11 +21,22 @@ repo: assets: # Common assets - # Rule for Path Rewrite Only + # Rules for Path Rewrite Only - from: ../../../../../../common/infra/bicep to: ./ ignore: - ".repo/**/*" + + - from: ../../api/js + to: ./src/api + ignore: + - ".repo/**/*" + + - from: ../../web/react-fluent + to: ./src/web + ignore: + - ".repo/**/*" + # End Path Rewrite Rules - from: ./../../ to: ./ diff --git a/templates/todo/projects/python-mongo/.repo/bicep/repo.yaml b/templates/todo/projects/python-mongo/.repo/bicep/repo.yaml index 675702c4574..724224f0ac2 100644 --- a/templates/todo/projects/python-mongo/.repo/bicep/repo.yaml +++ b/templates/todo/projects/python-mongo/.repo/bicep/repo.yaml @@ -22,12 +22,23 @@ repo: assets: # Common assets - # Rule for Path Rewrite Only + # Rules for Path Rewrite Only - from: ../../../../../../common/infra/bicep to: ./ ignore: - ".repo/**/*" + - from: ../../api/python + to: ./src/api + ignore: + - ".repo/**/*" + + - from: ../../web/react-fluent + to: ./src/web + ignore: + - ".repo/**/*" + # End Path Rewrite Rules + - from: ./../../ to: ./ ignore: From c0657b3b3246760d8f3d896f37945350733446c8 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Mon, 22 Aug 2022 20:21:04 -0700 Subject: [PATCH 17/30] add python-mongo, application insights terraform modules --- .../infra/terraform/applicationinsights.tf | 1241 +++++++++++++++++ .../terraform/applicationinsights_output.tf | 5 + .../applicationinsights_variables.tf | 29 + .../.repo/terraform/infra/main.tf | 306 ++++ .../.repo/terraform/infra/output.tf | 36 + .../.repo/terraform/infra/provider.tf | 30 + .../.repo/terraform/infra/variables.tf | 15 + 7 files changed, 1662 insertions(+) create mode 100644 templates/common/infra/terraform/applicationinsights.tf create mode 100644 templates/common/infra/terraform/applicationinsights_output.tf create mode 100644 templates/common/infra/terraform/applicationinsights_variables.tf create mode 100644 templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf create mode 100644 templates/todo/projects/python-mongo/.repo/terraform/infra/output.tf create mode 100644 templates/todo/projects/python-mongo/.repo/terraform/infra/provider.tf create mode 100644 templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf diff --git a/templates/common/infra/terraform/applicationinsights.tf b/templates/common/infra/terraform/applicationinsights.tf new file mode 100644 index 00000000000..cbacd385115 --- /dev/null +++ b/templates/common/infra/terraform/applicationinsights.tf @@ -0,0 +1,1241 @@ +terraform { + required_providers { + azurerm = { + version = "~>3.18.0" + source = "hashicorp/azurerm" + } + azurecaf = { + source = "aztfmod/azurecaf" + version = "1.2.15" + } + } +} +# ------------------------------------------------------------------------------------------------------ +# DEPLOY APPLICATION INSIGHTS +# ------------------------------------------------------------------------------------------------------ +resource "azurecaf_name" "applicationinsights_name" { + name = var.resource_token + resource_type = "azurerm_application_insights" + random_length = 0 + clean_input = true +} + +resource "azurerm_application_insights" "applicationinsights" { + name = azurecaf_name.applicationinsights_name.result + location = var.location + resource_group_name = var.rg_name + application_type = "web" + workspace_id = var.workspace_id + tags = var.tags +} + +data "azurerm_subscription" "current" {} + +resource "azurerm_portal_dashboard" "board" { + name = "dash-${var.resource_token}" + resource_group_name = var.rg_name + location = var.location + tags = var.tags + dashboard_properties = < Date: Mon, 22 Aug 2022 21:11:13 -0700 Subject: [PATCH 18/30] add repo.yml, azure.yml files --- .../python-mongo/.repo/terraform/azure.yaml | 15 +++ .../.repo/terraform/infra/main.tf | 2 +- .../python-mongo/.repo/terraform/repo.yaml | 98 +++++++++++++++++++ 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 templates/todo/projects/python-mongo/.repo/terraform/azure.yaml create mode 100644 templates/todo/projects/python-mongo/.repo/terraform/repo.yaml diff --git a/templates/todo/projects/python-mongo/.repo/terraform/azure.yaml b/templates/todo/projects/python-mongo/.repo/terraform/azure.yaml new file mode 100644 index 00000000000..ad99d4beefb --- /dev/null +++ b/templates/todo/projects/python-mongo/.repo/terraform/azure.yaml @@ -0,0 +1,15 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json + +name: todo-python-mongo +metadata: + template: todo-python-mongo@0.0.1-beta +services: + web: + project: ../../web/react-fluent + dist: build + language: js + host: appservice + api: + project: ../../api/python + language: py + host: appservice diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf index b17290061ac..1e679ca9ec8 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf @@ -27,7 +27,7 @@ resource "random_string" "resource_token" { } module "applicationinsights" { - source = "../../../../../common/infra/terraform" + source = "../../../../../../common/infra/terraform" location = var.location rg_name = azurerm_resource_group.rg.name env_name = var.name diff --git a/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml b/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml new file mode 100644 index 00000000000..8d8702798ae --- /dev/null +++ b/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml @@ -0,0 +1,98 @@ +templateApi: 1.0.0 +metadata: + type: repo + name: todo-python-mongo + description: ToDo Application with a Python API and Azure Cosmos DB API for MongoDB + +repo: + includeProjectAssets: false + + remotes: + - name: azure-samples-main + url: git@github.com:kaizentm/todo-python-mongo-terraform.git + - name: azure-samples-staging + url: git@github.com:kaizentm/todo-python-mongo-terraform.git + branch: staging + + rewrite: + patterns: + - "**/azure.@(yml|yaml)" + - "**/*.tf" + + assets: + # Common assets + + # Rules for Path Rewrite Only + - from: ../../../../../../common/infra/terraform + to: ./../../infra/modules + ignore: + - ".repo/**/*" + + - from: ../../api/python + to: ./src/api + ignore: + - ".repo/**/*" + + - from: ../../web/react-fluent + to: ./src/web + ignore: + - ".repo/**/*" + # End Path Rewrite Rules + + - from: ./../../ + to: ./ + ignore: + - ".repo/**/*" + - "repo.y[a]ml" + - "azure.y[a]ml" + + # openapi.yaml to root + - from: ../../../../api/common + to: ./ + patterns: + - openapi.yaml + + # openapi.yaml to api root + - from: ../../../../api/common + to: ./src/api + patterns: + - openapi.yaml + + # Template common + - from: ../../../../../common + to: ./ + ignore: + - "infra/**/*" + + - from: ../../../../../common/infra/terraform + to: ./infra/modules + + # Assets common + - from: ../../../../common/assets + to: ./assets + + # Tests common + - from: ../../../../common/tests + to: ./tests + + # Python API + - from: ../../../../api/python + to: ./src/api + ignore: + - "**/__pycache__/**" + - "**/@(venv|.venv)/**" + + # React Frontend + - from: ../../../../web/react-fluent + to: ./src/web + ignore: + - "build/**/*" + - "node_modules/**/*" + + # Infra + - from: ./infra/ + to: ./infra + + # Azure.yml + - from: ./azure.yaml + to: ./azure.yaml \ No newline at end of file From 6e0cb752cf273e16217f94c4a05ad3f085ba9c2b Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Wed, 24 Aug 2022 08:49:37 -0700 Subject: [PATCH 19/30] fix asset rules --- templates/todo/projects/python-mongo/.repo/terraform/repo.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml b/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml index 8d8702798ae..c3062f381b9 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml +++ b/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml @@ -24,7 +24,7 @@ repo: # Rules for Path Rewrite Only - from: ../../../../../../common/infra/terraform - to: ./../../infra/modules + to: ./modules ignore: - ".repo/**/*" From f7d4c4b25c7438f36d8a7a0109bdc99512c7f9ee Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Wed, 24 Aug 2022 09:05:16 -0700 Subject: [PATCH 20/30] ignore terraform files Co-authored-by: Hattan Shobokshi --- .gitignore | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c0678016c6b..33a3a045e34 100644 --- a/.gitignore +++ b/.gitignore @@ -36,4 +36,9 @@ obj/ bin/ node_modules/ test-results/ -playwright-report/ \ No newline at end of file +playwright-report/ + +# terraform .tfstate files +**/.terraform +*.tfstate* +*.terraform* \ No newline at end of file From 5d139d8e5565170d809911a7a06e6566e1da494e Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Fri, 26 Aug 2022 13:00:53 -0700 Subject: [PATCH 21/30] update remote main and staging urls Co-authored-by: Hattan Shobokshi --- .../todo/projects/python-mongo/.repo/terraform/repo.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml b/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml index c3062f381b9..b6a2c7cb3f6 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml +++ b/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml @@ -9,9 +9,9 @@ repo: remotes: - name: azure-samples-main - url: git@github.com:kaizentm/todo-python-mongo-terraform.git + url: git@github.com:Azure-Samples/todo-python-mongo-terraform.git - name: azure-samples-staging - url: git@github.com:kaizentm/todo-python-mongo-terraform.git + url: git@github.com:Azure-Samples/todo-python-mongo-terraform.git branch: staging rewrite: From 025d3d8b517dfb50f85085c7f019a40645fe018e Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Fri, 26 Aug 2022 13:31:29 -0700 Subject: [PATCH 22/30] fix typo, update cspell Co-authored-by: Hattan Shobokshi --- .vscode/cspell.global.yaml | 3 +++ .../common/infra/terraform/applicationinsights_variables.tf | 2 +- .../projects/python-mongo/.repo/terraform/infra/variables.tf | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.vscode/cspell.global.yaml b/.vscode/cspell.global.yaml index 16ef93051e6..db84a856f8e 100644 --- a/.vscode/cspell.global.yaml +++ b/.vscode/cspell.global.yaml @@ -70,6 +70,9 @@ ignoreWords: - httptrigger - resourcegroups - devcontainer + - azurecaf + - azurerm + - menuid useGitignore: true dictionaryDefinitions: - name: gitHubUserAliases diff --git a/templates/common/infra/terraform/applicationinsights_variables.tf b/templates/common/infra/terraform/applicationinsights_variables.tf index 1f84f541046..58ebd425c24 100644 --- a/templates/common/infra/terraform/applicationinsights_variables.tf +++ b/templates/common/infra/terraform/applicationinsights_variables.tf @@ -9,7 +9,7 @@ variable "rg_name" { } variable "env_name" { - description = "The name of the evnironemnt to be deployed" + description = "The name of the environment to be deployed" type = string } diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf index 8bac65504c6..2aff1c8509d 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf @@ -4,7 +4,7 @@ variable "location" { } variable "name" { - description = "The name of the azd evnironemnt to be deployed" + description = "The name of the azd environment to be deployed" type = string } From 3c7e7b72e3e656ffe49138ae7b4c65b72f032f35 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Fri, 26 Aug 2022 18:37:21 -0700 Subject: [PATCH 23/30] addreses PR feedback --- .../common/infra/terraform/applicationinsights.tf | 8 ++++---- .../infra/terraform/applicationinsights_output.tf | 1 - .../python-mongo/.repo/terraform/infra/main.tf | 11 +++++++---- .../python-mongo/.repo/terraform/infra/provider.tf | 4 ++-- .../projects/python-mongo/.repo/terraform/repo.yaml | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/templates/common/infra/terraform/applicationinsights.tf b/templates/common/infra/terraform/applicationinsights.tf index cbacd385115..25770feb2ce 100644 --- a/templates/common/infra/terraform/applicationinsights.tf +++ b/templates/common/infra/terraform/applicationinsights.tf @@ -32,10 +32,10 @@ resource "azurerm_application_insights" "applicationinsights" { data "azurerm_subscription" "current" {} resource "azurerm_portal_dashboard" "board" { - name = "dash-${var.resource_token}" - resource_group_name = var.rg_name - location = var.location - tags = var.tags + name = "dash-${var.resource_token}" + resource_group_name = var.rg_name + location = var.location + tags = var.tags dashboard_properties = < Date: Fri, 26 Aug 2022 18:47:02 -0700 Subject: [PATCH 24/30] update template name --- .../todo/projects/python-mongo/.repo/terraform/azure.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/todo/projects/python-mongo/.repo/terraform/azure.yaml b/templates/todo/projects/python-mongo/.repo/terraform/azure.yaml index ad99d4beefb..b7e5da5f20d 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/azure.yaml +++ b/templates/todo/projects/python-mongo/.repo/terraform/azure.yaml @@ -1,8 +1,8 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json -name: todo-python-mongo +name: todo-python-mongo-terraform metadata: - template: todo-python-mongo@0.0.1-beta + template: todo-python-mongo-terraform@0.0.1-beta services: web: project: ../../web/react-fluent From 01188dd8af0f4e5392ea682564c384dc37f6d532 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Fri, 26 Aug 2022 20:38:21 -0700 Subject: [PATCH 25/30] split resources in multiple files. --- .../.repo/terraform/infra/apps.tf | 119 ++++++++ .../.repo/terraform/infra/database.tf | 71 +++++ .../.repo/terraform/infra/keyvault.tf | 53 ++++ .../.repo/terraform/infra/loganalytics.tf | 18 ++ .../.repo/terraform/infra/main.tf | 275 +----------------- 5 files changed, 264 insertions(+), 272 deletions(-) create mode 100644 templates/todo/projects/python-mongo/.repo/terraform/infra/apps.tf create mode 100644 templates/todo/projects/python-mongo/.repo/terraform/infra/database.tf create mode 100644 templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf create mode 100644 templates/todo/projects/python-mongo/.repo/terraform/infra/loganalytics.tf diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/apps.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/apps.tf new file mode 100644 index 00000000000..362b9998b93 --- /dev/null +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/apps.tf @@ -0,0 +1,119 @@ +# ------------------------------------------------------------------------------------------------------ +# Deploy app service plan +# ------------------------------------------------------------------------------------------------------ +resource "azurecaf_name" "plan_name" { + name = random_string.resource_token.result + resource_type = "azurerm_app_service_plan" + random_length = 0 + clean_input = true +} + +resource "azurerm_service_plan" "plan" { + name = azurecaf_name.plan_name.result + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + os_type = "Linux" + sku_name = "B1" + + tags = local.tags +} + +# ------------------------------------------------------------------------------------------------------ +# Deploy app service web app +# ------------------------------------------------------------------------------------------------------ +resource "azurecaf_name" "web_name" { + name = "web-${random_string.resource_token.result}" + resource_type = "azurerm_app_service" + random_length = 0 + clean_input = true +} + +resource "azurerm_linux_web_app" "web" { + name = azurecaf_name.web_name.result + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + service_plan_id = azurerm_service_plan.plan.id + https_only = true + tags = merge(local.tags, { azd-service-name : "web" }) + + site_config { + always_on = true + ftps_state = "FtpsOnly" + app_command_line = "pm2 serve /home/site/wwwroot --no-daemon --spa" + application_stack { + node_version = "16-lts" + } + } + + app_settings = { + "SCM_DO_BUILD_DURING_DEPLOYMENT" = "false" + "APPLICATIONINSIGHTS_CONNECTION_STRING" = module.applicationinsights.APPLICATIONINSIGHTS_CONNECTION_STRING + } + + logs { + application_logs { + file_system_level = "Verbose" + } + detailed_error_messages = true + failed_request_tracing = true + http_logs { + file_system { + retention_in_days = 1 + retention_in_mb = 35 + } + } + } +} + +# ------------------------------------------------------------------------------------------------------ +# Deploy app service api +# ------------------------------------------------------------------------------------------------------ +resource "azurecaf_name" "appi_name" { + name = "api-${random_string.resource_token.result}" + resource_type = "azurerm_app_service" + random_length = 0 + clean_input = true +} + +resource "azurerm_linux_web_app" "api" { + name = azurecaf_name.appi_name.result + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + service_plan_id = azurerm_service_plan.plan.id + https_only = true + tags = merge(local.tags, { "azd-service-name" : "api" }) + + site_config { + always_on = true + ftps_state = "FtpsOnly" + app_command_line = local.api_command_line + application_stack { + python_version = "3.8" + } + } + + identity { + type = "SystemAssigned" + } + + app_settings = { + "AZURE_COSMOS_CONNECTION_STRING_KEY" = "AZURE-COSMOS-CONNECTION-STRING" + "AZURE_COSMOS_DATABASE_NAME" = azurerm_cosmosdb_mongo_database.mongodb.name + "SCM_DO_BUILD_DURING_DEPLOYMENT" = "true" + "AZURE_KEY_VAULT_ENDPOINT" = azurerm_key_vault.kv.vault_uri + "APPLICATIONINSIGHTS_CONNECTION_STRING" = module.applicationinsights.APPLICATIONINSIGHTS_CONNECTION_STRING + } + logs { + application_logs { + file_system_level = "Verbose" + } + detailed_error_messages = true + failed_request_tracing = true + http_logs { + file_system { + retention_in_days = 1 + retention_in_mb = 35 + } + } + } +} diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/database.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/database.tf new file mode 100644 index 00000000000..d94f6f48f25 --- /dev/null +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/database.tf @@ -0,0 +1,71 @@ +# ------------------------------------------------------------------------------------------------------ +# Deploy cosmos db account +# ------------------------------------------------------------------------------------------------------ +resource "azurecaf_name" "db_acc_name" { + name = random_string.resource_token.result + resource_type = "azurerm_cosmosdb_account" + random_length = 0 + clean_input = true +} + +resource "azurerm_cosmosdb_account" "db" { + name = azurecaf_name.db_acc_name.result + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + offer_type = "Standard" + kind = "MongoDB" + enable_automatic_failover = false + enable_multiple_write_locations = false + mongo_server_version = "4.0" + tags = local.tags + + capabilities { + name = "EnableServerless" + } + + consistency_policy { + consistency_level = "Session" + } + + geo_location { + location = azurerm_resource_group.rg.location + failover_priority = 0 + zone_redundant = false + } +} + +# ------------------------------------------------------------------------------------------------------ +# Deploy cosmos mongo db and collections +# ------------------------------------------------------------------------------------------------------ +resource "azurerm_cosmosdb_mongo_database" "mongodb" { + name = "Todo" + resource_group_name = azurerm_cosmosdb_account.db.resource_group_name + account_name = azurerm_cosmosdb_account.db.name +} + +resource "azurerm_cosmosdb_mongo_collection" "todolist" { + name = "TodoList" + resource_group_name = azurerm_cosmosdb_account.db.resource_group_name + account_name = azurerm_cosmosdb_account.db.name + database_name = azurerm_cosmosdb_mongo_database.mongodb.name + shard_key = "_id" + + + index { + keys = ["_id"] + unique = true + } +} + +resource "azurerm_cosmosdb_mongo_collection" "todocollection" { + name = "TodoItem" + resource_group_name = azurerm_cosmosdb_account.db.resource_group_name + account_name = azurerm_cosmosdb_account.db.name + database_name = azurerm_cosmosdb_mongo_database.mongodb.name + shard_key = "_id" + + index { + keys = ["_id"] + unique = true + } +} \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf new file mode 100644 index 00000000000..c5457f16dbf --- /dev/null +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf @@ -0,0 +1,53 @@ +# ------------------------------------------------------------------------------------------------------ +# DEPLOY AZURE KEYVAULT +# ------------------------------------------------------------------------------------------------------ +resource "azurecaf_name" "kv_name" { + name = random_string.resource_token.result + resource_type = "azurerm_key_vault" + random_length = 0 + clean_input = true +} + +resource "azurerm_key_vault" "kv" { + name = azurecaf_name.kv_name.result + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + tenant_id = data.azurerm_client_config.current.tenant_id + purge_protection_enabled = false + sku_name = "standard" + + tags = local.tags +} + +resource "azurerm_key_vault_access_policy" "app" { + key_vault_id = azurerm_key_vault.kv.id + tenant_id = data.azurerm_client_config.current.tenant_id + object_id = azurerm_linux_web_app.api.identity.0.principal_id + + secret_permissions = [ + "Get", + "Set", + "List", + "Delete", + ] +} + +resource "azurerm_key_vault_access_policy" "user" { + count = var.principalId == "" ? 0 : 1 + key_vault_id = azurerm_key_vault.kv.id + tenant_id = data.azurerm_client_config.current.tenant_id + object_id = var.principalId + + secret_permissions = [ + "Get", + "Set", + "List", + "Delete", + ] +} + +resource "azurerm_key_vault_secret" "dbconnection" { + name = "AZURE-COSMOS-CONNECTION-STRING" + value = azurerm_cosmosdb_account.db.connection_strings[0] + key_vault_id = azurerm_key_vault.kv.id +} \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/loganalytics.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/loganalytics.tf new file mode 100644 index 00000000000..dedb1f01410 --- /dev/null +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/loganalytics.tf @@ -0,0 +1,18 @@ +# ------------------------------------------------------------------------------------------------------ +# Deploy log analytics workspace +# ------------------------------------------------------------------------------------------------------ +resource "azurecaf_name" "workspace_name" { + name = random_string.resource_token.result + resource_type = "azurerm_log_analytics_workspace" + random_length = 0 + clean_input = true +} + +resource "azurerm_log_analytics_workspace" "workspace" { + name = azurecaf_name.workspace_name.result + location = azurerm_resource_group.rg.location + resource_group_name = azurerm_resource_group.rg.name + sku = "PerGB2018" + retention_in_days = 30 + tags = local.tags +} diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf index 3bbf0a6571f..a9b624fbe19 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf @@ -26,6 +26,9 @@ resource "random_string" "resource_token" { special = false } +# ------------------------------------------------------------------------------------------------------ +# Deploy application insights +# ------------------------------------------------------------------------------------------------------ module "applicationinsights" { source = "../../../../../../common/infra/terraform" location = var.location @@ -34,276 +37,4 @@ module "applicationinsights" { workspace_id = azurerm_log_analytics_workspace.workspace.id tags = azurerm_resource_group.rg.tags resource_token = random_string.resource_token.result - -} - -# ------------------------------------------------------------------------------------------------------ -# DEPLOY AZURE KEYVAULT -# ------------------------------------------------------------------------------------------------------ - -resource "azurecaf_name" "kv_name" { - name = random_string.resource_token.result - resource_type = "azurerm_key_vault" - random_length = 0 - clean_input = true } - -resource "azurerm_key_vault" "kv" { - name = azurecaf_name.kv_name.result - location = azurerm_resource_group.rg.location - resource_group_name = azurerm_resource_group.rg.name - tenant_id = data.azurerm_client_config.current.tenant_id - purge_protection_enabled = false - sku_name = "standard" - - tags = local.tags -} - -resource "azurerm_key_vault_access_policy" "app" { - key_vault_id = azurerm_key_vault.kv.id - tenant_id = data.azurerm_client_config.current.tenant_id - object_id = azurerm_linux_web_app.api.identity.0.principal_id - - secret_permissions = [ - "Get", - "Set", - "List", - "Delete", - ] -} - -resource "azurerm_key_vault_access_policy" "user" { - count = var.principalId == "" ? 0 : 1 - key_vault_id = azurerm_key_vault.kv.id - tenant_id = data.azurerm_client_config.current.tenant_id - object_id = var.principalId - - secret_permissions = [ - "Get", - "Set", - "List", - "Delete", - - ] -} - -resource "azurerm_key_vault_secret" "dbconnection" { - name = "AZURE-COSMOS-CONNECTION-STRING" - value = azurerm_cosmosdb_account.db.connection_strings[0] - key_vault_id = azurerm_key_vault.kv.id - -} -# ------------------------------------------------------------------------------------------------------ -# Deploy app service plan -# ------------------------------------------------------------------------------------------------------ -resource "azurecaf_name" "plan_name" { - name = random_string.resource_token.result - resource_type = "azurerm_app_service_plan" - random_length = 0 - clean_input = true -} -resource "azurerm_service_plan" "plan" { - name = azurecaf_name.plan_name.result - location = azurerm_resource_group.rg.location - resource_group_name = azurerm_resource_group.rg.name - os_type = "Linux" - sku_name = "B1" - - tags = local.tags -} - -# ------------------------------------------------------------------------------------------------------ -# Deploy app service web app -# ------------------------------------------------------------------------------------------------------ -resource "azurecaf_name" "web_name" { - name = "web-${random_string.resource_token.result}" - resource_type = "azurerm_app_service" - random_length = 0 - clean_input = true -} -resource "azurerm_linux_web_app" "web" { - name = azurecaf_name.web_name.result - location = azurerm_resource_group.rg.location - resource_group_name = azurerm_resource_group.rg.name - service_plan_id = azurerm_service_plan.plan.id - https_only = true - tags = merge(local.tags, { azd-service-name : "web" }) - - site_config { - always_on = true - ftps_state = "FtpsOnly" - app_command_line = "pm2 serve /home/site/wwwroot --no-daemon --spa" - application_stack { - node_version = "16-lts" - } - } - - app_settings = { - "SCM_DO_BUILD_DURING_DEPLOYMENT" = "false" - "APPLICATIONINSIGHTS_CONNECTION_STRING" = module.applicationinsights.APPLICATIONINSIGHTS_CONNECTION_STRING - } - - logs { - application_logs { - file_system_level = "Verbose" - } - detailed_error_messages = true - failed_request_tracing = true - http_logs { - file_system { - retention_in_days = 1 - retention_in_mb = 35 - } - } - } - -} - -# ------------------------------------------------------------------------------------------------------ -# Deploy app service api -# ------------------------------------------------------------------------------------------------------ -resource "azurecaf_name" "appi_name" { - name = "api-${random_string.resource_token.result}" - resource_type = "azurerm_app_service" - random_length = 0 - clean_input = true -} - - -resource "azurerm_linux_web_app" "api" { - name = azurecaf_name.appi_name.result - location = azurerm_resource_group.rg.location - resource_group_name = azurerm_resource_group.rg.name - service_plan_id = azurerm_service_plan.plan.id - https_only = true - tags = merge(local.tags, { "azd-service-name" : "api" }) - - site_config { - always_on = true - ftps_state = "FtpsOnly" - app_command_line = local.api_command_line - application_stack { - python_version = "3.8" - } - } - - identity { - type = "SystemAssigned" - } - - app_settings = { - "AZURE_COSMOS_CONNECTION_STRING_KEY" = "AZURE-COSMOS-CONNECTION-STRING" - "AZURE_COSMOS_DATABASE_NAME" = azurerm_cosmosdb_mongo_database.mongodb.name - "SCM_DO_BUILD_DURING_DEPLOYMENT" = "true" - "AZURE_KEY_VAULT_ENDPOINT" = azurerm_key_vault.kv.vault_uri - "APPLICATIONINSIGHTS_CONNECTION_STRING" = module.applicationinsights.APPLICATIONINSIGHTS_CONNECTION_STRING - } - logs { - application_logs { - file_system_level = "Verbose" - } - detailed_error_messages = true - failed_request_tracing = true - http_logs { - file_system { - retention_in_days = 1 - retention_in_mb = 35 - } - } - } -} - -# ------------------------------------------------------------------------------------------------------ -# Deploy log analytics workspace -# ------------------------------------------------------------------------------------------------------ -resource "azurecaf_name" "workspace_name" { - name = random_string.resource_token.result - resource_type = "azurerm_log_analytics_workspace" - random_length = 0 - clean_input = true -} - -resource "azurerm_log_analytics_workspace" "workspace" { - name = azurecaf_name.workspace_name.result - location = azurerm_resource_group.rg.location - resource_group_name = azurerm_resource_group.rg.name - sku = "PerGB2018" - retention_in_days = 30 - tags = local.tags -} - -# ------------------------------------------------------------------------------------------------------ -# Deploy cosmos db account -# ------------------------------------------------------------------------------------------------------ -resource "azurecaf_name" "db_acc_name" { - name = random_string.resource_token.result - resource_type = "azurerm_cosmosdb_account" - random_length = 0 - clean_input = true -} - -resource "azurerm_cosmosdb_account" "db" { - name = azurecaf_name.db_acc_name.result - location = azurerm_resource_group.rg.location - resource_group_name = azurerm_resource_group.rg.name - offer_type = "Standard" - kind = "MongoDB" - enable_automatic_failover = false - enable_multiple_write_locations = false - mongo_server_version = "4.0" - - tags = local.tags - - - capabilities { - name = "EnableServerless" - } - - consistency_policy { - consistency_level = "Session" - } - - geo_location { - location = azurerm_resource_group.rg.location - failover_priority = 0 - zone_redundant = false - } - -} - -# ------------------------------------------------------------------------------------------------------ -# Deploy cosmos mongo db and collections -# ------------------------------------------------------------------------------------------------------ -resource "azurerm_cosmosdb_mongo_database" "mongodb" { - name = "Todo" - resource_group_name = azurerm_cosmosdb_account.db.resource_group_name - account_name = azurerm_cosmosdb_account.db.name -} - -resource "azurerm_cosmosdb_mongo_collection" "todolist" { - name = "TodoList" - resource_group_name = azurerm_cosmosdb_account.db.resource_group_name - account_name = azurerm_cosmosdb_account.db.name - database_name = azurerm_cosmosdb_mongo_database.mongodb.name - shard_key = "_id" - - - index { - keys = ["_id"] - unique = true - } -} - -resource "azurerm_cosmosdb_mongo_collection" "todocollection" { - name = "TodoItem" - resource_group_name = azurerm_cosmosdb_account.db.resource_group_name - account_name = azurerm_cosmosdb_account.db.name - database_name = azurerm_cosmosdb_mongo_database.mongodb.name - shard_key = "_id" - - - index { - keys = ["_id"] - unique = true - } -} \ No newline at end of file From 17dc803b0b99c5464f402986f49077e241c8ab64 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Mon, 29 Aug 2022 01:01:53 -0700 Subject: [PATCH 26/30] resolve cspell --- .vscode/cspell.global.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.vscode/cspell.global.yaml b/.vscode/cspell.global.yaml index db84a856f8e..2efbd6b6137 100644 --- a/.vscode/cspell.global.yaml +++ b/.vscode/cspell.global.yaml @@ -72,6 +72,7 @@ ignoreWords: - devcontainer - azurecaf - azurerm + - aztfmod - menuid useGitignore: true dictionaryDefinitions: From 65bee8b1ca843094f55d52ad94fa8481c3e1fe2c Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Mon, 29 Aug 2022 15:45:24 -0700 Subject: [PATCH 27/30] address review comments --- .gitignore | 1 - .../.repo/terraform/infra/{database.tf => cosmos.tf} | 0 .../projects/python-mongo/.repo/terraform/infra/keyvault.tf | 4 ++-- .../todo/projects/python-mongo/.repo/terraform/infra/main.tf | 1 + .../projects/python-mongo/.repo/terraform/infra/variables.tf | 2 +- 5 files changed, 4 insertions(+), 4 deletions(-) rename templates/todo/projects/python-mongo/.repo/terraform/infra/{database.tf => cosmos.tf} (100%) diff --git a/.gitignore b/.gitignore index 33a3a045e34..7c57e3e4f06 100644 --- a/.gitignore +++ b/.gitignore @@ -36,7 +36,6 @@ obj/ bin/ node_modules/ test-results/ -playwright-report/ # terraform .tfstate files **/.terraform diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/database.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/cosmos.tf similarity index 100% rename from templates/todo/projects/python-mongo/.repo/terraform/infra/database.tf rename to templates/todo/projects/python-mongo/.repo/terraform/infra/cosmos.tf diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf index c5457f16dbf..1cea32beedc 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/keyvault.tf @@ -33,10 +33,10 @@ resource "azurerm_key_vault_access_policy" "app" { } resource "azurerm_key_vault_access_policy" "user" { - count = var.principalId == "" ? 0 : 1 + count = var.principal_id == "" ? 0 : 1 key_vault_id = azurerm_key_vault.kv.id tenant_id = data.azurerm_client_config.current.tenant_id - object_id = var.principalId + object_id = var.principal_id secret_permissions = [ "Get", diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf index a9b624fbe19..79cc919ff8f 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf @@ -11,6 +11,7 @@ resource "azurecaf_name" "rg_name" { random_length = 0 clean_input = true } + resource "azurerm_resource_group" "rg" { name = azurecaf_name.rg_name.result location = var.location diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf index 2aff1c8509d..dc79a47fa05 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf @@ -8,7 +8,7 @@ variable "name" { type = string } -variable "principalId" { +variable "principal_id" { description = "The Id of the azd service principal to add to deployed keyvault access policies" type = string default = "" From b9691cd6437cbcc4d3b0785ee4d9dcaa351767e3 Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Thu, 1 Sep 2022 13:20:07 -0700 Subject: [PATCH 28/30] add tfvars.json --- .../python-mongo/.repo/terraform/infra/main.tfvars.json | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 templates/todo/projects/python-mongo/.repo/terraform/infra/main.tfvars.json diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tfvars.json b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tfvars.json new file mode 100644 index 00000000000..dcd46ce57fa --- /dev/null +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tfvars.json @@ -0,0 +1,5 @@ +{ + "location": "${AZURE_LOCATION}", + "name": "${AZURE_ENV_NAME}", + "principal_id": "${AZURE_PRINCIPAL_ID}" +} \ No newline at end of file From 3cccab7cedc98361b1b4f6ab01594a11d51134cd Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Thu, 1 Sep 2022 16:40:03 -0700 Subject: [PATCH 29/30] add rewrite path rules --- .../applicationinsights.tf | 0 .../applicationinsights_output.tf | 0 .../applicationinsights_variables.tf | 0 .../.repo/terraform/infra/main.tf | 2 +- .../python-mongo/.repo/terraform/repo.yaml | 42 ++++++++----------- 5 files changed, 19 insertions(+), 25 deletions(-) rename templates/common/infra/terraform/{ => applicationinsights}/applicationinsights.tf (100%) rename templates/common/infra/terraform/{ => applicationinsights}/applicationinsights_output.tf (100%) rename templates/common/infra/terraform/{ => applicationinsights}/applicationinsights_variables.tf (100%) diff --git a/templates/common/infra/terraform/applicationinsights.tf b/templates/common/infra/terraform/applicationinsights/applicationinsights.tf similarity index 100% rename from templates/common/infra/terraform/applicationinsights.tf rename to templates/common/infra/terraform/applicationinsights/applicationinsights.tf diff --git a/templates/common/infra/terraform/applicationinsights_output.tf b/templates/common/infra/terraform/applicationinsights/applicationinsights_output.tf similarity index 100% rename from templates/common/infra/terraform/applicationinsights_output.tf rename to templates/common/infra/terraform/applicationinsights/applicationinsights_output.tf diff --git a/templates/common/infra/terraform/applicationinsights_variables.tf b/templates/common/infra/terraform/applicationinsights/applicationinsights_variables.tf similarity index 100% rename from templates/common/infra/terraform/applicationinsights_variables.tf rename to templates/common/infra/terraform/applicationinsights/applicationinsights_variables.tf diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf index 79cc919ff8f..2f7c44759d1 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf @@ -31,7 +31,7 @@ resource "random_string" "resource_token" { # Deploy application insights # ------------------------------------------------------------------------------------------------------ module "applicationinsights" { - source = "../../../../../../common/infra/terraform" + source = "../../../../../../common/infra/terraform/applicationinsights" location = var.location rg_name = azurerm_resource_group.rg.name env_name = var.name diff --git a/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml b/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml index 534003f3204..03d2fbc285c 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml +++ b/templates/todo/projects/python-mongo/.repo/terraform/repo.yaml @@ -15,30 +15,24 @@ repo: branch: staging rewrite: - patterns: - - "**/azure.@(yml|yaml)" - - "**/*.tf" + rules: + - from: ../../../../../../common/infra/terraform/applicationinsights + to: ./modules/applicationinsights + patterns: + - "**/*.tf" - assets: - # Common assets - - # Rules for Path Rewrite Only - - from: ../../../../../../common/infra/terraform - to: ./modules - ignore: - - ".repo/**/*" + - from: ../../api/python + to: ./src/api + patterns: + - "**/azure.@(yml|yaml)" - - from: ../../api/python - to: ./src/api - ignore: - - ".repo/**/*" - - - from: ../../web/react-fluent - to: ./src/web - ignore: - - ".repo/**/*" - # End Path Rewrite Rules - + - from: ../../web/react-fluent + to: ./src/web + patterns: + - "**/azure.@(yml|yaml)" + + assets: + # Common assets - from: ./../../ to: ./ ignore: @@ -64,8 +58,8 @@ repo: ignore: - "infra/**/*" - - from: ../../../../../common/infra/terraform - to: ./infra/modules + - from: ../../../../../common/infra/terraform/applicationinsights + to: ./infra/modules/applicationinsights # Assets common - from: ../../../../common/assets From bd804fbdb7ac39d46b28843d15351da0abdc5a9a Mon Sep 17 00:00:00 2001 From: Hadwa Gaber Date: Thu, 1 Sep 2022 18:25:12 -0700 Subject: [PATCH 30/30] rename to environment_name --- .../applicationinsights_variables.tf | 2 +- .../python-mongo/.repo/terraform/infra/main.tf | 18 +++++++++--------- .../.repo/terraform/infra/main.tfvars.json | 2 +- .../.repo/terraform/infra/variables.tf | 2 +- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/templates/common/infra/terraform/applicationinsights/applicationinsights_variables.tf b/templates/common/infra/terraform/applicationinsights/applicationinsights_variables.tf index 58ebd425c24..7db057e1f7d 100644 --- a/templates/common/infra/terraform/applicationinsights/applicationinsights_variables.tf +++ b/templates/common/infra/terraform/applicationinsights/applicationinsights_variables.tf @@ -8,7 +8,7 @@ variable "rg_name" { type = string } -variable "env_name" { +variable "environment_name" { description = "The name of the environment to be deployed" type = string } diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf index 2f7c44759d1..e52cf248ba6 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tf @@ -1,12 +1,12 @@ locals { - tags = { azd-env-name : var.name } + tags = { azd-env-name : var.environment_name } api_command_line = "gunicorn --workers 4 --threads 2 --timeout 60 --access-logfile \"-\" --error-logfile \"-\" --bind=0.0.0.0:8000 -k uvicorn.workers.UvicornWorker todo.app:app" } # ------------------------------------------------------------------------------------------------------ # Deploy resource Group # ------------------------------------------------------------------------------------------------------ resource "azurecaf_name" "rg_name" { - name = var.name + name = var.environment_name resource_type = "azurerm_resource_group" random_length = 0 clean_input = true @@ -31,11 +31,11 @@ resource "random_string" "resource_token" { # Deploy application insights # ------------------------------------------------------------------------------------------------------ module "applicationinsights" { - source = "../../../../../../common/infra/terraform/applicationinsights" - location = var.location - rg_name = azurerm_resource_group.rg.name - env_name = var.name - workspace_id = azurerm_log_analytics_workspace.workspace.id - tags = azurerm_resource_group.rg.tags - resource_token = random_string.resource_token.result + source = "../../../../../../common/infra/terraform/applicationinsights" + location = var.location + rg_name = azurerm_resource_group.rg.name + environment_name = var.environment_name + workspace_id = azurerm_log_analytics_workspace.workspace.id + tags = azurerm_resource_group.rg.tags + resource_token = random_string.resource_token.result } diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tfvars.json b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tfvars.json index dcd46ce57fa..d088e4274c6 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tfvars.json +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/main.tfvars.json @@ -1,5 +1,5 @@ { "location": "${AZURE_LOCATION}", - "name": "${AZURE_ENV_NAME}", + "environment_name": "${AZURE_ENV_NAME}", "principal_id": "${AZURE_PRINCIPAL_ID}" } \ No newline at end of file diff --git a/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf b/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf index dc79a47fa05..725d8a79ad3 100644 --- a/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf +++ b/templates/todo/projects/python-mongo/.repo/terraform/infra/variables.tf @@ -3,7 +3,7 @@ variable "location" { type = string } -variable "name" { +variable "environment_name" { description = "The name of the azd environment to be deployed" type = string }