91 lines
3.1 KiB
PowerShell
91 lines
3.1 KiB
PowerShell
|
function Get-AwsStandardDynamicParameters {
|
||
|
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Returns a RuntimeDefinedParameterDictionary with all locally configured AWS Profiles and Alkami-supported Regions
|
||
|
|
||
|
.DESCRIPTION
|
||
|
Returns a RuntimeDefinedParameterDictionary with all locally configured AWS Profiles and Alkami-supported Regions as DynamicParameters in functions.
|
||
|
|
||
|
.PARAMETER RegionParameterName
|
||
|
The parameter name to set on the Region parameter. Defaults to Region
|
||
|
|
||
|
.PARAMETER RegionParameterSetName
|
||
|
The parameter set to associate the dynamic Region parameter with. Defaults to all parameter sets.
|
||
|
|
||
|
.PARAMETER RegionParameterRequired
|
||
|
Whether or not the Region parameter is mandatory. Defaults to false.
|
||
|
|
||
|
.PARAMETER ProfileParameterName
|
||
|
The parameter name to set on the Profile Name parameter. Defaults to ProfileName
|
||
|
|
||
|
.PARAMETER ProfileParameterSetName
|
||
|
The parameter set to associate the dynamic ProfileName parameter with. Defaults to all parameter sets.
|
||
|
|
||
|
.PARAMETER ProfileParameterRequired
|
||
|
Whether or not the ProfileName parameter is mandatory. Defaults to false.
|
||
|
|
||
|
.EXAMPLE
|
||
|
Get-AwsStandardDynamicParameters
|
||
|
|
||
|
Key Value
|
||
|
--- -----
|
||
|
Region System.Management.Automation.RuntimeDefinedParameter
|
||
|
Profile System.Management.Automation.RuntimeDefinedParameter
|
||
|
|
||
|
.LINK
|
||
|
Get-DynamicAwsProfilesParameter
|
||
|
|
||
|
.LINK
|
||
|
Get-DynamicAwsRegionParameter
|
||
|
#>
|
||
|
|
||
|
[Cmdletbinding()]
|
||
|
[OutputType([System.Management.Automation.RuntimeDefinedParameterDictionary])]
|
||
|
param(
|
||
|
|
||
|
[Parameter(Mandatory=$false)]
|
||
|
[string]$RegionParameterName = "Region",
|
||
|
|
||
|
[Parameter(Mandatory=$false)]
|
||
|
[string]$RegionParameterSetName = "__AllParameterSets",
|
||
|
|
||
|
[Parameter(Mandatory=$false)]
|
||
|
[switch]$RegionParameterRequired,
|
||
|
|
||
|
[Parameter(Mandatory=$false)]
|
||
|
[string]$ProfileParameterName = "ProfileName",
|
||
|
|
||
|
[Parameter(Mandatory=$false)]
|
||
|
[string]$ProfileParameterSetName = "__AllParameterSets",
|
||
|
|
||
|
[Parameter(Mandatory=$false)]
|
||
|
[switch]$ProfileParameterRequired
|
||
|
)
|
||
|
|
||
|
$regionDynamicParams = @{
|
||
|
|
||
|
"DynamicParameterName" = $RegionParameterName;
|
||
|
"ParameterSetName" = $RegionParameterSetName;
|
||
|
"IsMandatoryParameter" = $RegionParameterRequired
|
||
|
}
|
||
|
|
||
|
$regionRuntimeParameter = Get-DynamicAwsRegionParameter @regionDynamicParams
|
||
|
|
||
|
$profileDynamicParams = @{
|
||
|
|
||
|
"DynamicParameterName" = $ProfileParameterName;
|
||
|
"ParameterSetName" = $ProfileParameterSetName;
|
||
|
"IsMandatoryParameter" = $ProfileParameterRequired
|
||
|
}
|
||
|
|
||
|
$profileRuntimeParameter = Get-DynamicAwsProfilesParameter @profileDynamicParams
|
||
|
|
||
|
# The Dynamic params functions return dictionaries so they can be used independently if needed
|
||
|
# We will add both returned values to a new Dictionary and return it for use by the calling function
|
||
|
$runtimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
|
||
|
$runtimeParameterDictionary.Add($RegionParameterName, $($regionRuntimeParameter.Values[0]))
|
||
|
$runtimeParameterDictionary.Add($ProfileParameterName, $($profileRuntimeParameter.Values[0]))
|
||
|
|
||
|
return $runtimeParameterDictionary
|
||
|
}
|