Actions for IAM using Amazon SDKs
The following code examples demonstrate how to perform individual IAM actions with Amazon SDKs. These excerpts call the IAM API and are not intended to be run in isolation. Each example includes a link to GitHub, where you can find instructions on how to set up and run the code in context.
The following examples include only the most commonly used actions. For a complete list, see the Amazon Identity and Access Management (IAM) API Reference.
Examples
- Add a user to a group
- Attach a policy to a role
- Attach a policy to a user
- Attach an inline policy to a role
- Create a group
- Create a policy
- Create a policy version
- Create a role
- Create a service-linked role
- Create a user
- Create an access key
- Create an alias for an account
- Create an inline policy for a group
- Create an inline policy for a user
- Delete a group
- Delete a group policy
- Delete a policy
- Delete a role
- Delete a role policy
- Delete a server certificate
- Delete a service-linked role
- Delete a user
- Delete an access key
- Delete an account alias
- Delete an inline policy from a user
- Detach a policy from a role
- Detach a policy from a user
- Generate a credential report
- Get a credential report
- Get a detailed authorization report for your account
- Get a policy
- Get a policy version
- Get a role
- Get a server certificate
- Get a summary of account usage
- Get a user
- Get data about the last use of an access key
- Get the account password policy
- List SAML providers
- List a user's access keys
- List account aliases
- List groups
- List inline policies for a role
- List inline policies for a user
- List policies
- List policies attached to a role
- List roles
- List server certificates
- List users
- Remove a user from a group
- Update a server certificate
- Update a user
- Update an access key