AWS Security ChangesHomeSearch

AWS code-library documentation change

Service: code-library · 2025-06-28 · Documentation medium

File: code-library/latest/ug/ec2_example_ec2_CreateKeyPair_section.md

Summary

Added PowerShell V5 example for CreateKeyPair with emphasis on ASCII encoding for valid key generation

Security assessment

Highlights security best practice for proper key file encoding to prevent key corruption, but doesn't address an active vulnerability

Diff

diff --git a/code-library/latest/ug/ec2_example_ec2_CreateKeyPair_section.md b/code-library/latest/ug/ec2_example_ec2_CreateKeyPair_section.md
index 55cb3225a..4556dc081 100644
--- a//code-library/latest/ug/ec2_example_ec2_CreateKeyPair_section.md
+++ b//code-library/latest/ug/ec2_example_ec2_CreateKeyPair_section.md
@@ -462,0 +463,14 @@ PowerShell
+**Tools for PowerShell V5**
+    
+
+**Example 1: This example creates a key pair and captures the PEM-encoded RSA private key in a file with the specified name. When you are using PowerShell, the encoding must be set to ascii to generate a valid key. For more information, see Create, Display, and Delete Amazon EC2 Key Pairs (https://docs.aws.amazon.com/cli/latest/userguide/cli-services-ec2-keypairs.html) in the AWS Command Line Interface User Guide.**
+    
+    
+    (New-EC2KeyPair -KeyName "my-key-pair").KeyMaterial | Out-File -Encoding ascii -FilePath C:\path\my-key-pair.pem
+    
+
+  * For API details, see [CreateKeyPair](https://docs.aws.amazon.com/powershell/v5/reference) in _AWS Tools for PowerShell Cmdlet Reference (V5)_. 
+
+
+
+