### Minimal IAM Enforcement Setup Example Source: https://github.com/floci-io/floci/blob/main/docs/services/iam.md This example demonstrates setting up minimal IAM enforcement. It includes creating a user, generating access keys, creating and attaching a policy that allows S3 listing, and then performing an S3 list operation using the created credentials. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # Create a user and get credentials aws iam create-user --user-name alice KEY=$(aws iam create-access-key --user-name alice --query 'AccessKey.[AccessKeyId,SecretAccessKey]' --output text) AKID=$(echo $KEY | awk '{print $1}') SECRET=$(echo $KEY | awk '{print $2}') # Create and attach a policy that allows S3 list POLICY_ARN=$(aws iam create-policy \ --policy-name allow-s3-list \ --policy-document '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:ListAllMyBuckets","Resource":"*"}]}' \ --query 'Policy.Arn' --output text) aws iam attach-user-policy --user-name alice --policy-arn $POLICY_ARN # alice can now list buckets AWS_ACCESS_KEY_ID=$AKID AWS_SECRET_ACCESS_KEY=$SECRET \ aws s3 ls ``` -------------------------------- ### Start Floci Emulator with CLI Source: https://github.com/floci-io/floci/blob/main/README.md Use the Floci CLI to start the local AWS emulator. This is the quickest way to get started. ```bash floci start ``` -------------------------------- ### Setup Individual SDKs Source: https://github.com/floci-io/floci/blob/main/compatibility-tests/README.md Commands for setting up individual SDK test environments, including installing Python dependencies, Node.js modules, or cloning necessary tools for AWS CLI tests. ```bash # Setup all SDKs just setup # Setup individual SDKs just setup-python # pip install -r requirements.txt just setup-typescript # npm install just setup-awscli # Clone bats-core, bats-support, bats-assert ``` -------------------------------- ### Retrieve AppConfig Configuration via Data Plane Source: https://github.com/floci-io/floci/blob/main/docs/services/appconfig.md This example shows how to start a configuration session and then retrieve the latest configuration using the AppConfigData plane. Remember to replace ``, ``, and `` with your actual resource identifiers. ```bash # Start configuration session TOKEN=$(aws appconfigdata start-configuration-session \ --application-identifier \ --environment-identifier \ --configuration-profile-identifier \ --query "InitialConfigurationToken" --output text \ --endpoint-url http://localhost:4566) # Get latest configuration aws appconfigdata get-latest-configuration \ --configuration-token $TOKEN \ --endpoint-url http://localhost:4566 ``` -------------------------------- ### Query Data Lake with S3, Glue, and Athena Source: https://github.com/floci-io/floci/blob/main/docs/services/athena.md This comprehensive example shows how to set up a data lake by creating an S3 bucket, uploading JSON data, registering a table in Glue, and then querying it using Athena. It includes steps for starting the query, polling for completion, and fetching results. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # 1. Create S3 bucket and upload data aws s3 mb s3://my-data-lake echo '{"id":1,"amount":10.0} {"id":2,"amount":20.0} {"id":3,"amount":30.0}' | aws s3 cp - s3://my-data-lake/orders/data.json # 2. Register table in Glue aws glue create-database --database-input '{"Name":"analytics"}' aws glue create-table \ --database-name analytics \ --table-input '{ "Name": "orders", "StorageDescriptor": { "Location": "s3://my-data-lake/orders/", "InputFormat": "org.apache.hadoop.mapred.TextInputFormat", "OutputFormat": "org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat", "SerdeInfo": { "SerializationLibrary": "org.openx.data.jsonserde.JsonSerDe" }, "Columns": [ {"Name": "id", "Type": "int"}, {"Name": "amount", "Type": "double"} ] } }' # 3. Run Athena query QUERY_ID=$(aws athena start-query-execution \ --query-string "SELECT sum(amount) AS total FROM orders" \ --query-execution-context Database=analytics \ --query 'QueryExecutionId' \ --output text) # 4. Poll until done while true; do STATE=$(aws athena get-query-execution \ --query-execution-id $QUERY_ID \ --query 'QueryExecution.Status.State' \ --output text) [ "$STATE" = "SUCCEEDED" ] && break [ "$STATE" = "FAILED" ] && echo "Query failed" && exit 1 sleep 1 done # 5. Fetch results aws athena get-query-results --query-execution-id $QUERY_ID ``` -------------------------------- ### Create and Manage CloudTrail Trails Source: https://github.com/floci-io/floci/blob/main/docs/services/cloudtrail.md This example demonstrates how to set up and manage a CloudTrail trail using the AWS CLI with Floci's emulation. It includes setting the endpoint, creating an S3 bucket, creating a trail, starting logging, checking trail status, and describing trails. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # A trail needs a destination S3 bucket aws s3 mb s3://my-trail-bucket aws cloudtrail create-trail \ --name demo-trail \ --s3-bucket-name my-trail-bucket aws cloudtrail start-logging --name demo-trail aws cloudtrail get-trail-status --name demo-trail aws cloudtrail describe-trails ``` -------------------------------- ### Install and Run Just Task Runner Source: https://github.com/floci-io/floci/blob/main/compatibility-tests/README.md Installs the 'just' task runner and demonstrates commands for setting up the environment and running all tests or specific SDK tests. ```bash # Install just (task runner) # macOS: brew install just # Linux: cargo install just # Copy and configure environment cp env.example .env # Install dependencies just setup # Run all tests just test-all # Run specific SDK tests just test-python just test-typescript just test-awscli ``` -------------------------------- ### Install Testcontainers Floci Go Module Source: https://github.com/floci-io/floci/blob/main/docs/testcontainers/go.md Install the testcontainers-floci-go module using go get. Requires Go 1.25+ and Testcontainers for Go v0.42+. ```bash go get github.com/floci-io/testcontainers-floci-go ``` -------------------------------- ### Start Floci with Docker Compose Source: https://github.com/floci-io/floci/blob/main/README.md Command to start the Floci emulator after configuring it with Docker Compose. ```bash docker compose up ``` -------------------------------- ### Start Configuration Recorder Source: https://github.com/floci-io/floci/blob/main/docs/services/config.md Initiates the configuration recording process for a specified recorder. Ensure the recorder has been successfully created before starting it. ```bash aws configservice start-configuration-recorder --configuration-recorder-name default ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/floci-io/floci/blob/main/compatibility-tests/sdk-test-node/README.md Installs project dependencies and runs all compatibility tests. Alternatively, use 'just' for a streamlined test execution. ```bash npm install # All groups npm test # Via just (from compatibility-tests/) just test-typescript ``` -------------------------------- ### Start, Get, and List Transcribe Jobs with AWS CLI Source: https://github.com/floci-io/floci/blob/main/docs/services/transcribe.md Demonstrates how to start, retrieve, and list transcription jobs using the AWS CLI. Ensure AWS environment variables and endpoint URL are set correctly. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 export AWS_DEFAULT_REGION=us-east-1 export AWS_ACCESS_KEY_ID=test export AWS_SECRET_ACCESS_KEY=test aws transcribe start-transcription-job \ --transcription-job-name floci-demo \ --media MediaFileUri=s3://my-bucket/audio.mp3 \ --language-code en-US \ --media-format mp3 aws transcribe get-transcription-job \ --transcription-job-name floci-demo aws transcribe create-vocabulary \ --vocabulary-name floci-vocab \ --language-code en-US aws transcribe list-vocabularies \ --name-contains floci ``` -------------------------------- ### DynamoDB Put and Get Item Example Source: https://github.com/floci-io/floci/blob/main/docs/testcontainers/go.md This Go test function demonstrates creating a DynamoDB table, putting an item into it, and then retrieving it using Testcontainers to provide a local DynamoDB instance. ```go func TestDynamoDBPutGet(t *testing.T) { ctx := context.Background() container, err := floci.NewFlociContainer().Start(ctx) if err != nil { t.Fatal(err) } defer container.Stop(ctx) cfg, _ := config.LoadDefaultConfig(ctx, config.WithRegion(container.GetRegion()), config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider( container.GetAccessKey(), container.GetSecretKey(), "", )), config.WithBaseEndpoint(container.GetEndpoint()), ) client := dynamodb.NewFromConfig(cfg) _, err = client.CreateTable(ctx, &dynamodb.CreateTableInput{ TableName: aws.String("Orders"), BillingMode: types.BillingModePayPerRequest, AttributeDefinitions: []types.AttributeDefinition{ {AttributeName: aws.String("id"), AttributeType: types.ScalarAttributeTypeS}, }, KeySchema: []types.KeySchemaElement{ {AttributeName: aws.String("id"), KeyType: types.KeyTypeHash}, }, }) if err != nil { t.Fatal(err) } _, err = client.PutItem(ctx, &dynamodb.PutItemInput{ TableName: aws.String("Orders"), Item: map[string]types.AttributeValue{ "id": &types.AttributeValueMemberS{Value: "order-1"}, "status": &types.AttributeValueMemberS{Value: "placed"}, }, }) if err != nil { t.Fatal(err) } result, err := client.GetItem(ctx, &dynamodb.GetItemInput{ TableName: aws.String("Orders"), Key: map[string]types.AttributeValue{ "id": &types.AttributeValueMemberS{Value: "order-1"}, }, }) if err != nil { t.Fatal(err) } status := result.Item["status"].(*types.AttributeValueMemberS).Value if status != "placed" { t.Errorf("expected status 'placed', got '%s'", status) } } ``` -------------------------------- ### Basic S3 Bucket Test with Jest Source: https://github.com/floci-io/floci/blob/main/docs/testcontainers/nodejs.md This example demonstrates how to start a Floci container and use it to test S3 bucket creation and listing with the AWS SDK for JavaScript. ```typescript import { FlociContainer } from "@floci/testcontainers"; import { S3Client, CreateBucketCommand, ListBucketsCommand } from "@aws-sdk/client-s3"; describe("S3", () => { let floci: FlociContainer; beforeAll(async () => { floci = await new FlociContainer().start(); }); afterAll(async () => { await floci.stop(); }); it("should create and list a bucket", async () => { const s3 = new S3Client({ endpoint: floci.getEndpoint(), region: floci.getRegion(), credentials: { accessKeyId: floci.getAccessKey(), secretAccessKey: floci.getSecretKey(), }, forcePathStyle: true, }); await s3.send(new CreateBucketCommand({ Bucket: "my-bucket" })); const { Buckets } = await s3.send(new ListBucketsCommand({})); expect(Buckets?.some(b => b.Name === "my-bucket")).toBe(true); }); }); ``` -------------------------------- ### Python Boto3 Cloud Map Setup and Discovery Source: https://github.com/floci-io/floci/blob/main/docs/services/cloudmap.md Shows how to set up and use AWS Cloud Map with the Boto3 Python SDK. This includes creating HTTP namespaces, services, registering instances, and discovering instances. Requires Boto3 to be installed and configured. ```python import boto3 client = boto3.client( "servicediscovery", endpoint_url="http://localhost:4566", region_name="us-east-1", ) ns = client.create_http_namespace(Name="floci-demo") client.get_operation(OperationId=ns["OperationId"]) # Status == "SUCCESS" namespace_id = client.list_namespaces()["Namespaces"][0]["Id"] service = client.create_service(Name="backend", NamespaceId=namespace_id) client.register_instance( ServiceId=service["Service"]["Id"], InstanceId="i-0123456789", Attributes={"AWS_INSTANCE_IPV4": "10.0.0.10"}, ) found = client.discover_instances(NamespaceName="floci-demo", ServiceName="backend") print(found["Instances"]) ``` -------------------------------- ### Install Java using SDKMAN Source: https://github.com/floci-io/floci/blob/main/CONTRIBUTING.md Installs Java 25+ using SDKMAN, a convenient tool for managing SDK versions. Ensure SDKMAN is initialized before installing. ```bash curl -s "https://get.sdkman.io" | bash source "$HOME/.sdkman/bin/sdkman-init.sh" sdk install java 25-open ``` -------------------------------- ### Python SDK: Get Products and Parse Price List Source: https://github.com/floci-io/floci/blob/main/docs/services/pricing.md Use the boto3 SDK to retrieve product offers and parse the JSON-encoded product strings from the PriceList. This example demonstrates fetching EC2 products and printing their SKUs. ```python import boto3 client = boto3.client( "pricing", endpoint_url="http://localhost:4566", region_name="us-east-1", ) resp = client.get_products( ServiceCode="AmazonEC2", Filters=[ {"Type": "TERM_MATCH", "Field": "instanceType", "Value": "t3.micro"}, {"Type": "TERM_MATCH", "Field": "regionCode", "Value": "us-east-1"}, ], ) for item in resp["PriceList"]: # AWS returns PriceList as an array of JSON strings; parse each separately. import json print(json.loads(item)["product"]["sku"]) ``` -------------------------------- ### StartExecution Source: https://github.com/floci-io/floci/blob/main/docs/services/step-functions.md Starts a new execution of a state machine. ```APIDOC ## StartExecution ### Description Starts a new execution. ### Method POST ### Endpoint / ### Parameters #### Query Parameters - **X-Amz-Target** (string) - Required - `"AmazonStatesService.StartExecution"` #### Request Body - **stateMachineArn** (string) - Required - The ARN of the state machine to execute. - **input** (string) - Optional - The JSON input for the execution. - **name** (string) - Optional - A unique name for the execution. If omitted, a unique name is generated. ### Request Example ```json { "stateMachineArn": "arn:aws:states:us-east-1:123456789012:stateMachine:my-workflow", "input": "{\"key\": \"value\"}" } ``` ### Response #### Success Response (200) - **executionArn** (string) - The ARN of the execution. - **startDate** (timestamp) - The date and time the execution started. #### Response Example ```json { "executionArn": "arn:aws:states:us-east-1:123456789012:stateMachine:my-workflow:execution-id-12345", "startDate": "2023-10-27T10:05:00.000Z" } ``` ``` -------------------------------- ### Example: Query Source: https://github.com/floci-io/floci/blob/main/docs/services/dynamodb.md Example of how to query items in a DynamoDB table by partition key using the AWS CLI. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # Query (partition key) aws dynamodb query \ --table-name Users \ --key-condition-expression "userId = :id" \ --expression-attribute-values '{':id':{"S":"u1"}}' \ --endpoint-url $AWS_ENDPOINT_URL ``` -------------------------------- ### Install testcontainers-floci Source: https://github.com/floci-io/floci/blob/main/docs/testcontainers/python.md Install the testcontainers-floci package using pip, poetry, or uv. ```sh pip install testcontainers-floci ``` ```sh # poetry poetry add --group dev testcontainers-floci # uv uv add --dev testcontainers-floci ``` -------------------------------- ### Start Step Functions Execution Source: https://github.com/floci-io/floci/blob/main/docs/services/step-functions.md Starts a new execution for a given state machine ARN with optional input. The execution ARN is outputted. ```bash # Start an execution EXEC_ARN=$(aws stepfunctions start-execution \ --state-machine-arn $SM_ARN \ --input '{"key":"value"}' \ --query executionArn --output text \ --endpoint-url $AWS_ENDPOINT_URL) ``` -------------------------------- ### Start Floci and Create S3 Bucket Source: https://github.com/floci-io/floci/blob/main/docs/index.md This snippet demonstrates starting the Floci service in detached mode and then using the AWS CLI to create an S3 bucket, targeting the local Floci endpoint. ```bash docker compose up -d aws --endpoint-url http://localhost:4566 s3 mb s3://my-bucket ``` -------------------------------- ### Start Floci from Source Source: https://github.com/floci-io/floci/blob/main/docs/getting-started/quick-start.md Clone the Floci repository and use Maven to run it in development mode with hot reloading enabled. This method starts Floci on port 4566. ```bash git clone https://github.com/floci-io/floci.git cd floci mvn quarkus:dev # hot reload, port 4566 ``` -------------------------------- ### RDS Data API Example Source: https://github.com/floci-io/floci/blob/main/docs/services/rds-data.md This example demonstrates how to set up an RDS cluster, retrieve its ARN, create a secret for database credentials, and execute a SQL statement using the RDS Data API. Ensure the AWS endpoint URL is correctly set. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 aws rds create-db-cluster \ --db-cluster-identifier appdb \ --engine aurora-mysql \ --master-username admin \ --master-user-password secret123 \ --database-name app \ --endpoint-url "$AWS_ENDPOINT_URL" RESOURCE_ARN=$(aws rds describe-db-clusters \ --db-cluster-identifier appdb \ --query 'DBClusters[0].DBClusterArn' \ --output text \ --endpoint-url "$AWS_ENDPOINT_URL") SECRET_ARN=$(aws secretsmanager create-secret \ --name appdb/data-api \ --secret-string '{"username":"admin","password":"secret123"}' \ --query ARN \ --output text \ --endpoint-url "$AWS_ENDPOINT_URL") aws rds-data execute-statement \ --resource-arn "$RESOURCE_ARN" \ --secret-arn "$SECRET_ARN" \ --database app \ --sql "select 1 as count" \ --include-result-metadata \ --endpoint-url "$AWS_ENDPOINT_URL" ``` -------------------------------- ### StartBuild Source: https://github.com/floci-io/floci/blob/main/docs/services/codebuild.md Launches a new build execution using the specified project configuration. Returns immediately with the build status. ```APIDOC ## StartBuild ### Description Launches a new build execution using the specified project configuration. Returns immediately with the build status. ### Method POST ### Endpoint / ### Headers - **X-Amz-Target**: CodeBuild_20161006.StartBuild ### Parameters #### Request Body - **projectName** (string) - Required - The name of the project to use for the build. - **buildspecOverride** (string) - Optional - An inline buildspec to use for the build, overriding the one in the project configuration. ### Request Example ```bash aws --endpoint-url http://localhost:4566 codebuild start-build \ --project-name my-project \ --buildspec-override 'version: 0.2 phases: build: commands: - echo hello > output.txt artifacts: files: - output.txt' ``` ### Response #### Success Response (200) - **build** (object) - The record for the started build. - **id** (string) - The unique identifier for the build. - **buildStatus** (string) - The current status of the build (e.g., IN_PROGRESS). #### Response Example ```json { "build": { "id": "my-project:a1b2c3d4-e5f6-7890-1234-567890abcdef", "buildStatus": "IN_PROGRESS" } } ``` ``` -------------------------------- ### Configure TRACE Logging for SQS Service in TestContainers Example Source: https://github.com/floci-io/floci/blob/main/docs/configuration/advanced/application-yml.md Example of setting TRACE logging for the SQS service when using Floci within a TestContainers setup. ```java new GenericContainer<>("floci/floci:latest") .withExposedPorts(4566) .withEnv("QUARKUS_LOG_CATEGORY__IO_GITHUB_HECTORVENT_FLOCI_SERVICES_SQS__LEVEL", "TRACE"); ``` -------------------------------- ### Create AppConfig Deployment Strategy and Start Deployment Source: https://github.com/floci-io/floci/blob/main/docs/services/appconfig.md These commands define an immediate deployment strategy and then initiate the deployment of a configuration version to an environment. You will need to substitute ``, ``, ``, and `` with your specific identifiers. ```bash # Create immediate deployment strategy aws appconfig create-deployment-strategy \ --name immediate \ --deployment-duration-in-minutes 0 \ --growth-factor 100 \ --final-bake-time-in-minutes 0 \ --endpoint-url http://localhost:4566 # Start deployment aws appconfig start-deployment \ --application-id \ --environment-id \ --configuration-profile-id \ --configuration-version 1 \ --deployment-strategy-id \ --endpoint-url http://localhost:4566 ``` -------------------------------- ### DynamoDB Item Put and Get Test Source: https://github.com/floci-io/floci/blob/main/docs/testcontainers/nodejs.md This example demonstrates testing DynamoDB operations, specifically creating a table, putting an item, and getting it back, using a Floci container and the AWS SDK for JavaScript. ```typescript import { FlociContainer } from "@floci/testcontainers"; import { DynamoDBClient, CreateTableCommand, PutItemCommand, GetItemCommand, } from "@aws-sdk/client-dynamodb"; describe("DynamoDB", () => { let floci: FlociContainer; let dynamo: DynamoDBClient; beforeAll(async () => { floci = await new FlociContainer().start(); dynamo = new DynamoDBClient({ endpoint: floci.getEndpoint(), region: floci.getRegion(), credentials: { accessKeyId: floci.getAccessKey(), secretAccessKey: floci.getSecretKey(), }, }); }); afterAll(async () => { await floci.stop(); }); it("should put and get an item", async () => { await dynamo.send( new CreateTableCommand({ TableName: "Orders", AttributeDefinitions: [{ AttributeName: "id", AttributeType: "S" }], KeySchema: [{ AttributeName: "id", KeyType: "HASH" }], BillingMode: "PAY_PER_REQUEST", }) ); await dynamo.send( new PutItemCommand({ TableName: "Orders", Item: { id: { S: "order-1" }, status: { S: "placed" }, }, }) ); const { Item } = await dynamo.send( new GetItemCommand({ TableName: "Orders", Key: { id: { S: "order-1" } }, }) ); expect(Item?.status?.S).toBe("placed"); }); }); ``` -------------------------------- ### Create AppConfig Hosted Configuration Profile and Version Source: https://github.com/floci-io/floci/blob/main/docs/services/appconfig.md This snippet demonstrates how to set up a hosted configuration profile and then create a new version of that configuration with specific content. Replace `` and `` with your actual IDs. ```bash # Create configuration profile aws appconfig create-configuration-profile \ --application-id \ --name my-profile \ --location-uri hosted \ --type AWS.Freeform \ --endpoint-url http://localhost:4566 # Create hosted configuration version aws appconfig create-hosted-configuration-version \ --application-id \ --configuration-profile-id \ --content "{\"foo\": \"bar\"}" \ --content-type application/json \ --endpoint-url http://localhost:4566 ``` -------------------------------- ### Vitest Global Setup for Testcontainers Source: https://github.com/floci-io/floci/blob/main/docs/testcontainers/nodejs.md Configure Vitest to start a Testcontainers instance once for all tests and expose its endpoint via an environment variable. ```typescript // vitest.global-setup.ts import { FlociContainer } from "@floci/testcontainers"; let floci: FlociContainer; export async function setup() { floci = await new FlociContainer().start(); process.env.FLOCI_ENDPOINT = floci.getEndpoint(); } export async function teardown() { await floci?.stop(); } ``` ```typescript // vitest.config.ts import { defineConfig } from "vitest/config"; export default defineConfig({ test: { globalSetup: "./vitest.global-setup.ts", }, }); ``` -------------------------------- ### Jest Global Setup for Testcontainers Source: https://github.com/floci-io/floci/blob/main/docs/testcontainers/nodejs.md Configure Jest to start a Testcontainers instance once for all tests and expose its endpoint via an environment variable. ```typescript // jest.global-setup.ts import { FlociContainer } from "@floci/testcontainers"; let floci: FlociContainer; export async function setup() { floci = await new FlociContainer().start(); process.env.FLOCI_ENDPOINT = floci.getEndpoint(); } export async function teardown() { await floci?.stop(); } ``` ```json // jest.config.json { "globalSetup": "./jest.global-setup.ts" } ``` -------------------------------- ### Get CloudWatch Metric Statistics Source: https://github.com/floci-io/floci/blob/main/docs/services/cloudwatch.md Fetch statistical data for a metric over a specified time period. This example retrieves the Sum for the last hour. ```bash aws cloudwatch get-metric-statistics \ --namespace MyApp \ --metric-name RequestCount \ --dimensions Name=Service,Value=api \ --start-time $(date -u -v-1H +%Y-%m-%dT%H:%M:%SZ) \ --end-time $(date -u +%Y-%m-%dT%H:%M:%SZ) \ --period 300 \ --statistics Sum \ --endpoint-url $AWS_ENDPOINT_URL ``` -------------------------------- ### Python Boto3 SSM Client Configuration Source: https://github.com/floci-io/floci/blob/main/README.md Set up the boto3 SSM client to interact with Floci at the local endpoint. This example demonstrates putting and getting a parameter. ```python import boto3 client = boto3.client( "ssm", endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test", ) client.put_parameter( Name="/demo/app/message", Value="hello from floci", Type="String", Overwrite=True, ) response = client.get_parameter(Name="/demo/app/message") print(response["Parameter"]["Value"]) ``` -------------------------------- ### Create RDS DB Instance and Connect Source: https://github.com/floci-io/floci/blob/main/docs/configuration/ports.md Illustrates creating an RDS DB instance and connecting to its proxied port using psql. ```bash aws rds create-db-instance \ --db-instance-identifier mydb \ --db-instance-class db.t3.micro \ --engine postgres \ --master-username admin \ --master-user-password secret \ --endpoint-url http://localhost:4566 # Connect using the proxied port (returned in DescribeDBInstances Endpoint.Port) psql -h localhost -p 7001 -U admin ``` -------------------------------- ### Clone and Run Floci with Maven Wrapper Source: https://github.com/floci-io/floci/blob/main/CONTRIBUTING.md Clones the Floci repository and starts the application in development mode with hot-reloading enabled. Uses the Maven wrapper, so Maven installation is not required. ```bash git clone https://github.com/floci-io/floci.git cd floci ./mvnw quarkus:dev # hot reload on port 4566 ``` -------------------------------- ### Node.js/TypeScript Testcontainers Floci Integration Source: https://github.com/floci-io/floci/blob/main/README.md Example of using Floci Testcontainers in Node.js/TypeScript tests to create an S3 bucket. This includes starting and stopping the container and configuring the S3 client. ```ts import { FlociContainer } from "@floci/testcontainers"; import { S3Client, CreateBucketCommand } from "@aws-sdk/client-s3"; describe("S3", () => { let floci: FlociContainer; beforeAll(async () => { floci = await new FlociContainer().start(); }); afterAll(async () => { await floci.stop(); }); it("creates a bucket", async () => { const s3 = new S3Client({ endpoint: floci.getEndpoint(), region: floci.getRegion(), credentials: { accessKeyId: floci.getAccessKey(), secretAccessKey: floci.getSecretKey(), }, forcePathStyle: true, }); await s3.send(new CreateBucketCommand({ Bucket: "my-bucket" })); }); }); ``` -------------------------------- ### AWS CLI Cloud Map Setup and Discovery Source: https://github.com/floci-io/floci/blob/main/docs/services/cloudmap.md Demonstrates setting up AWS Cloud Map using the AWS CLI, including creating namespaces, services, registering instances, and discovering instances. Ensure AWS credentials and endpoint are configured. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 export AWS_DEFAULT_REGION=us-east-1 export AWS_ACCESS_KEY_ID=test export AWS_SECRET_ACCESS_KEY=test aws servicediscovery create-http-namespace --name floci-demo aws servicediscovery list-namespaces aws servicediscovery create-service \ --name backend \ --namespace-id ns-xxxxxxxxxxxxxxxxxxxx aws servicediscovery register-instance \ --service-id srv-xxxxxxxxxxxxxxxxxxxx \ --instance-id i-0123456789 \ --attributes AWS_INSTANCE_IPV4=10.0.0.10 aws servicediscovery discover-instances \ --namespace-name floci-demo \ --service-name backend ``` -------------------------------- ### StartServer Source: https://github.com/floci-io/floci/blob/main/docs/services/transfer.md Transitions a file transfer server from the `OFFLINE` state to the `ONLINE` state. ```APIDOC ## POST /servers/{serverId}/start ### Description Transitions a server from `OFFLINE` to `ONLINE`. ### Method POST ### Endpoint `/servers/{serverId}/start` ### Parameters #### Path Parameters - **serverId** (string) - Required - The unique identifier of the server to start. ### Response #### Success Response (200) - **ServerId** (string) - The unique identifier of the started server. #### Response Example ```json { "ServerId": "s-01234567890abcdef" } ``` ``` -------------------------------- ### Start and Get Transcribe Job with Python Boto3 Source: https://github.com/floci-io/floci/blob/main/docs/services/transcribe.md Shows how to initiate a transcription job and retrieve its status using the Python Boto3 SDK. The client is configured to use the local Floci endpoint. ```python import boto3 client = boto3.client( "transcribe", endpoint_url="http://localhost:4566", region_name="us-east-1", ) client.start_transcription_job( TranscriptionJobName="floci-demo", Media={"MediaFileUri": "s3://my-bucket/audio.mp3"}, LanguageCode="en-US", MediaFormat="mp3", ) job = client.get_transcription_job(TranscriptionJobName="floci-demo") print(job["TranscriptionJob"]["TranscriptionJobStatus"]) # COMPLETED ``` -------------------------------- ### Create and Configure a REST API Source: https://github.com/floci-io/floci/blob/main/docs/services/api-gateway.md This snippet demonstrates the creation of a REST API, including setting up resources, methods, and integrations, and deploying it to a stage. Ensure AWS CLI is configured with the correct endpoint URL. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # Create a REST API API_ID=$(aws apigateway create-rest-api \ --name "My API" \ --query id --output text \ --endpoint-url $AWS_ENDPOINT_URL) # Get the root resource ROOT_ID=$(aws apigateway get-resources \ --rest-api-id $API_ID \ --query 'items[?path==`/`].id' --output text \ --endpoint-url $AWS_ENDPOINT_URL) # Create a resource RESOURCE_ID=$(aws apigateway create-resource \ --rest-api-id $API_ID \ --parent-id $ROOT_ID \ --path-part users \ --query id --output text \ --endpoint-url $AWS_ENDPOINT_URL) # Add a GET method aws apigateway put-method \ --rest-api-id $API_ID \ --resource-id $RESOURCE_ID \ --http-method GET \ --authorization-type NONE \ --endpoint-url $AWS_ENDPOINT_URL # Add a Lambda integration aws apigateway put-integration \ --rest-api-id $API_ID \ --resource-id $RESOURCE_ID \ --http-method GET \ --type AWS_PROXY \ --integration-http-method POST \ --uri "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:000000000000:function:my-function/invocations" \ --endpoint-url $AWS_ENDPOINT_URL # Deploy to a stage aws apigateway create-deployment \ --rest-api-id $API_ID \ --stage-name dev \ --endpoint-url $AWS_ENDPOINT_URL # Call the deployed API curl http://localhost:4566/restapis/$API_ID/dev/_user_request_/users ``` -------------------------------- ### Start, Poll, and Get Results for a Simple Athena Query Source: https://github.com/floci-io/floci/blob/main/docs/services/athena.md This snippet demonstrates how to execute a basic SQL query against Athena, poll for its completion, and retrieve the results. Ensure AWS credentials and endpoint are configured. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # Start a query QUERY_ID=$(aws athena start-query-execution \ --query-string "SELECT 42 AS answer" \ --query 'QueryExecutionId' \ --output text) # Wait for completion aws athena get-query-execution --query-execution-id $QUERY_ID # Get results aws athena get-query-results --query-execution-id $QUERY_ID ``` -------------------------------- ### Configure Floci Services with Testcontainers Go Source: https://github.com/floci-io/floci/blob/main/docs/testcontainers/go.md Demonstrates how to initialize a Floci container and configure multiple services like S3, SQS, and DynamoDB using their respective WithConfig methods. ```go container, err := floci.NewFlociContainer(). WithS3Config(floci.S3Config{ Enabled: true, DefaultPresignExpirySeconds: 7200, }). WithSqsConfig(floci.SqsConfig{ Enabled: true, DefaultVisibilityTimeout: 60, MaxMessageSize: 131072, }). WithDynamoDbConfig(floci.DynamoDbConfig{ Enabled: true, }). Start(ctx) ``` -------------------------------- ### Run Floci on Podman (Rootless) Source: https://github.com/floci-io/floci/blob/main/docs/configuration/docker.md Example command to run Floci under rootless Podman, including network creation and necessary environment variables for proper communication. ```bash podman network create floci-net podman run -d --name floci \ --network floci-net \ -p 4566:4566 \ -v /run/user/$(id -u)/podman/podman.sock:/var/run/docker.sock:Z \ -e FLOCI_SERVICES_LAMBDA_DOCKER_NETWORK=floci-net \ -e FLOCI_HOSTNAME=floci \ floci/floci ``` -------------------------------- ### Create EKS Cluster and Describe Source: https://github.com/floci-io/floci/blob/main/docs/configuration/ports.md Shows how to create an EKS cluster and retrieve its API server endpoint, which will be on a host-bound port. ```bash aws eks create-cluster \ --name my-cluster \ --role-arn arn:aws:iam::000000000000:role/eks-role \ --resources-vpc-config subnetIds=[],securityGroupIds=[] \ --endpoint-url http://localhost:4566 # DescribeCluster returns the API server address, e.g. https://localhost:6500 ``` -------------------------------- ### Run Go SDK Compatibility Tests via Just Source: https://github.com/floci-io/floci/blob/main/compatibility-tests/sdk-test-go/README.md Execute Go SDK compatibility tests using the 'just' command, assuming you are in the 'compatibility-tests/' directory. ```bash just test-go ``` -------------------------------- ### Subscribe to Kinesis Shard via EFO Source: https://github.com/floci-io/floci/blob/main/docs/services/kinesis.md Subscribes to a specific shard of a Kinesis stream for enhanced fan-out (EFO). This example shows how the AWS CLI streams events to stdout. Replace \ with your actual consumer ARN and specify the shard ID and starting position. ```bash # Subscribe (AWS CLI streams events to stdout) aws kinesis subscribe-to-shard \ --consumer-arn \ --shard-id shardId-000000000000 \ --starting-position Type=TRIM_HORIZON ``` -------------------------------- ### Connect to MySQL Instance Source: https://github.com/floci-io/floci/blob/main/docs/services/rds.md Connect to a MySQL instance using the mysql client. Specify the host, port, username, and password. ```bash # Connect with mysql client mysql -h 127.0.0.1 -P 7002 -u root -psecret123 ``` -------------------------------- ### Connect to PostgreSQL Instance Source: https://github.com/floci-io/floci/blob/main/docs/services/rds.md Connect to a PostgreSQL instance using the psql client. Use the host and port obtained from the describe-db-instances command. ```bash # Connect with psql (use the port returned above) psql -h localhost -p 7001 -U admin ``` -------------------------------- ### AWS EKS CLI Examples Source: https://github.com/floci-io/floci/blob/main/docs/services/eks.md These commands demonstrate common AWS EKS operations using the AWS CLI. Ensure your AWS credentials and endpoint are configured correctly for local testing with Floci. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 export AWS_DEFAULT_REGION=us-east-1 export AWS_ACCESS_KEY_ID=test export AWS_SECRET_ACCESS_KEY=test ``` ```bash # Create a cluster aws eks create-cluster \ --name my-cluster \ --role-arn arn:aws:iam::000000000000:role/eks-role \ --resources-vpc-config subnetIds=[],securityGroupIds=[] \ --kubernetes-version 1.29 ``` ```bash # Describe the cluster aws eks describe-cluster --name my-cluster ``` ```bash # List clusters aws eks list-clusters ``` ```bash # Tag a cluster aws eks tag-resource \ --resource-arn arn:aws:eks:us-east-1:000000000000:cluster/my-cluster \ --tags env=dev,team=platform ``` ```bash # Delete a cluster aws eks delete-cluster --name my-cluster ``` -------------------------------- ### AWS WAF v2 CLI Examples Source: https://github.com/floci-io/floci/blob/main/docs/services/wafv2.md Demonstrates creating an IP set, a default-allow web ACL, and listing web ACLs using the AWS CLI with Floci's WAF v2 emulation. Ensure the AWS_ENDPOINT_URL is set to http://localhost:4566. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # Create an IP set aws wafv2 create-ip-set \ --name blocklist --scope REGIONAL \ --ip-address-version IPV4 \ --addresses 192.0.2.0/24 # Create a web ACL that allows by default aws wafv2 create-web-acl \ --name demo-acl --scope REGIONAL \ --default-action Allow={} \ --visibility-config SampledRequestsEnabled=true,CloudWatchMetricsEnabled=true,MetricName=demo aws wafv2 list-web-acls --scope REGIONAL ``` -------------------------------- ### Path-Style S3 URL Example Source: https://github.com/floci-io/floci/blob/main/docs/services/s3.md This is an example of a path-style S3 URL. ```text http://localhost:4566/my-bucket/my-key ``` -------------------------------- ### DescribeRule Source: https://github.com/floci-io/floci/blob/main/docs/services/eventbridge.md Gets details about a rule. Use this to get details about a rule in your account. ```APIDOC ## DescribeRule ### Description Gets details about a rule. Use this to get details about a rule in your account. ### Method POST ### Endpoint http://localhost:4566/ ### Parameters #### Request Body - **Name** (string) - Required - The name of the rule. - **EventBusName** (string) - Optional - The name of the event bus associated with the rule. If you omit this, the `default` event bus is used. ### Request Example { "Name": "order-placed-rule", "EventBusName": "my-bus" } ### Response #### Success Response (200) - **RuleArn** (string) - The Amazon Resource Name (ARN) of the rule. - **Name** (string) - The name of the rule. - **State** (string) - The state of the rule (ENABLED or DISABLED). - **EventPattern** (string) - The event pattern. - **ScheduleExpression** (string) - The schedule expression. - **Description** (string) - The description of the rule. - **EventBusName** (string) - The name of the event bus. - **CreatedBy** (string) - The ARN of the AWS account that created the rule. - **RoleArn** (string) - The ARN of the IAM role used to publish events to targets or subscribe to event streams. #### Response Example { "RuleArn": "arn:aws:events:us-east-1:123456789012:rule/my-bus/order-placed-rule", "Name": "order-placed-rule", "State": "ENABLED", "EventPattern": "{\"source\":[\"com.myapp\"],\"detail-type\":[\"OrderPlaced\"]}", "ScheduleExpression": null, "Description": null, "EventBusName": "my-bus", "CreatedBy": "arn:aws:iam::123456789012:root", "RoleArn": null } ``` -------------------------------- ### Start Lambda Deployment CLI Source: https://github.com/floci-io/floci/blob/main/docs/services/codedeploy.md Command to initiate a Lambda deployment. It requires the application name, deployment group name, and revision details, including the AppSpec content. ```bash # Start a Lambda deployment aws --endpoint-url http://localhost:4566 deploy create-deployment \ --application-name my-app \ --deployment-group-name my-group \ --revision 'revisionType=AppSpecContent,appSpecContent={content="{\"version\":0.0,\"Resources\":[{\"myFunction\":{\"Type\":\"AWS::Lambda::Function\",\"Properties\":{\"Name\":\"my-function\",\"Alias\":\"live\",\"CurrentVersion\":\"1\",\"TargetVersion\":\"2\"}}}]}"}' ``` -------------------------------- ### Virtual-Hosted Style S3 URL Example Source: https://github.com/floci-io/floci/blob/main/docs/services/s3.md This is an example of a virtual-hosted style S3 URL. ```text http://my-bucket.s3.localhost.floci.io:4566/my-key ``` -------------------------------- ### Fast CI Storage Mode Source: https://github.com/floci-io/floci/blob/main/docs/configuration/storage.md Use 'memory' mode for the fastest startup and test execution, as all data is kept in memory. ```bash FLOCI_STORAGE_MODE=memory ``` -------------------------------- ### AWS CLI Configuration and Converse Example Source: https://github.com/floci-io/floci/blob/main/docs/services/bedrock-runtime.md Sets up environment variables for AWS CLI to point to the local endpoint and demonstrates a 'converse' operation. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 export AWS_DEFAULT_REGION=us-east-1 export AWS_ACCESS_KEY_ID=test export AWS_SECRET_ACCESS_KEY=test # Converse aws bedrock-runtime converse \ --model-id anthropic.claude-3-haiku-20240307-v1:0 \ --messages '[{"role":"user","content":[{"text":"hi"}]}]' ``` -------------------------------- ### Start Floci with TLS Enabled Locally Source: https://github.com/floci-io/floci/blob/main/compatibility-tests/sdk-test-node/README.md Initiates the Floci emulator with TLS enabled for testing HTTPS and WSS connectivity. Requires Java and Maven. ```bash FLOCI_TLS_ENABLED=true ./mvnw quarkus:dev ``` -------------------------------- ### DescribeEventBus Source: https://github.com/floci-io/floci/blob/main/docs/services/eventbridge.md Gets event bus details. Use this to get details about an event bus in your account. ```APIDOC ## DescribeEventBus ### Description Gets event bus details. Use this to get details about an event bus in your account. ### Method POST ### Endpoint http://localhost:4566/ ### Parameters #### Request Body - **Name** (string) - Optional - The name of the event bus to describe. If not specified, the default event bus is described. ### Request Example { "Name": "my-bus" } ### Response #### Success Response (200) - **Name** (string) - The name of the event bus. - **Arn** (string) - The Amazon Resource Name (ARN) of the event bus. - **Policy** (string) - The event bus policy. - **KmsKeyArn** (string) - The identifier of the KMS key associated with the event bus. - **DeadLetterConfig** (object) - Configuration details of the dead-letter queue to use for the event bus. - **FirewallConfig** (object) - Configuration details of the event bus firewall. #### Response Example { "Name": "my-bus", "Arn": "arn:aws:events:us-east-1:123456789012:event-bus/my-bus", "Policy": "{\"Version\":\"1.0\",\"Statement\":[...]}", "KmsKeyArn": "arn:aws:kms:us-east-1:123456789012:key/your-kms-key-id", "DeadLetterConfig": { "Arn": "arn:aws:sqs:us-east-1:123456789012:my-dead-letter-queue" }, "FirewallConfig": { "FirewallRules": [ { "Name": "block-unauthorized", "Action": "BLOCK" } ] } } ``` -------------------------------- ### Python pip Installation for Testcontainers Floci Source: https://github.com/floci-io/floci/blob/main/README.md Install the testcontainers-floci package for Python projects using pip. ```sh pip install testcontainers-floci ``` -------------------------------- ### Start Schema Creation Source: https://github.com/floci-io/floci/blob/main/docs/services/appsync.md Initiates the creation of a GraphQL schema for your API. Replace API_ID with your actual API ID. ```bash # Start schema creation aws appsync start-schema-creation \ --api-id API_ID \ --definition 'type Query { hello: String }' \ --endpoint-url $AWS_ENDPOINT_URL ``` -------------------------------- ### Node.js/TypeScript npm Installation Source: https://github.com/floci-io/floci/blob/main/README.md Install the Floci Testcontainers package for Node.js or TypeScript projects using npm. ```sh npm install --save-dev @floci/testcontainers ```