### Install fakecloud SDK for Go Source: https://fakecloud.dev/docs/getting-started/sdk-setup Use go get to install the fakecloud SDK for Go. ```bash go get github.com/faiscadev/fakecloud/sdks/goCopy ``` -------------------------------- ### Install fakecloud via Script Source: https://fakecloud.dev/docs/getting-started/install Recommended method for quick installation. Downloads the latest release and adds the binary to your PATH. ```bash curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash ``` -------------------------------- ### Start FakeCloud Source: https://fakecloud.dev/docs/getting-started/first-test Start the fakecloud service. It listens on http://localhost:4566. Leave it running in a terminal. ```bash fakecloudCopy ``` -------------------------------- ### Start fakecloud Service Source: https://fakecloud.dev/docs/services/organizations Starts the fakecloud service. This is a basic command to initiate the service. ```bash fakecloud & ``` -------------------------------- ### Start fakecloud with Docker Compose Source: https://fakecloud.dev/docs/getting-started/install Start the fakecloud service defined in docker-compose.yml. ```bash docker compose up ``` -------------------------------- ### Install fakecloud SDK for PHP Source: https://fakecloud.dev/docs/getting-started/sdk-setup Use composer to install the fakecloud SDK for PHP. ```bash composer require fakecloud/fakecloudCopy ``` -------------------------------- ### Installation Source: https://fakecloud.dev/docs/sdks/php Install the fakecloud SDK for PHP using Composer. Requires PHP 8.1+ and uses the built-in `curl` extension. ```APIDOC ## Install ``` composer require fakecloud/fakecloud ``` Requires PHP 8.1+. Uses the built-in `curl` extension and `json_decode`/`json_encode`. No external dependencies. ``` -------------------------------- ### Full Test Loop Example Source: https://fakecloud.dev/docs/sdks/typescript An example demonstrating a full test loop, including publishing a message to SQS and verifying it using the fakecloud SDK. ```typescript import { FakeCloud } from "fakecloud"; import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs"; const fc = new FakeCloud(); const sqs = new SQSClient({ endpoint: "http://localhost:4566", region: "us-east-1", credentials: { accessKeyId: "test", secretAccessKey: "test" }, }); beforeEach(() => fc.reset()); test("app publishes to SQS", async () => { await sqs.send(new SendMessageCommand({ QueueUrl: "http://localhost:4566/000000000000/my-queue", MessageBody: "hello", })); const { messages } = await fc.sqs.getMessages(); expect(messages).toHaveLength(1); expect(messages[0].body).toBe("hello"); });Copy ``` -------------------------------- ### Install fakecloud SDK for Python Source: https://fakecloud.dev/docs/getting-started/sdk-setup Use pip to install the fakecloud SDK for Python. ```bash pip install fakecloudCopy ``` -------------------------------- ### Full Test Loop Example Source: https://fakecloud.dev/docs/sdks/php An example demonstrating a typical test loop using the fakecloud SDK, including setting response rules, classifying messages, and checking invocations, as well as simulating and handling throttling errors. ```APIDOC ## Example: full test loop ```php use FakeCloud\FakeCloud; use FakeCloud\BedrockFaultRule; use FakeCloud\BedrockResponseRule; $fc = new FakeCloud(); $modelId = 'anthropic.claude-3-haiku-20240307-v1:0'; // PHPUnit setUp $fc->reset(); // Test: classifier branches on spam vs ham $fc->bedrock()->setResponseRules($modelId, [ new BedrockResponseRule('buy now', '{"label":"spam"}'), new BedrockResponseRule(null, '{"label":"ham"}'), ]); classify('hello friend'); classify('buy now cheap pills'); $invocations = $fc->bedrock()->getInvocations()->invocations; $this->assertCount(2, $invocations); $this->assertStringContainsString('ham', $invocations[0]->output); $this->assertStringContainsString('spam', $invocations[1]->output); // Test: retries on throttling $fc->reset(); $fc->bedrock()->queueFault( new BedrockFaultRule('ThrottlingException', 'Rate exceeded', 429, 1) ); classify('hello'); $invocations = $fc->bedrock()->getInvocations()->invocations; $this->assertCount(2, $invocations); $this->assertStringContainsString('ThrottlingException', $invocations[0]->error); $this->assertNull($invocations[1]->error); ``` ``` -------------------------------- ### Initialize fakecloud client (async) Source: https://fakecloud.dev/docs/sdks/python Initialize the asynchronous fakecloud client using an async context manager. This example also shows how to reset the service state. ```python from fakecloud import AsyncFakeCloud async with AsyncFakeCloud() as fc: await fc.reset()Copy ``` -------------------------------- ### Install fakecloud with Cargo Source: https://fakecloud.dev/docs/getting-started/install Install fakecloud using Cargo, the Rust package manager. Requires Rust and Cargo to be installed. ```rust cargo install fakecloud ``` -------------------------------- ### Install fakecloud SDK for PHP Source: https://fakecloud.dev/docs/sdks/php Use Composer to install the fakecloud SDK. Requires PHP 8.1+ and uses built-in PHP extensions. ```bash composer require fakecloud/fakecloud ``` -------------------------------- ### Install fakecloud SDK for TypeScript Source: https://fakecloud.dev/docs/getting-started/sdk-setup Use npm to install the fakecloud SDK for TypeScript. ```bash npm install fakecloudCopy ``` -------------------------------- ### Example: End-to-end Test Source: https://fakecloud.dev/docs/sdks/rust An example demonstrating an end-to-end test scenario involving publishing a message to SQS and verifying it using the fakecloud SDK. ```APIDOC use aws_sdk_sqs::Client; use aws_config::BehaviorVersion; use fakecloud_sdk::FakeCloudClient; #[tokio::test] async fn app_publishes_to_sqs() { let fc = FakeCloudClient::default(); 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 messages = fc.sqs().get_messages().await.unwrap(); assert_eq!(messages.len(), 1); assert_eq!(messages[0].body, "hello"); } ``` -------------------------------- ### Install fakecloud CLI Source: https://fakecloud.dev/docs Installs the fakecloud CLI using a curl script. No Cargo or Docker is required. ```bash $ curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash $ fakecloud ``` -------------------------------- ### Pytest Fixture Example Source: https://fakecloud.dev/docs/sdks/python Example of using a pytest fixture to initialize the FakeCloud client and reset its state after each test. ```APIDOC ## Example: pytest fixture ``` import pytest import boto3 from fakecloud import FakeCloud @pytest.fixture def fc(): client = FakeCloud() yield client client.reset() @pytest.fixture def sqs(): return boto3.client( "sqs", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test", ) def test_app_publishes_to_sqs(fc, sqs): sqs.send_message( QueueUrl="http://localhost:4566/000000000000/my-queue", MessageBody="hello", ) messages = fc.sqs.get_messages() assert len(messages) == 1 assert messages[0].body == "hello"Copy ``` ``` -------------------------------- ### End-to-end Test Example Source: https://fakecloud.dev/docs/sdks/go An example of an end-to-end test demonstrating how to use the fakecloud Go SDK with AWS SDK for Go v2 to test an application that publishes to SQS. ```APIDOC ## Example: end-to-end test ``` package main_test import ( "context" "testing" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/sqs" "github.com/faiscadev/fakecloud/sdks/go/fakecloud" ) func TestAppPublishesToSQS(t *testing.T) { fc := fakecloud.NewDefault() if err := fc.Reset(); err != nil { t.Fatal(err) } cfg, _ := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-east-1"), config.WithCredentialsProvider(aws.AnonymousCredentials{}), ) sqsClient := sqs.NewFromConfig(cfg, func(o *sqs.Options) { o.BaseEndpoint = aws.String("http://localhost:4566") }) _, err := sqsClient.SendMessage(context.TODO(), &sqs.SendMessageInput{ QueueUrl: aws.String("http://localhost:4566/000000000000/my-queue"), MessageBody: aws.String("hello"), }) if err != nil { t.Fatal(err) } messages, err := fc.SQS.GetMessages() if err != nil { t.Fatal(err) } if len(messages) != 1 { t.Fatalf("expected 1 message, got %d", len(messages)) } if messages[0].Body != "hello" { t.Fatalf("expected body 'hello', got %q", messages[0].Body) } }Copy ``` ``` -------------------------------- ### Cursor Rules for fakecloud Source: https://fakecloud.dev/docs/guides/ai-coding-tools Place this in `.cursor/rules` to guide Cursor in using fakecloud for AWS integration tests. It includes installation, running the emulator, and credential setup. ```plaintext For AWS integration tests, use fakecloud (local AWS emulator) at http://localhost:4566. Install: curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash Run: fakecloud Use dummy credentials (access_key=test, secret_key=test). Do not mock the AWS SDK. Use the real SDK against fakecloud. Docs: https://fakecloud.dev/llms.txtCopy ``` -------------------------------- ### Get Glue Job Runs Source: https://fakecloud.dev/docs/services/glue Retrieves all JobRuns recorded by StartJobRun. This endpoint returns details about each job run, including its ID, job name, attempt number, start and completion times, state, arguments, and execution time. It supports filtering by job name. ```APIDOC ## GET /_fakecloud/glue/job-runs ### Description Retrieves all `JobRun` records created by `StartJobRun`. This endpoint returns details for each job run, including its ID, job name, attempt number, start and completion times, state, arguments, and execution time. It accepts an optional `?job_name=foo` query parameter to filter results for a specific job. ### Method GET ### Endpoint `/_fakecloud/glue/job-runs` ### Parameters #### Query Parameters - **job_name** (string) - Optional - Filters the job runs to a specific job name. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the job run. - **jobName** (string) - The name of the job associated with this run. - **attempt** (integer) - The attempt number for this job run. - **startedOn** (string) - Timestamp when the job run started. - **completedOn** (string) - Timestamp when the job run completed. - **jobRunState** (string) - The state of the job run (e.g., SUCCEEDED, FAILED). - **arguments** (object) - Arguments passed to the job run. - **executionTime** (integer) - The duration of the job run in milliseconds. ``` -------------------------------- ### Create Glue Database and Table for Athena Source: https://fakecloud.dev/docs/services/athena Use these commands to set up a Glue database and a table with specified columns and location, preparing it for querying with Athena. ```bash aws --endpoint-url http://localhost:4566 glue create-database \ --database-input Name=analytics ``` ```bash aws --endpoint-url http://localhost:4566 glue create-table \ --database-name analytics \ --table-input 'Name=events,StorageDescriptor={Columns=[{Name=id,Type=string},{Name=ts,Type=string}],Location=s3://my-bucket/events/}' ``` -------------------------------- ### Create ALB, Target Group, Listener, and Register Target Source: https://fakecloud.dev/docs/services/elbv2 This sequence of commands demonstrates the basic setup for an Application Load Balancer (ALB) using Fakecloud's elbv2 commands. It includes creating the ALB, a target group, wiring a listener to the target group, and registering a target instance. ```bash LB=$(aws --endpoint-url http://localhost:4566 elbv2 create-load-balancer \ --name web-alb --type application \ --subnets subnet-aaa subnet-bbb \ --query 'LoadBalancers[0].LoadBalancerArn' --output text) TG=$(aws --endpoint-url http://localhost:4566 elbv2 create-target-group \ --name web-tg --protocol HTTP --port 80 --vpc-id vpc-12345 \ --target-type instance \ --query 'TargetGroups[0].TargetGroupArn' --output text) aws --endpoint-url http://localhost:4566 elbv2 create-listener \ --load-balancer-arn "$LB" --protocol HTTP --port 80 \ --default-actions Type=forward,TargetGroupArn=$TG aws --endpoint-url http://localhost:4566 elbv2 register-targets \ --target-group-arn "$TG" --targets Id=i-deadbeef,Port=80 ``` ```bash aws --endpoint-url http://localhost:4566 elbv2 describe-target-health \ --target-group-arn "$TG" ``` -------------------------------- ### Full Test Loop Example Source: https://fakecloud.dev/docs/sdks/java Demonstrates a complete test scenario using FakeCloud, including Bedrock response rules, invocation assertions, and fault queuing. ```java import dev.fakecloud.FakeCloud; import dev.fakecloud.Types.BedrockFaultRule; import dev.fakecloud.Types.BedrockResponseRule; import java.util.List; FakeCloud fc = new FakeCloud(); String modelId = "anthropic.claude-3-haiku-20240307-v1:0"; @BeforeEach void reset() { fc.reset(); } @Test void classifierBranchesOnSpamVsHam() { fc.bedrock().setResponseRules(modelId, List.of( new BedrockResponseRule("buy now", "{\"label\":\"spam\"}"), new BedrockResponseRule(null, "{\"label\":\"ham\"}"))); classify("hello friend"); classify("buy now cheap pills"); var invocations = fc.bedrock().getInvocations().invocations(); assertEquals(2, invocations.size()); assertTrue(invocations.get(0).output().contains("ham")); assertTrue(invocations.get(1).output().contains("spam")); } @Test void retriesOnThrottlingException() { fc.bedrock().queueFault(new BedrockFaultRule( "ThrottlingException", "Rate exceeded", 429, 1, null, null)); classify("hello"); var invocations = fc.bedrock().getInvocations().invocations(); assertEquals(2, invocations.size()); assertTrue(invocations.get(0).error().contains("ThrottlingException")); assertNull(invocations.get(1).error()); } ``` -------------------------------- ### Bootstrap IAM User and Test Permissions Source: https://fakecloud.dev/docs/reference/security Demonstrates bootstrapping a user with root credentials, attaching a resource-scoped policy, and testing access. This example requires fakecloud to be running with IAM enforcement enabled. ```bash # Start fakecloud with enforcement on. FAKECLOUD_VERIFY_SIGV4=true FAKECLOUD_IAM=strict ./fakecloud # Root-bypass bootstrap. AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test \ aws --endpoint-url http://localhost:4566 iam create-user --user-name alice AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test \ aws --endpoint-url http://localhost:4566 iam create-access-key --user-name alice # -> emits AKIA..., SECRET... AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test \ aws --endpoint-url http://localhost:4566 iam put-user-policy \ --user-name alice \ --policy-name ReadSelf \ --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"iam:GetUser","Resource":"arn:aws:iam::123456789012:user/alice"}]}' # Alice can read herself... AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= \ aws --endpoint-url http://localhost:4566 iam get-user --user-name alice # -> success # ...but not anyone else. AWS_ACCESS_KEY_ID= AWS_SECRET_ACCESS_KEY= \ aws --endpoint-url http://localhost:4566 iam get-user --user-name root # -> AccessDeniedException ``` -------------------------------- ### Build and Run fakecloud from Source Source: https://fakecloud.dev/docs/getting-started/install Clone the repository, navigate to the directory, and build/run the release binary using Cargo. This method is suitable for development or when needing the latest unreleased changes. ```bash git clone https://github.com/faiscadev/fakecloud.git cd fakecloud cargo run --release --bin fakecloud ``` -------------------------------- ### Initialize fakecloud SDK in Python Source: https://fakecloud.dev/docs/getting-started/sdk-setup Initialize the FakeCloud client and perform a reset and email retrieval. ```python from fakecloud import FakeCloud fc = FakeCloud() fc.reset() emails = fc.ses.get_emails()Copy ``` -------------------------------- ### Initialize fakecloud SDK in PHP Source: https://fakecloud.dev/docs/sdks/php Instantiate the FakeCloud client. It defaults to http://localhost:4566 or can be configured with an explicit base URL. ```php use FakeCloud\FakeCloud; $fc = new FakeCloud(); // defaults to http://localhost:4566 $fc = new FakeCloud('http://localhost:5000'); // explicit base URL ``` -------------------------------- ### Initialize fakecloud SDK in Python (Async) Source: https://fakecloud.dev/docs/getting-started/sdk-setup Initialize the AsyncFakeCloud client for asynchronous operations, performing a reset and email retrieval. ```python from fakecloud import AsyncFakeCloud async with AsyncFakeCloud() as fc: await fc.reset() emails = await fc.ses.get_emails()Copy ``` -------------------------------- ### Initialize fakecloud SDK in Go Source: https://fakecloud.dev/docs/getting-started/sdk-setup Initialize the fakecloud client with a specific endpoint and perform a reset and email retrieval. ```go import "github.com/faiscadev/fakecloud/sdks/go/fakecloud" fc := fakecloud.New("http://localhost:4566") fc.Reset() emails, _ := fc.SES.GetEmails()Copy ``` -------------------------------- ### Verify fakecloud Installation Source: https://fakecloud.dev/docs/getting-started/install Check if fakecloud is running by sending a request to its health endpoint on the default port 4566. A JSON response indicates a successful installation. ```bash curl http://localhost:4566/_fakecloud/health ``` -------------------------------- ### Initialize Fakecloud Go Client Source: https://fakecloud.dev/docs/sdks/go Instantiate the Fakecloud client using either a custom URL or the default localhost address. ```go import "github.com/faiscadev/fakecloud/sdks/go/fakecloud" fc := fakecloud.New("http://localhost:4566") // or with default URL: fc := fakecloud.NewDefault() // http://localhost:4566Copy ``` -------------------------------- ### Initialize fakecloud SDK in PHP Source: https://fakecloud.dev/docs/getting-started/sdk-setup Initialize the FakeCloud client and perform a reset and email retrieval. Defaults to http://localhost:4566. ```php use FakeCloud\FakeCloud; $fc = new FakeCloud(); // defaults to http://localhost:4566 $fc->reset(); $emails = $fc->ses()->getEmails()->emails;Copy ``` -------------------------------- ### Get Account Configuration Source: https://fakecloud.dev/docs/services/acm Retrieves the account-wide configuration settings for ACM. ```APIDOC ## GetAccountConfiguration ### Description Retrieves the account-wide configuration settings for AWS Certificate Manager (ACM), including the configured number of days before certificate expiry for notifications. ### Method GET ### Endpoint /account-configuration ### Response #### Success Response (200) - **ExpiryEvents** (object) - Configuration for expiry event notifications. - **DaysBeforeExpiry** (integer) - The number of days before certificate expiry to send notifications. #### Response Example ```json { "ExpiryEvents": { "DaysBeforeExpiry": 30 } } ``` ``` -------------------------------- ### Record Operations Source: https://fakecloud.dev/docs/services/kinesis Operations for putting and getting records from Kinesis data streams. ```APIDOC ## PutRecord ### Description Writes a single data record into an enhanced Kinesis data stream from your data producer application. ### Method POST ### Endpoint /records ### Parameters #### Query Parameters - **StreamName** (string) - Required - The name of the stream to put the record into. - **PartitionKey** (string) - Required - Identifies the stream where the data record is stored. - **Data** (string) - Required - The data blob to put into the stream. - **ExplicitHashKey** (string) - Optional - The hash value for the partition key. ### Request Example ```json { "StreamName": "my-stream", "PartitionKey": "partition-1", "Data": "SGVsbG8gV29ybGQh" } ``` ### Response #### Success Response (200) - **SequenceNumber** (string) - The sequence number of the record. - **ShardId** (string) - The ID of the shard that the record was put into. #### Response Example ```json { "SequenceNumber": "49590338271490256608559692537010507922795858873322375714", "ShardId": "shardId-000000000000" } ``` ``` ```APIDOC ## PutRecords ### Description Writes multiple data records into a Kinesis data stream in a single call. ### Method POST ### Endpoint /records/batch ### Parameters #### Query Parameters - **StreamName** (string) - Required - The name of the stream to put the records into. #### Request Body - **Records** (array) - Required - An array of record objects. - **PartitionKey** (string) - Required - The partition key for the record. - **Data** (string) - Required - The data blob for the record. - **ExplicitHashKey** (string) - Optional - The hash value for the partition key. ### Request Example ```json { "StreamName": "my-stream", "Records": [ { "PartitionKey": "partition-1", "Data": "SGVsbG8gV29ybGQh" }, { "PartitionKey": "partition-2", "Data": "V2VsY29tZSB0byBLSW5pc2lzIQ==" } ] } ``` ### Response #### Success Response (200) - **Records** (array) - An array of results for each record put. - **SequenceNumber** (string) - The sequence number of the record. - **ShardId** (string) - The ID of the shard that the record was put into. - **FailedPutRecordCount** (integer) - The number of records that failed to be put. #### Response Example ```json { "Records": [ { "SequenceNumber": "49590338271490256608559692537010507922795858873322375714", "ShardId": "shardId-000000000000" }, { "SequenceNumber": "49590338271490256608559692537010507922795858873322375715", "ShardId": "shardId-000000000000" } ], "FailedPutRecordCount": 0 } ``` ``` ```APIDOC ## GetRecords ### Description Retrieves data records from a Kinesis data stream. ### Method GET ### Endpoint /records ### Parameters #### Query Parameters - **ShardIterator** (string) - Required - The shard iterator that defines the position in the shard from which to begin reading records. - **Limit** (integer) - Optional - The maximum number of data records to return. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **Records** (array) - A list of data records. - **Data** (string) - The data blob. - **PartitionKey** (string) - The partition key. - **SequenceNumber** (string) - The sequence number. - **NextShardIterator** (string) - The iterator to use for the next call to GetRecords. #### Response Example ```json { "Records": [ { "Data": "SGVsbG8gV29ybGQh", "PartitionKey": "partition-1", "SequenceNumber": "49590338271490256608559692537010507922795858873322375714" } ], "NextShardIterator": "aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789" } ``` ``` ```APIDOC ## GetShardIterator ### Description Creates a shard iterator for the specified shard and starting point. ### Method GET ### Endpoint /shards/{ShardId}/iterator ### Parameters #### Path Parameters - **ShardId** (string) - Required - The shard ID. #### Query Parameters - **StreamName** (string) - Required - The name of the stream. - **ShardIteratorType** (string) - Required - The type of shard iterator to create (e.g., AT_SEQUENCE_NUMBER, AFTER_SEQUENCE_NUMBER, TRIM_HORIZON, LATEST). - **StartingSequenceNumber** (string) - Optional - The sequence number to start from (required if ShardIteratorType is AFTER_SEQUENCE_NUMBER). ### Request Example ```json {} ``` ### Response #### Success Response (200) - **ShardIterator** (string) - The shard iterator. #### Response Example ```json { "ShardIterator": "aBcDeFgHiJkLmNoPqRsTuVwXyZ0123456789" } ``` ``` -------------------------------- ### Initialize fakecloud client (sync) Source: https://fakecloud.dev/docs/sdks/python Initialize the synchronous fakecloud client. It defaults to http://localhost:4566, but you can specify a different endpoint. ```python from fakecloud import FakeCloud fc = FakeCloud() # defaults to http://localhost:4566 # or fc = FakeCloud("http://localhost:5000")Copy ``` -------------------------------- ### Full Test Loop Example with fakecloud PHP SDK Source: https://fakecloud.dev/docs/sdks/php Demonstrates a complete test scenario using the fakecloud PHP SDK, including setting Bedrock response rules, classifying text, queuing faults for retries, and asserting invocation results. ```php use FakeCloud\FakeCloud; use FakeCloud\BedrockFaultRule; use FakeCloud\BedrockResponseRule; $fc = new FakeCloud(); $modelId = 'anthropic.claude-3-haiku-20240307-v1:0'; // PHPUnit setUp $fc->reset(); // Test: classifier branches on spam vs ham $fc->bedrock()->setResponseRules($modelId, [ new BedrockResponseRule('buy now', '{"label":"spam"}'), new BedrockResponseRule(null, '{"label":"ham"}'), ]); classify('hello friend'); classify('buy now cheap pills'); $invocations = $fc->bedrock()->getInvocations()->invocations; $this->assertCount(2, $invocations); $this->assertStringContainsString('ham', $invocations[0]->output); $this->assertStringContainsString('spam', $invocations[1]->output); // Test: retries on throttling $fc->reset(); $fc->bedrock()->queueFault( new BedrockFaultRule('ThrottlingException', 'Rate exceeded', 429, 1) ); classify('hello'); $invocations = $fc->bedrock()->getInvocations()->invocations; $this->assertCount(2, $invocations); $this->assertStringContainsString('ThrottlingException', $invocations[0]->error); $this->assertNull($invocations[1]->error); ``` -------------------------------- ### Get S3 Bucket Notifications Source: https://fakecloud.dev/docs/reference/introspection Retrieves all captured S3 bucket notification events. ```APIDOC ## GET /_fakecloud/s3/notifications ### Description All bucket notification events captured. ### Method GET ### Endpoint `/_fakecloud/s3/notifications` ``` -------------------------------- ### Get Certificate Source: https://fakecloud.dev/docs/services/acm Retrieves the PEM-encoded certificate chain and the certificate body for a given certificate ARN. ```APIDOC ## GetCertificate ### Description Retrieves the PEM-encoded certificate chain and the certificate body for a given certificate ARN. This is useful for retrieving the actual certificate content after it has been issued. ### Method POST ### Endpoint /certificates/{certificateArn}/download ### Parameters #### Path Parameters - **certificateArn** (string) - Required - The ARN of the certificate to retrieve. ### Response #### Success Response (200) - **CertificateBody** (string) - The PEM-encoded certificate body. - **CertificateChain** (string) - The PEM-encoded certificate chain. #### Response Example ```json { "CertificateBody": "-----BEGIN CERTIFICATE-----\nMIID...\n-----END CERTIFICATE-----", "CertificateChain": "-----BEGIN CERTIFICATE-----\nMIID...\n-----END CERTIFICATE-----" } ``` ``` -------------------------------- ### Smoke Test for AWS Glue Control Plane Source: https://fakecloud.dev/docs/services/glue This example demonstrates creating a database, table, registering partitions, pruning them with an expression, and managing jobs and job runs using the AWS CLI with fakecloud. ```bash fakecloud & aws --endpoint-url http://localhost:4566 glue create-database \ --database-input Name=analytics aws --endpoint-url http://localhost:4566 glue create-table \ --database-name analytics \ --table-input 'Name=events,PartitionKeys=[{Name=dt,Type=string}],StorageDescriptor={Columns=[{Name=id,Type=string}],Location=s3://my-bucket/events/}' # Register a few partitions, then prune them server-side. for d in 2026-05-09 2026-05-10 2026-05-11; do aws --endpoint-url http://localhost:4566 glue create-partition \ --database-name analytics --table-name events \ --partition-input Values=$d,StorageDescriptor={Location=s3://my-bucket/events/dt=$d/} done aws --endpoint-url http://localhost:4566 glue get-partitions \ --database-name analytics --table-name events \ --expression "dt >= '2026-05-10'" # Job + JobRun control plane. aws --endpoint-url http://localhost:4566 glue create-job \ --name daily-rollup \ --role arn:aws:iam::000000000000:role/glue \ --command Name=glueetl,ScriptLocation=s3://my-bucket/scripts/rollup.py,PythonVersion=3 \ --glue-version 4.0 RUN_ID=$(aws --endpoint-url http://localhost:4566 glue start-job-run \ --job-name daily-rollup --query 'JobRunId' --output text) aws --endpoint-url http://localhost:4566 glue get-job-run \ --job-name daily-rollup --run-id $RUN_IDCopy ``` -------------------------------- ### Lambda Evict Container Source: https://fakecloud.dev/docs/reference/introspection Forces a cold start by evicting warm containers for a specific Lambda function. ```APIDOC ## POST /_fakecloud/lambda/{function_name}/evict-container ### Description Force a cold start by evicting warm containers. ### Method POST ### Endpoint `/_fakecloud/lambda/{function_name}/evict-container` ### Parameters #### Path Parameters - **function_name** (string) - Required - The name of the Lambda function. ``` -------------------------------- ### Deploy CloudFormation Stack with FakeCloud Source: https://fakecloud.dev/docs/services/cloudformation This example demonstrates how to create a CloudFormation stack using a YAML template and the AWS CLI against a FakeCloud endpoint. Ensure FakeCloud is running before executing. ```bash fakecloud & cat > template.yaml <<'YAML' AWSTemplateFormatVersion: '2010-09-09' Parameters: Stage: Type: String AllowedValues: [dev, prod] Default: dev Conditions: IsProd: !Equals [!Ref Stage, prod] Resources: Queue: Type: AWS::SQS::Queue Properties: QueueName: !Sub orders-${Stage} VisibilityTimeout: !If [IsProd, 300, 30] Outputs: QueueUrl: Value: !Ref Queue Export: Name: !Sub orders-url-${Stage} YAML aws --endpoint-url http://localhost:4566 cloudformation create-stack \ --stack-name orders --template-body file://template.yaml \ --parameters ParameterKey=Stage,ParameterValue=prod aws --endpoint-url http://localhost:4566 cloudformation describe-stack-events \ --stack-name orders aws --endpoint-url http://localhost:4566 cloudformation list-exports ``` -------------------------------- ### Get SES Event Destination Deliveries Source: https://fakecloud.dev/docs/reference/introspection Logs all events dispatched to a configured SES event destination. ```APIDOC ## GET /_fakecloud/ses/event-destinations/deliveries ### Description Log of every event dispatched to a configured event destination. ### Method GET ### Endpoint `/_fakecloud/ses/event-destinations/deliveries` ``` -------------------------------- ### Initialization Source: https://fakecloud.dev/docs/sdks/php Initialize the fakecloud SDK client. You can use the default base URL or specify a custom one. ```APIDOC ## Initialize ```php use FakeCloud\FakeCloud; $fc = new FakeCloud(); // defaults to http://localhost:4566 $fc = new FakeCloud('http://localhost:5000'); // explicit base URL ``` ``` -------------------------------- ### Get SES SMTP Submissions Source: https://fakecloud.dev/docs/reference/introspection Lists messages accepted via the SES SMTP submission listener. ```APIDOC ## GET /_fakecloud/ses/smtp/submissions ### Description Messages accepted via the SMTP submission listener. ### Method GET ### Endpoint `/_fakecloud/ses/smtp/submissions` ``` -------------------------------- ### Query Execution Operations Source: https://fakecloud.dev/docs/services/athena Control and monitor the execution of SQL queries, including starting, stopping, and retrieving results. ```APIDOC ## Query Execution Operations ### StartQueryExecution Starts the execution of a SQL query. Supports `SELECT`, `SHOW DATABASES`, `SHOW TABLES`, `DESCRIBE`, and parameter substitution for prepared statements. Complex queries fall back to a single-row result. ### StopQueryExecution Stops the execution of a running query, setting its state to `CANCELLED`. ### BatchGetQueryExecution Retrieves the status of multiple query executions. ### GetQueryRuntimeStatistics Retrieves runtime statistics for a query execution. ``` -------------------------------- ### Start Athena Query Execution to Show Tables Source: https://fakecloud.dev/docs/services/athena Initiates a query execution in Athena to list all tables within a specified database. Ensure the workgroup and output location are correctly configured. ```bash aws --endpoint-url http://localhost:4566 athena start-query-execution \ --query-string "SHOW TABLES IN analytics" \ --work-group primary \ --result-configuration OutputLocation=s3://my-bucket/results/ ``` -------------------------------- ### GitHub Copilot Instructions for fakecloud Source: https://fakecloud.dev/docs/guides/ai-coding-tools Add this to `.github/copilot-instructions.md` to inform GitHub Copilot about using fakecloud for AWS integration tests. It covers running fakecloud and SDK configuration. ```markdown ## AWS Testing Use fakecloud as a local AWS emulator for integration tests. - Run: `fakecloud` (listens on http://localhost:4566) - Configure endpoint_url to http://localhost:4566 with dummy credentials - Don't mock the AWS SDK. Use real SDK calls against fakecloud. - Docs: https://fakecloud.dev/llms.txtCopy ``` -------------------------------- ### Cohere Command Request Format Source: https://fakecloud.dev/docs/guides/testing-bedrock Example request body structure for Cohere Command models via Bedrock. ```json { "prompt": "Your prompt here", "max_tokens": 1024 } ``` -------------------------------- ### Meta Llama Request Format Source: https://fakecloud.dev/docs/guides/testing-bedrock Example request body structure for Meta Llama models via Bedrock. ```json { "prompt": "Your prompt here", "max_gen_len": 1024, "temperature": 0.7 } ```