diff --git a/.github/workflows/re_test-integration-azure.yml b/.github/workflows/re_test-integration-azure.yml index 0a25ef7e0..5e0c4c3f3 100644 --- a/.github/workflows/re_test-integration-azure.yml +++ b/.github/workflows/re_test-integration-azure.yml @@ -1,5 +1,8 @@ name: Azure Integration Tests +env: + BOOSTER_AZURE_SERVICE_PLAN_BASIC: 'true' + on: workflow_call: inputs: diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index 08749f19d..32ca48475 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -391,6 +391,7 @@ importers: eslint-plugin-import: ^2.26.0 eslint-plugin-prettier: 3.4.0 eslint-plugin-unicorn: ~44.0.2 + express: ^4.17.1 express-unless: 2.1.3 faker: 5.1.0 graphology-types: ^0.24.0 @@ -423,6 +424,7 @@ importers: '@boostercloud/framework-types': link:../framework-types '@effect-ts/core': 0.60.5 aws-sdk: 2.853.0 + express: 4.18.2 express-unless: 2.1.3 graphql: 16.8.1 tslib: 2.6.2 @@ -1596,7 +1598,7 @@ packages: '@aws-cdk/aws-codecommit': 1.204.0_scjupxxta56mdpzkdveav52ufq '@aws-cdk/aws-codestarnotifications': 1.204.0_add7c2jq5lcc6idtuigbkwnzeu '@aws-cdk/aws-ec2': 1.204.0_r4d2a6r7lnkv26zjzkdsvuam2a - '@aws-cdk/aws-ecr': 1.204.0_4bnk2gpayjo75fecjckge2dkni + '@aws-cdk/aws-ecr': 1.204.0_bi2u42js5xhxqcsg5gqefde4xi '@aws-cdk/aws-ecr-assets': 1.204.0_scjupxxta56mdpzkdveav52ufq '@aws-cdk/aws-events': 1.204.0_w2xl3dexbzdynnzeafah4cuzfm '@aws-cdk/aws-iam': 1.204.0_add7c2jq5lcc6idtuigbkwnzeu @@ -1811,7 +1813,7 @@ packages: constructs: ^3.3.69 dependencies: '@aws-cdk/assets': 1.204.0_uszt2j4mor3yrbm3tre3az4zvy - '@aws-cdk/aws-ecr': 1.204.0_4bnk2gpayjo75fecjckge2dkni + '@aws-cdk/aws-ecr': 1.204.0_bi2u42js5xhxqcsg5gqefde4xi '@aws-cdk/aws-iam': 1.204.0_add7c2jq5lcc6idtuigbkwnzeu '@aws-cdk/aws-s3': 1.204.0_bi2u42js5xhxqcsg5gqefde4xi '@aws-cdk/core': 1.204.0_hol6usdabdbzhugfw355k4ebam @@ -1821,7 +1823,7 @@ packages: - '@aws-cdk/aws-events' dev: false - /@aws-cdk/aws-ecr/1.204.0_4bnk2gpayjo75fecjckge2dkni: + /@aws-cdk/aws-ecr/1.204.0_bi2u42js5xhxqcsg5gqefde4xi: resolution: {integrity: sha512-oCts9e+ackWoFHeyn/3oKm3X1lSizleWNNXHp5WGM38lpNVrtCLMKSShu5iXJBhqRH2Mz1AcA4fDMWhe8DvJFA==} engines: {node: '>= 14.15.0'} deprecated: |- @@ -1837,8 +1839,11 @@ packages: dependencies: '@aws-cdk/aws-events': 1.204.0_w2xl3dexbzdynnzeafah4cuzfm '@aws-cdk/aws-iam': 1.204.0_add7c2jq5lcc6idtuigbkwnzeu + '@aws-cdk/aws-kms': 1.204.0_cttdkzy7hngahjug7jmkfylr2y '@aws-cdk/core': 1.204.0_hol6usdabdbzhugfw355k4ebam constructs: 3.4.344 + transitivePeerDependencies: + - '@aws-cdk/cx-api' dev: false /@aws-cdk/aws-ecs/1.204.0_iu2vquo67t63xu6vdymsg3ufny: @@ -1864,7 +1869,7 @@ packages: '@aws-cdk/aws-certificatemanager': 1.204.0_xtqk4litqxecxsqs3sd6ajo2ja '@aws-cdk/aws-cloudwatch': 1.204.0_w2xl3dexbzdynnzeafah4cuzfm '@aws-cdk/aws-ec2': 1.204.0_r4d2a6r7lnkv26zjzkdsvuam2a - '@aws-cdk/aws-ecr': 1.204.0_4bnk2gpayjo75fecjckge2dkni + '@aws-cdk/aws-ecr': 1.204.0_bi2u42js5xhxqcsg5gqefde4xi '@aws-cdk/aws-ecr-assets': 1.204.0_scjupxxta56mdpzkdveav52ufq '@aws-cdk/aws-elasticloadbalancing': 1.204.0_s2iwowsvskkmujjbrmx4g5hlsi '@aws-cdk/aws-elasticloadbalancingv2': 1.204.0_xbmlyikxd4zabyotfrt4oo4gli @@ -2210,7 +2215,7 @@ packages: '@aws-cdk/aws-cloudwatch': 1.204.0_w2xl3dexbzdynnzeafah4cuzfm '@aws-cdk/aws-codeguruprofiler': 1.204.0_w2xl3dexbzdynnzeafah4cuzfm '@aws-cdk/aws-ec2': 1.204.0_r4d2a6r7lnkv26zjzkdsvuam2a - '@aws-cdk/aws-ecr': 1.204.0_4bnk2gpayjo75fecjckge2dkni + '@aws-cdk/aws-ecr': 1.204.0_bi2u42js5xhxqcsg5gqefde4xi '@aws-cdk/aws-ecr-assets': 1.204.0_scjupxxta56mdpzkdveav52ufq '@aws-cdk/aws-efs': 1.204.0_r4d2a6r7lnkv26zjzkdsvuam2a '@aws-cdk/aws-events': 1.204.0_w2xl3dexbzdynnzeafah4cuzfm @@ -5958,7 +5963,7 @@ packages: dependencies: semver: 7.5.4 shelljs: 0.8.5 - typescript: 5.4.0-dev.20231220 + typescript: 5.4.0-dev.20240125 /duration/0.2.2: resolution: {integrity: sha512-06kgtea+bGreF5eKYgI/36A6pLXggY7oR4p1pq4SmdFBn1ReOL5D8RhG64VrqfTTKNucqqtBAwEj8aB88mcqrg==} @@ -10998,8 +11003,8 @@ packages: engines: {node: '>=14.17'} hasBin: true - /typescript/5.4.0-dev.20231220: - resolution: {integrity: sha512-gO+86xJ5TnxXTrU2jXZewS9x95rKXCGpDuYUmdKC8rVfEchLrcH2LASQUXguQ2yinln8lrCttDZfO4d6gpuE4g==} + /typescript/5.4.0-dev.20240125: + resolution: {integrity: sha512-/3h02nH68UOVG1hUqdAKxwHtV9JcTrxiODJCzWqJEkFmKWdVDnZ1NuGWl0KsgpXgdC4bYbEf5fIe3Or6lg91tA==} engines: {node: '>=14.17'} hasBin: true diff --git a/packages/framework-provider-azure-infrastructure/src/infrastructure/helper/utils.ts b/packages/framework-provider-azure-infrastructure/src/infrastructure/helper/utils.ts index 50be4a0c5..b8ad16c4d 100644 --- a/packages/framework-provider-azure-infrastructure/src/infrastructure/helper/utils.ts +++ b/packages/framework-provider-azure-infrastructure/src/infrastructure/helper/utils.ts @@ -32,16 +32,21 @@ export function toTerraformName(name: string, suffix = ''): string { const cleanName = terraformCleanText(name) const totalLength = cleanName.length + cleanSuffix.length if (totalLength <= MAX_TERRAFORM_SIZE_NAME) { - return cleanName + cleanSuffix + return startsWithLetter(cleanName + cleanSuffix) } if (cleanName.length <= cleanSuffix.length) { - return (cleanName + cleanSuffix).substr(0, MAX_TERRAFORM_SIZE_NAME - 1) + const newName = (cleanName + cleanSuffix).substr(0, MAX_TERRAFORM_SIZE_NAME - 1) + return startsWithLetter(newName) } const extraLength = totalLength - MAX_TERRAFORM_SIZE_NAME const fixedCleanName = cleanName.substr(extraLength) - return fixedCleanName + cleanSuffix + return startsWithLetter(fixedCleanName + cleanSuffix) +} + +function startsWithLetter(text: string): string { + return text.match(/^\d/) ? 'B' + text.substring(1) : text } export function toAzureName(name: string, maxSize = 24): string { diff --git a/packages/framework-provider-azure-infrastructure/src/infrastructure/synth/application-synth.ts b/packages/framework-provider-azure-infrastructure/src/infrastructure/synth/application-synth.ts index fad8b3eaf..d7fddbdb3 100644 --- a/packages/framework-provider-azure-infrastructure/src/infrastructure/synth/application-synth.ts +++ b/packages/framework-provider-azure-infrastructure/src/infrastructure/synth/application-synth.ts @@ -35,6 +35,16 @@ export class ApplicationSynth { readonly config: BoosterConfig readonly stackNames: StackNames + readonly CONSUMPTION_PLAN = { + skuName: 'Y1', + workerCount: 1, + } + + readonly BASIC_PLAN = { + skuName: 'B1', + workerCount: 2, + } + public constructor(terraformStack: TerraformStack) { this.config = readProjectConfig(process.cwd()) const azurermProvider = new AzurermProvider(terraformStack, 'azureFeature', { @@ -77,7 +87,22 @@ export class ApplicationSynth { stack.containers = TerraformContainers.build(stack, this.config) this.buildEventHub(stack) this.buildWebPubSub(stack) - stack.applicationServicePlan = TerraformServicePlan.build(stack, 'psp', 'Y1', 1) + const basicServicePlan = process.env.BOOSTER_AZURE_SERVICE_PLAN_BASIC ?? 'false' + if (basicServicePlan === 'true') { + stack.applicationServicePlan = TerraformServicePlan.build( + stack, + 'psp', + this.BASIC_PLAN.skuName, + this.BASIC_PLAN.workerCount + ) + } else { + stack.applicationServicePlan = TerraformServicePlan.build( + stack, + 'psp', + this.CONSUMPTION_PLAN.skuName, + this.CONSUMPTION_PLAN.workerCount + ) + } stack.storageAccount = TerraformStorageAccount.build(stack, 'sp') stack.functionApp = this.buildDefaultFunctionApp(stack, zipFile) this.buildWebPubSubHub(stack) diff --git a/packages/framework-provider-azure-infrastructure/test/infrastructure/helper/utils.test.ts b/packages/framework-provider-azure-infrastructure/test/infrastructure/helper/utils.test.ts index 874636d32..fd3d19524 100644 --- a/packages/framework-provider-azure-infrastructure/test/infrastructure/helper/utils.test.ts +++ b/packages/framework-provider-azure-infrastructure/test/infrastructure/helper/utils.test.ts @@ -17,7 +17,7 @@ describe('Users want to use utility methods', () => { it('with a long name and suffix return last name characters and the whole suffix', () => { const result = toTerraformName('0123456789012345678901234', 'suffix') - expect(result).to.be.equal('789012345678901234suffix') + expect(result).to.be.equal('B89012345678901234suffix') }) it('with a name and a 24 characters suffix return name and first suffix characters', () => { diff --git a/website/docs/10_going-deeper/data-migrations.md b/website/docs/10_going-deeper/data-migrations.md index 475e0da76..71946230f 100644 --- a/website/docs/10_going-deeper/data-migrations.md +++ b/website/docs/10_going-deeper/data-migrations.md @@ -210,3 +210,5 @@ export interface FunctionAppFunctionsDefinition { hostJsonPath?: string } ``` + +Booster 2.3.0 allows you to set the app service plan used to deploy the main function app. Setting the `BOOSTER_AZURE_SERVICE_PLAN_BASIC` environment variable to true will force the use of a basic service plan instead of the default consumption plan.