Set an IAM Policy for an IAM User - Amazon Tools for PowerShell
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Set an IAM Policy for an IAM User

The following commands show how to assign an IAM policy to an IAM user. The policy specified below provides the user with "Power User Access". This policy is identical to the Power User Access policy template provided in the IAM console. The name for the policy shown below follows the naming convention used for IAM policy templates such as the template for Power User Access. The convention is

<template name>+<user name>+<date stamp>

In order to specify the policy document, we use a PowerShell here-string. We assign the contents of the here-string to a variable and then use the variable as a parameter value in Write-IAMUserPolicy.

PS > $policyDoc = @" >> { >> "Version": "2012-10-17", >> "Statement": [ >> { >> "Effect": "Allow", >> "NotAction": "iam:*", >> "Resource": "*" >> } >> ] >> } >> "@ >> PS > Write-IAMUserPolicy -UserName myNewUser -PolicyName "PowerUserAccess-myNewUser-201211201605" -PolicyDocument $policyDoc ServiceResponse --------------- Amazon.IdentityManagement.Model.PutUserPolicyResponse

See Also