AWS Security ChangesHomeSearch

AWS code-library documentation change

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

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

Summary

Added PowerShell V5 example for adding IAM role to instance profile

Security assessment

The example shows role association with EC2 instances, a security best practice for permissions management, but does not address a specific security issue.

Diff

diff --git a/code-library/latest/ug/iam_example_iam_AddRoleToInstanceProfile_section.md b/code-library/latest/ug/iam_example_iam_AddRoleToInstanceProfile_section.md
index 8698c720c..ab9ba9ace 100644
--- a//code-library/latest/ug/iam_example_iam_AddRoleToInstanceProfile_section.md
+++ b//code-library/latest/ug/iam_example_iam_AddRoleToInstanceProfile_section.md
@@ -54,0 +55,14 @@ PowerShell
+**Tools for PowerShell V5**
+    
+
+**Example 1: This command adds the role named`S3Access` to an existing instance profile named `webserver`. To create the instance profile, use the `New-IAMInstanceProfile` command. After you create the instance profile and associate it with a role using this command, you can attach it to an EC2 instance. To do that, use the `New-EC2Instance` cmdlet with either the `InstanceProfile_Arn` or the `InstanceProfile-Name` parameter to launch the new instance.**
+    
+    
+    Add-IAMRoleToInstanceProfile -RoleName "S3Access" -InstanceProfileName "webserver"
+    
+
+  * For API details, see [AddRoleToInstanceProfile](https://docs.aws.amazon.com/powershell/v5/reference) in _AWS Tools for PowerShell Cmdlet Reference (V5)_. 
+
+
+
+