aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
235 stars 78 forks source link

Import-Ec2KeyPair example needs updating #140

Closed indented-automation closed 3 years ago

indented-automation commented 4 years ago

The example for Import-Ec2KeyPair is out of date. If used, it will raise a warning.

Expected Behavior

This is the expected example text:

PS C:\> $publickey=Get-Content "C:\Users\TestUser\.ssh\id_rsa.pub" -Raw
PS C:\> $pkbase64 = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($publickey))
PS C:\> Import-EC2KeyPair -KeyName Example-user-key -PublicKey $pkbase64

Current Behavior

The example uses the PublicKeyMaterial parameter, which causes the obsolete warning to be displayed.

C:\> Import-Ec2KeyPair -KeyName KeyName -PublicKeyMaterial $pkbase64
WARNING: Parameter 'PublicKeyMaterial' is obsolete. This parameter is obsolete and will be removed in a future version. Use 'PublicKey' instead.

Possible Solution

The example, I believe in https://github.com/aws/aws-tools-for-powershell/blob/7d148285dbd8e0e465f4b5ceccc4053b82b763e2/generator/AWSPSGeneratorLib/HelpMaterials/Examples/EC2/Import-EC2KeyPair.xml should be updated to use the PublicKey parameter which will avoid the Warning message.

If you are able to confirm I'll raise a short PR to fix the issue.

Your Environment

matteo-prosperi commented 4 years ago

I confirm that the sample should be updated.

ashishdhingra commented 3 years ago

Sample updated in commit https://github.com/aws/aws-tools-for-powershell/commit/1d3dc66b67c60e41c3841b8328f3be98e9258f98