### Create and Configure REST API Source: https://floci.io/floci/services/api-gateway This example demonstrates creating a REST API, setting up a resource, adding a GET method with a Lambda proxy integration, and deploying it to a stage. It concludes with an example of calling the deployed API. ```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 ``` -------------------------------- ### Examples Source: https://floci.io/floci/services/s3 Command-line examples for interacting with the S3 service. ```APIDOC ## Examples ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # Create bucket aws s3 mb s3://my-bucket --endpoint-url $AWS_ENDPOINT_URL # Upload a file aws s3 cp ./report.pdf s3://my-bucket/reports/report.pdf --endpoint-url $AWS_ENDPOINT_URL # Upload inline content echo '{"hello":"world"}' | aws s3 cp - s3://my-bucket/data.json --endpoint-url $AWS_ENDPOINT_URL # Download aws s3 cp s3://my-bucket/data.json ./data.json --endpoint-url $AWS_ENDPOINT_URL # Inspect object attributes without downloading the body aws s3api get-object-attributes \ --bucket my-bucket \ --key data.json \ --object-attributes ETag ObjectSize StorageClass \ --endpoint-url $AWS_ENDPOINT_URL # List aws s3 ls s3://my-bucket --endpoint-url $AWS_ENDPOINT_URL # Delete aws s3 rm s3://my-bucket/data.json --endpoint-url $AWS_ENDPOINT_URL # Enable versioning aws s3api put-bucket-versioning \ --bucket my-bucket \ --versioning-configuration Status=Enabled \ --endpoint-url $AWS_ENDPOINT_URL # Generate a pre-signed URL (valid for 1 hour) aws s3 presign s3://my-bucket/report.pdf \ --expires-in 3600 \ --endpoint-url $AWS_ENDPOINT_URL ``` ``` -------------------------------- ### Verify Floci Setup with Smoke Tests Source: https://floci.io/floci/getting-started/quick-start Run basic S3, SQS, and DynamoDB commands to verify the installation. ```bash # S3 — create a bucket and upload a file aws s3 mb s3://my-bucket --endpoint-url $AWS_ENDPOINT_URL echo "hello floci" | aws s3 cp - s3://my-bucket/hello.txt --endpoint-url $AWS_ENDPOINT_URL aws s3 ls s3://my-bucket --endpoint-url $AWS_ENDPOINT_URL # SQS — create a queue and send a message aws sqs create-queue --queue-name orders --endpoint-url $AWS_ENDPOINT_URL aws sqs send-message \ --queue-url $AWS_ENDPOINT_URL/000000000000/orders \ --message-body '{"event":"order.placed"}' \ --endpoint-url $AWS_ENDPOINT_URL # DynamoDB — create a table aws dynamodb create-table \ --table-name Users \ --attribute-definitions AttributeName=id,AttributeType=S \ --key-schema AttributeName=id,KeyType=HASH \ --billing-mode PAY_PER_REQUEST \ --endpoint-url $AWS_ENDPOINT_URL ``` -------------------------------- ### Retrieve Configuration via AppConfigData Data Plane Source: https://floci.io/floci/services/appconfig This example demonstrates how to start a configuration session and then retrieve the latest configuration using the AppConfigData data plane. It captures the configuration token for subsequent requests. ```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 ``` -------------------------------- ### SQS Examples Source: https://floci.io/floci/services/sqs Examples demonstrating common SQS operations using the AWS CLI. ```APIDOC ## Examples ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # Create a standard queue aws sqs create-queue --queue-name orders --endpoint-url $AWS_ENDPOINT_URL # Create a FIFO queue aws sqs create-queue \ --queue-name orders.fifo \ --attributes FifoQueue=true \ --endpoint-url $AWS_ENDPOINT_URL # Send a message QUEUE_URL="$AWS_ENDPOINT_URL/000000000000/orders" aws sqs send-message \ --queue-url $QUEUE_URL \ --message-body '{"event":"order.placed","id":"abc123"}' \ --endpoint-url $AWS_ENDPOINT_URL # Receive messages aws sqs receive-message \ --queue-url $QUEUE_URL \ --max-number-of-messages 10 \ --endpoint-url $AWS_ENDPOINT_URL # Delete a message (replace RECEIPT_HANDLE with the value from ReceiveMessage) aws sqs delete-message \ --queue-url $QUEUE_URL \ --receipt-handle "RECEIPT_HANDLE" \ --endpoint-url $AWS_ENDPOINT_URL # Set up a dead-letter queue DLQ_ARN=$(aws sqs get-queue-attributes \ --queue-url $AWS_ENDPOINT_URL/000000000000/orders-dlq \ --attribute-names QueueArn \ --query Attributes.QueueArn \ --output text \ --endpoint-url $AWS_ENDPOINT_URL) aws sqs set-queue-attributes \ --queue-url $QUEUE_URL \ --attributes "{\"RedrivePolicy\":\"{\\\"deadLetterTargetArn\\\":\\\"$DLQ_ARN\\\",\\\"maxReceiveCount\\\":3}\"}" \ --endpoint-url $AWS_ENDPOINT_URL ``` ``` -------------------------------- ### KMS API Examples Source: https://floci.io/floci/services/kms Examples demonstrating common KMS operations using the AWS CLI. ```APIDOC ## KMS API Examples ### Set Endpoint URL ```bash export AWS_ENDPOINT_URL=http://localhost:4566 ``` ### Create a Symmetric Key ```bash KEY_ID=$(aws kms create-key \ --description "My encryption key" \ --query KeyMetadata.KeyId --output text \ --endpoint-url $AWS_ENDPOINT_URL) ``` ### Create an Alias ```bash aws kms create-alias \ --alias-name alias/my-key \ --target-key-id $KEY_ID \ --endpoint-url $AWS_ENDPOINT_URL ``` ### Encrypt Data ```bash CIPHER=$(aws kms encrypt \ --key-id alias/my-key \ --plaintext "Hello, World!" \ --query CiphertextBlob --output text \ --endpoint-url $AWS_ENDPOINT_URL) ``` ### Decrypt Data ```bash aws kms decrypt \ --ciphertext-blob $CIPHER \ --query Plaintext --output text \ --endpoint-url $AWS_ENDPOINT_URL | base64 --decode ``` ### Generate Data Key (Envelope Encryption) ```bash aws kms generate-data-key \ --key-id alias/my-key \ --key-spec AES_256 \ --endpoint-url $AWS_ENDPOINT_URL ``` ``` -------------------------------- ### CloudFormation API Examples Source: https://floci.io/floci/services/cloudformation Practical examples demonstrating how to use the CloudFormation API for common operations. ```APIDOC ## CloudFormation API Examples **Environment Variable:** `export AWS_ENDPOINT_URL=http://localhost:4566` ### Validate a Template ```bash aws cloudformation validate-template \ --template-body file://template.yml \ --endpoint-url $AWS_ENDPOINT_URL ``` ### Deploy a Stack ```bash aws cloudformation create-stack \ --stack-name my-stack \ --template-body file://template.yml \ --parameters ParameterKey=Env,ParameterValue=dev \ --endpoint-url $AWS_ENDPOINT_URL ``` ### Check Stack Status ```bash aws cloudformation describe-stacks \ --stack-name my-stack \ --endpoint-url $AWS_ENDPOINT_URL ``` ### Watch Stack Events ```bash aws cloudformation describe-stack-events \ --stack-name my-stack \ --endpoint-url $AWS_ENDPOINT_URL ``` ### Update a Stack ```bash aws cloudformation update-stack \ --stack-name my-stack \ --template-body file://template.yml \ --endpoint-url $AWS_ENDPOINT_URL ``` ### Delete a Stack ```bash aws cloudformation delete-stack \ --stack-name my-stack \ --endpoint-url $AWS_ENDPOINT_URL ``` ### Create a Change Set ```bash aws cloudformation create-change-set \ --stack-name my-stack \ --change-set-name my-change-set \ --template-body file://template.yml \ --endpoint-url $AWS_ENDPOINT_URL ``` ### List Change Sets ```bash aws cloudformation list-change-sets \ --stack-name my-stack \ --endpoint-url $AWS_ENDPOINT_URL ``` ### Describe a Change Set ```bash aws cloudformation describe-change-set \ --stack-name my-stack \ --change-set-name my-change-set \ --endpoint-url $AWS_ENDPOINT_URL ``` ### Delete a Change Set ```bash aws cloudformation delete-change-set \ --stack-name my-stack \ --change-set-name my-change-set \ --endpoint-url $AWS_ENDPOINT_URL ``` ``` -------------------------------- ### Interact with ECS using Java SDK Source: https://floci.io/floci/services/ecs Example showing how to initialize the EcsClient and perform basic operations like cluster creation and task execution. ```java EcsClient ecs = EcsClient.builder() .endpointOverride(URI.create("http://localhost:4566")) .region(Region.US_EAST_1) .credentialsProvider(StaticCredentialsProvider.create( AwsBasicCredentials.create("test", "test"))) .build(); // Create cluster ecs.createCluster(r -> r.clusterName("my-cluster")); // Register task definition ecs.registerTaskDefinition(r -> r .family("my-task") .containerDefinitions(c -> c .name("app") .image("nginx:latest") .cpu(256) .memory(512) .essential(true)) .requiresCompatibilities(Compatibility.FARGATE) .cpu("256") .memory("512") .networkMode(NetworkMode.AWSVPC)); // Run a task RunTaskResponse response = ecs.runTask(r -> r .cluster("my-cluster") .taskDefinition("my-task") .launchType(LaunchType.FARGATE) .count(1)); String taskArn = response.tasks().get(0).taskArn(); ``` -------------------------------- ### Put Targets Example Source: https://floci.io/floci/services/eventbridge Example of how to add targets to a rule. ```APIDOC ## POST /targets ### Description Adds targets to a rule. ### Method POST ### Endpoint `http://localhost:4566/` ### Parameters #### Query Parameters - **X-Amz-Target** (string) - Required - `"AmazonEventBridge.PutTargets"` - **Content-Type** (string) - Required - `"application/x-amz-json-1.1"` #### Request Body - **Rule** (string) - Required - The name of the rule. - **EventBusName** (string) - Optional - The event bus associated with the rule. - **Targets** (array) - Required - The targets to add to the rule. Each target is a JSON object with an `Id` and `Arn`. - **Id** (string) - Required - The ID of the target. - **Arn** (string) - Required - The ARN of the target. ### Request Example ```json { "Rule": "order-placed-rule", "EventBusName": "my-bus", "Targets": [ { "Id": "process-order", "Arn": "arn:aws:lambda:us-east-1:000000000000:function:process-order" } ] } ``` ### Response #### Success Response (200) - **FailedAttempts** (integer) - The number of failed attempts to add targets. #### Response Example ```json { "FailedAttempts": 0 } ``` ``` -------------------------------- ### List Rules on Default Bus Example Source: https://floci.io/floci/services/eventbridge Example of how to list rules on the default event bus. ```APIDOC ## POST /rules ### Description Lists rules on the default event bus. ### Method POST ### Endpoint `http://localhost:4566/` ### Parameters #### Query Parameters - **X-Amz-Target** (string) - Required - `"AmazonEventBridge.ListRules"` - **Content-Type** (string) - Required - `"application/x-amz-json-1.1"` #### Request Body - **EventBusName** (string) - Optional - The name of the event bus to list rules from. Defaults to the default event bus. ### Request Example ```json { "EventBusName": "default" } ``` ### Response #### Success Response (200) - **Rules** (array) - A list of rules. - **Name** (string) - The name of the rule. - **Arn** (string) - The ARN of the rule. - **EventPattern** (string) - The event pattern of the rule. - **State** (string) - The state of the rule (ENABLED or DISABLED). - **Description** (string) - The description of the rule. - **ScheduleExpression** (string) - The schedule expression of the rule. #### Response Example ```json { "Rules": [ { "Name": "default-rule", "Arn": "arn:aws:events:us-east-1:000000000000:rule/default/default-rule", "EventPattern": "{}", "State": "ENABLED" } ] } ``` ``` -------------------------------- ### Put Events Example Source: https://floci.io/floci/services/eventbridge Example of how to publish custom events to an event bus. ```APIDOC ## POST /events ### Description Publishes custom events to an event bus. ### Method POST ### Endpoint `http://localhost:4566/` ### Parameters #### Query Parameters - **X-Amz-Target** (string) - Required - `"AmazonEventBridge.PutEvents"` - **Content-Type** (string) - Required - `"application/x-amz-json-1.1"` #### Request Body - **Entries** (array) - Required - A list of events to be placed on the event bus. Each entry is a JSON object. - **Source** (string) - Required - The source of the event. - **DetailType** (string) - Required - The type of event. - **Detail** (string) - Optional - The event data, in JSON format. - **EventBusName** (string) - Optional - The name of the event bus to receive the event. ### Request Example ```json { "Entries": [ { "Source": "com.myapp", "DetailType": "OrderPlaced", "Detail": "{\"orderId\":\"123\",\"amount\":99.99}", "EventBusName": "my-bus" } ] } ``` ### Response #### Success Response (200) - **FailedEntryCount** (integer) - The number of events that failed to be placed on the event bus. - **Entries** (array) - A list of successfully placed events. #### Response Example ```json { "FailedEntryCount": 0, "Entries": [ { "EventId": "example-event-id" } ] } ``` ``` -------------------------------- ### Clone and Run Floci from Source Source: https://floci.io/floci/getting-started/installation Clone the repository and start the application in development mode with hot reload. ```bash git clone https://github.com/floci-io/floci.git cd floci mvn quarkus:dev # dev mode with hot reload on port 4566 ``` -------------------------------- ### Start Floci with Native Image Source: https://floci.io/floci/getting-started/quick-start Use the native image for sub-second startup and minimal memory usage. ```yaml services: floci: image: hectorvent/floci:latest ports: - "4566:4566" volumes: # Local directory bind mount (default) - ./data:/app/data # OR named volume (optional): # - floci-data:/app/data # volumes: # floci-data: ``` ```bash docker compose up -d ``` -------------------------------- ### Send to Default Bus Example Source: https://floci.io/floci/services/eventbridge Example of how to send events to the default event bus. ```APIDOC ## POST /events ### Description Publishes custom events to the default event bus. ### Method POST ### Endpoint `http://localhost:4566/` ### Parameters #### Query Parameters - **X-Amz-Target** (string) - Required - `"AmazonEventBridge.PutEvents"` - **Content-Type** (string) - Required - `"application/x-amz-json-1.1"` #### Request Body - **Entries** (array) - Required - A list of events to be placed on the event bus. Each entry is a JSON object. - **Source** (string) - Required - The source of the event. - **DetailType** (string) - Required - The type of event. - **Detail** (string) - Optional - The event data, in JSON format. - **EventBusName** (string) - Optional - The name of the event bus to receive the event. Defaults to the default event bus. ### Request Example ```json { "Entries": [ { "Source": "myapp", "DetailType": "test", "Detail": "{}" } ] } ``` ### Response #### Success Response (200) - **FailedEntryCount** (integer) - The number of events that failed to be placed on the event bus. - **Entries** (array) - A list of successfully placed events. #### Response Example ```json { "FailedEntryCount": 0, "Entries": [ { "EventId": "example-event-id" } ] } ``` ``` -------------------------------- ### Put Rule Example Source: https://floci.io/floci/services/eventbridge Example of how to create or update a rule with an event pattern. ```APIDOC ## POST /rule ### Description Creates or updates a rule with a schedule or event pattern. ### Method POST ### Endpoint `http://localhost:4566/` ### Parameters #### Query Parameters - **X-Amz-Target** (string) - Required - `"AmazonEventBridge.PutRule"` - **Content-Type** (string) - Required - `"application/x-amz-json-1.1"` #### Request Body - **Name** (string) - Required - The name of the rule. - **EventBusName** (string) - Optional - The event bus to associate with the rule. - **EventPattern** (string) - Optional - The event pattern to match events against. - **ScheduleExpression** (string) - Optional - The schedule expression that defines when the rule triggers. - **State** (string) - Optional - Specifies whether the rule is enabled or disabled. Valid values are ENABLED and DISABLED. - **Description** (string) - Optional - A description of the rule. - **RoleArn** (string) - Optional - The Amazon Resource Name (ARN) of the IAM role used for event processing. ### Request Example ```json { "Name": "order-placed-rule", "EventBusName": "my-bus", "EventPattern": "{\"source\":[\"com.myapp\"],\"detail-type\":[\"OrderPlaced\"]}", "State": "ENABLED" } ``` ### Response #### Success Response (200) - **RuleArn** (string) - The ARN of the rule that was created or updated. #### Response Example ```json { "RuleArn": "arn:aws:events:us-east-1:000000000000:rule/my-bus/order-placed-rule" } ``` ``` -------------------------------- ### StartExecution API Source: https://floci.io/floci/services/step-functions Starts a new execution of a state machine. ```APIDOC ## POST / ### Description Starts a new execution of a state machine. ### 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 input data for the execution, in JSON format. - **name** (string) - Optional - A 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:my-execution-id", "startDate": "2023-10-27T10:05:00.000Z" } ``` ``` -------------------------------- ### Start Floci and Verify with AWS CLI Source: https://floci.io/floci Launch the container and use the AWS CLI to interact with the local endpoint. ```bash docker compose up -d aws --endpoint-url http://localhost:4566 s3 mb s3://my-bucket ``` -------------------------------- ### Create Event Bus Example Source: https://floci.io/floci/services/eventbridge Example of how to create a custom event bus using the EventBridge API. ```APIDOC ## POST /event-bus ### Description Creates a custom event bus. ### Method POST ### Endpoint `http://localhost:4566/` ### Parameters #### Query Parameters - **X-Amz-Target** (string) - Required - `"AmazonEventBridge.CreateEventBus"` - **Content-Type** (string) - Required - `"application/x-amz-json-1.1"` #### Request Body - **Name** (string) - Required - The name of the event bus to create. ### Request Example ```json { "Name": "my-bus" } ``` ### Response #### Success Response (200) - **Name** (string) - The name of the created event bus. - **Arn** (string) - The ARN of the created event bus. - **Policy** (string) - The event bus policy. #### Response Example ```json { "Name": "my-bus", "Arn": "arn:aws:events:us-east-1:000000000000:event-bus/my-bus", "Policy": "{\"Version\":\"1.0\",\"Statement\":[]}" } ``` ``` -------------------------------- ### Deploy Configuration with AWS AppConfig Source: https://floci.io/floci/services/appconfig This snippet shows how to create an immediate deployment strategy and then start a deployment for a specific configuration version. You will need to replace placeholders like ``, ``, ``, and ``. ```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 ``` -------------------------------- ### ECS Configuration Example Source: https://floci.io/floci/services/ecs Configure the ECS service, including enabling it, setting mock mode to skip Docker, specifying the Docker network, and default memory/CPU units. ```yaml floci: services: ecs: enabled: true mock: false # Set true to skip Docker and run tasks as in-process stubs docker-network: "" # Docker network for task containers default-memory-mb: 512 default-cpu-units: 256 ``` -------------------------------- ### Put Record Example Source: https://floci.io/floci/services/kinesis Example of how to put a single record into a Kinesis stream. ```APIDOC ## POST /api/records (PutRecord) ### Description Writes a single record to a specified Kinesis stream. ### Method POST ### Endpoint `http://localhost:4566/` ### Parameters #### Query Parameters - `X-Amz-Target` (string) - Required - `Kinesis_20131202.PutRecord` #### Request Body - **streamName** (string) - Required - The name of the stream. - **partitionKey** (string) - Required - The partition key for the record. - **data** (string) - Required - The data blob for the record, which is base64-encoded when the API is called from the AWS SDK. - **explicitHashKey** (string) - Optional - The hash for the partition key, used by consumers to determine the shard the data is written to. - **sequenceNumberForOrdering** (string) - Optional - If provided, the record is only written if the sequence number matches the one provided. ### Request Example ```json { "streamName": "events", "partitionKey": "user-123", "data": "{\"event\":\"page_view\",\"page\":\"/home\"}" } ``` ### Response #### Success Response (200) - **shardId** (string) - The shard ID for the record. - **sequenceNumber** (string) - The sequence number of the record. - **encryptionKeyId** (string) - The KMS key ARN used for encryption, if applicable. #### Response Example ```json { "shardId": "shardId-000000000000", "sequenceNumber": "49546986989198745041693827514997117051973174741777930755", "encryptionKeyId": null } ``` ``` -------------------------------- ### Create Stream Example Source: https://floci.io/floci/services/kinesis Example of how to create a new Kinesis stream with a specified name and shard count. ```APIDOC ## POST /api/streams (CreateStream) ### Description Creates a new Kinesis stream. ### Method POST ### Endpoint `http://localhost:4566/` ### Parameters #### Query Parameters - `X-Amz-Target` (string) - Required - `Kinesis_20131202.CreateStream` #### Request Body - **streamName** (string) - Required - The name of the stream to create. - **shardCount** (integer) - Required - The number of shards to provision for the stream. ### Request Example ```json { "streamName": "events", "shardCount": 2 } ``` ### Response #### Success Response (200) - **streamDescription** (object) - Contains details about the created stream. - **streamName** (string) - The name of the stream. - **streamARN** (string) - The Amazon Resource Name (ARN) of the stream. - **streamStatus** (string) - The current status of the stream (e.g., CREATING, ACTIVE). - **shards** (array) - An array of shard objects. - **retentionPeriodHours** (integer) - The retention period of the stream in hours. - **streamCreationTimestamp** (timestamp) - The timestamp when the stream was created. #### Response Example ```json { "streamDescription": { "streamName": "events", "streamARN": "arn:aws:kinesis:us-east-1:000000000000:stream/events", "streamStatus": "CREATING", "shards": [ { "shardId": "shardId-000000000000", "hashKeyRange": { "startingHashKey": "0", "endingHashKey": "340282366920938463463374607431768211455" }, "sequenceNumberRange": { "startingSequenceNumber": "49546986989198745041693827514997117051973174741777930754" } } ], "retentionPeriodHours": 24, "streamCreationTimestamp": "2023-10-27T10:00:00Z" } } ``` ``` -------------------------------- ### Start Floci with JVM Image Source: https://floci.io/floci/getting-started/quick-start Use the JVM image for broader platform compatibility. ```yaml services: floci: image: hectorvent/floci:latest-jvm ports: - "4566:4566" volumes: # Local directory bind mount (default) - ./data:/app/data # OR named volume (optional): # - floci-data:/app/data # volumes: # floci-data: ``` ```bash docker compose up -d ``` -------------------------------- ### Configure AWS SDKs for Path-Style Access Source: https://floci.io/floci/services/s3 Examples for enabling path-style addressing in Java, Node.js, and Python SDKs. ```java S3Client s3 = S3Client.builder() .endpointOverride(URI.create("http://localhost:4566")) .serviceConfiguration(S3Configuration.builder() .pathStyleAccessEnabled(true) .build()) .build(); ``` ```javascript const s3 = new S3Client({ endpoint: "http://localhost:4566", forcePathStyle: true, }); ``` ```python s3 = boto3.client("s3", endpoint_url="http://localhost:4566", config=Config(s3={"addressing_style": "path"})) ``` -------------------------------- ### Package and Deploy Node.js Lambda Function Source: https://floci.io/floci/services/lambda This example shows how to package a simple Node.js Lambda function and deploy it using the AWS CLI. Ensure AWS_ENDPOINT_URL is set. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # Package a simple Node.js function cat > index.mjs << 'EOF' export const handler = async (event) => { console.log("Event:", JSON.stringify(event)); return { statusCode: 200, body: JSON.stringify({ hello: "world" }) }; }; EOF zip function.zip index.mjs # Deploy the function aws lambda create-function \ --function-name my-function \ --runtime nodejs22.x \ --role arn:aws:iam::000000000000:role/lambda-role \ --handler index.handler \ --zip-file fileb://function.zip \ --endpoint-url $AWS_ENDPOINT_URL ``` -------------------------------- ### Create HTTP API Source: https://floci.io/floci/services/api-gateway This example shows how to create an HTTP API using the API Gateway v2 protocol. Ensure the AWS_ENDPOINT_URL is set correctly. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # Create an HTTP API API_ID=$(aws apigatewayv2 create-api \ --name "My HTTP API" \ --protocol-type HTTP \ --query ApiId --output text \ --endpoint-url $AWS_ENDPOINT_URL) ``` -------------------------------- ### Configure Docker Compose for Floci Source: https://floci.io/floci/services/ecs Examples for setting up Floci in Docker Compose for CI/test environments versus local development with real containers. ```yaml # docker-compose.yml — CI / test environment services: floci: image: hectorvent/floci:latest environment: FLOCI_SERVICES_ECS_MOCK: "true" ``` ```yaml # docker-compose.yml — local development (real containers) services: floci: image: hectorvent/floci:latest volumes: - /var/run/docker.sock:/var/run/docker.sock environment: FLOCI_SERVICES_ECS_MOCK: "false" FLOCI_SERVICES_ECS_DOCKER_NETWORK: my_network ``` -------------------------------- ### GET /schedules Source: https://floci.io/floci/services/scheduler Lists all schedules. ```APIDOC ## GET /schedules ### Description List schedules. ### Method GET ### Endpoint /schedules ``` -------------------------------- ### Get Schedule Details Source: https://floci.io/floci/services/scheduler Use the `get-schedule` command to retrieve the configuration details of a specific schedule. ```bash aws scheduler get-schedule \ --name my-schedule \ --endpoint-url $AWS_ENDPOINT_URL ``` -------------------------------- ### Configure Docker Images for Hooks Source: https://floci.io/floci/configuration/initialization-hooks Examples for extending Floci Docker images to include necessary CLI tools for hook execution. ```dockerfile FROM hectorvent/floci:latest-aws # AWS CLI is already installed ``` ```dockerfile FROM hectorvent/floci:latest-jvm RUN apk add --no-cache aws-cli ``` ```dockerfile FROM hectorvent/floci:latest-jvm RUN apk add --no-cache aws-cli jq curl ``` -------------------------------- ### Docker Compose with Initialization Hooks Source: https://floci.io/floci/configuration/docker-compose Mount hook scripts into the container to execute custom setup and teardown logic. Scripts are placed in `./init/start.d` for startup and `./init/stop.d` for shutdown. ```yaml services: floci: image: hectorvent/floci:latest ports: - "4566:4566" volumes: - ./init/start.d:/etc/floci/init/start.d:ro - ./init/stop.d:/etc/floci/init/stop.d:ro ``` -------------------------------- ### Manage Step Functions via AWS CLI Source: https://floci.io/floci/services/step-functions Commands for creating a state machine, starting an execution, and retrieving status or history using the AWS CLI with a custom endpoint. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 # Create a state machine SM_ARN=$(aws stepfunctions create-state-machine \ --name my-workflow \ --definition '{ "Comment": "Simple workflow", "StartAt": "HelloWorld", "States": { "HelloWorld": { "Type": "Pass", "Result": {"message": "Hello, World!"}, "End": true } } }' \ --role-arn arn:aws:iam::000000000000:role/step-functions-role \ --query stateMachineArn --output text \ --endpoint-url $AWS_ENDPOINT_URL) # 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) # Check status aws stepfunctions describe-execution \ --execution-arn $EXEC_ARN \ --endpoint-url $AWS_ENDPOINT_URL # Get event history aws stepfunctions get-execution-history \ --execution-arn $EXEC_ARN \ --endpoint-url $AWS_ENDPOINT_URL ``` -------------------------------- ### Configure Python (boto3) Client for Floci Source: https://floci.io/floci/getting-started/aws-setup Create a helper function to instantiate boto3 clients for Floci, specifying the endpoint URL, region, and credentials. This example demonstrates creating S3, SQS, and DynamoDB clients. ```python import boto3 def floci_client(service): return boto3.client( service, endpoint_url="http://localhost:4566", region_name="us-east-1", aws_access_key_id="test", aws_secret_access_key="test", ) s3 = floci_client("s3") sqs = floci_client("sqs") dynamo = floci_client("dynamodb") ``` -------------------------------- ### Configure Java AWS SDK v2 Client for Floci Source: https://floci.io/floci/getting-started/aws-setup Set up clients for Java AWS SDK v2 by providing the Floci endpoint, region, and static credentials. This example shows configuration for DynamoDB and SQS clients. ```java // Reusable endpoint override URI endpoint = URI.create("http://localhost:4566"); AwsCredentialsProvider creds = StaticCredentialsProvider.create( AwsBasicCredentials.create("test", "test")); Region region = Region.US_EAST_1; // Build any client the same way DynamoDbClient dynamo = DynamoDbClient.builder() .endpointOverride(endpoint) .region(region) .credentialsProvider(creds) .build(); SqsClient sqs = SqsClient.builder() .endpointOverride(endpoint) .region(region) .credentialsProvider(creds) .build(); ``` -------------------------------- ### Configure Go AWS SDK Client for Floci Source: https://floci.io/floci/getting-started/aws-setup Load default configuration for the Go AWS SDK, specifying the region, static credentials, and an endpoint resolver for Floci. This setup is essential for interacting with Floci services using Go. ```go import ( "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/credentials" ) cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion("us-east-1"), config.WithCredentialsProvider(credentials.NewStaticCredentialsProvider("test", "test", "")), config.WithEndpointResolverWithOptions( aws.EndpointResolverWithOptionsFunc( func(service, region string, opts ...interface{}) (aws.Endpoint, error) { return aws.Endpoint{URL: "http://localhost:4566"}, nil }, ), ), ) ``` -------------------------------- ### Get Records Example Source: https://floci.io/floci/services/kinesis Example of how to get records from a Kinesis stream shard using a shard iterator. ```APIDOC ## POST /api/records (GetRecords) ### Description Reads records from a Kinesis stream shard using a shard iterator. ### Method POST ### Endpoint `http://localhost:4566/` ### Parameters #### Query Parameters - `X-Amz-Target` (string) - Required - `Kinesis_20131202.GetRecords` #### Request Body - **shardIterator** (string) - Required - The shard iterator returned by `GetShardIterator`. - **limit** (integer) - Optional - The maximum number of records to return. Default is 10,000. - ** போக்கு** (integer) - Optional - The maximum number of milliseconds the GetRecords call will wait for data. Default is 0. ### Request Example ```json { "shardIterator": "YOUR_SHARD_ITERATOR", "limit": 100 } ``` ### Response #### Success Response (200) - **records** (array) - An array of records retrieved from the shard. - **sequenceNumber** (string) - The sequence number of the record. - **approximateArrivalTimestamp** (timestamp) - The approximate time the record was received by Kinesis. - **data** (string) - The data blob of the record (base64 encoded). - **partitionKey** (string) - The partition key associated with the record. - **encryptionKeyId** (string) - The KMS key ARN used for encryption, if applicable. - **nextShardIterator** (string) - The iterator to use for the next `GetRecords` request. - **millisBehindLatest** (integer) - The number of milliseconds the iterator is behind the latest data. #### Response Example ```json { "records": [ { "sequenceNumber": "49546986989198745041693827514997117051973174741777930755", "approximateArrivalTimestamp": "2023-10-27T10:05:00Z", "data": "eyAgZXZlbnQ6IFwicGFnZV92aWV3XCIsIFwicGFnZVwiOiBcIi9ob21lXCIgfQ==", "partitionKey": "user-123", "encryptionKeyId": null } ], "nextShardIterator": "NEXT_SHARD_ITERATOR_VALUE", "millisBehindLatest": 1000 } ``` ``` -------------------------------- ### Initialize and Run Development Environment Source: https://floci.io/floci/contributing Commands to clone the repository and execute the project using Maven with Quarkus development mode. ```bash # Clone git clone https://github.com/floci-io/floci.git cd floci # Run in dev mode (hot reload, port 4566) mvn quarkus:dev # Run all tests mvn test # Run a specific test mvn test -Dtest=SsmIntegrationTest mvn test -Dtest=SsmIntegrationTest#putParameter ``` -------------------------------- ### Get CloudWatch Metric Statistics Source: https://floci.io/floci/services/cloudwatch Retrieve statistics for a specific metric, including start and end times, period, and statistics type. Requires dimensions and namespace. ```bash # Get statistics 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 ``` -------------------------------- ### Build Floci from Source Source: https://floci.io/floci/getting-started/quick-start Clone the repository and run the development environment. ```bash git clone https://github.com/floci-io/floci.git cd floci mvn quarkus:dev # hot reload, port 4566 ``` -------------------------------- ### GET /2021-01-01/opensearch/domain/{name} Source: https://floci.io/floci/services/opensearch Get details for a specific OpenSearch domain. ```APIDOC ## GET /2021-01-01/opensearch/domain/{name} ### Description Get domain details. ### Method GET ### Endpoint /2021-01-01/opensearch/domain/{name} ### Parameters #### Path Parameters - **name** (string) - Required - The name of the domain. ``` -------------------------------- ### Create Configuration Profile and Hosted Version with AWS AppConfig Source: https://floci.io/floci/services/appconfig These commands demonstrate how to create a configuration profile with a 'hosted' location and then upload a hosted configuration version. Replace `` and `` with your specific 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 ``` -------------------------------- ### Build Native Executable Source: https://floci.io/floci/getting-started/installation Compile the application into a native binary using GraalVM or Mandrel. ```bash mvn clean package -Pnative -DskipTests ./target/floci-runner ``` -------------------------------- ### Build Production JAR Source: https://floci.io/floci/getting-started/installation Package the application into a JAR file and execute it using the Java runtime. ```bash mvn clean package -DskipTests java -jar target/quarkus-app/quarkus-run.jar ``` -------------------------------- ### Define Startup Hook Script Source: https://floci.io/floci/configuration/initialization-hooks A sample startup script that seeds an SSM parameter via the AWS CLI. ```bash #!/bin/sh set -eu aws --endpoint-url http://localhost:4566 \ ssm put-parameter \ --name /demo/app/bootstrapped \ --type String \ --value true \ --overwrite ``` -------------------------------- ### GET /2021-01-01/domain Source: https://floci.io/floci/services/opensearch List all OpenSearch domains. ```APIDOC ## GET /2021-01-01/domain ### Description List all domains. ### Method GET ### Endpoint /2021-01-01/domain ### Parameters #### Query Parameters - **engineType** (string) - Optional - Filter domains by engine type. ``` -------------------------------- ### Run Instances Source: https://floci.io/floci/services/ec2 Launches one or more EC2 instances. ```APIDOC ## POST /api/ec2/instances/run ### Description Launches new EC2 instances with specified configurations. ### Method POST ### Endpoint `/api/ec2/instances/run` ### Parameters #### Request Body - **`ImageId`** (string) - Required - The ID of the AMI to use for the instance. - **`InstanceType`** (string) - Required - The type of instance to launch (e.g., `t2.micro`). - **`MinCount`** (integer) - Required - The minimum number of instances to launch. - **`MaxCount`** (integer) - Required - The maximum number of instances to launch. - **`endpoint-url`** (string) - Optional - The base URL for the EC2 API. ### Request Example ```json { "ImageId": "ami-0abcdef1234567890", "InstanceType": "t2.micro", "MinCount": 1, "MaxCount": 1, "endpoint-url": "http://localhost:4566" } ``` ### Response #### Success Response (200) - **`Instances`** (array) - A list of launched instance objects. - **`InstanceId`** (string) - The ID of the launched instance. #### Response Example ```json { "Instances": [ { "InstanceId": "i-0123456789abcdef0" } ] } ``` ``` -------------------------------- ### GET /schedule-groups Source: https://floci.io/floci/services/scheduler Lists all available schedule groups. ```APIDOC ## GET /schedule-groups ### Description List schedule groups. ### Method GET ### Endpoint /schedule-groups ```