Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Azure SKU Gateway and RUs environment variables #1523

Merged
merged 2 commits into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@boostercloud/framework-core",
"comment": "Add Azure sku gateway and rus environment variables",
"type": "minor"
}
],
"packageName": "@boostercloud/framework-core"
}
233 changes: 146 additions & 87 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
export const MAX_CONTAINER_THROUGHPUT = parseInt(process.env.AZURE_MAX_CONTAINER_THROUGHPUT ?? '400', 10)
export const MAX_DATABASE_THROUGHPUT = parseInt(process.env.AZURE_MAX_DATABASE_THROUGHPUT ?? '400', 10)
const DEFAULT_MAX_THROUGHPUT = '1000'
export const MAX_CONTAINER_THROUGHPUT = parseInt(process.env.AZURE_MAX_CONTAINER_THROUGHPUT ?? DEFAULT_MAX_THROUGHPUT, 10)
export const MAX_DATABASE_THROUGHPUT = parseInt(process.env.AZURE_MAX_DATABASE_THROUGHPUT ?? DEFAULT_MAX_THROUGHPUT, 10)

export const BASIC_SERVICE_PLAN = process.env.BOOSTER_AZURE_SERVICE_PLAN_BASIC ?? 'false'
export const USE_WAF = process.env.BOOSTER_USE_WAF ?? 'false'
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { TerraformPublicIp } from './gateway/terraform-public-ip'
import { TerraformPublicIpData } from './gateway/terraform-public-ip-data'
import { TerraformSubnet } from './gateway/terraform-subnet'
import { TerraformSubnetSecurity } from './gateway/terraform-subnet-security'
import { BASIC_SERVICE_PLAN } from '../constants'

export class ApplicationSynth {
readonly config: BoosterConfig
Expand Down Expand Up @@ -91,8 +92,7 @@ export class ApplicationSynth {
stack.containers = TerraformContainers.build(stack, this.config)
this.buildEventHub(stack)
this.buildWebPubSub(stack)
const basicServicePlan = process.env.BOOSTER_AZURE_SERVICE_PLAN_BASIC ?? 'false'
if (basicServicePlan === 'true') {
if (BASIC_SERVICE_PLAN === 'true') {
stack.applicationServicePlan = TerraformServicePlan.build(
stack,
'psp',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { applicationGateway } from '@cdktf/provider-azurerm'
import { ApplicationSynthStack } from '../../types/application-synth-stack'
import { USE_WAF } from '../../constants'
import { ApplicationGatewayConfig } from '@cdktf/provider-azurerm/lib/application-gateway'

const STANDARD_V2 = 'Standard_v2'
const WAF_V2 = 'WAF_v2'

export class TerraformApplicationGateway {
static build({
Expand All @@ -22,21 +27,17 @@ export class TerraformApplicationGateway {
if (!publicIP) {
throw new Error('Undefined publicIP resource')
}
return new applicationGateway.ApplicationGateway(terraformStack, 'ag', {
const skuType = USE_WAF === 'true' ? WAF_V2 : STANDARD_V2
const gatewayConfiguration: Exclude<ApplicationGatewayConfig, 'wafConfiguration'> = {
name: `${resourceGroupName}apigw`,
location: resourceGroup.location,
resourceGroupName: resourceGroupName,
provider: azureProvider,
sku: {
name: 'WAF_v2',
tier: 'WAF_v2',
name: skuType,
tier: skuType,
capacity: 1,
},
wafConfiguration: {
enabled: true,
firewallMode: 'Detection',
ruleSetVersion: '3.0',
},
gatewayIpConfiguration: [
{
name: 'myGatewayIpConfiguration',
Expand Down Expand Up @@ -150,6 +151,18 @@ export class TerraformApplicationGateway {
rewriteRuleSetName: 'mainRewriteRuleSet',
},
],
})
}
if (USE_WAF === 'true') {
return new applicationGateway.ApplicationGateway(terraformStack, 'ag', {
...gatewayConfiguration,
wafConfiguration: {
enabled: true,
firewallMode: 'Detection',
ruleSetVersion: '3.0',
},
})
}

return new applicationGateway.ApplicationGateway(terraformStack, 'ag', gatewayConfiguration)
}
}
6 changes: 5 additions & 1 deletion website/docs/10_going-deeper/data-migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,8 @@ export interface FunctionAppFunctionsDefinition<T extends Binding = Binding> {
}
```

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.
Booster 2.3.0 allows you to set the Azure App Service Plan used to deploy the main function app. Setting the `BOOSTER_AZURE_SERVICE_PLAN_BASIC` (default value false) environment variable to true will force the use of a basic service plan instead of the default consumption plan.

## Migrate to Booster version 2.6.0

Booster 2.6.0 allows you to set the Azure Application Gateway SKU used. Setting the `BOOSTER_USE_WAF` (default value false) environment variable to true will force the use of a WAF sku instead of the Standard sku.
4 changes: 2 additions & 2 deletions website/docs/10_going-deeper/infrastructure-providers.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ After the service principal is created, create a bash script with the following

SP_DISPLAY_NAME="<service-principal-name>" #replace <service-principal-name> with the name of your own SP
REGION="East US" #replace with a region of your choice, see full list here: https://azure.microsoft.com/en-us/global-infrastructure/locations/
AZURE_MAX_CONTAINER_THROUGHPUT=400 #replace with a desired value for CosmosDB container throughput
AZURE_MAX_DATABASE_THROUGHPUT=400 #replace with a desired value for CosmosDB database throughput
AZURE_MAX_CONTAINER_THROUGHPUT=1000 #replace with a desired value for CosmosDB container throughput
AZURE_MAX_DATABASE_THROUGHPUT=1000 #replace with a desired value for CosmosDB database throughput

export AZURE_APP_ID=$(az ad sp list --display-name ${SP_DISPLAY_NAME} | jq -r '.[].appId')
export AZURE_TENANT_ID=$(az ad sp list --display-name ${SP_DISPLAY_NAME} | jq -r '.[].appOwnerOrganizationId')
Expand Down
Loading