ps/Modules/Alkami.DevOps.TeamCity/Public/Get-TeamCityEc2Instance.ps1

34 lines
973 B
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function Get-TeamCityEc2Instance {
<#
.SYNOPSIS
Returns an array of the TeamCity EC2 Instances
.PARAMETER Type
Type of TeamCity host(s) to return: All, Server(s), or Agent(s)
.PARAMETER ProfileName
AWS ProfileName
#>
[CmdletBinding()]
[OutputType([Amazon.EC2.Model.Instance[]])]
param(
[Parameter(Mandatory = $false)]
[ValidateSet("All", "Server", "Agent")]
[string]$Type = "All",
[Parameter(Mandatory = $true)]
[string]$ProfileName
)
$logLead = Get-LogLeadName
Write-Host "$logLead : Getting hostnames of type $Type"
$teamcityHostnames = Get-TeamCityHostnames -Type $Type
Write-Host "$logLead : Getting instances for hostnames $($teamcityHostnames)"
$teamcityInstances = Get-EC2InstancesByHostname -Servers $teamcityHostnames -ProfileName $ProfileName
Write-Host "$logLead : Found $($teamcityInstances.count)(count) instances to return"
return $teamcityInstances
}