Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Add existing VPC option #10

Merged
merged 2 commits into from
Feb 18, 2021
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
36 changes: 11 additions & 25 deletions .taskcat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,14 @@ tests:
AvailabilityZones: "$[taskcat_getaz_2]"
UiPathFQDN: test.shivansh.dev #testone.uipathmarketplace.net

# three-az-orchestrator:
# template: ./templates/main.template.yaml
# regions:
# - us-east-1
# parameters:
# AvailabilityZones: "$[taskcat_getaz_3]"
# UiPathFQDN: testtwo.uipathmarketplace.net

# add-license-orchestrator:
# template: ./templates/main.template.yaml
# regions:
# - us-west-1
# parameters:
# AvailabilityZones: "$[taskcat_getaz_2]"
# UiPathFQDN: testthree.uipathmarketplace.net
# OrchestratorLicense: "orchlicense"

# europe-orchestrator:
# template: ./templates/main.template.yaml
# regions:
# - eu-west-1
# parameters:
# AvailabilityZones: "$[taskcat_getaz_2]"
# UiPathFQDN: testfour.uipathmarketplace.net
# OrchestratorInstanceCount: "3"
existing-vpc:
template: ./templates/uipath-orchestrator.template.yaml
regions:
- us-east-1
parameters:
AvailabilityZones: "$[taskcat_getaz_2]"
UiPathFQDN: testtwo.shivansh.dev #testone.uipathmarketplace.net
VPCCIDR: 10.0.0.0/16
VPCID: <<vpc-id>>
PrivateSubnetIDs: <<subnet-id-1,subnet-id-2,subnet-id-3>>
PublicSubnetIDs: <<subnet-id-1,subnet-id-2,subnet-id-3>>
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ This Quick Start is for users who wants to deploy UiPath Orchestrator on the AWS

The [AWS CloudFormation template](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/template?stackName=uipath&templateURL=https://aws-quickstart.s3.amazonaws.com/quickstart-uipath-orchestrator/templates/main.template.yaml) included with the Quick Start automates deploying UiPath Orchestrator on AWS. You can also use the AWS CloudFormation template as a starting point for your own implementation.

![Quick Start architecture for UiPath Orchestrator on AWS](./UIPath-Orchestrator-arch.png)
For deploying into existing VPCs, this [AWS CloudFormation template](https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/create/template?stackName=uipath&templateURL=https://aws-quickstart.s3.amazonaws.com/quickstart-uipath-orchestrator/templates/uipath-orchestrator.template.yaml) can be used as an entrypoint.

![Quick Start architecture for UiPath Orchestrator on AWS](./architecture.png)

As shown in the architecture diagram, the Quick Start sets up the following:

Expand Down
Binary file added architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions scripts/Install-UiPathRobots.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,25 +74,25 @@ function Main {
}

Install-RobotWithMSI -msiPath $msiPath -robotInstallType $robotType
if ($robotType -eq "Unattended" -and $cloudName -eq "AWS") {
Add-LocalAdministrator -userName $userName
}
else {
Write-Output "Robot type selected is Attended, skipping adding local administrator."
}

if ($orchestratorUrl -and $orchAdmin -and $orchPassword -and $tenant) {
Write-Output "orchestratorUrl $orchestratorUrl"
Write-Output "orchAdmin $orchAdmin"
Write-Output "orchPassword $orchPassword"
Write-Output "tenant $tenant"

$websession = Get-UiPathOrchestratorLoginSession

Add-UiPathRobotFolder -session $websession -folderName $folderName
if ($cloudName -eq "AWS") {
Add-UiPathRobotUser -session $websession -robotUsername "$env:computername\$userName" -userName $userName
Write-Output "Added AWS Robot: $userName"
if ($robotType -eq "Unattended") {
Add-LocalAdministrator -userName $userName
Add-UiPathRobotUser -session $websession -robotUsername "$env:computername\$userName" -userName $userName
Write-Output "Added AWS Robot: $userName"
}
elseif ($robotType -eq "Attended") {
Add-UiPathRobotUser -session $websession -robotUsername "$env:computername\Administrator" -userName $userName
Write-Output "Added AWS Robot: $userName"
}
}
elseif ($cloudName -eq "Azure") {
Add-UiPathRobotUser -session $websession -userName $userName -robotUsername $robotUserName
Expand Down
34 changes: 34 additions & 0 deletions scripts/modules/AzureUtils.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<#
.Description
Get-AzCloudEnvironment calls the instance metadata service to determine the environment on which the resource is deployed to.
#>
function Get-AzCloudEnvironment {
try {
$tries = 0
$retryCount = 5
Write-Host "Getting environment from instance metadata service"
while ($tries -le $retryCount) {
try {
$azEnvironment = (Invoke-RestMethod -Headers @{"Metadata"="true"} -Method GET -Uri "http://169.254.169.254/metadata/instance?api-version=2020-09-01" -TimeoutSec 180).compute.azEnvironment
break
}
catch {
$tries++
Write-Host "Exception: $_"
if ($tries -gt $retryCount) {
throw $_
}
else {
Write-Host "Failed to reach instance metadata service. Retrying again in $($tries * 10) seconds"
Start-Sleep ($tries * 10)
}
}
}
}
catch {
Write-Error -Exception $_.Exception -Message "Instance metadata service is unavailable."
throw $_.Exception
}

return $azEnvironment
}
38 changes: 38 additions & 0 deletions scripts/modules/CleanUpUtils.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

<#
.Description
Remove-OrchArtifacts requires OrchestratorAPIUtils module to be loaded.
Removes the Orchestrator Users and Machine templates that match the -uniqueString parameter
#>
function Remove-OrchArtifacts {
param(
[Parameter(Mandatory = $true)]
[string]$uniqueString,

[Parameter(Mandatory = $true)]
[ValidateScript( { if (($_ -as [System.URI]).AbsoluteURI -eq $null) { throw "Invalid" } return $true })]
[string]$orchUrl,

[Parameter(Mandatory = $true)]
[string]$orchAdmin,

[Parameter(Mandatory = $true)]
[string]$orchPassword,

[Parameter(Mandatory = $false)]
[string]$tenant = "Default"

)

$robotsUsernames = Get-OrchTenantUsersByString -userString $uniqueString -orchUrl $orchUrl -orchAdmin $orchAdmin -orchPassword $orchPassword -tenant $tenant

foreach ($robot in $robotsUsernames.value) {
Remove-OrchTenantUsersById -robotId $robot.id -orchUrl $orchUrl -orchAdmin $orchAdmin -orchPassword $orchPassword -tenant $tenant
}

$robotsMachineTemplates = Get-OrchTenantMachineTemplatesByString -machineString $uniqueString -orchUrl $orchUrl -orchAdmin $orchAdmin -orchPassword $orchPassword -tenant $tenant

foreach ($machineTemplate in $robotsMachineTemplates.value) {
Remove-OrchTenantMachineTemplateById -machineTemplateId $machineTemplate.id -orchUrl $orchUrl -orchAdmin $orchAdmin -orchPassword $orchPassword -tenant $tenant
}
}
207 changes: 207 additions & 0 deletions scripts/modules/OrchestratorAPIUtils.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
function Get-UiPathOrchestratorLoginSession {
param(
[Parameter(Mandatory = $true)]
[ValidateScript( { if (($_ -as [System.URI]).AbsoluteURI -eq $null) { throw "Invalid" } return $true })]
[string]$orchUrl,

[Parameter(Mandatory = $true)]
[string]$orchAdmin,

[Parameter(Mandatory = $true)]
[string]$orchPassword,

[Parameter(Mandatory = $false)]
[string]$tenant = "Default"

)
$dataLogin = @{
tenancyName = $tenant
usernameOrEmailAddress = $orchAdmin
password = $orchPassword
} | ConvertTo-Json

$orchUrlLogin = "$orchUrl/api/Account/Authenticate"

try {
$orchWebResponse = Invoke-RestMethod -Uri $orchUrlLogin `
-Method Post `
-Body $dataLogin `
-ContentType "application/json" `
-UseBasicParsing `
-SessionVariable websession
}
catch {
Write-Error "Authentication failed with message: $($_.ErrorDetails.Message)"
Exit 1
}
$websession.Headers.Add('Authorization', "Bearer " + $orchWebResponse.result)
return $websession
}

function Get-OrchTenantUsersByString {
param(
[Parameter(Mandatory = $true)]
[string]$userString,

[Parameter(Mandatory = $true)]
[ValidateScript( { if (($_ -as [System.URI]).AbsoluteURI -eq $null) { throw "Invalid" } return $true })]
[string]$orchUrl,

[Parameter(Mandatory = $true)]
[string]$orchAdmin,

[Parameter(Mandatory = $true)]
[string]$orchPassword,

[Parameter(Mandatory = $false)]
[string]$tenant = "Default"
)

$websession = Get-UiPathOrchestratorLoginSession -orchUrl $orchUrl `
-orchAdmin $orchAdmin `
-orchPassword $orchPassword `
-tenant $tenant

$orchUsersURL = "$orchUrl/odata/Users"

$robotsUsers = Invoke-RestMethod -Uri "$orchUsersURL`?`$filter=contains(UserName, `'$($userString)`')" `
-Method Get `
-UseBasicParsing `
-WebSession $websession

return $robotsUsers
}

function Remove-OrchTenantUsersById {
param(
[Parameter(Mandatory = $true)]
[string]$robotId,

[Parameter(Mandatory = $true)]
[ValidateScript( { if (($_ -as [System.URI]).AbsoluteURI -eq $null) { throw "Invalid" } return $true })]
[string]$orchUrl,

[Parameter(Mandatory = $true)]
[string]$orchAdmin,

[Parameter(Mandatory = $true)]
[string]$orchPassword,

[Parameter(Mandatory = $false)]
[string]$tenant = "Default"
)

$websession = Get-UiPathOrchestratorLoginSession -orchUrl $orchUrl `
-orchAdmin $orchAdmin `
-orchPassword $orchPassword `
-tenant $tenant

$orchUsersURL = "$orchUrl/odata/Users"
Invoke-RestMethod -Uri "$orchUsersURL($robotId)" `
-Method Delete `
-UseBasicParsing `
-WebSession $websession
}

function Get-OrchTenantMachineTemplatesByString {
param(
[Parameter(Mandatory = $true)]
[string]$machineString,

[Parameter(Mandatory = $true)]
[ValidateScript( { if (($_ -as [System.URI]).AbsoluteURI -eq $null) { throw "Invalid" } return $true })]
[string]$orchUrl,

[Parameter(Mandatory = $true)]
[string]$orchAdmin,

[Parameter(Mandatory = $true)]
[string]$orchPassword,

[Parameter(Mandatory = $false)]
[string]$tenant = "Default"
)

$websession = Get-UiPathOrchestratorLoginSession -orchUrl $orchUrl `
-orchAdmin $orchAdmin `
-orchPassword $orchPassword `
-tenant $tenant

$orchMachinesURL = "$orchUrl/odata/Machines"

$machineTemplates = Invoke-RestMethod -Uri "$orchMachinesURL`?`$filter=contains(Name, `'$($machineString)`')" `
-Method GET `
-ContentType "application/json" `
-UseBasicParsing `
-WebSession $websession

return $machineTemplates
}

function Remove-OrchTenantMachineTemplateById {
param(
[Parameter(Mandatory = $true)]
[string]$machineTemplateId,

[Parameter(Mandatory = $true)]
[ValidateScript( { if (($_ -as [System.URI]).AbsoluteURI -eq $null) { throw "Invalid" } return $true })]
[string]$orchUrl,

[Parameter(Mandatory = $true)]
[string]$orchAdmin,

[Parameter(Mandatory = $true)]
[string]$orchPassword,

[Parameter(Mandatory = $false)]
[string]$tenant = "Default"
)

$websession = Get-UiPathOrchestratorLoginSession -orchUrl $orchUrl `
-orchAdmin $orchAdmin `
-orchPassword $orchPassword `
-tenant $tenant

$orchUsersURL = "$orchUrl/odata/Machines"
Invoke-RestMethod -Uri "$orchUsersURL($machineTemplateId)" `
-Method Delete `
-UseBasicParsing `
-WebSession $websession
}

function Remove-ChangePasswordOnFirstLoginPolicy {
param(

[Parameter(Mandatory = $true)]
[ValidateScript( { if (($_ -as [System.URI]).AbsoluteURI -eq $null) { throw "Invalid" } return $true })]
[string]$orchUrl,

[Parameter(Mandatory = $true)]
[string]$orchAdmin,

[Parameter(Mandatory = $true)]
[string]$orchPassword,

[Parameter(Mandatory = $false)]
[string]$tenant = "host"
)

$websession = Get-UiPathOrchestratorLoginSession -orchUrl $orchUrl `
-orchAdmin $orchAdmin `
-orchPassword $orchPassword `
-tenant $tenant

$orchSettingsURL = "$orchUrl/odata/Settings"
$body = @{
Name = "Auth.Password.ShouldChangePasswordAfterFirstLogin"
Value = "false"
Scope = "All"
Id = "Auth.Password.ShouldChangePasswordAfterFirstLogin"
} | ConvertTo-Json
Invoke-RestMethod -Uri "$orchSettingsURL('Auth.Password.ShouldChangePasswordAfterFirstLogin')" `
-Method Put `
-ContentType "application/json;odata.metadata=minimal;odata.streaming=true" `
-UseBasicParsing `
-WebSession $websession `
-Body $body
}
Loading