AWS code-library documentation change
Summary
Added PowerShell V5 examples demonstrating secure credential usage for patch snapshot retrieval
Security assessment
Emphasizes using instance profile credentials to avoid credential exposure, promoting security best practices
Diff
diff --git a/code-library/latest/ug/ssm_example_ssm_GetDeployablePatchSnapshotForInstance_section.md b/code-library/latest/ug/ssm_example_ssm_GetDeployablePatchSnapshotForInstance_section.md index 3e720d201..153bc60e7 100644 --- a//code-library/latest/ug/ssm_example_ssm_GetDeployablePatchSnapshotForInstance_section.md +++ b//code-library/latest/ug/ssm_example_ssm_GetDeployablePatchSnapshotForInstance_section.md @@ -82,0 +83,34 @@ PowerShell +**Tools for PowerShell V5** + + +**Example 1: This example displays the current snapshot for the patch baseline used by an Instance. This command must be run from the instance using the instance credentials. To ensure it uses the instance credentials, the example passes an`Amazon.Runtime.InstanceProfileAWSCredentials` object to the Credentials parameter.** + + + $credentials = [Amazon.Runtime.InstanceProfileAWSCredentials]::new() + Get-SSMDeployablePatchSnapshotForInstance -SnapshotId "4681775b-098f-4435-a956-0ef33373ac11" -InstanceId "i-0cb2b964d3e14fd9f" -Credentials $credentials + + +**Output:** + + + InstanceId SnapshotDownloadUrl + ---------- ------------------- + i-0cb2b964d3e14fd9f https://patch-baseline-snapshot-us-west-2.s3-us-west-2.amazonaws.com/853d0d3db0f0cafe...1692/4681775b-098f-4435... + +**Example 2: This example shows how to get the full SnapshotDownloadUrl. This command must be run from the instance using the instance credentials. To ensure it uses the instance credentials, the example configures the PowerShell session to use an`Amazon.Runtime.InstanceProfileAWSCredentials` object.** + + + Set-AWSCredential -Credential ([Amazon.Runtime.InstanceProfileAWSCredentials]::new()) + (Get-SSMDeployablePatchSnapshotForInstance -SnapshotId "4681775b-098f-4435-a956-0ef33373ac11" -InstanceId "i-0cb2b964d3e14fd9f").SnapshotDownloadUrl + + +**Output:** + + + https://patch-baseline-snapshot-us-west-2.s3-us-west-2.amazonaws.com/853d0d3db0f0cafe... + + * For API details, see [GetDeployablePatchSnapshotForInstance](https://docs.aws.amazon.com/powershell/v5/reference) in _AWS Tools for PowerShell Cmdlet Reference (V5)_. + + + +