Skip to content

Commit

Permalink
Merged in feature/amazon (pull request deuill#19)
Browse files Browse the repository at this point in the history
Feature/amazon

Approved-by: Matthew Tyas <matthew.tyas@antstream.com>
  • Loading branch information
James Stow committed Apr 26, 2019
2 parents a65fd38 + bb31f91 commit 746b6be
Show file tree
Hide file tree
Showing 14 changed files with 1,620 additions and 89 deletions.
52 changes: 52 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "PowerShell Launch Current File",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"args": [],
"cwd": "${file}"
},
{
"name": "PowerShell Launch Current File in Temporary Console",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"args": [],
"cwd": "${file}",
"createTemporaryIntegratedConsole": true
},
{
"name": "PowerShell Launch Current File w/Args Prompt",
"type": "PowerShell",
"request": "launch",
"script": "${file}",
"args": [
"${command:SpecifyScriptArgs}"
],
"cwd": "${file}"
},
{
"name": "PowerShell Attach to Host Process",
"type": "PowerShell",
"request": "attach"
},
{
"name": "PowerShell Interactive Session",
"type": "PowerShell",
"request": "launch",
"cwd": ""
},
{
"name": "PowerShell Attach Interactive Session Runspace",
"type": "PowerShell",
"request": "attach",
"processId": "current"
}
]
}
105 changes: 105 additions & 0 deletions modules/antstream.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
$scriptDir = $PSScriptRoot

$rootDir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($scriptDir, "..\"))
$moduleDir = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($rootDir, "modules\"))

Import-Module "$moduleDir\azure.psm1" -Force
Import-Module "$moduleDir\resource-locator.psm1" -Force

function FormatName()
{
param(
[Parameter(Mandatory=$false)][string]$owner = "as",
[Parameter(Mandatory=$true)][string]$environment,
[Parameter(Mandatory=$true)][string]$region,
[Parameter(Mandatory=$true)][string]$type,
[Parameter(Mandatory=$true)][string]$feature
)

$result = "${owner}-${environment}-${type}-${feature}-${region}"

return $result
}

function GetGameserverSettings()
{
param(
[Parameter(Mandatory=$true)][string]$azurePassword,
[Parameter(Mandatory=$true)][string]$azureUsername,
[Parameter(Mandatory=$true)][string]$azureSubscriptionName,
[Parameter(Mandatory=$true)][string]$environment,
[Parameter(Mandatory=$true)][string]$region
)

$secureAzurePassword = $azurePassword | ConvertTo-SecureString -asPlainText -Force
$azureCredentials = New-Object -TypeName System.Management.Automation.PSCredential($azureUsername, $secureAzurePassword)
Disable-AzureDataCollection -WarningAction SilentlyContinue

#1
Write-Host -ForegroundColor Cyan "Step 1: Logging in to Azure..."
Add-AzureRmAccount -credential $azureCredentials | Out-Null
Write-Host "Logged in."

#2
Write-Host -ForegroundColor Cyan "Step 2: Selecting subscription..."
$AzureSub = Select-AzureRmSubscription -SubscriptionName $azureSubscriptionName -Verbose
Write-Host "We are now in $AzureSub.Subscription"

$romResourceGroup = GetGameRomResourceGroupName -environment $environment -region $region

#Don't want subscription in resource locator as should all be as-sub-working in one storage account once migrated

if ($environment -eq "TEST") {
$romSubscription = "as-sub-working"
$settingsSubscription = "as-sub-working"
$emulatorsSubscription = "as-sub-working"
} else {
$romSubscription = "as-sub-live"
$settingsSubscription = "as-sub-working"
$emulatorsSubscription = "as-sub-productivity"
}

$settingsResourceGroup = "as-asl-working"

Write-Host -ForegroundColor Cyan "Step 4: Generating SAS tokens"

$settingsStorageAccount = GetGameSettingsStorageAccount
Write-Host "Game Settings Storage Account: ${settingsStorageAccount}"

$romStorageAccount = GetRomStorageAccount -environment $environment -region $region

Write-Host "Rom Storage Account: ${romStorageAccount}"

$romSasKey = GetSasToken $romStorageAccount $romResourceGroup $romSubscription
$settingsSasKey = GetSasToken $settingsStorageAccount $settingsResourceGroup $settingsSubscription

Write-Host -ForegroundColor Cyan "Getting Eventhubs Key"
$eventHubResourceGroupName = GetEventHubsResourceGroup -environment $environment
$eventHubNameSpaceName = GetEventHubsNamespace -environment $environment -region $region

$eventHubsKey = (Get-AzureRmEventHubKey -ResourceGroupName $eventHubResourceGroupName -Namespace $eventHubNameSpaceName -Name "RootManageSharedAccessKey").PrimaryKey
$emulatorStorageAccount = GetEmulatorStorageAccount -environment $environment -region $region

Write-Host "Getting Emulator Storage Account Access Key"
$emulatorStorageResourceGroup = GetEmulatorStorageResourceGroupName -environment $environment -region $region

$AzureSub = Select-AzureRmSubscription -SubscriptionName $emulatorsSubscription -Verbose

Write-Host "Emulator Storage Account: ${emulatorStorageAccount}, Emulator Resource Group: ${emulatorStorageResourceGroup}"
$emulatorAccessKey = GetKeyForStorageAccount -resourceGroup $emulatorStorageResourceGroup -accountName $emulatorStorageAccount
$emulatorShareName = GetEmulatorFileShareName -environment $environment

$AzureSub = Select-AzureRmSubscription -SubscriptionName $azureSubscriptionName -Verbose
Write-Host "Emultor File Share Name: ${emulatorShareName}"

return @{
EmulatorStorageAccount = $emulatorStorageAccount;
RomStorageAccount = $romStorageAccount;
SettingsStorageAccount = $settingsStorageAccount;
EmulatorShareName = $emulatorShareName;
RomSasKey = $romSasKey;
SettingsSasKey = $settingsSasKey;
EventHubsKey = $eventHubsKey;
EmulatorAccessKey = $emulatorAccessKey;
}
}
Loading

0 comments on commit 746b6be

Please sign in to comment.