-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c01bc7a
commit 1660cee
Showing
6 changed files
with
146 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
aws-toolbox/Public/IAM/Set-ATIAMCliExternalCredentials.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
function Set-ATIAMCliExternalCredentials | ||
{ | ||
<# | ||
.SYNOPSIS | ||
Configue aws-toolbox as an AWS CLI Credential Process | ||
.DESCRIPTION | ||
This cmdlet maps a PowerShell stored profile into the AWS CLI credential file | ||
as a provider of external credentials. This is useful to get AWS CLI to use a | ||
saved SAML profile when e.g. you use Active Directory integration to authenticate | ||
with AWS | ||
.PARAMETER ProfileName | ||
Name of PowerShell stored profile to use. | ||
.PARAMETER CliProfileName | ||
Name of profile to create in CLI credentials file. If omitted, then the name | ||
passed to ProfileName will be used. | ||
#> | ||
[CmdletBinding()] | ||
param | ||
( | ||
[string]$CliProfileName | ||
) | ||
|
||
DynamicParam | ||
{ | ||
$validateSet = Get-AWSCredential -ListProfileDetail | Select-Object -ExpandProperty ProfileName | Sort-Object -Unique | ||
New-DynamicParam -Name ProfileName -Mandatory -ValidateSet $validateSet -HelpMessage 'Name of PowerShell stored profile to use' | ||
} | ||
|
||
begin | ||
{ | ||
foreach ($p in $PSBoundParameters.Keys) | ||
{ | ||
if (-not (Get-Variable -Name $p -Scope Local -ErrorAction SilentlyContinue)) | ||
{ | ||
Set-Variable -Name $p -Value $PSBoundParameters[$p] -Scope Local | ||
} | ||
} | ||
if ($null -eq $ProfileName) | ||
{ | ||
throw "Profile Name not set" | ||
} | ||
} | ||
|
||
process | ||
{} | ||
|
||
end | ||
{ | ||
if ([string]::IsNullOrEmpty($CliProfileName)) | ||
{ | ||
$CliProfileName = $ProfileName | ||
} | ||
|
||
$creds = Read-CliConfigurationFile -Credentials | ||
|
||
if ($creds.ContainsKey($CliProfileName)) | ||
{ | ||
$creds.Remove($CliProfileName) | ||
} | ||
|
||
$creds[$CliProfileName] = @{ | ||
credential_process = (Get-CredentialProcess).CredentialProcess -f $ProfileName | ||
} | ||
|
||
$creds | Write-CliConfigurationFile -Credentials | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters