-
Notifications
You must be signed in to change notification settings - Fork 1
/
CopyParameters.ps1
30 lines (25 loc) · 849 Bytes
/
CopyParameters.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
param(
[Parameter(Mandatory=$true)]
$sourcePrefixPath,
[Parameter(Mandatory=$true)]
$targetPrefixPath
)
Import-Module AWSPowerShell;
Write-Host "Using sourcePrefixPath $sourcePrefixPath"
Write-Host "Using targetPrefixPath $targetPrefixPath"
try
{
Write-Host "Getting configuration from AWS Parameter Store"
Get-SSMParametersByPath -Path $sourcePrefixPath -WithDecryption $true -Recursive $true | ForEach-Object {
#Out-String -InputObject $_
$newPath = $_.Name.Replace($sourcePrefixPath, $targetPrefixPath);
Write-Host "Copy parameter $($_.Name) to $newPath"
Write-SSMParameter -Name $newPath -Type $_.Type -Value $_.Value -Force
};
Write-Host "Parameters copied successfully";
}
catch {
Write-Host "Unable to copy parameters"
Write-Host $_.Exception.Message;
Write-Host $_.Exception;
}