function Get-LoginsToTest { <# .SYNOPSIS Gets logins to perform validation web tests against. .DESCRIPTION Currently pulls from S3 bucket to get a .json file of logins. .PARAMETER AwsProfile Aws profile for connecting to S3 .NOTES Returns a JSON string #> [cmdletbinding()] [OutputType([System.String])] Param ( [Parameter(Mandatory = $true)] [string]$AwsProfile ) $logLead = (Get-LogLeadName) $environmentType = $AwsProfile.Replace("temp-","").ToLower() $bucketName = "alkami-devops-validations-$environmentType" $key = "logins.json" $fileName = [System.IO.Path]::GetRandomFileName() $S3Script = { param($sbBucketName, $sbKey, $sbFileName, $sbAwsProfile) (Read-S3Object -BucketName $sbBucketName -Key $sbKey -File $sbFileName -ProfileName $sbAwsProfile) | Out-Null } try{ Write-Host "$logLead Getting file from S3." (Invoke-CommandWithRetry -Arguments ($bucketName, $key, $fileName, $AwsProfile) -MaxRetries 3 -Exponential -ScriptBlock $S3Script) Write-Host "$logLead Getting content from file." $contentJson = Get-Content -Path ".\$fileName" -Raw -ErrorAction SilentlyContinue if($null -eq $contentJson) { throw "Could not get Json content from file!" } } finally { if(Test-Path ".\$fileName" -PathType Leaf) { Write-Host "$logLead Removing file [$fileName]" (Remove-FileSystemItem -Path ".\$fileName") | Out-Null } } return ($contentJson | Out-String) }