Rust SDK

Install and use the fakecloud SDK for Rust tests.

Install

cargo add fakecloud-sdk

Rust 1.75+. Async-only, built on reqwest + tokio.

Initialize

use fakecloud_sdk::FakeCloud;

let fc = FakeCloud::new("http://localhost:4566");

Every sub-client is constructed lazily via an accessor (fc.lambda(), fc.sqs(), ...). All endpoint methods are async and return Result<T, fakecloud_sdk::Error>.

Top-level

MethodDescription
health().awaitServer health check
reset().awaitReset all service state
reset_service(service).awaitReset a single service
reset_service_for_account(service, account).awaitReset one service in one account
create_admin(req).awaitCreate an admin user in another account

fc.acm()

MethodDescription
set_certificate_status(arn_or_id, req).awaitFlip a stored certificate's status (and optional failure reason)
get_certificate_chain_info(arn_or_id).awaitInspect PEM block counts and byte sizes of a stored chain
approve_certificate(arn_or_id).awaitApprove a PENDING_VALIDATION certificate

fc.apigatewayv2()

MethodDescription
get_requests().awaitList recorded HTTP API requests
connections().awaitList WebSocket connections
mtls_info(name).awaitInspect mTLS trust-store status for a domain name
ws_url(api_id, stage)Build a ws:// URL for a WebSocket API (sync)

fc.application_autoscaling()

MethodDescription
tick().awaitRe-evaluate target-tracking policies and emit scaling actions
scheduled_tick().awaitFire any scheduled actions whose time has arrived

fc.athena()

MethodDescription
get_named_queries().awaitList recorded Athena named queries

fc.bedrock()

MethodDescription
get_invocations().awaitList recorded Bedrock runtime invocations
set_model_response(model_id, text).awaitConfigure a single canned response for a model
set_response_rules(model_id, rules).awaitReplace prompt-conditional response rules for a model
clear_response_rules(model_id).awaitClear all prompt-conditional response rules for a model
queue_fault(rule).awaitQueue a fault rule (e.g. ThrottlingException) for the next N calls
get_faults().awaitList currently queued fault rules
clear_faults().awaitClear all queued fault rules

fc.bedrock_agent()

MethodDescription
get_agents().awaitList configured Bedrock agents

fc.bedrock_agent_runtime()

MethodDescription
get_invocations().awaitList recorded Bedrock Agent runtime invocations

fc.cloudfront()

MethodDescription
set_distribution_status(id, req).awaitOverride a CloudFront distribution's deployment status

fc.cognito()

MethodDescription
get_user_codes(pool_id, username).awaitPending confirmation codes for a specific user
get_confirmation_codes().awaitList all pending confirmation codes
confirm_user(pool_id, username).awaitForce-confirm a user
get_tokens().awaitList currently active tokens
expire_tokens(req).awaitExpire tokens for a pool/user
get_auth_events().awaitList recorded auth events
get_pre_token_gen_invocations().awaitList Pre-Token-Generation Lambda invocations
mint_authorization_code(req).awaitMint an OAuth2 authorization code without a real browser
set_compromised_passwords(req).awaitSeed the compromised-credentials list
get_webauthn_credentials().awaitList registered WebAuthn credentials

fc.dynamodb()

MethodDescription
tick_ttl().awaitTick the DynamoDB TTL processor

fc.ecr()

MethodDescription
get_images().awaitList stored ECR images
get_repositories().awaitList ECR repositories
get_pull_through_rules().awaitList pull-through cache rules

fc.ecs()

MethodDescription
get_clusters().awaitList ECS clusters with task counts
get_tasks(filter).awaitList tasks, optionally filtered by cluster / family / status
get_task_logs(task_id).awaitFetch captured stdout/stderr for a task
force_stop_task(task_id).awaitForce a task into STOPPED
mark_task_failed(task_id, req).awaitMark a task failed with a custom reason / exit code
get_events().awaitList ECS service / task lifecycle events
get_metadata_by_arn(task_arn).awaitFetch task metadata by full ARN
task_credentials(task_id).awaitFetch IAM credentials served to the task
task_metadata_v3(task_id).awaitTask Metadata Endpoint v3 payload
task_metadata_v4(task_id).awaitTask Metadata Endpoint v4 payload

fc.elasticache()

MethodDescription
get_clusters().awaitList ElastiCache clusters
get_replication_groups().awaitList replication groups
get_serverless_caches().awaitList serverless caches
get_acls().awaitList RBAC ACLs

fc.elbv2()

MethodDescription
get_load_balancers().awaitList ALB / NLB / GWLB load balancers
get_listeners().awaitList listeners across load balancers
get_rules().awaitList listener rules
get_target_groups().awaitList target groups
flush_access_logs().awaitFlush buffered access-log entries
waf_counts().awaitInspect WAF allow/block counters

fc.events()

MethodDescription
get_history().awaitGet event history and delivery records
fire_rule(req).awaitFire an EventBridge rule manually

fc.glue()

MethodDescription
get_jobs().awaitList configured Glue jobs
get_job_runs(job_name).awaitList job runs, optionally for one job

fc.kms()

MethodDescription
usage().awaitKMS key usage counters (encrypt/decrypt/sign/etc)

fc.lambda()

MethodDescription
get_invocations().awaitList recorded Lambda invocations
get_warm_containers().awaitList warm (cached) Lambda containers
evict_container(function_name).awaitEvict a warm container
download_function_code(function_name).awaitDownload the uploaded function zip
download_layer_content(layer_name, ver).awaitDownload a layer version's content

fc.logs()

MethodDescription
inject_anomaly(req).awaitInject a synthetic CloudWatch Logs anomaly
get_delivery_config().awaitInspect log-delivery configuration
get_field_indexes(group).awaitInspect field indexes for a log group

fc.organizations()

MethodDescription
get_accounts().awaitList Organizations member accounts

fc.rds()

MethodDescription
get_instances().awaitList managed RDS instances with runtime metadata
lambda_invoke(req).awaitInvoke a Lambda via the aws_lambda PG extension bridge
s3_import(req).awaitSimulate the aws_s3.table_import_from_s3 extension call
s3_export(req).awaitSimulate the aws_s3.query_export_to_s3 extension call

fc.route53()

MethodDescription
dnssec_material(hosted_zone_id).awaitInspect DNSSEC key-signing material
dnssec_sign(hosted_zone_id, req).awaitSign a payload with the zone's KSK
set_health_check_status(id, req).awaitOverride a health check's status

fc.s3()

MethodDescription
get_notifications().awaitList S3 notification events
tick_lifecycle().awaitTick the lifecycle processor
get_access_points().awaitList S3 access points
get_object_lambda_responses().awaitList Object Lambda transformed responses

fc.scheduler()

MethodDescription
get_schedules().awaitList EventBridge Scheduler schedules
fire_schedule(name, group).awaitFire a schedule immediately

fc.secretsmanager()

MethodDescription
tick_rotation().awaitTick the rotation scheduler

fc.ses()

MethodDescription
get_emails().awaitList all sent emails
simulate_inbound(req).awaitSimulate an inbound email (receipt rules)
get_metrics().awaitAggregate send / bounce / complaint counters
get_bounces().awaitList recorded bounces
set_sandbox(enabled).awaitToggle SES sandbox mode
get_event_destination_deliveries().awaitList event-destination delivery records
get_dkim_public_key(domain).awaitFetch the public DKIM key for a domain
set_mail_from_status(req).awaitOverride a domain's MAIL-FROM verification status
get_message_insights(message_id).awaitFetch message-insights breakdown for a message
get_smtp_submissions().awaitList inbound SMTP submission records

fc.sns()

MethodDescription
get_messages().awaitList all published messages
get_pending_confirmations().awaitList subscriptions pending confirmation
confirm_subscription(req).awaitConfirm a pending subscription
cert_pem().awaitFetch the PEM used to sign SNS HTTP/S deliveries
sms().awaitList recorded SMS deliveries

fc.sqs()

MethodDescription
get_messages().awaitList all messages across all queues
tick_expiration().awaitTick the message expiration processor
force_dlq(queue_name).awaitForce all messages to the queue's DLQ

fc.ssm()

MethodDescription
set_command_status(command_id, req).awaitOverride an SSM Run Command's status
fail_command(command_id, req).awaitMark an SSM Run Command failed with a reason
parameter_policy_events().awaitList parameter-policy expiration / notification events
inject_session(req).awaitInject a synthetic SSM Session

fc.stepfunctions()

MethodDescription
get_executions().awaitList standard executions
get_sync_executions().awaitList Express sync executions
enqueue_activity_task(req).awaitEnqueue a task for an activity worker
get_execution_tree(execution_arn).awaitFetch a nested execution tree

fc.wafv2()

MethodDescription
evaluate(body).awaitEvaluate a request against configured WAFv2 rules

Error handling

All methods return Result<T, fakecloud_sdk::Error>. Error has two variants:

use fakecloud_sdk::{FakeCloud, Error};

let fc = FakeCloud::new("http://localhost:4566");
match fc.cognito().confirm_user("pool-1", "nobody").await {
    Ok(_) => {}
    Err(Error::Api { status, body }) => {
        println!("status {status}, body {body}");
    }
    Err(Error::Http(e)) => eprintln!("transport: {e}"),
}

Example: end-to-end test

use aws_sdk_sqs::Client;
use aws_config::BehaviorVersion;
use fakecloud_sdk::FakeCloud;

#[tokio::test]
async fn app_publishes_to_sqs() {
    let fc = FakeCloud::new("http://localhost:4566");
    fc.reset().await.unwrap();

    let config = aws_config::defaults(BehaviorVersion::latest())
        .endpoint_url("http://localhost:4566")
        .region("us-east-1")
        .load()
        .await;
    let sqs = Client::new(&config);

    sqs.send_message()
        .queue_url("http://localhost:4566/000000000000/my-queue")
        .message_body("hello")
        .send()
        .await
        .unwrap();

    let resp = fc.sqs().get_messages().await.unwrap();
    assert_eq!(resp.messages.len(), 1);
    assert_eq!(resp.messages[0].body, "hello");
}

Source