-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Akshay Shekhawat <[email protected]>
- Loading branch information
1 parent
c894125
commit 72253dd
Showing
6 changed files
with
539 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,238 @@ | ||
@description('Name for the Metlo Instance') | ||
param vmName string = 'Metlo-Manager' | ||
|
||
var adminUsername = 'azureuser' | ||
|
||
var authenticationType = 'sshPublicKey' | ||
|
||
@description('SSH Key or password for the Virtual Machine. SSH key is recommended.') | ||
@secure() | ||
param adminPasswordOrKey string | ||
|
||
var dnsLabelPrefix = toLower('${vmName}-${uniqueString(resourceGroup().id)}') | ||
|
||
@description('Location for all resources. Leave as default to take value from resource group') | ||
param location string = resourceGroup().location | ||
|
||
var vmSize = 'Standard_B2s' | ||
|
||
var virtualNetworkName = 'metloVNet' | ||
|
||
var subnetName = 'metloSubnet' | ||
|
||
var networkSecurityGroupName = 'metloSecGroupNet' | ||
|
||
var customDataName = 'metloPostDeploymentScript' | ||
// var customData = '[base64("sudo metlo init-env && sudo metlo update && sudo metlo start")]' | ||
|
||
var publicIPAddressName = '${vmName}PublicIP' | ||
var networkInterfaceName = '${vmName}NetInt' | ||
var osDiskType = 'Standard_LRS' | ||
var subnetAddressPrefix = '10.1.0.0/24' | ||
var addressPrefix = '10.1.0.0/16' | ||
var linuxConfiguration = { | ||
disablePasswordAuthentication: true | ||
ssh: { | ||
publicKeys: [ | ||
{ | ||
path: '/home/${adminUsername}/.ssh/authorized_keys' | ||
keyData: adminPasswordOrKey | ||
} | ||
] | ||
} | ||
} | ||
|
||
resource nic 'Microsoft.Network/networkInterfaces@2021-05-01' = { | ||
name: networkInterfaceName | ||
location: location | ||
properties: { | ||
ipConfigurations: [ | ||
{ | ||
name: 'ipconfig1' | ||
properties: { | ||
subnet: { | ||
id: subnet.id | ||
} | ||
privateIPAllocationMethod: 'Dynamic' | ||
publicIPAddress: { | ||
id: publicIP.id | ||
} | ||
} | ||
} | ||
] | ||
networkSecurityGroup: { | ||
id: nsg.id | ||
} | ||
} | ||
} | ||
|
||
resource nsg 'Microsoft.Network/networkSecurityGroups@2021-05-01' = { | ||
name: networkSecurityGroupName | ||
location: location | ||
properties: { | ||
securityRules: [ | ||
{ | ||
name: 'MetloSSH' | ||
properties: { | ||
priority: 1000 | ||
protocol: 'Tcp' | ||
access: 'Allow' | ||
direction: 'Inbound' | ||
sourceAddressPrefix: '*' | ||
sourcePortRange: '*' | ||
destinationAddressPrefix: '*' | ||
destinationPortRange: '22' | ||
} | ||
} | ||
{ | ||
name: 'Metlo-Collector' | ||
properties: { | ||
priority: 1001 | ||
protocol: 'Tcp' | ||
access: 'Allow' | ||
direction: 'Inbound' | ||
sourceAddressPrefix: '*' | ||
sourcePortRange: '*' | ||
destinationAddressPrefix: '*' | ||
destinationPortRange: '8081' | ||
} | ||
} | ||
{ | ||
name: 'Metlo-Frontend-10-8' | ||
properties: { | ||
priority: 1002 | ||
protocol: 'Tcp' | ||
access: 'Allow' | ||
direction: 'Inbound' | ||
sourceAddressPrefix: '10.0.0.0/8' | ||
sourcePortRange: '*' | ||
destinationAddressPrefix: '*' | ||
destinationPortRange: '8000' | ||
} | ||
} | ||
{ | ||
name: 'Metlo-Frontend-172.16-12' | ||
properties: { | ||
priority: 1003 | ||
protocol: 'Tcp' | ||
access: 'Allow' | ||
direction: 'Inbound' | ||
sourceAddressPrefix: '172.16.0.0/12' | ||
sourcePortRange: '*' | ||
destinationAddressPrefix: '*' | ||
destinationPortRange: '8000' | ||
} | ||
} | ||
{ | ||
name: 'Metlo-Frontend-192.168-16' | ||
properties: { | ||
priority: 1004 | ||
protocol: 'Tcp' | ||
access: 'Allow' | ||
direction: 'Inbound' | ||
sourceAddressPrefix: '192.168.0.0/16' | ||
sourcePortRange: '*' | ||
destinationAddressPrefix: '*' | ||
destinationPortRange: '8000' | ||
} | ||
} | ||
] | ||
} | ||
} | ||
|
||
resource vnet 'Microsoft.Network/virtualNetworks@2021-05-01' = { | ||
name: virtualNetworkName | ||
location: location | ||
properties: { | ||
addressSpace: { | ||
addressPrefixes: [ | ||
addressPrefix | ||
] | ||
} | ||
} | ||
} | ||
|
||
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2021-05-01' = { | ||
parent: vnet | ||
name: subnetName | ||
properties: { | ||
addressPrefix: subnetAddressPrefix | ||
privateEndpointNetworkPolicies: 'Enabled' | ||
privateLinkServiceNetworkPolicies: 'Enabled' | ||
} | ||
} | ||
|
||
resource publicIP 'Microsoft.Network/publicIPAddresses@2021-05-01' = { | ||
name: publicIPAddressName | ||
location: location | ||
sku: { | ||
name: 'Basic' | ||
} | ||
properties: { | ||
publicIPAllocationMethod: 'Dynamic' | ||
publicIPAddressVersion: 'IPv4' | ||
dnsSettings: { | ||
domainNameLabel: dnsLabelPrefix | ||
} | ||
idleTimeoutInMinutes: 4 | ||
} | ||
} | ||
|
||
resource vm 'Microsoft.Compute/virtualMachines@2021-11-01' = { | ||
name: vmName | ||
location: location | ||
properties: { | ||
userData: '' | ||
hardwareProfile: { | ||
vmSize: vmSize | ||
} | ||
storageProfile: { | ||
osDisk: { | ||
createOption: 'FromImage' | ||
managedDisk: { | ||
storageAccountType: osDiskType | ||
} | ||
} | ||
imageReference: { | ||
publisher: 'Canonical' | ||
offer: 'UbuntuServer' | ||
sku: '18.04-LTS' | ||
version: 'latest' | ||
} | ||
} | ||
networkProfile: { | ||
networkInterfaces: [ | ||
{ | ||
id: nic.id | ||
} | ||
] | ||
} | ||
osProfile: { | ||
computerName: vmName | ||
adminUsername: adminUsername | ||
adminPassword: adminPasswordOrKey | ||
linuxConfiguration: ((authenticationType == 'password') ? null : linuxConfiguration) | ||
} | ||
} | ||
} | ||
|
||
resource script 'Microsoft.Compute/virtualMachines/extensions@2022-08-01' = { | ||
name: format('{0}/{1}', vmName, customDataName) | ||
location: location | ||
dependsOn: [ vm ] | ||
properties: { | ||
publisher: 'Microsoft.OSTCExtensions' | ||
type: 'CustomScriptForLinux' | ||
typeHandlerVersion: '1.2' | ||
settings: { | ||
fileUris: [ | ||
'https://raw.githubusercontent.com/metlo-labs/metlo/master/deploy/deploy_script.sh' | ||
] | ||
commandToExecute: 'sudo /bin/bash deploy_script.sh' | ||
} | ||
} | ||
} | ||
|
||
output adminUsername string = adminUsername | ||
output hostname string = publicIP.properties.dnsSettings.fqdn | ||
output sshCommand string = 'ssh ${adminUsername}@${publicIP.properties.dnsSettings.fqdn}' |
Oops, something went wrong.