There are more AWS SDK examples available in the AWS Doc SDK Examples
Code examples for IAM using AWS SDKs
The following code examples show you how to use AWS Identity and Access Management (IAM) with an AWS software development kit (SDK).
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios and cross-service examples.
Scenarios are code examples that show you how to accomplish a specific task by calling multiple functions within the same service.
More resources
IAM User Guide – More information about IAM.
IAM API Reference – Details about all available IAM actions.
AWS Developer Center
– Code examples that you can filter by category or full-text search. AWS SDK Examples
– GitHub repo with complete code in preferred languages. Includes instructions for setting up and running the code.
Get started
The following code examples show how to get started using IAM.
Code examples
- Actions
- 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 SAML provider
- 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
- Create an instance profile
- Delete SAML provider
- 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
- Delete an instance profile
- 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 service-linked role's deletion status
- 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
- Upload a server certificate
- Scenarios