Skip to content

Commit

Permalink
add basic app service plan option (#1507)
Browse files Browse the repository at this point in the history
* add basic app service plan option

* add basic app service plan option

* add basic app service plan option

* fix terraform names

* add environment variable to action
  • Loading branch information
gonzalogarciajaubert authored Jan 25, 2024
1 parent c2b6efa commit e4e46ed
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 13 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/re_test-integration-azure.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: Azure Integration Tests

env:
BOOSTER_AZURE_SERVICE_PLAN_BASIC: 'true'

on:
workflow_call:
inputs:
Expand Down
21 changes: 13 additions & 8 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
2 changes: 2 additions & 0 deletions website/docs/10_going-deeper/data-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,5 @@ export interface FunctionAppFunctionsDefinition<T extends Binding = Binding> {
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.

0 comments on commit e4e46ed

Please sign in to comment.