### Install and Start fakecloud Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/blog/ecr-localstack-moto-docker-push.md Installs fakecloud using a curl script and starts the service in the background. Ensure fakecloud is running before proceeding with other commands. ```sh # Start fakecloud. curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash fakecloud & ``` -------------------------------- ### Quick Start Example Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/java/README.md Initialize FakeCloud client and perform common operations like checking health, resetting state, and inspecting service messages. ```java import dev.fakecloud.FakeCloud; import dev.fakecloud.Types.*; FakeCloud fc = new FakeCloud("http://localhost:4566"); // Check server health var health = fc.health(); System.out.println(health.version() + " " + health.services()); // Reset all state between tests fc.reset(); // Inspect SES emails sent during a test var emails = fc.ses().getEmails().emails(); System.out.println("Sent " + emails.size() + " emails"); // Inspect SNS messages var messages = fc.sns().getMessages().messages(); // Inspect SQS messages across all queues var queues = fc.sqs().getMessages().queues(); // Advance DynamoDB TTL processor int expired = fc.dynamodb().tickTtl().expiredItems(); // Advance S3 lifecycle processor int expiredObjects = fc.s3().tickLifecycle().expiredObjects(); ``` -------------------------------- ### Install fakecloud Go SDK Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/go/README.md Use 'go get' to install the fakecloud Go SDK. ```sh go get github.com/faiscadev/fakecloud/sdks/go ``` -------------------------------- ### GitHub Actions: Install and Run fakecloud Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/blog/integration-testing-aws-in-ci.md Installs the fakecloud binary and starts it in the background. Sets AWS environment variables for SDK configuration. Includes a health check to ensure fakecloud is ready before proceeding. ```yaml name: test on: [push, pull_request] jobs: integration: runs-on: ubuntu-latest env: AWS_ENDPOINT_URL: http://localhost:4566 AWS_ACCESS_KEY_ID: test AWS_SECRET_ACCESS_KEY: test AWS_REGION: us-east-1 steps: - uses: actions/checkout@v4 - name: Install fakecloud run: curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash - name: Start fakecloud run: fakecloud & - name: Wait for fakecloud run: | for i in $(seq 1 30); curl -sf http://localhost:4566/_fakecloud/health && exit 0 sleep 1 echo "fakecloud did not start" exit 1 - uses: actions/setup-node@v4 with: node-version: 20 - run: npm ci - run: npm test ``` -------------------------------- ### Installation Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/sdks/go.md Install the fakecloud SDK for Go using the go get command. Requires Go 1.21+. ```APIDOC ## Install ```sh go get github.com/faiscadev/fakecloud/sdks/go ``` Go 1.21+. ``` -------------------------------- ### Quick Start with FakeCloud SDK Source: https://github.com/faiscadev/fakecloud/blob/main/crates/fakecloud-sdk/README.md Initialize the FakeCloud client, check health, reset services, and inspect SES emails. This example demonstrates basic SDK usage for common testing scenarios. ```rust use fakecloud_sdk::FakeCloud; #[tokio::main] async fn main() -> Result<(), Box> { let fc = FakeCloud::new("http://localhost:4566"); let health = fc.health().await?; println!("{}", health.version); fc.reset().await?; let emails = fc.ses().get_emails().await?; println!("sent {} emails", emails.emails.len()); Ok(()) } ``` -------------------------------- ### Python (boto3) DynamoDB client setup and basic operations Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/dynamodb-emulator.md Configure the boto3 client to use the local fakecloud endpoint. This example demonstrates creating a table, putting an item, and getting an item. ```python import boto3 ddb = boto3.client('dynamodb', endpoint_url='http://localhost:4566', aws_access_key_id='test', aws_secret_access_key='test', region_name='us-east-1') ddb.create_table( TableName='users', KeySchema=[{'AttributeName': 'id', 'KeyType': 'HASH'}], AttributeDefinitions=[{'AttributeName': 'id', 'AttributeType': 'S'}], BillingMode='PAY_PER_REQUEST') ddb.put_item(TableName='users', Item={'id': {'S': 'u1'}, 'name': {'S': 'Alice'}}) resp = ddb.get_item(TableName='users', Key={'id': {'S': 'u1'}}) print(resp['Item']) ``` -------------------------------- ### CI Setup without Docker: Install and Run fakecloud Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/localstack-alternative.md Demonstrates how to install fakecloud using a curl script and run it in a CI environment without Docker. Includes a verification step using AWS CLI. ```bash - run: curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash - run: fakecloud & - run: sleep 1 && aws --endpoint-url http://localhost:4566 s3 ls # verify ``` -------------------------------- ### Install and Run fakecloud Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/local-elasticache.md Install fakecloud using the provided script and run it to start the local ElastiCache environment. Point your AWS SDK at http://localhost:4566. ```APIDOC ## Install fakecloud ```sh curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash ``` ## Run fakecloud ```sh fakecloud ``` ## Configure AWS SDK Point your AWS SDK at `http://localhost:4566`. ``` -------------------------------- ### Go (aws-sdk-go-v2) Example Source: https://github.com/faiscadev/fakecloud/blob/main/website/static/llms-full.txt Example of how to use the aws-sdk-go-v2 for Go with FakeCloud. ```APIDOC ## Go (aws-sdk-go-v2) ### Description Example of how to use the aws-sdk-go-v2 for Go with FakeCloud. ### Code Example ```go cfg, _ := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-east-1"), config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider("test", "test", "")), ) client := sqs.NewFromConfig(cfg, func(o *sqs.Options) { o.BaseEndpoint = aws.String("http://localhost:4566") }) ``` ``` -------------------------------- ### AWS CLI Examples Source: https://github.com/faiscadev/fakecloud/blob/main/website/static/llms-full.txt Examples of how to use the AWS Command Line Interface with FakeCloud. ```APIDOC ## AWS CLI ### Description Examples of how to use the AWS Command Line Interface with FakeCloud. ### Setup ```sh export AWS_ACCESS_KEY_ID=test export AWS_SECRET_ACCESS_KEY=test export AWS_DEFAULT_REGION=us-east-1 ``` ### Example Commands #### Create SQS Queue ```sh aws --endpoint-url http://localhost:4566 sqs create-queue --queue-name my-queue ``` #### Create S3 Bucket ```sh aws --endpoint-url http://localhost:4566 s3 mb s3://my-bucket ``` #### Create DynamoDB Table ```sh aws --endpoint-url http://localhost:4566 dynamodb create-table --table-name my-table --attribute-definitions AttributeName=id,AttributeType=S --key-schema AttributeName=id,KeyType=HASH --billing-mode PAY_PER_REQUEST ``` ``` -------------------------------- ### Python (boto3) Example Source: https://github.com/faiscadev/fakecloud/blob/main/website/static/llms-full.txt Example of how to use the boto3 SDK for Python with FakeCloud. ```APIDOC ## Python (boto3) ### Description Example of how to use the boto3 SDK for Python with FakeCloud. ### Code Example ```python import boto3 sqs = boto3.client('sqs', endpoint_url='http://localhost:4566', region_name='us-east-1', aws_access_key_id='test', aws_secret_access_key='test' ) sqs.create_queue(QueueName='my-queue') ``` ``` -------------------------------- ### Start FakeCloud Server Source: https://github.com/faiscadev/fakecloud/blob/main/examples/terraform/README.md Start the FakeCloud server locally. It defaults to listening on 0.0.0.0:4566. ```sh cd cargo run --bin fakecloud # listens on 0.0.0.0:4566 by default ``` -------------------------------- ### Install FakeCloud PHP SDK Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/php/README.md Install the fakecloud PHP client SDK using Composer. ```bash composer require fakecloud/fakecloud ``` -------------------------------- ### Install and Run Fakecloud Bedrock Emulator Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/bedrock-emulator.md Install fakecloud using the provided script and run it. Point your AWS SDK to http://localhost:4566. ```sh curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash fakecloud ``` -------------------------------- ### Start FakeCloud Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/getting-started/first-test.md Start the fakecloud service. It will listen on http://localhost:4566. Keep this running in a terminal. ```sh fakecloud ``` -------------------------------- ### Example: Full Test Loop Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/sdks/php.md An example demonstrating a full test loop using the fakecloud SDK, including setting Bedrock response rules, queuing faults, 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); ``` -------------------------------- ### Install fakecloud SDK Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/python/README.md Install the fakecloud Python SDK using pip. ```bash pip install fakecloud ``` -------------------------------- ### Full Test Example Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/sdks/java.md An example demonstrating a typical test loop using the FakeCloud Java SDK, including Bedrock client interactions and assertions. ```APIDOC ## Example: full test loop ```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()); } ``` ``` -------------------------------- ### Install fakecloud with script Source: https://github.com/faiscadev/fakecloud/blob/main/website/static/llms-full.txt Use the provided curl script to install fakecloud. Options are available to specify a version or installation directory. ```sh curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash ``` ```sh # Install a specific version curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash -s -- --version v0.1.0 # Install to a custom directory curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash -s -- --install-dir ~/.local/bin ``` -------------------------------- ### Fakecloud Installation Options Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/test-lambda-locally.md Provides alternative methods for installing fakecloud: binary, Docker, and Cargo. ```sh - Binary: curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash - Docker: docker run --rm -p 4566:4566 -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/faiscadev/fakecloud - Cargo: cargo install fakecloud ``` -------------------------------- ### Rust (aws-sdk-rust) Example Source: https://github.com/faiscadev/fakecloud/blob/main/website/static/llms-full.txt Example of how to use the aws-sdk-rust for Rust with FakeCloud. ```APIDOC ## Rust (aws-sdk-rust) ### Description Example of how to use the aws-sdk-rust for Rust with FakeCloud. ### Code Example ```rust let config = aws_config::defaults(aws_config::BehaviorVersion::latest()) .endpoint_url("http://localhost:4566") .region(aws_config::Region::new("us-east-1")) .credentials_provider(aws_credential_types::Credentials::new("test", "test", None, None, "test")) .load() .await; let client = aws_sdk_sqs::Client::new(&config); client.create_queue().queue_name("my-queue").send().await.unwrap(); ``` ``` -------------------------------- ### Install fakecloud CLI Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/vs/localstack.md Installs the fakecloud CLI tool using a curl script and then runs the fakecloud binary. ```sh curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash fakecloud ``` -------------------------------- ### Install fakecloud SDK Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/typescript/README.md Install the fakecloud npm package using npm. ```bash npm install fakecloud ``` -------------------------------- ### Python (boto3) SQS Example Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/sqs-emulator.md Example of creating an SQS client, queue, sending a message, and receiving messages using Python's boto3 SDK, configured to use the local fakecloud endpoint. ```python import boto3 sqs = boto3.client('sqs', endpoint_url='http://localhost:4566', aws_access_key_id='test', aws_secret_access_key='test', region_name='us-east-1') q = sqs.create_queue(QueueName='jobs') sqs.send_message(QueueUrl=q['QueueUrl'], MessageBody='{"job": "resize", "id": 42}') resp = sqs.receive_message(QueueUrl=q['QueueUrl'], WaitTimeSeconds=1) print(resp.get('Messages', [])) ``` -------------------------------- ### Install PHP Dependencies Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/php/README.md Installs the necessary PHP dependencies using Composer within the `sdks/php` directory. ```bash # Install PHP dependencies cd sdks/php composer install ``` -------------------------------- ### Install fakecloud Single Binary Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/blog/migrate-from-localstack.md Install fakecloud using a curl script and then run it directly. This option avoids Docker and is generally faster for CI environments. ```sh # Option A: single binary, no Docker curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash fakecloud ``` -------------------------------- ### Run Sample App Source: https://github.com/faiscadev/fakecloud/blob/main/examples/sample-app/README.md Command to execute the sample application. Requires Python 3.8+ and boto3 installed. ```bash python app.py ``` -------------------------------- ### FakeCloud Setup in GitHub Actions CI Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/blog/test-lambda-locally.md This YAML configuration demonstrates how to set up FakeCloud in a GitHub Actions workflow. It includes installing FakeCloud, starting the service, and running tests with AWS environment variables configured for local endpoints. ```yaml # .github/workflows/test.yml jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash - run: fakecloud & - run: | for i in $(seq 1 30); do curl -sf http://localhost:4566/_fakecloud/health && break sleep 1 done - run: npm ci && npm test env: AWS_ENDPOINT_URL: http://localhost:4566 AWS_ACCESS_KEY_ID: test AWS_SECRET_ACCESS_KEY: test AWS_REGION: us-east-1 ``` -------------------------------- ### Quick Start with fakecloud Go SDK Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/go/README.md Initialize the client, check health, list emails and SNS messages, and reset state. ```go package main import ( "context" "fmt" "log" fakecloud "github.com/faiscadev/fakecloud/sdks/go" ) func main() { fc := fakecloud.New("http://localhost:4566") ctx := context.Background() // Check health health, err := fc.Health(ctx) if err != nil { log.Fatal(err) } fmt.Printf("Status: %s, Version: %s\n", health.Status, health.Version) // List sent emails emails, err := fc.SES().GetEmails(ctx) if err != nil { log.Fatal(err) } for _, e := range emails.Emails { fmt.Printf("Email %s: %s -> %v\n", e.MessageID, e.From, e.To) } // List SNS messages msgs, err := fc.SNS().GetMessages(ctx) if err != nil { log.Fatal(err) } fmt.Printf("SNS messages: %d\n", len(msgs.Messages)) // Reset all state if err := fc.Reset(ctx); err != nil { log.Fatal(err) } } ``` -------------------------------- ### Install fakecloud from Source Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/getting-started/install.md Clone the repository, navigate to the directory, and use Cargo to build and run the release binary. ```sh git clone https://github.com/faiscadev/fakecloud.git cd fakecloud cargo run --release --bin fakecloud ``` -------------------------------- ### Create and Send Email Templates with Python Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/ses-emulator.md Demonstrates creating an email template named 'welcome' and then sending an email using that template with personalized data. Requires SESv2 client configuration. ```python ses.create_email_template( TemplateName='welcome', TemplateContent={ 'Subject': 'Hi {{name}}', 'Text': 'Welcome, {{name}}!', }) ses.send_email( FromEmailAddress='sender@example.com', Destination={'ToAddresses': ['alice@example.com']}, Content={'Template': { 'TemplateName': 'welcome', 'TemplateData': '{"name":"Alice"}', }}) ``` -------------------------------- ### Initialize Go SDK Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/sdks/go.md Instantiate the fakecloud client using `fakecloud.New` with a custom URL or `fakecloud.NewDefault` for the default local URL. ```go import "github.com/faiscadev/fakecloud/sdks/go/fakecloud" fc := fakecloud.New("http://localhost:4566") // or with default URL: fc := fakecloud.NewDefault() // http://localhost:4566 ``` -------------------------------- ### Node.js (AWS SDK v3) DynamoDB client setup Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/dynamodb-emulator.md Configure the AWS SDK v3 client for Node.js to use the local fakecloud endpoint by setting environment variables. This example shows the setup for creating a table. ```typescript process.env.AWS_ENDPOINT_URL = 'http://localhost:4566'; process.env.AWS_ACCESS_KEY_ID = 'test'; process.env.AWS_SECRET_ACCESS_KEY = 'test'; process.env.AWS_REGION = 'us-east-1'; import { DynamoDBClient, CreateTableCommand, PutItemCommand, GetItemCommand } from '@aws-sdk/client-dynamodb'; const ddb = new DynamoDBClient({}); await ddb.send(new CreateTableCommand({ TableName: 'users', KeySchema: [{ AttributeName: 'id', KeyType: 'HASH' }], AttributeDefinitions: [{ AttributeName: 'id', AttributeType: 'S' }], BillingMode: 'PAY_PER_REQUEST', })); ``` -------------------------------- ### Initialization Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/sdks/java.md How to create an instance of the FakeCloud client, with options for default or custom base URLs. ```APIDOC ## Initialize ```java import dev.fakecloud.FakeCloud; FakeCloud fc = new FakeCloud(); // defaults to http://localhost:4566 FakeCloud fc2 = new FakeCloud("http://localhost:5000"); // explicit base URL ``` ``` -------------------------------- ### Install fakecloud via Docker Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/blog/migrate-from-localstack.md Run fakecloud as a Docker container, exposing the default port 4566. This is a straightforward way to get fakecloud running. ```sh # Option B: Docker docker run --rm -p 4566:4566 ghcr.io/faiscadev/fakecloud ``` -------------------------------- ### CloudFormation Smoke Test Setup Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/services/cloudformation.md Starts a fakecloud instance, defines a CloudFormation template for an SQS queue, and creates a stack with production parameters. This is useful for testing CloudFormation deployments. ```sh 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 ``` -------------------------------- ### Start Athena Query Execution Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/services/athena.md Initiates a query execution in AWS Athena. Specify the query string, workgroup, and an S3 output location for results. This example shows how to list tables in a database. ```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/ ``` -------------------------------- ### Initialize AsyncFakeCloud (async) Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/sdks/python.md Instantiate and use the asynchronous FakeCloud client within 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() ``` -------------------------------- ### Update GitHub Actions for fakecloud install-and-run Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/blog/migrate-from-localstack.md Configure GitHub Actions to install and run fakecloud directly using a script, bypassing Docker. This method is faster for CI runners compared to starting a LocalStack container. ```yaml steps: - run: curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash - run: fakecloud & - run: | for i in $(seq 1 30); do curl -sf http://localhost:4566/_fakecloud/health && exit 0 sleep 1 done exit 1 ``` -------------------------------- ### Get Clusters SDK Usage Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/services/ecs.md These examples demonstrate how to use the Fakecloud client SDKs to retrieve a list of ECS clusters. The SDKs provide typed wrappers for introspection endpoints, simplifying interaction compared to direct HTTP requests. ```go // Go clusters, _ := fakecloud.New("http://localhost:4566").ECS().GetClusters(ctx) ``` ```python # Python async with FakeCloud() as fc: clusters = await fc.ecs.get_clusters() ``` ```typescript // TypeScript const fc = new FakeCloud(); const { clusters } = await fc.ecs.getClusters(); ``` ```rust // Rust let fc = FakeCloud::new("http://localhost:4566"); let clusters = fc.ecs().get_clusters().await?; ``` -------------------------------- ### FakeCloud Sync Client Quick Start Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/python/README.md Demonstrates how to use the synchronous client for basic interactions with fakecloud, such as checking server health and retrieving SES emails. ```APIDOC ## Quick start - Sync ```python from fakecloud import FakeCloudSync with FakeCloudSync("http://localhost:4566") as fc: health = fc.health() print(health.status) emails = fc.ses.get_emails() for email in emails.emails: print(email.subject) ``` ``` -------------------------------- ### Handwritten E2E Test for SQS CreateQueue Source: https://github.com/faiscadev/fakecloud/blob/main/crates/fakecloud-conformance/README.md Example of a handwritten end-to-end test for the SQS CreateQueue operation. It uses the official AWS SDK client and is annotated with `#[test_action]` for conformance tracking. Ensure the `TestServer` is started and the client is correctly initialized. ```rust #[test_action("sqs", "CreateQueue", checksum = "0a1fae82")] #[tokio::test] async fn sqs_create_queue() { let server = TestServer::start().await; let client = server.sqs_client().await; let resp = client.create_queue().queue_name("conformance-test").send().await.unwrap(); assert!(resp.queue_url().is_some()); } ``` -------------------------------- ### Async Quick Start with FakeCloud Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/python/README.md Demonstrates basic usage of the asynchronous FakeCloud client to check health, list SES emails, SNS messages, Lambda invocations, and reset state. ```python import asyncio from fakecloud import FakeCloud async def main(): async with FakeCloud("http://localhost:4566") as fc: # Check server health health = await fc.health() print(health.status, health.version) # List sent SES emails emails = await fc.ses.get_emails() for email in emails.emails: print(f"{email.from_addr} -> {email.to}: {email.subject}") # List SNS messages messages = await fc.sns.get_messages() for msg in messages.messages: print(f"{msg.topic_arn}: {msg.message}") # Inspect Lambda invocations invocations = await fc.lambda_.get_invocations() for inv in invocations.invocations: print(f"{inv.function_arn}: {inv.payload}") # Reset all state between tests await fc.reset() asyncio.run(main()) ``` -------------------------------- ### Test ElastiCache with Real Redis Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/local-elasticache.md This snippet demonstrates setting up and testing an application that caches data via a real Redis instance, which is accessed through the fakecloud ElastiCache emulation. It includes setup for creating a cache cluster and a test case for setting and getting a value. ```typescript import { ElastiCacheClient, CreateCacheClusterCommand, DescribeCacheClustersCommand } from '@aws-sdk/client-elasticache'; import { createClient } from 'redis'; const ec = new ElastiCacheClient({ endpoint: 'http://localhost:4566' }); beforeAll(async () => { await ec.send(new CreateCacheClusterCommand({ CacheClusterId: 'test', Engine: 'redis', CacheNodeType: 'cache.t3.micro', NumCacheNodes: 1, })); // ... poll for "available" ... }); test('app caches via real redis behind ElastiCache emulation', async () => { const redis = createClient({ url: 'redis://localhost:6379' }); await redis.connect(); await redis.set('key', 'value'); expect(await redis.get('key')).toBe('value'); }); ``` -------------------------------- ### Initialize fakecloud SDK in PHP Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/sdks/php.md Instantiate the FakeCloud client, optionally providing a custom 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 (sync) Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/sdks/python.md Instantiate the synchronous FakeCloud client. You can use the default localhost address or specify a custom one. ```python from fakecloud import FakeCloud fc = FakeCloud() # defaults to http://localhost:4566 # or fc = FakeCloud("http://localhost:5000") ``` -------------------------------- ### Generate CI Workflow for Fakecloud Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/blog/aws-integration-tests-with-claude-code-cursor.md This YAML snippet shows a GitHub Actions workflow generated by an agent to set up and run fakecloud for integration tests. It includes steps for checking out code, installing fakecloud, starting the service, and running tests with AWS environment variables configured. ```yaml # .github/workflows/test.yml — generated by the agent jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - run: curl -fsSL https://raw.githubusercontent.com/faiscadev/fakecloud/main/install.sh | bash - run: fakecloud & - run: | for i in $(seq 1 30); do curl -sf http://localhost:4566/_fakecloud/health && break sleep 1 done - run: npm ci && npm test env: AWS_ENDPOINT_URL: http://localhost:4566 AWS_ACCESS_KEY_ID: test AWS_SECRET_ACCESS_KEY: test AWS_REGION: us-east-1 ``` -------------------------------- ### Install fakecloud via Cargo Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/getting-started/install.md Install fakecloud using Cargo, the Rust package manager. Run 'fakecloud' after installation. ```sh cargo install fakecloud fakecloud ``` -------------------------------- ### Create Organization and Log Details Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/reference/organizations.md Demonstrates how to create a new AWS organization using the SDK and log its ID and the management account ID. Ensure the SDK configuration is properly set up before use. ```rust use aws_sdk_organizations::Client; let client = Client::new(&sdk_config); let created = client.create_organization().send().await?; let org = created.organization().unwrap(); println!("{} managed by {}", org.id().unwrap(), org.master_account_id().unwrap()); ``` -------------------------------- ### Install fakecloud with Cargo Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/fake-aws-server.md Installs fakecloud directly from source using Cargo, the Rust package manager. This method requires Rust to be installed. ```sh cargo install fakecloud ``` -------------------------------- ### Install fakecloud via Cargo Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/blog/migrate-from-localstack.md Install fakecloud using the Cargo package manager if you have Rust and Cargo installed. This is useful for local development or custom builds. ```sh # Option C: cargo cargo install fakecloud ``` -------------------------------- ### Run Full Fakecloud Conformance Harness Source: https://github.com/faiscadev/fakecloud/blob/main/crates/fakecloud-conformance/README.md Execute the complete conformance harness against a fresh instance of Fakecloud. This command spawns Fakecloud automatically. ```bash cargo run -p fakecloud-conformance -- run ``` -------------------------------- ### Installation Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/sdks/java.md Instructions for adding the FakeCloud SDK to your project using Gradle or Maven. ```APIDOC ## Install Gradle (Kotlin DSL): ```kotlin dependencies { testImplementation("dev.fakecloud:fakecloud:0.12.0") } ``` Maven: ```xml dev.fakecloud fakecloud 0.12.0 test ``` Requires Java 17+. Uses the JDK's built-in `HttpClient` and Jackson for JSON. ``` -------------------------------- ### Error Handling Example Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/java/README.md Example demonstrating how to catch `FakeCloudError` exceptions. ```java import dev.fakecloud.FakeCloudError; import dev.fakecloud.Types.ConfirmUserRequest; FakeCloud fc = new FakeCloud(); try { fc.cognito().confirmUser(new ConfirmUserRequest("pool-1", "nobody")); } catch (FakeCloudError err) { System.out.println(err.status()); // 404 System.out.println(err.body()); // "user not found" } ``` -------------------------------- ### JavaScript/TypeScript (aws-sdk-js v3) Example Source: https://github.com/faiscadev/fakecloud/blob/main/website/static/llms-full.txt Example of how to use the aws-sdk-js v3 for JavaScript/TypeScript with FakeCloud. ```APIDOC ## JavaScript/TypeScript (aws-sdk-js v3) ### Description Example of how to use the aws-sdk-js v3 for JavaScript/TypeScript with FakeCloud. ### Code Example ```typescript import { SQSClient, CreateQueueCommand } from '@aws-sdk/client-sqs'; const client = new SQSClient({ endpoint: 'http://localhost:4566', region: 'us-east-1', credentials: { accessKeyId: 'test', secretAccessKey: 'test' }, }); await client.send(new CreateQueueCommand({ QueueName: 'my-queue' })); ``` ``` -------------------------------- ### Pytest Fixture Example Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/sdks/python.md Example demonstrating how to use the FakeCloud SDK with pytest fixtures. ```APIDOC ## Example: pytest fixture ```python 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" ``` ``` -------------------------------- ### FakeCloud Async Client Quick Start Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/python/README.md Demonstrates how to use the asynchronous client to interact with fakecloud services like health checks, SES, SNS, and Lambda, and how to reset the state. ```APIDOC ## Quick start - Async ```python import asyncio from fakecloud import FakeCloud async def main(): async with FakeCloud("http://localhost:4566") as fc: # Check server health health = await fc.health() print(health.status, health.version) # List sent SES emails emails = await fc.ses.get_emails() for email in emails.emails: print(f"{email.from_addr} -> {email.to}: {email.subject}") # List SNS messages messages = await fc.sns.get_messages() for msg in messages.messages: print(f"{msg.topic_arn}: {msg.message}") # Inspect Lambda invocations invocations = await fc.lambda_.get_invocations() for inv in invocations.invocations: print(f"{inv.function_arn}: {inv.payload}") # Reset all state between tests await fc.reset() asyncio.run(main()) ``` ``` -------------------------------- ### Bootstrap User and Attach Policy Source: https://github.com/faiscadev/fakecloud/blob/main/website/content/docs/reference/security.md This sequence bootstraps a user with root credentials, creates an access key for them, and attaches a resource-scoped IAM policy. It demonstrates setting up a user with specific read permissions. ```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"}]}' ``` -------------------------------- ### Build and Test Java SDK Source: https://github.com/faiscadev/fakecloud/blob/main/sdks/java/README.md Navigate to the Java SDK directory and run Gradle to build and execute tests against the FakeCloud binary. ```bash # Run unit + E2E tests against the freshly-built binary cd sdks/java ./gradlew build ```