Skip to content

Ministack: Free, open-source local AWS emulator - 60+ services, Terraform compatible, real databases. Free forever. MIT licensed.

feat(iam): login profiles (CreateLoginProfile/Get/Update/Delete) (#844)

lahmish901fc248a990
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03e9c915..a6e84235 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -7,6 +7,13 @@ Versioning follows [Semantic Versioning](https://semver.org/).
---
+## [Unreleased]
+
+### Added
+- **IAM — `CreateLoginProfile`, `GetLoginProfile`, `UpdateLoginProfile`, `DeleteLoginProfile`** — models whether an IAM user has a console password (the signal that a user is a human). `CreateLoginProfile` stores `UserName`, `CreateDate`, and `PasswordResetRequired` without persisting the password value (seed-side). `GetLoginProfile` returns `NoSuchEntity` (404) when no profile exists. `UpdateLoginProfile` updates `PasswordResetRequired`. `DeleteLoginProfile` removes the profile. All four operations match the real AWS request/response shapes exactly so identity-discovery agents can distinguish humans from service accounts using `get-login-profile`.
+
+---
+
## [1.3.59] — 2026-06-05
### Added
diff --git a/README.md b/README.md
index 74936934..a2da830a 100644
--- a/README.md
+++ b/README.md
@@ -356,7 +356,7 @@ subnet = ec2.create_subnet(
| **DynamoDB** | CreateTable, UpdateTable, DeleteTable, DescribeTable, ListTables, PutItem, GetItem, DeleteItem, UpdateItem, Query, Scan, BatchWriteItem, BatchGetItem, TransactWriteItems, TransactGetItems, DescribeTimeToLive, UpdateTimeToLive, DescribeContinuousBackups, UpdateContinuousBackups, DescribeEndpoints, TagResource, UntagResource, ListTagsOfResource, EnableKinesisStreamingDestination, DisableKinesisStreamingDestination, DescribeKinesisStreamingDestination, UpdateKinesisStreamingDestination | TTL enforced via thread-safe background reaper (60s cadence); DynamoDB Streams — `StreamSpecification` emits INSERT/MODIFY/REMOVE records on all write operations, respects `StreamViewType`; Kinesis streaming destinations (`aws_dynamodb_kinesis_streaming_destination`) fan item mutations out into any Kinesis stream by ARN while the destination is ACTIVE |
| **DynamoDB Streams** | ListStreams, DescribeStream, GetShardIterator, GetRecords | Reads records emitted by the main DynamoDB service via `boto3.client("dynamodbstreams")` — single synthetic shard per stream; `TRIM_HORIZON`/`LATEST`/`AT_SEQUENCE_NUMBER`/`AFTER_SEQUENCE_NUMBER` iterator types; `NEW_AND_OLD_IMAGES`, `NEW_IMAGE`, `OLD_IMAGE`, `KEYS_ONLY` view types; opaque base64 iterator tokens |
| **Lambda** | CreateFunction, DeleteFunction, GetFunction, GetFunctionConfiguration, ListFunctions, Invoke, UpdateFunctionCode, UpdateFunctionConfiguration, AddPermission, RemovePermission, GetPolicy, ListVersionsByFunction, PublishVersion, CreateAlias, GetAlias, UpdateAlias, DeleteAlias, ListAliases, TagResource, UntagResource, ListTags, CreateEventSourceMapping, DeleteEventSourceMapping, GetEventSourceMapping, ListEventSourceMappings, UpdateEventSourceMapping, CreateFunctionUrlConfig, GetFunctionUrlConfig, UpdateFunctionUrlConfig, DeleteFunctionUrlConfig, ListFunctionUrlConfigs, PutFunctionConcurrency, GetFunctionConcurrency, DeleteFunctionConcurrency, PutFunctionEventInvokeConfig, GetFunctionEventInvokeConfig, DeleteFunctionEventInvokeConfig, PublishLayerVersion, GetLayerVersion, GetLayerVersionByArn, ListLayerVersions, DeleteLayerVersion, ListLayers, AddLayerVersionPermission, RemoveLayerVersionPermission, GetLayerVersionPolicy, CheckpointDurableExecution, GetDurableExecution, GetDurableExecutionState, GetDurableExecutionHistory, ListDurableExecutionsByFunction, StopDurableExecution, SendDurableExecutionCallbackSuccess, SendDurableExecutionCallbackFailure, SendDurableExecutionCallbackHeartbeat | Python and Node.js runtimes execute with warm worker pool; `provided.al2023`/`provided.al2` runtimes execute via Docker RIE (Go, Rust, C++ support); `Publish=True` creates immutable numbered versions; Code via `ZipFile`, `S3Bucket`/`S3Key` (with optional `S3ObjectVersion`), or `ImageUri` (Docker image); `PackageType: Image` pulls and invokes user-provided Docker images via Lambda RIE; SQS, Kinesis, and DynamoDB Streams event source mappings; Function URL CRUD; Lambda Layers CRUD; Aliases; Concurrency; EventInvokeConfig; **Durable Functions** — `CreateFunction` accepts `DurableConfig`; checkpoint/state/history/list/stop ops at the preview API (`2025-12-01`); external `SendCallback{Success,Failure,Heartbeat}` resume the SDK across invocations; resume scheduler fires WAIT expiries, callback timeouts, and step-retry backoffs; verified against the official `aws-durable-execution-sdk-python` and `aws-durable-execution-sdk-java`; **X-Ray active tracing** — `TracingConfig.Mode=Active` injects `_X_AMZN_TRACE_ID` (`Root=1-<hex>-<hex>;Parent=<hex>;Sampled=1`) into the runtime per invocation so the AWS X-Ray SDK runs without `Missing AWS Lambda trace data`; supported on the warm Python / Node executor, provided runtimes, and the local subprocess fallback (docker RIE upstream does not implement X-Ray and is logged but unsupported) |
-| **IAM** | CreateUser, GetUser, ListUsers, DeleteUser, CreateRole, GetRole, ListRoles, DeleteRole, CreatePolicy, GetPolicy, DeletePolicy, AttachRolePolicy, DetachRolePolicy, PutRolePolicy, GetRolePolicy, DeleteRolePolicy, ListRolePolicies, ListAttachedRolePolicies, CreateAccessKey, ListAccessKeys, DeleteAccessKey, UpdateAccessKey, GetAccessKeyLastUsed, CreateInstanceProfile, GetInstanceProfile, DeleteInstanceProfile, AddRoleToInstanceProfile, RemoveRoleFromInstanceProfile, ListInstanceProfiles, CreateGroup, GetGroup, AddUserToGroup, RemoveUserFromGroup, CreateServiceLinkedRole, DeleteServiceLinkedRole, GetServiceLinkedRoleDeletionStatus, CreateOpenIDConnectProvider, TagRole, UntagRole, TagUser, UntagUser, TagPolicy, UntagPolicy | |
+| **IAM** | CreateUser, GetUser, ListUsers, DeleteUser, CreateRole, GetRole, ListRoles, DeleteRole, CreatePolicy, GetPolicy, DeletePolicy, AttachRolePolicy, DetachRolePolicy, PutRolePolicy, GetRolePolicy, DeleteRolePolicy, ListRolePolicies, ListAttachedRolePolicies, CreateAccessKey, ListAccessKeys, DeleteAccessKey, UpdateAccessKey, GetAccessKeyLastUsed, CreateInstanceProfile, GetInstanceProfile, DeleteInstanceProfile, AddRoleToInstanceProfile, RemoveRoleFromInstanceProfile, ListInstanceProfiles, CreateGroup, GetGroup, AddUserToGroup, RemoveUserFromGroup, CreateServiceLinkedRole, DeleteServiceLinkedRole, GetServiceLinkedRoleDeletionStatus, CreateOpenIDConnectProvider, TagRole, UntagRole, TagUser, UntagUser, TagPolicy, UntagPolicy, CreateLoginProfile, GetLoginProfile, UpdateLoginProfile, DeleteLoginProfile | |
| **STS** | GetCallerIdentity, AssumeRole, GetSessionToken, AssumeRoleWithWebIdentity | |
| **IMDS** (EC2 Instance Metadata) | `PUT /latest/api/token`, `GET /latest/meta-data/instance-id`, `GET /latest/meta-data/iam/security-credentials/`, `GET /latest/meta-data/iam/security-credentials/<role>`, `GET /latest/meta-data/iam/info`, `GET /latest/meta-data/placement/{region,availability-zone,...}`, `GET /latest/dynamic/instance-identity/document` | IMDSv1 + IMDSv2; default credential chain falls through to a `ministack-instance-role` document with `ASIA*` session creds. Point SDKs at ministack via `AWS_EC2_METADATA_SERVICE_ENDPOINT=http://localhost:4566` (or `ec2_metadata_service_endpoint` in `~/.aws/config`); set `MINISTACK_IMDS_V2_REQUIRED=1` to require the token PUT |
| **ECS Task Metadata V4** | `GET /v4/<token>`, `GET /v4/<token>/task`, `GET /v4/<token>/stats`, `GET /v4/<token>/task/stats` | Per-container token injected as `ECS_CONTAINER_METADATA_URI_V4` on every container started by `RunTask`. `/task` returns sibling containers in the same task. Containers reach the gateway via `host.docker.internal` (mapped through `extra_hosts: host-gateway`, so it works on user-defined Docker networks); `networkMode: host` containers use loopback. Volatile by design (stripped on persistence, cleared by `/_ministack/reset`) |
diff --git a/ministack/services/iam.py b/ministack/services/iam.py
index 3fb50ab2..50d2ea5e 100644
--- a/ministack/services/iam.py
+++ b/ministack/services/iam.py
@@ -55,6 +55,7 @@ _groups = AccountScopedDict()
_user_inline_policies = AccountScopedDict()
_oidc_providers = AccountScopedDict()
_service_linked_role_deletion_tasks = AccountScopedDict()
+_login_profiles = AccountScopedDict()
# -- AWS-managed policies ---------------------------------------------------
@@ -281,6 +282,7 @@ def get_state():
"service_linked_role_deletion_tasks": copy.deepcopy(_service_linked_role_deletion_tasks),
"user_inline_policies": copy.deepcopy(_user_inline_policies),
"aws_managed_attachment_counts": copy.deepcopy(_aws_managed_attachment_counts),
+ "login_profiles": copy.deepcopy(_login_profiles),
}
@@ -296,6 +298,7 @@ def restore_state(data):
_service_linked_role_deletion_tasks.update(data.get("service_linked_role_deletion_tasks", {}))
_user_inline_policies.update(data.get("user_inline_policies", {}))
_aws_managed_attachment_counts.update(data.get("aws_managed_attachment_counts", {}))
+ _login_profiles.update(data.get("login_profiles", {}))
try:
@@ -1526,6 +1529,69 @@ def _get_service_linked_role_deletion_status(p):
ns="iam")
+# -------------------- Login profiles --------------------
+
+
+def _login_profile_xml(name):
+ lp = _login_profiles[name]
+ pwr = "true" if lp.get("PasswordResetRequired") else "false"
+ return (f"<UserName>{lp['UserName']}</UserName>"
+ f"<CreateDate>{lp['CreateDate']}</CreateDate>"
+ f"<PasswordResetRequired>{pwr}</PasswordResetRequired>")
+
+
+def _create_login_profile(p):
+ name = _p(p, "UserName")
+ if name not in _users:
+ return _error(404, "NoSuchEntity",
+ f"The user with name {name} cannot be found.", ns="iam")
+ if name in _login_profiles:
+ return _error(409, "EntityAlreadyExists",
+ f"Login profile for user {name} already exists.", ns="iam")
+ _login_profiles[name] = {
+ "UserName": name,
+ "CreateDate": _now(),
+ "PasswordResetRequired": _p(p, "PasswordResetRequired", "false").lower() == "true",
+ }
+ return _xml(200, "CreateLoginProfileResponse",
+ f"<CreateLoginProfileResult>"
+ f"<LoginProfile>{_login_profile_xml(name)}</LoginProfile>"
+ f"</CreateLoginProfileResult>",
+ ns="iam")
+
+
+def _get_login_profile(p):
+ name = _p(p, "UserName")
+ if name not in _login_profiles:
+ return _error(404, "NoSuchEntity",
+ f"Login profile for user {name} cannot be found.", ns="iam")
+ return _xml(200, "GetLoginProfileResponse",
+ f"<GetLoginProfileResult>"
+ f"<LoginProfile>{_login_profile_xml(name)}</LoginProfile>"
+ f"</GetLoginProfileResult>",
+ ns="iam")
+
+
+def _update_login_profile(p):
+ name = _p(p, "UserName")
+ if name not in _login_profiles:
+ return _error(404, "NoSuchEntity",
+ f"Login profile for user {name} cannot be found.", ns="iam")
+ pwr = _p(p, "PasswordResetRequired", "")
+ if pwr:
+ _login_profiles[name]["PasswordResetRequired"] = pwr.lower() == "true"
+ return _xml(200, "UpdateLoginProfileResponse", "", ns="iam")
+
+
+def _delete_login_profile(p):
+ name = _p(p, "UserName")
+ if name not in _login_profiles:
+ return _error(404, "NoSuchEntity",
+ f"Login profile for user {name} cannot be found.", ns="iam")
+ del _login_profiles[name]
+ return _xml(200, "DeleteLoginProfileResponse", "", ns="iam")
+
+
# -------------------- OIDC providers --------------------
def _create_oidc_provider(p):
@@ -1913,6 +1979,10 @@ _IAM_HANDLERS = {
"CreateOpenIDConnectProvider": _create_oidc_provider,
"GetOpenIDConnectProvider": _get_oidc_provider,
"DeleteOpenIDConnectProvider": _delete_oidc_provider,
+ "CreateLoginProfile": _create_login_profile,
+ "GetLoginProfile": _get_login_profile,
+ "UpdateLoginProfile": _update_login_profile,
+ "DeleteLoginProfile": _delete_login_profile,
"TagPolicy": _tag_policy,
"UntagPolicy": _untag_policy,
"ListPolicyTags": _list_policy_tags,
@@ -1929,6 +1999,7 @@ def reset():
_user_inline_policies.clear()
_oidc_providers.clear()
_service_linked_role_deletion_tasks.clear()
+ _login_profiles.clear()
# Re-seed AWS-managed policies. They're not customer state, so a
# reset call should restore the canonical set rather than leave the
# store empty. Per-account attachment counters are session state
diff --git a/tests/test_iam.py b/tests/test_iam.py
index 69d3b661..d37f50d7 100644
--- a/tests/test_iam.py
+++ b/tests/test_iam.py
@@ -735,3 +735,58 @@ def test_iam_aws_managed_attachment_count_persists_through_state_round_trip():
_iam.restore_state(snapshot)
assert _iam._aws_managed_attachment_counts.get(arn) == 2
+
+
+# ── Login profiles ────────────────────────────────────────────────────
+
+
+def test_iam_create_get_login_profile(iam):
+ name = "lp-user-create-get"
+ iam.create_user(UserName=name)
+ try:
+ resp = iam.create_login_profile(UserName=name, Password="Test1234!", PasswordResetRequired=True)
+ profile = resp["LoginProfile"]
+ assert profile["UserName"] == name
+ assert "CreateDate" in profile
+ assert profile["PasswordResetRequired"] is True
+
+ resp2 = iam.get_login_profile(UserName=name)
+ assert resp2["LoginProfile"]["UserName"] == name
+ assert "CreateDate" in resp2["LoginProfile"]
+ finally:
+ try:
+ iam.delete_login_profile(UserName=name)
+ except Exception:
+ pass
+ iam.delete_user(UserName=name)
+
+
+def test_iam_get_login_profile_absent(iam):
+ name = "lp-user-absent"
+ iam.create_user(UserName=name)
+ try:
+ with pytest.raises(iam.exceptions.NoSuchEntityException):
+ iam.get_login_profile(UserName=name)
+ finally:
+ iam.delete_user(UserName=name)
+
+
+def test_iam_create_login_profile_no_user(iam):
+ with pytest.raises(iam.exceptions.NoSuchEntityException):
+ iam.create_login_profile(UserName="lp-ghost-user-xyz", Password="Test1234!")
+
+
+def test_iam_delete_login_profile(iam):
+ name = "lp-user-delete"
+ iam.create_user(UserName=name)
+ try:
+ iam.create_login_profile(UserName=name, Password="Test1234!")
+ iam.delete_login_profile(UserName=name)
+ with pytest.raises(iam.exceptions.NoSuchEntityException):
+ iam.get_login_profile(UserName=name)
+ finally:
+ try:
+ iam.delete_login_profile(UserName=name)
+ except Exception:
+ pass
+ iam.delete_user(UserName=name)