Skip to content

Commit

Permalink
Refactor main.bicep: Update default values for acrName and location p…
Browse files Browse the repository at this point in the history
…arameters
  • Loading branch information
crlsocro committed Sep 19, 2024
1 parent 3282b9e commit 84bad6c
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 55 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/deploy-azure-resources-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
on:
push:
branches:
# - main
- 'feature/**'
# paths:
# - 'infra/**'

name: Deploy to Azure Resource Group

env:
SQL_SERVER_PASSWORD: ${{ secrets.SQL_SERVER_PASSWORD_TEST }}

jobs:
deploy-azure-resources-test:
runs-on: ubuntu-latest
steps:

- name: Checkout code
uses: actions/checkout@v4

- name: Log into Azure
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS_TEST }}

- name: Deploy Azure Resources test
uses: azure/arm-deploy@v2
with:
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION }}
resourceGroupName: ${{ secrets.AZURE_RG_TEST }}
template: infra/main.bicep
parameters: "sqlServerPassword=${{env.SQL_SERVER_PASSWORD}}"
failOnStdErr: false


54 changes: 0 additions & 54 deletions .github/workflows/deploy-azure-resources.yml

This file was deleted.

39 changes: 38 additions & 1 deletion infra/main.bicep
Original file line number Diff line number Diff line change
@@ -1,13 +1,50 @@
@description('The name of the Azure Container Registry.')
param acrName string = 'bouvetcontainerregistrytest'
param acrName string = 'bds-test-acr'

@description('Key Vault module name')
param keyVaultName string = 'bds-test-kv'

@description('The location for the registry.')
param location string = 'norwayeast'

@description('The name of the SQL Server.')
param serverName string = 'bds-test-sqlserver'

@description('The name of the SQL Database.')
param sqlDBName string = 'bds-test-sqldb'

@description('The username for the SQL Server.')
param sqlServerUsername string = 'bdsadmin'

@secure()
@description('The administrator password used for the sql server instance created.')
param sqlServerPassword string



module containerRegistry 'modules/containerRegistry.bicep' = {
name: acrName
params: {
acrName: acrName
location: location
}
}

module keyVault 'modules/keyVault.bicep' = {
name: keyVaultName
params: {
resourceName: keyVaultName
location: location
}
}

module sqlServer 'modules/sqlServer.bicep' = {
name: serverName
params: {
serverName: serverName
sqlDBName: sqlDBName
location: location
administratorLogin: sqlServerUsername
administratorLoginPassword: sqlServerPassword
}
}
20 changes: 20 additions & 0 deletions infra/modules/keyVault.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@description('Key Vault module name')
param resourceName string

@description('The location for the Key Vault.')
param location string


resource keyVault 'Microsoft.KeyVault/vaults@2023-07-01' = {
name: resourceName
location: location
sku: {
family: 'A'
name: 'string'
}
enableSoftDelete: true
softDeleteRetentionInDays: 90
accessPolicies:[]
}

output keyVaultId string = keyVault.id
Empty file removed infra/modules/sqlDatabase.bicep
Empty file.
35 changes: 35 additions & 0 deletions infra/modules/sqlServer.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@description('The name of the SQL Server.')
param serverName string

@description('The name of the SQL Database.')
param sqlDBName string

@description('The location for the SQL Server.')
param location string

@description('The administrator login for the SQL Server.')
param administratorLogin string

@description('The administrator login password for the SQL Server.')
param administratorLoginPassword string

resource sqlServer 'Microsoft.Sql/servers@2022-05-01-preview' = {
name: serverName
location: location
properties: {
administratorLogin: administratorLogin
administratorLoginPassword: administratorLoginPassword
}
}

resource sqlDB 'Microsoft.Sql/servers/databases@2022-05-01-preview' = {
parent: sqlServer
name: sqlDBName
location: location
sku: {
name: 'S0'
tier: 'Standard'
}
}

output connectionString string = 'Server=tcp:${serverName}${environment().suffixes.sqlServerHostname},1433; Initial Catalog=${sqlDBName}; Persist Security Info=False; User ID=${administratorLoginPassword}; Password=${administratorLoginPassword}; MultipleActiveResultSets=False; Encrypt=True; TrustServerCertificate=False; Connection Timeout=300;'

0 comments on commit 84bad6c

Please sign in to comment.