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

Basic VNET integration and security improvements #27

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
21 changes: 21 additions & 0 deletions deploy/bicep/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,30 @@ param sqlServerName string = 'sql-${uniqueSuffix}'
param sqlDatabaseName string = 'reddog'
param sqlAdminLogin string = 'reddog'
param sqlAdminLoginPassword string = take(newGuid(), 16)
param virtualNetworkName string = 'containerapps-${uniqueString(uniqueSeed)}'
param subnetName string = 'containerapps-${uniqueString(uniqueSeed)}'

module vnetModule 'modules/vnet.bicep' = {
name: '${deployment().name}--containerAppsVnet'
params: {
location: location
virtualNetworkName: virtualNetworkName
subnetName: subnetName
}
}

module containerAppsEnvModule 'modules/capps-env.bicep' = {
name: '${deployment().name}--containerAppsEnv'
dependsOn: [
vnetModule
]
params: {
location: location
containerAppsEnvName: containerAppsEnvName
logAnalyticsWorkspaceName: logAnalyticsWorkspaceName
appInsightsName: appInsightsName
virtualNetworkName: virtualNetworkName
subnetName: subnetName
}
}

Expand Down Expand Up @@ -54,10 +70,15 @@ module cosmosModule 'modules/cosmos.bicep' = {

module storageModule 'modules/storage.bicep' = {
name: '${deployment().name}--storage'
dependsOn: [
vnetModule
]
params: {
storageAccountName: storageAccountName
blobContainerName: blobContainerName
location: location
virtualNetworkName: virtualNetworkName
subnetName: subnetName
}
}

Expand Down
12 changes: 11 additions & 1 deletion deploy/bicep/modules/capps-env.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ param containerAppsEnvName string
param logAnalyticsWorkspaceName string
param appInsightsName string
param location string
param virtualNetworkName string
param subnetName string

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2021-08-01' existing = {
name: virtualNetworkName
}

resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-03-01-preview' = {
name: logAnalyticsWorkspaceName
Expand All @@ -21,7 +27,7 @@ resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' = {
name: appInsightsName
location: location
kind: 'web'
properties: {
properties: {
Application_Type: 'web'
}
}
Expand All @@ -38,6 +44,10 @@ resource containerAppsEnv 'Microsoft.App/managedEnvironments@2022-01-01-preview'
sharedKey: logAnalyticsWorkspace.listKeys().primarySharedKey
}
}
vnetConfiguration: {
infrastructureSubnetId: '${virtualNetwork.id}/subnets/${subnetName}'
internal: false
}
}
}

Expand Down
1 change: 1 addition & 0 deletions deploy/bicep/modules/sqlserver.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ resource sqlserver 'Microsoft.Sql/servers@2021-05-01-preview' = {
properties: {
administratorLogin: sqlAdminLogin
administratorLoginPassword: sqlAdminLoginPassword
minimalTlsVersion: '1.2'
}
}

Expand Down
24 changes: 24 additions & 0 deletions deploy/bicep/modules/storage.bicep
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
param storageAccountName string
param blobContainerName string
param location string
param virtualNetworkName string
param subnetName string

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2021-08-01' existing = {
name: virtualNetworkName
}

resource storageAccount 'Microsoft.Storage/storageAccounts@2021-06-01' = {
name: storageAccountName
Expand All @@ -9,6 +15,24 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2021-06-01' = {
sku: {
name: 'Standard_LRS'
}
properties: {
minimumTlsVersion: 'TLS1_2'
publicNetworkAccess: 'Enabled'
allowBlobPublicAccess: false
supportsHttpsTrafficOnly: true
networkAcls: {
bypass: 'AzureServices'
defaultAction: 'Deny'
ipRules: []
resourceAccessRules: []
virtualNetworkRules: [
{
action: 'Allow'
id: '${virtualNetwork.id}/subnets/${subnetName}'
}
]
}
}
}

resource blobService 'Microsoft.Storage/storageAccounts/blobServices@2021-06-01' = {
Expand Down
34 changes: 34 additions & 0 deletions deploy/bicep/modules/vnet.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
param virtualNetworkName string
param subnetName string
param location string

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2021-08-01' = {
name: virtualNetworkName
location: location
properties: {
addressSpace: {
addressPrefixes: [
'10.0.0.0/16'
]
}
subnets: [
{
name: subnetName
properties: {
addressPrefix: '10.0.0.0/23'
serviceEndpoints: [
{
service: 'Microsoft.Storage'
}
]
}
}
]
}

resource subnet1 'subnets' existing = {
name: subnetName
}
}

output subnet1ResourceId string = virtualNetwork::subnet1.id