60 lines
1.7 KiB
PowerShell
60 lines
1.7 KiB
PowerShell
|
function Get-YeatsRotationLambdaArn {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Retrieves the environment-specific ARN for the Yeats rotation Lambda.
|
||
|
|
||
|
.PARAMETER EnvironmentTag
|
||
|
[string] The 'alk:env' value for the Yeats rotation Lambda name.
|
||
|
|
||
|
.PARAMETER ProfileName
|
||
|
[string] The AWS profile to use during search operation.
|
||
|
|
||
|
.PARAMETER Region
|
||
|
[string] The AWS region to use during search operation.
|
||
|
|
||
|
.EXAMPLE
|
||
|
Get-YeatsRotationLambdaArn -EnvironmentTag 'devshared' -ProfileName 'temp-dev'
|
||
|
|
||
|
arn:aws:lambda:us-east-1:327695573722:function:alk-devshared-yeats-process-rotation-event
|
||
|
#>
|
||
|
|
||
|
[CmdletBinding()]
|
||
|
[OutputType([string])]
|
||
|
param (
|
||
|
[Parameter(Mandatory = $true)]
|
||
|
[ValidateNotNullOrEmpty()]
|
||
|
[string] $EnvironmentTag,
|
||
|
|
||
|
[Parameter(Mandatory = $true)]
|
||
|
[ValidateNotNullOrEmpty()]
|
||
|
[string] $ProfileName,
|
||
|
|
||
|
[Parameter(Mandatory = $false)]
|
||
|
[ValidateScript({$_ -in (Get-AWSRegion).region})]
|
||
|
[string] $Region = 'us-east-1'
|
||
|
)
|
||
|
|
||
|
$logLead = Get-LogLeadName
|
||
|
$result = $null
|
||
|
|
||
|
Import-AWSModule
|
||
|
|
||
|
# Build the Lambda name. All of this is constant except for the environment designator.
|
||
|
$lambdaName = "alk-${EnvironmentTag}-yeats-process-rotation-event"
|
||
|
Write-Verbose "$logLead : Calculated Yeats rotation Lambda name as '$lambdaName'"
|
||
|
|
||
|
try {
|
||
|
|
||
|
$lambda = Get-LMFunctionConfiguration -FunctionName $lambdaName -ProfileName $ProfileName -Region $Region
|
||
|
$result = $lambda.FunctionArn
|
||
|
|
||
|
Write-Verbose "$logLead : Yeats rotation Lambda ARN = '$result'"
|
||
|
|
||
|
} catch {
|
||
|
|
||
|
Write-Warning "$logLead : Unable to find Yeats rotation Lambda named '$lambdaName' with provided input.`nError encountered was: '$PSItem'"
|
||
|
}
|
||
|
|
||
|
return $result
|
||
|
}
|