ps/Modules/Cole.PowerShell.Developer/Public/Set-LocalCachedAWSProfile.ps1

31 lines
965 B
PowerShell
Raw Permalink Normal View History

2023-05-30 22:51:22 -07:00
function Set-LocalCachedAWSProfile {
<#
.SYNOPSIS
Used to store or change the locally cached AWS profile from the environment store
.PARAMETER ProfileName
The name of an AWS profile
.PARAMETER NoValidate
Don't check the local profile configuration to make sure the profile exists
#>
[CmdletBinding()]
[OutputType([void])]
param (
[Parameter(Mandatory = $true, Position = 0)]
[string]$ProfileName,
[switch]$NoValidate
)
$logLead = (Get-LogLeadName)
if (!$NoValidate) {
$credentials = (Get-LocalConfiguredAWSProfileNames)
if (!$credentials.Contains($ProfileName)) {
throw "$logLead : Can not find the value [$ProfileName] in your local credentials file. Valid values are [$($credentials -join ',')]"
}
Assert-ValidAWSProfileName -ProfileName $ProfileName
}
Set-EnvironmentVariable -Name "USERCACHE_AWSProfileKey" -Value $ProfileName -StoreName User
}