Skip to content

IAM & STS ​

AWS Identity and Access Management for managing users, groups, roles, and policies. STS provides temporary credentials.


IAM ​

Protocol: AwsQuery (Action= parameter in form body) Signing name: iamPersistent: Yes

IAM is a global service — resources are not region-specific.

Quick Start (IAM) ​

Create a role, attach a managed policy, and create access keys:

bash
# Create a role with a Lambda trust policy
aws --endpoint-url http://localhost:4566 iam create-role \
  --role-name my-lambda-role \
  --assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"lambda.amazonaws.com"},"Action":"sts:AssumeRole"}]}'

# Attach AWSLambdaBasicExecutionRole
aws --endpoint-url http://localhost:4566 iam attach-role-policy \
  --role-name my-lambda-role \
  --policy-arn arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole

# Create a user and access key
aws --endpoint-url http://localhost:4566 iam create-user --user-name bob
aws --endpoint-url http://localhost:4566 iam create-access-key --user-name bob

Quick Start (STS) ​

bash
# Get caller identity
curl -s -X POST http://localhost:4566 \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -H "Authorization: AWS4-HMAC-SHA256 Credential=test/20260421/us-east-1/sts/aws4_request, SignedHeaders=host, Signature=fake" \
  --data-urlencode 'Action=GetCallerIdentity' \
  --data-urlencode 'Version=2011-06-15'

IAM Operations ​

Users ​

OperationDescription
CreateUserCreate an IAM user. Input: UserName, optional Path, Tags. Returns: User with UserId, Arn, CreateDate
GetUserGet user details. Input: optional UserName (defaults to caller)
UpdateUserUpdate user name or path. Input: UserName, optional NewUserName, NewPath
DeleteUserDelete a user. Must detach all policies first
ListUsersList all users. Supports PathPrefix, MaxItems, Marker pagination
CreateAccessKeyGenerate access key ID + secret for a user
DeleteAccessKeyDelete an access key by ID
ListAccessKeysList access keys for a user (secret is not returned after creation)
TagUser / UntagUser / ListUserTagsTag management

Groups ​

OperationDescription
CreateGroupCreate a group. Input: GroupName, optional Path
GetGroupGet group with member list
DeleteGroupDelete a group
ListGroupsList all groups
AddUserToGroupAdd a user to a group. Input: GroupName, UserName
RemoveUserFromGroupRemove a user from a group

Roles ​

OperationDescription
CreateRoleCreate a role with a trust policy. Input: RoleName, AssumeRolePolicyDocument (JSON), optional Description, MaxSessionDuration, Path, Tags. Returns: Role with RoleId, Arn
GetRoleGet role details including trust policy and attached policies
UpdateRoleUpdate role description or max session duration
DeleteRoleDelete a role. Must detach all policies first
ListRolesList all roles
UpdateAssumeRolePolicyUpdate the role's trust policy document
TagRole / UntagRole / ListRoleTagsTag management

Managed Policies ​

OperationDescription
CreatePolicyCreate a managed policy. Input: PolicyName, PolicyDocument (JSON), optional Description, Path. Returns: Policy with PolicyArn
GetPolicyGet policy metadata (not document — use GetPolicyVersion)
DeletePolicyDelete a policy
ListPoliciesList managed policies. Use Scope=Local for custom policies
CreatePolicyVersionCreate a new policy version. Input: PolicyArn, PolicyDocument, optional SetAsDefault
GetPolicyVersionGet a specific version's document. Input: PolicyArn, VersionId
DeletePolicyVersionDelete a non-default policy version
ListPolicyVersionsList all versions of a policy
SetDefaultPolicyVersionSet the default active version

Attaching Policies ​

OperationDescription
AttachUserPolicyAttach a managed policy to a user
DetachUserPolicyDetach a managed policy from a user
AttachRolePolicyAttach a managed policy to a role
DetachRolePolicyDetach a managed policy from a role
AttachGroupPolicyAttach a managed policy to a group
DetachGroupPolicyDetach a managed policy from a group
ListAttachedUserPoliciesList managed policies attached to a user
ListAttachedRolePoliciesList managed policies attached to a role
ListAttachedGroupPoliciesList managed policies attached to a group

Inline Policies ​

OperationDescription
PutUserPolicyCreate/replace an inline policy on a user
GetUserPolicyGet an inline policy document
DeleteUserPolicyDelete an inline policy
ListUserPoliciesList inline policy names for a user
PutRolePolicyCreate/replace an inline policy on a role
GetRolePolicyGet an inline policy document on a role
DeleteRolePolicyDelete an inline policy on a role
ListRolePoliciesList inline policy names for a role
PutGroupPolicyCreate/replace an inline policy on a group

Instance Profiles ​

OperationDescription
CreateInstanceProfileCreate an instance profile
DeleteInstanceProfileDelete an instance profile
GetInstanceProfileGet instance profile details
ListInstanceProfilesList all instance profiles; supports PathPrefix filter
ListInstanceProfilesForRoleList instance profiles associated with a role
AddRoleToInstanceProfileAttach a role to an instance profile
RemoveRoleFromInstanceProfileDetach a role
TagInstanceProfile / UntagInstanceProfile / ListInstanceProfileTagsTag management

Login Profiles (Console Passwords) ​

OperationDescription
CreateLoginProfileCreate a console password for a user. Input: UserName, Password, optional PasswordResetRequired
GetLoginProfileGet login profile metadata (not the password itself)
UpdateLoginProfileUpdate the password or reset flag
DeleteLoginProfileRemove the console password from a user

Policy Simulation ​

OperationDescription
SimulateCustomPolicyEvaluates a policy document against a list of actions and resources using the real IAM engine. Returns per-(action, resource) EvalDecision of allowed, explicitDeny, or implicitDeny
SimulatePrincipalPolicyEvaluates a principal's effective policies (user/role inline + attached + group policies) against actions and resources. Same decision semantics
GetContextKeysForCustomPolicyReturns the context keys referenced in a policy document's Condition blocks
GetContextKeysForPrincipalPolicyReturns context keys referenced across all of a principal's attached and inline policies

Misc Stubs ​

OperationDescription
ListServiceSpecificCredentialsReturns empty list (CodeCommit / Keyspaces credentials not tracked)
ListSigningCertificatesReturns empty list (X.509 signing certificates not tracked)

Account ​

OperationDescription
CreateAccountAliasSet account alias
DeleteAccountAliasRemove account alias
ListAccountAliasesList aliases
GetAccountPasswordPolicyGet password policy
UpdateAccountPasswordPolicyUpdate password policy
GetAccountSummaryAccount-level summary (user/role/policy counts)
GetAccountAuthorizationDetailsFull account auth details for all users, groups, and roles

OIDC Providers ​

OperationDescription
CreateOpenIDConnectProviderRegister an OIDC IdP with thumbprint
GetOpenIDConnectProviderGet OIDC provider
ListOpenIDConnectProvidersList OIDC providers
DeleteOpenIDConnectProviderDelete an OIDC provider
AddClientIDToOpenIDConnectProviderAdd a client ID
RemoveClientIDFromOpenIDConnectProviderRemove a client ID
UpdateOpenIDConnectProviderThumbprintUpdate thumbprint

SAML Providers ​

OperationDescription
CreateSAMLProviderCreate a SAML IdP. Input: Name, SAMLMetadataDocument
GetSAMLProviderGet SAML provider
ListSAMLProvidersList SAML providers
DeleteSAMLProviderDelete a SAML provider
UpdateSAMLProviderUpdate SAML metadata

MFA Devices ​

OperationDescription
CreateVirtualMFADeviceCreate a virtual MFA device (returns QR code seed)
ListVirtualMFADevicesList virtual MFA devices
DeleteVirtualMFADeviceDelete a virtual MFA device
EnableMFADeviceEnable MFA for a user
DeactivateMFADeviceDisable MFA for a user
ListMFADevicesList MFA devices for a user

STS ​

Protocol: AwsQuerySigning name: stsPersistent: No

OperationDescription
GetCallerIdentityReturn the Account, UserId, and Arn of the caller
AssumeRoleGet temporary credentials for a role. Input: RoleArn, RoleSessionName, optional DurationSeconds (900–43200), ExternalId
GetSessionTokenGet temporary credentials for a user. Input: optional DurationSeconds, SerialNumber, TokenCode
AssumeRoleWithWebIdentityExchange a web identity token (OIDC) for credentials. Input: RoleArn, RoleSessionName, WebIdentityToken
AssumeRoleWithSAMLExchange a SAML assertion for credentials

SDK Example ​

typescript
import { IAMClient, CreateUserCommand, CreateAccessKeyCommand, CreateRoleCommand, AttachRolePolicyCommand } from '@aws-sdk/client-iam';
import { STSClient, GetCallerIdentityCommand, AssumeRoleCommand } from '@aws-sdk/client-sts';

const iam = new IAMClient({
  region: 'us-east-1',
  endpoint: 'http://localhost:4566',
  credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});

// Create user
await iam.send(new CreateUserCommand({ UserName: 'alice' }));

// Create access key
const { AccessKey } = await iam.send(new CreateAccessKeyCommand({ UserName: 'alice' }));
console.log('Key ID:', AccessKey?.AccessKeyId);
console.log('Secret:', AccessKey?.SecretAccessKey);

// Create a role
const { Role } = await iam.send(new CreateRoleCommand({
  RoleName: 'lambda-execution-role',
  AssumeRolePolicyDocument: JSON.stringify({
    Version: '2012-10-17',
    Statement: [{
      Effect: 'Allow',
      Principal: { Service: 'lambda.amazonaws.com' },
      Action: 'sts:AssumeRole',
    }],
  }),
  Description: 'Lambda execution role',
}));

// Attach managed policy
await iam.send(new AttachRolePolicyCommand({
  RoleName: 'lambda-execution-role',
  PolicyArn: 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole',
}));

// STS: who am I?
const sts = new STSClient({
  region: 'us-east-1',
  endpoint: 'http://localhost:4566',
  credentials: { accessKeyId: 'test', secretAccessKey: 'test' },
});

const identity = await sts.send(new GetCallerIdentityCommand({}));
console.log('Account:', identity.Account);  // 000000000000
console.log('User:', identity.UserId);
console.log('ARN:', identity.Arn);

// Assume a role
const { Credentials } = await sts.send(new AssumeRoleCommand({
  RoleArn: Role!.Arn!,
  RoleSessionName: 'my-session',
  DurationSeconds: 3600,
}));
console.log('Temp Key ID:', Credentials?.AccessKeyId);

CLI Example ​

bash
# Create role
aws --endpoint-url http://localhost:4566 iam create-role \
  --role-name my-role \
  --assume-role-policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"Service":"lambda.amazonaws.com"},"Action":"sts:AssumeRole"}]}'

# Attach policy
aws --endpoint-url http://localhost:4566 iam attach-role-policy \
  --role-name my-role \
  --policy-arn arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess

# Get caller identity
aws --endpoint-url http://localhost:4566 sts get-caller-identity

# Assume role
aws --endpoint-url http://localhost:4566 sts assume-role \
  --role-arn arn:aws:iam::000000000000:role/my-role \
  --role-session-name test-session

Policy Enforcement ​

IAM policy evaluation is opt-in via the AWSIM_IAM_ENFORCE=true environment variable. When enabled, AWSim evaluates identity policies, resource policies, permissions boundaries, SCPs, and session policies using the real policy engine (all 26 AWS condition operators plus ForAllValues/ForAnyValue/IfExists qualifiers).

Enforcement currently covers S3, DynamoDB, KMS, SQS, SNS, Secrets Manager, Lambda, and IAM; other services are silently bypassed. See the IAM Enforcement guide for enablement, supported operators, and examples.

Policy validation is always on: CreatePolicy, CreatePolicyVersion, CreateRole, UpdateAssumeRolePolicy, and Put{User,Role,Group}Policy return MalformedPolicyDocument (HTTP 400) for syntactically invalid JSON or unknown condition operators.

Behavior Notes ​

  • When AWSIM_IAM_ENFORCE is not set, requests are allowed regardless of attached policies — useful for rapid prototyping. Set it to true to evaluate policies.
  • Credentials issued by AssumeRole and GetSessionToken are accepted by all AWSim services. Under enforcement, they inherit the role's identity policies.
  • IAM is persistent: users, groups, roles, and policies survive AWSim restarts.
  • Permission boundaries, resource policies, and SCPs are parsed and stored. They are evaluated only under AWSIM_IAM_ENFORCE=true.
  • GetCallerIdentity always returns account ID 000000000000 regardless of credentials used.

Released under MIT / Apache-2.0 License