Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57aa866144 | |||
| ac96c6451e | |||
| 39664957fe | |||
| 00b3af3813 | |||
| d8d7dd021b | |||
| eaf5ca6ade | |||
| cc64729599 | |||
| 9f17f72cc3 | |||
| d8d94a773d | |||
| 957579c8b7 |
@@ -1,21 +1,17 @@
|
|||||||
<p align="center">
|
<p align="center">
|
||||||
<img src="docs/assets/floci-black.svg#gh-light-mode-only" alt="Floci" width="500" />
|
<img src="docs/assets/thecloud-logo.png" alt="TheCloud" width="160" />
|
||||||
<img src="docs/assets/floci-white.svg#gh-dark-mode-only" alt="Floci" width="500" />
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h1 align="center">TheCloud AWS runtime</h1>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<strong>Any Cloud. Locally.</strong><br />
|
<strong>Any Cloud. Locally.</strong><br />
|
||||||
Light, fluffy, and always free<br />
|
The local AWS emulator behind TheCloud.<br />
|
||||||
No account. No auth token. No feature gates. Just <code>docker compose up</code>.
|
No account. No auth token. No feature gates. Just <code>docker compose up</code>.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
<a href="https://github.com/floci-io/floci/releases/latest"><img src="https://img.shields.io/github/v/release/floci-io/floci?label=latest%20release&color=blue" alt="Latest Release"></a>
|
|
||||||
<a href="https://github.com/floci-io/floci/actions/workflows/release.yml"><img src="https://img.shields.io/github/actions/workflow/status/floci-io/floci/release.yml?label=build" alt="Build Status"></a>
|
|
||||||
<a href="https://hub.docker.com/r/floci/floci"><img src="https://img.shields.io/docker/pulls/floci/floci?label=docker%20pulls" alt="Docker Pulls"></a>
|
|
||||||
<a href="https://hub.docker.com/r/floci/floci"><img src="https://img.shields.io/docker/image-size/floci/floci/latest?label=image%20size" alt="Docker Image Size"></a>
|
|
||||||
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-green" alt="License: MIT"></a>
|
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-green" alt="License: MIT"></a>
|
||||||
<a href="https://github.com/floci-io/floci/stargazers"><img src="https://img.shields.io/github/stars/floci-io/floci?style=flat" alt="GitHub Stars"></a>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
@@ -24,41 +20,43 @@
|
|||||||
<a href="#supported-services">Services</a> ·
|
<a href="#supported-services">Services</a> ·
|
||||||
<a href="#sdk-integration">SDKs</a> ·
|
<a href="#sdk-integration">SDKs</a> ·
|
||||||
<a href="#testcontainers">Testcontainers</a> ·
|
<a href="#testcontainers">Testcontainers</a> ·
|
||||||
<a href="#migrating-from-localstack">Migration</a> ·
|
<a href="#migrating-from-localstack">Migration</a>
|
||||||
<a href="https://floci.io/floci/">Docs</a>
|
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## What is Floci?
|
## What is this?
|
||||||
|
|
||||||
Floci is a free, open-source local AWS emulator for development, testing, and CI.
|
TheCloud's AWS runtime is a local AWS emulator for development, testing, and CI. It is the runtime behind [TheCloud](https://gitea.zacksolutions.dev/Zakaria/floci-ui), a self-hosted cloud console.
|
||||||
|
|
||||||
It gives you AWS-shaped services on your machine without requiring a cloud account, an auth token, or paid feature gates. Point your AWS SDK, CLI, Terraform, CDK, OpenTofu, or test suite at `http://localhost:4566` and keep your existing workflows.
|
It gives you AWS-shaped services on your machine without a cloud account, an auth token, or paid feature gates. Point your AWS SDK, CLI, Terraform, CDK, OpenTofu, or test suite at `http://localhost:4566` and keep your existing workflows.
|
||||||
|
|
||||||
Already using LocalStack? Floci is a drop-in replacement: swap the image and keep going. See [Migrating from LocalStack](#migrating-from-localstack).
|
It is a fork of the open-source [Floci](https://github.com/floci-io/floci) emulator. Upstream fixes are brought in by cherry-picking from Floci's `main`, alongside TheCloud's own changes, for example:
|
||||||
|
|
||||||
Floci is the AWS member of the [Floci](https://github.com/floci-io) emulator family, named after [floccus](https://en.wikipedia.org/wiki/Cirrocumulus_floccus), the cloud formation that looks like popcorn.
|
- Cognito hosted login with identity-provider buttons, and `PreventUserExistenceErrors` honoured on app clients.
|
||||||
|
- CloudFront distributions served at `<id>.cloudfront.localhost`.
|
||||||
|
- SES delivering real email through an SMTP relay that signs in with a password (Gmail app passwords work).
|
||||||
|
- HTTP API JWT authorizers that verify tokens from this runtime's own Cognito pools.
|
||||||
|
|
||||||
| Emulator | Cloud | Port |
|
Companion runtimes for other clouds come from upstream: [floci-az](https://github.com/floci-io/floci-az) for Azure on port 4577 and [floci-gcp](https://github.com/floci-io/floci-gcp) for GCP on port 4588.
|
||||||
|---|---|:---:|
|
|
||||||
| **[floci](https://github.com/floci-io/floci)** | **AWS** | **4566** |
|
|
||||||
| [floci-az](https://github.com/floci-io/floci-az) | Azure | 4577 |
|
|
||||||
| [floci-gcp](https://github.com/floci-io/floci-gcp) | GCP | 4588 |
|
|
||||||
| [floci-oci](https://github.com/floci-io/floci-oci) | OCI | 4599 |
|
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
The fastest way to run Floci is with the official [CLI](https://github.com/floci-io/floci-cli)
|
Build and start the runtime from this repository:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
floci start
|
git clone https://gitea.zacksolutions.dev/Zakaria/FlociClone.git
|
||||||
|
cd FlociClone
|
||||||
|
docker compose up -d
|
||||||
```
|
```
|
||||||
|
|
||||||
Export the AWS environment variables:
|
Export the AWS environment variables:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
eval $(floci env)
|
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
|
||||||
```
|
```
|
||||||
|
|
||||||
Use your existing AWS tools normally:
|
Use your existing AWS tools normally:
|
||||||
@@ -75,121 +73,41 @@ aws dynamodb create-table \
|
|||||||
aws dynamodb list-tables
|
aws dynamodb list-tables
|
||||||
```
|
```
|
||||||
|
|
||||||
### Watch it run
|
|
||||||
|
|
||||||
This short demo shows the CLI flow: start Floci, export the local AWS environment, run standard AWS CLI commands, and stop the emulator.
|
|
||||||
|
|
||||||
https://github.com/user-attachments/assets/b55714dc-ef36-40ae-a734-cd2cadc288a8
|
|
||||||
|
|
||||||
All AWS services are available at `http://localhost:4566`. Any region works. Credentials can be any non-empty values unless you explicitly enable stricter service-specific auth checks.
|
All AWS services are available at `http://localhost:4566`. Any region works. Credentials can be any non-empty values unless you explicitly enable stricter service-specific auth checks.
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Prefer Docker Compose?</summary>
|
<summary>Prefer <code>docker run</code>, or dev mode?</summary>
|
||||||
|
|
||||||
Create a `compose.yaml` file:
|
Build the image, then run it with the Docker socket so container-backed services work:
|
||||||
|
|
||||||
```yaml
|
|
||||||
services:
|
|
||||||
floci:
|
|
||||||
image: floci/floci:latest
|
|
||||||
ports:
|
|
||||||
- "4566:4566"
|
|
||||||
```
|
|
||||||
|
|
||||||
Start Floci:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker compose up
|
docker build -f docker/Dockerfile -t floci-floci:latest .
|
||||||
|
docker run -d --name floci -p 4566:4566 \
|
||||||
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
|
floci-floci:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
Then configure your AWS environment manually:
|
Or run it in Quarkus dev mode, which needs JDK 25:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
export AWS_ENDPOINT_URL=http://localhost:4566
|
./mvnw quarkus:dev
|
||||||
export AWS_DEFAULT_REGION=us-east-1
|
|
||||||
export AWS_ACCESS_KEY_ID=test
|
|
||||||
export AWS_SECRET_ACCESS_KEY=test
|
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Using the old <code>hectorvent/floci</code> image?</summary>
|
|
||||||
|
|
||||||
Update your image name:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# Before
|
|
||||||
image: hectorvent/floci:latest
|
|
||||||
|
|
||||||
# After
|
|
||||||
image: floci/floci:latest
|
|
||||||
```
|
|
||||||
|
|
||||||
The old `hectorvent/floci` repository no longer receives updates.
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
## Web Console
|
## Web Console
|
||||||
|
|
||||||
Floci ships a browser console for inspecting the resources in your local emulator.
|
[TheCloud](https://gitea.zacksolutions.dev/Zakaria/floci-ui) is the console for this runtime. It runs as its own app on port 4500, talks to the runtime at `FLOCI_ENDPOINT`, and covers the services listed in its README.
|
||||||
|
|
||||||
**Open it at:** `http://localhost:4566/_floci/ui`
|
The runtime can also start a console for you as a sidecar container on first visit to `http://localhost:4566/_floci/ui`. That needs the Docker socket, and the image is set with `FLOCI_SERVICES_UI_IMAGE`; point it at your TheCloud build to use it.
|
||||||
|
|
||||||
Nothing runs at boot. The first request pulls the console image, starts it as a sidecar container on Floci's Docker network, hands it Floci's own reachable address plus the standard AWS environment, polls its health endpoint, and redirects the browser once it reports it can reach Floci. The sidecar's port is bound by Docker, so it needs no `ports:` entry of your own, and its logs are streamed into CloudWatch Logs under `/floci/ui`.
|
|
||||||
|
|
||||||
Starting a container needs the Docker socket:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
services:
|
|
||||||
floci:
|
|
||||||
image: floci/floci:latest
|
|
||||||
ports:
|
|
||||||
- "4566:4566"
|
|
||||||
volumes:
|
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
```
|
|
||||||
|
|
||||||
| Variable | Default | Description |
|
| Variable | Default | Description |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `FLOCI_SERVICES_UI_ENABLED` | `true` | Enable the console sidecar |
|
| `FLOCI_SERVICES_UI_ENABLED` | `true` | Enable the console sidecar |
|
||||||
| `FLOCI_SERVICES_UI_IMAGE` | `floci/floci-ui:latest` | Console image to run |
|
| `FLOCI_SERVICES_UI_IMAGE` | `floci/floci-ui:latest` | Console image to run, for example `floci/floci-ui:local` for a local TheCloud build |
|
||||||
| `FLOCI_SERVICES_UI_CONTAINER_NAME` | `floci-ui` | Name of the sidecar container |
|
| `FLOCI_SERVICES_UI_CONTAINER_NAME` | `floci-ui` | Name of the sidecar container |
|
||||||
| `FLOCI_SERVICES_UI_PORT` | `4500` | Host port the console is published on |
|
| `FLOCI_SERVICES_UI_PORT` | `4500` | Host port the console is published on |
|
||||||
| `FLOCI_SERVICES_UI_KEEP_RUNNING_ON_SHUTDOWN` | `false` | Leave the sidecar running when Floci stops |
|
| `FLOCI_SERVICES_UI_KEEP_RUNNING_ON_SHUTDOWN` | `false` | Leave the sidecar running when the runtime stops |
|
||||||
|
|
||||||
### Running a different console
|
|
||||||
|
|
||||||
The console is not fixed to the one Floci ships. Any console implementing the [Floci console contract](https://floci.io/floci/ui/console-contract/) runs with nothing but an image name: listen on the port in `PORT`, serve `GET /api/health`, talk to Floci at `AWS_ENDPOINT_URL`.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
environment:
|
|
||||||
FLOCI_SERVICES_UI_IMAGE: acme/my-console:1.0
|
|
||||||
```
|
|
||||||
|
|
||||||
A console that differs from the contract's defaults says so in its own `io.floci.console.*` image labels, so its operators do not have to. [StackPort](https://github.com/DaviReisVieira/stackport), for example, listens on 8080 rather than 4500; on an image that predates the labels, say it by hand:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
environment:
|
|
||||||
FLOCI_SERVICES_UI_IMAGE: davireis/stackport:latest
|
|
||||||
FLOCI_SERVICES_UI_CONTAINER_NAME: floci-stackport
|
|
||||||
FLOCI_SERVICES_UI_PORT: "8080"
|
|
||||||
FLOCI_SERVICES_UI_INTERNAL_PORT: "8080"
|
|
||||||
```
|
|
||||||
|
|
||||||
[Floci Dash](https://github.com/ofsazib/floci-dash) is another. It honours `PORT`, so only the two things it does differ on need naming:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
environment:
|
|
||||||
FLOCI_SERVICES_UI_IMAGE: ghcr.io/ofsazib/floci-dash:latest
|
|
||||||
FLOCI_SERVICES_UI_CONTAINER_NAME: floci-dash
|
|
||||||
FLOCI_SERVICES_UI_ENDPOINT_ENV: FLOCI_URL
|
|
||||||
FLOCI_SERVICES_UI_STATUS_PATH: /api/healthz
|
|
||||||
```
|
|
||||||
|
|
||||||
The endpoint itself is never configured by hand: Floci resolves its own reachable address at start time and injects it as `AWS_ENDPOINT_URL`.
|
|
||||||
|
|
||||||
Full reference: [Web Console](https://floci.io/floci/ui/) and [Console Contract v1](https://floci.io/floci/ui/console-contract/).
|
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
@@ -212,14 +130,7 @@ Lambda, RDS, Neptune, ElastiCache, MSK, MSK Connect, ECS, EC2, EKS, OpenSearch,
|
|||||||
|
|
||||||
Point standard AWS clients at `http://localhost:4566`. Existing credentials, regions, SDKs, CLI commands, and IaC workflows stay familiar.
|
Point standard AWS clients at `http://localhost:4566`. Existing credentials, regions, SDKs, CLI commands, and IaC workflows stay familiar.
|
||||||
|
|
||||||
Terraform can provision AWS-shaped resources locally through Floci using the standard HashiCorp AWS provider. See the [Terraform with Floci guide](docs/getting-started/terraform.md) for provider configuration, resource examples, and optional emulated S3 state.
|
Terraform can provision AWS-shaped resources locally through this runtime using the standard HashiCorp AWS provider. See the [Terraform guide](docs/getting-started/terraform.md) for provider configuration, resource examples, and optional emulated S3 state.
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary><strong>Fast enough for CI</strong></summary>
|
|
||||||
|
|
||||||
The native image starts in milliseconds and keeps idle memory low, making it practical for local development and test pipelines.
|
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
@@ -230,36 +141,13 @@ Choose from in-memory, persistent, hybrid, and write-ahead log storage depending
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## Why Floci?
|
|
||||||
|
|
||||||
LocalStack's community edition [sunset in March 2026](https://blog.localstack.cloud/the-road-ahead-for-localstack/), requiring auth tokens and freezing security updates. Floci is the no-strings-attached alternative.
|
|
||||||
|
|
||||||
| Capability | Floci | LocalStack Community |
|
|
||||||
|---|:---:|:---:|
|
|
||||||
| Auth token required | No | Yes |
|
|
||||||
| Security updates | Yes | Frozen |
|
|
||||||
| Startup time | ~24 ms | ~3.3 s |
|
|
||||||
| Idle memory | ~13 MiB | ~143 MiB |
|
|
||||||
| Docker image size | ~90 MB | ~1.0 GB |
|
|
||||||
| License | MIT | Restricted |
|
|
||||||
| API Gateway v2 / HTTP API | Yes | No |
|
|
||||||
| Cognito | Yes | No |
|
|
||||||
| RDS, ElastiCache, MSK, MSK Connect | Real Docker | No |
|
|
||||||
| Neptune (graph DB + Gremlin WebSocket) | Real Docker | No |
|
|
||||||
| DocumentDB (MongoDB-compatible) | Real Docker | No |
|
|
||||||
| ECS, EC2, EKS | Real Docker | No |
|
|
||||||
| CodeBuild | Real Docker execution | No |
|
|
||||||
| Native binary | ~40 MB | No |
|
|
||||||
|
|
||||||
**Broad AWS coverage. Free forever.** See the [Services Overview](https://floci.io/floci/services/) for the full list of emulated services.
|
|
||||||
|
|
||||||
## Architecture Overview
|
## Architecture Overview
|
||||||
|
|
||||||
```mermaid
|
```mermaid
|
||||||
flowchart LR
|
flowchart LR
|
||||||
Client["AWS SDK / CLI"]
|
Client["AWS SDK / CLI"]
|
||||||
|
|
||||||
subgraph Floci ["Floci, port 4566"]
|
subgraph Runtime ["TheCloud AWS runtime, port 4566"]
|
||||||
Router["HTTP Router\nJAX-RS / Vert.x"]
|
Router["HTTP Router\nJAX-RS / Vert.x"]
|
||||||
|
|
||||||
subgraph Stateless ["Stateless Services"]
|
subgraph Stateless ["Stateless Services"]
|
||||||
@@ -288,7 +176,7 @@ flowchart LR
|
|||||||
|
|
||||||
## Supported Services
|
## Supported Services
|
||||||
|
|
||||||
Floci supports local emulation for application services, data services, eventing, identity, infrastructure, billing, and container-backed workloads.
|
The runtime emulates application services, data services, eventing, identity, infrastructure, billing, and container-backed workloads.
|
||||||
|
|
||||||
| Category | Services |
|
| Category | Services |
|
||||||
|---|---|
|
|---|---|
|
||||||
@@ -303,7 +191,7 @@ Floci supports local emulation for application services, data services, eventing
|
|||||||
| Cost and billing | AWS Budgets, Pricing, Cost Explorer, Cost and Usage Reports, BCM Pricing Calculator, BCM Data Exports |
|
| Cost and billing | AWS Budgets, Pricing, Cost Explorer, Cost and Usage Reports, BCM Pricing Calculator, BCM Data Exports |
|
||||||
| Resilience, backup, and config | AWS FIS, AWS Backup, AWS Config, AppConfig, AppConfigData, CloudFormation, Cloud Control API |
|
| Resilience, backup, and config | AWS FIS, AWS Backup, AWS Config, AppConfig, AppConfigData, CloudFormation, Cloud Control API |
|
||||||
|
|
||||||
For operation-level compatibility, see the [Services Overview](https://floci.io/floci/services/).
|
For operation-level detail, see upstream Floci's [Services Overview](https://floci.io/floci/services/); it can list upstream work this fork has not picked up yet.
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary>Detailed service notes</summary>
|
<summary>Detailed service notes</summary>
|
||||||
@@ -378,7 +266,7 @@ For operation-level compatibility, see the [Services Overview](https://floci.io/
|
|||||||
| AWS Backup | In-process | Vaults, backup plans, selections, simulated job lifecycle, recovery points |
|
| AWS Backup | In-process | Vaults, backup plans, selections, simulated job lifecycle, recovery points |
|
||||||
| AWS FIS | In-process | All 26 management APIs for templates, experiments, target accounts, action and target discovery, safety lever, tagging, and pagination; experiment execution is a safe control-plane simulation and does not inject faults into other services |
|
| AWS FIS | In-process | All 26 management APIs for templates, experiments, target accounts, action and target discovery, safety lever, tagging, and pagination; experiment execution is a safe control-plane simulation and does not inject faults into other services |
|
||||||
| AWS Config | In-process | Config rules, evaluation-driven compliance (PutEvaluations, compliance details and summaries), configuration recorders, delivery channels, retention configuration, conformance packs, tagging |
|
| AWS Config | In-process | Config rules, evaluation-driven compliance (PutEvaluations, compliance details and summaries), configuration recorders, delivery channels, retention configuration, conformance packs, tagging |
|
||||||
| Organizations | In-process | Organizations, roots, nested OUs, member accounts, all policy types with `FullAWSAccess` and effective-policy inheritance, trusted service access, delegated administrators, resource policy, and the full invitation/handshake flow; created accounts are usable Floci accounts and member accounts can read the organization they belong to |
|
| Organizations | In-process | Organizations, roots, nested OUs, member accounts, all policy types with `FullAWSAccess` and effective-policy inheritance, trusted service access, delegated administrators, resource policy, and the full invitation/handshake flow; created accounts are usable accounts in the runtime and member accounts can read the organization they belong to |
|
||||||
| CloudTrail | In-process | Trails, event selectors (S3 data events with bucket/prefix matching), `StartLogging`/`StopLogging`, scheduled gzipped log file emission to the destination bucket at AWS-shaped key paths, IAM-deny path emits `AccessDenied` records |
|
| CloudTrail | In-process | Trails, event selectors (S3 data events with bucket/prefix matching), `StartLogging`/`StopLogging`, scheduled gzipped log file emission to the destination bucket at AWS-shaped key paths, IAM-deny path emits `AccessDenied` records |
|
||||||
| CloudFront | In-process | Distributions, origins, cache behaviors, invalidations, tagging |
|
| CloudFront | In-process | Distributions, origins, cache behaviors, invalidations, tagging |
|
||||||
| WAF v2 | In-process | Web ACLs, IP sets, regex pattern sets, rule groups, logging configs, resource associations, tagging (REGIONAL and CLOUDFRONT scopes) |
|
| WAF v2 | In-process | Web ACLs, IP sets, regex pattern sets, rule groups, logging configs, resource associations, tagging (REGIONAL and CLOUDFRONT scopes) |
|
||||||
@@ -389,7 +277,7 @@ For operation-level compatibility, see the [Services Overview](https://floci.io/
|
|||||||
| Textract | In-process stub | API-compatible stubs, dummy block data, async job simulation |
|
| Textract | In-process stub | API-compatible stubs, dummy block data, async job simulation |
|
||||||
| Transcribe | In-process stub | Transcription jobs and custom vocabularies; jobs complete immediately, no real audio processing |
|
| Transcribe | In-process stub | Transcription jobs and custom vocabularies; jobs complete immediately, no real audio processing |
|
||||||
| Pricing | In-process with static snapshot | Product discovery, attributes, price list files, pagination |
|
| Pricing | In-process with static snapshot | Product discovery, attributes, price list files, pagination |
|
||||||
| Cost Explorer | In-process | Cost synthesized from Floci resource state and pricing snapshots |
|
| Cost Explorer | In-process | Cost synthesized from the runtime's resource state and pricing snapshots |
|
||||||
| Cost and Usage Reports | In-process with floci-duck sidecar | CUR 2.0 and FOCUS 1.2 columns, account-scoped storage, Parquet emission |
|
| Cost and Usage Reports | In-process with floci-duck sidecar | CUR 2.0 and FOCUS 1.2 columns, account-scoped storage, Parquet emission |
|
||||||
| BCM Pricing Calculator | In-process | Workload estimate create, usage pricing, read, and delete lifecycle |
|
| BCM Pricing Calculator | In-process | Workload estimate create, usage pricing, read, and delete lifecycle |
|
||||||
| BCM Data Exports | In-process | Export lifecycle, executions, update and delete operations |
|
| BCM Data Exports | In-process | Export lifecycle, executions, update and delete operations |
|
||||||
@@ -398,7 +286,7 @@ For operation-level compatibility, see the [Services Overview](https://floci.io/
|
|||||||
|
|
||||||
## Real Docker Integration
|
## Real Docker Integration
|
||||||
|
|
||||||
Floci uses real Docker containers when in-process emulation would reduce fidelity. This applies to stateful databases, connection-heavy protocols, runtimes, and build systems.
|
The runtime uses real Docker containers when in-process emulation would reduce fidelity. This applies to stateful databases, connection-heavy protocols, runtimes, and build systems.
|
||||||
|
|
||||||
| Service | Default image | What is real |
|
| Service | Default image | What is real |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
@@ -416,12 +304,12 @@ Floci uses real Docker containers when in-process emulation would reduce fidelit
|
|||||||
| EC2 | AMI-mapped Linux images | Linux containers, SSH key injection, UserData, IMDS, IAM credentials |
|
| EC2 | AMI-mapped Linux images | Linux containers, SSH key injection, UserData, IMDS, IAM credentials |
|
||||||
| ECS | User-specified task image | Container lifecycle, start, stop, health checks |
|
| ECS | User-specified task image | Container lifecycle, start, stop, health checks |
|
||||||
| EKS | `rancher/k3s:latest` | Kubernetes API server via k3s |
|
| EKS | `rancher/k3s:latest` | Kubernetes API server via k3s |
|
||||||
| MWAA | `apache/airflow:<version>-python3.12` + `postgres:16-alpine` | Real Apache Airflow (LocalExecutor: scheduler + webserver) with its own Postgres metadata DB; webserver/CLI reachable via Floci's proxy |
|
| MWAA | `apache/airflow:<version>-python3.12` + `postgres:16-alpine` | Real Apache Airflow (LocalExecutor: scheduler + webserver) with its own Postgres metadata DB; webserver/CLI reachable via the runtime's proxy |
|
||||||
| CodeBuild | User-specified environment image | Buildspec execution, log streaming, S3 artifact upload |
|
| CodeBuild | User-specified environment image | Buildspec execution, log streaming, S3 artifact upload |
|
||||||
| OpenSearch | `opensearchproject/opensearch:2` | Full OpenSearch engine with REST API |
|
| OpenSearch | `opensearchproject/opensearch:2` | Full OpenSearch engine with REST API |
|
||||||
| ECR | `registry:2` | OCI-compatible registry for docker push and docker pull |
|
| ECR | `registry:2` | OCI-compatible registry for docker push and docker pull |
|
||||||
| Verified Permissions | `floci/floci-sidecar-cedar:1.1.0` | Cedar 4 policy parsing, schema validation and authorization decisions, via a [Floci sidecar](https://github.com/floci-io/floci-sidecars) |
|
| Verified Permissions | `floci/floci-sidecar-cedar:1.1.0` | Cedar 4 policy parsing, schema validation and authorization decisions, via an upstream [Floci sidecar](https://github.com/floci-io/floci-sidecars) |
|
||||||
| AppSync | `floci/floci-sidecar-graphql:0.2.0` | graphql-java schema validation, query planning and execution, via a [Floci sidecar](https://github.com/floci-io/floci-sidecars) |
|
| AppSync | `floci/floci-sidecar-graphql:0.2.0` | graphql-java schema validation, query planning and execution, via an upstream [Floci sidecar](https://github.com/floci-io/floci-sidecars) |
|
||||||
|
|
||||||
Docker-backed services require the Docker socket:
|
Docker-backed services require the Docker socket:
|
||||||
|
|
||||||
@@ -430,7 +318,7 @@ docker run -d --name floci \
|
|||||||
-p 4566:4566 \
|
-p 4566:4566 \
|
||||||
-v /var/run/docker.sock:/var/run/docker.sock \
|
-v /var/run/docker.sock:/var/run/docker.sock \
|
||||||
-u root \
|
-u root \
|
||||||
floci/floci:latest
|
floci-floci:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
### Overriding default images
|
### Overriding default images
|
||||||
@@ -454,7 +342,7 @@ docker run -d --name floci \
|
|||||||
|
|
||||||
## Persistence and Storage Modes
|
## Persistence and Storage Modes
|
||||||
|
|
||||||
Floci can trade speed for durability depending on the workflow. Configure the default mode with `FLOCI_STORAGE_MODE`, or override storage per service.
|
The runtime can trade speed for durability depending on the workflow. Configure the default mode with `FLOCI_STORAGE_MODE`, or override storage per service.
|
||||||
|
|
||||||
| Mode | Behavior | Best for | Durability |
|
| Mode | Behavior | Best for | Durability |
|
||||||
|---|---|---|:---:|
|
|---|---|---|:---:|
|
||||||
@@ -465,22 +353,22 @@ Floci can trade speed for durability depending on the workflow. Configure the de
|
|||||||
|
|
||||||
Use `memory` for fast test runs. Use `hybrid` when you want state preserved across container restarts without much overhead.
|
Use `memory` for fast test runs. Use `hybrid` when you want state preserved across container restarts without much overhead.
|
||||||
|
|
||||||
For more detail, see the [Storage Configuration documentation](https://floci.io/floci/configuration/storage/).
|
For more detail, see upstream Floci's [Storage Configuration documentation](https://floci.io/floci/configuration/storage/).
|
||||||
|
|
||||||
## Multi-Account Isolation
|
## Multi-Account Isolation
|
||||||
|
|
||||||
Floci supports per-account resource isolation with no extra setup. If `AWS_ACCESS_KEY_ID` is exactly 12 digits, Floci uses it as the account ID. Resources created by one account are invisible to another.
|
The runtime supports per-account resource isolation with no extra setup. If `AWS_ACCESS_KEY_ID` is exactly 12 digits, it is used as the account ID. Resources created by one account are invisible to another.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
AWS_ACCESS_KEY_ID=111111111111 aws sqs create-queue --queue-name orders
|
AWS_ACCESS_KEY_ID=111111111111 aws sqs create-queue --queue-name orders
|
||||||
AWS_ACCESS_KEY_ID=222222222222 aws sqs create-queue --queue-name orders
|
AWS_ACCESS_KEY_ID=222222222222 aws sqs create-queue --queue-name orders
|
||||||
```
|
```
|
||||||
|
|
||||||
Any other key format, such as `test` or `AKIA...`, causes Floci to fall back to `FLOCI_DEFAULT_ACCOUNT_ID`, which defaults to `000000000000`.
|
Any other key format, such as `test` or `AKIA...`, falls back to `FLOCI_DEFAULT_ACCOUNT_ID`, which defaults to `000000000000`.
|
||||||
|
|
||||||
STS temporary credentials are routed too: credentials from `AssumeRole` resolve to the assumed role's account, so the cross-account assume-role-then-provision pattern works locally. Resolution precedence is 12-digit AKID → temporary-session lookup → `FLOCI_DEFAULT_ACCOUNT_ID`.
|
STS temporary credentials are routed too: credentials from `AssumeRole` resolve to the assumed role's account, so the cross-account assume-role-then-provision pattern works locally. Resolution precedence is 12-digit AKID → temporary-session lookup → `FLOCI_DEFAULT_ACCOUNT_ID`.
|
||||||
|
|
||||||
See the [Multi-Account Isolation docs](https://floci.io/floci/configuration/multi-account/).
|
See upstream Floci's [Multi-Account Isolation docs](https://floci.io/floci/configuration/multi-account/).
|
||||||
|
|
||||||
## SDK Integration
|
## SDK Integration
|
||||||
|
|
||||||
@@ -526,7 +414,7 @@ client = boto3.client(
|
|||||||
|
|
||||||
client.put_parameter(
|
client.put_parameter(
|
||||||
Name="/demo/app/message",
|
Name="/demo/app/message",
|
||||||
Value="hello from floci",
|
Value="hello from TheCloud",
|
||||||
Type="String",
|
Type="String",
|
||||||
Overwrite=True,
|
Overwrite=True,
|
||||||
)
|
)
|
||||||
@@ -552,7 +440,7 @@ const client = new SQSClient({
|
|||||||
await client.send(
|
await client.send(
|
||||||
new SendMessageCommand({
|
new SendMessageCommand({
|
||||||
QueueUrl: "http://localhost:4566/000000000000/demo-queue",
|
QueueUrl: "http://localhost:4566/000000000000/demo-queue",
|
||||||
MessageBody: "hello from floci",
|
MessageBody: "hello from TheCloud",
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
```
|
```
|
||||||
@@ -613,7 +501,7 @@ use aws_sdk_secretsmanager::Client;
|
|||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let config = aws_config::defaults(aws_config::BehaviorVersion::latest())
|
let config = aws_config::defaults(aws_config::BehaviorVersion::latest())
|
||||||
.region(Region::new("us-east-1"))
|
.region(Region::new("us-east-1"))
|
||||||
.credentials_provider(Credentials::new("test", "test", None, None, "floci"))
|
.credentials_provider(Credentials::new("test", "test", None, None, "thecloud"))
|
||||||
.endpoint_url("http://localhost:4566")
|
.endpoint_url("http://localhost:4566")
|
||||||
.load()
|
.load()
|
||||||
.await;
|
.await;
|
||||||
@@ -623,7 +511,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
client
|
client
|
||||||
.create_secret()
|
.create_secret()
|
||||||
.name("demo/secret")
|
.name("demo/secret")
|
||||||
.secret_string("hello from floci")
|
.secret_string("hello from TheCloud")
|
||||||
.send()
|
.send()
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
@@ -649,7 +537,7 @@ aws --endpoint-url http://localhost:4566 s3 ls
|
|||||||
|
|
||||||
## Testcontainers
|
## Testcontainers
|
||||||
|
|
||||||
Floci has Testcontainers modules for starting isolated Floci instances directly from tests. This avoids shared state, manual daemon setup, and port conflicts.
|
Upstream Floci publishes Testcontainers modules for starting isolated instances directly from tests. This avoids shared state, manual daemon setup, and port conflicts. They start upstream's `floci/floci` image by default, so they test against upstream Floci rather than this fork unless you give them your own image.
|
||||||
|
|
||||||
For Testcontainers 1.x, use the versions as indicated in the table below.
|
For Testcontainers 1.x, use the versions as indicated in the table below.
|
||||||
|
|
||||||
@@ -767,7 +655,7 @@ def test_s3_create_bucket():
|
|||||||
|
|
||||||
## Compatibility Testing
|
## Compatibility Testing
|
||||||
|
|
||||||
The [`compatibility-tests`](./compatibility-tests/) directory validates Floci across SDKs and tooling workflows.
|
The [`compatibility-tests`](./compatibility-tests/) directory validates the runtime across SDKs and tooling workflows.
|
||||||
|
|
||||||
| Module | Language / Tool | SDK / Client | Tests |
|
| Module | Language / Tool | SDK / Client | Tests |
|
||||||
|---|---|---|---:|
|
|---|---|---|---:|
|
||||||
@@ -784,22 +672,19 @@ The [`compatibility-tests`](./compatibility-tests/) directory validates Floci ac
|
|||||||
|
|
||||||
## Migrating from LocalStack
|
## Migrating from LocalStack
|
||||||
|
|
||||||
Floci is a drop-in replacement for LocalStack Community. The port, credentials, SDK configuration, and CLI endpoint pattern work the same way. Swap the image and keep going.
|
The runtime is a drop-in replacement for LocalStack Community. The port, credentials, SDK configuration, and CLI endpoint pattern work the same way. Swap the image and keep going.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
# Before
|
# Before
|
||||||
image: localstack/localstack
|
image: localstack/localstack
|
||||||
|
|
||||||
# After, standard image
|
# After, your local build of this repository
|
||||||
image: floci/floci:latest
|
image: floci-floci:latest
|
||||||
|
|
||||||
# After, if init scripts need AWS CLI or boto3
|
|
||||||
image: floci/floci:latest-compat
|
|
||||||
```
|
```
|
||||||
|
|
||||||
LocalStack environment variables are translated automatically:
|
LocalStack environment variables are translated automatically:
|
||||||
|
|
||||||
| LocalStack | Floci equivalent |
|
| LocalStack | Equivalent |
|
||||||
|---|---|
|
|---|---|
|
||||||
| `LOCALSTACK_HOST` | `FLOCI_HOSTNAME` |
|
| `LOCALSTACK_HOST` | `FLOCI_HOSTNAME` |
|
||||||
| `PERSISTENCE=1` | `FLOCI_STORAGE_MODE=persistent` |
|
| `PERSISTENCE=1` | `FLOCI_STORAGE_MODE=persistent` |
|
||||||
@@ -809,43 +694,23 @@ LocalStack environment variables are translated automatically:
|
|||||||
|
|
||||||
Init scripts mounted under `/etc/localstack/init/` run unchanged. The `/_localstack/init` and `/_localstack/health` endpoints are still served. Once the emulator is up, the log also ends with a LocalStack-style `Ready.` line, so tooling that watches the log for it, such as the default wait strategy of Testcontainers' `LocalStackContainer`, works unchanged. Set `LOCALSTACK_PARITY=false` to opt out of automatic translation.
|
Init scripts mounted under `/etc/localstack/init/` run unchanged. The `/_localstack/init` and `/_localstack/health` endpoints are still served. Once the emulator is up, the log also ends with a LocalStack-style `Ready.` line, so tooling that watches the log for it, such as the default wait strategy of Testcontainers' `LocalStackContainer`, works unchanged. Set `LOCALSTACK_PARITY=false` to opt out of automatic translation.
|
||||||
|
|
||||||
See the [full migration guide](https://floci.io/floci/getting-started/migrate-from-localstack/).
|
See upstream Floci's [full migration guide](https://floci.io/floci/getting-started/migrate-from-localstack/).
|
||||||
|
|
||||||
## Image Tags
|
## Building and Updating
|
||||||
|
|
||||||
Every tag combines a variant and a channel.
|
The image is built from this repository; nothing is published to Docker Hub:
|
||||||
|
|
||||||
| Channel | Standard | Baseline (ARM64 only) | Compat with AWS CLI and boto3 |
|
```bash
|
||||||
|---|---|---|---|
|
docker build -f docker/Dockerfile -t floci-floci:latest .
|
||||||
| Release, floating | `latest` | `latest-baseline` | `latest-compat` |
|
|
||||||
| Release, pinned | `x.y.z` | `x.y.z-baseline` | `x.y.z-compat` |
|
|
||||||
| Nightly, floating | `nightly` | — | `nightly-compat` |
|
|
||||||
| Nightly, dated | `nightly-mmddyyyy` | — | `nightly-mmddyyyy-compat` |
|
|
||||||
|
|
||||||
Use `latest` for stable releases, a pinned version for reproducible builds, and `nightly` to track `main`.
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
# Recommended
|
|
||||||
image: floci/floci:latest
|
|
||||||
|
|
||||||
# Includes AWS CLI and boto3
|
|
||||||
image: floci/floci:latest-compat
|
|
||||||
|
|
||||||
# ARM64 baseline for Raspberry Pi 4 / pre-LSE cores
|
|
||||||
image: floci/floci:latest-baseline
|
|
||||||
|
|
||||||
# Pinned release
|
|
||||||
image: floci/floci:x.y.z
|
|
||||||
|
|
||||||
# Track main
|
|
||||||
image: floci/floci:nightly
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### Release train
|
Tests run with Maven and JDK 25:
|
||||||
|
|
||||||
Stable releases ship on the **1st and 3rd Tuesday of each month**. Between trains, `floci/floci:nightly` tracks `main`. Every merged fix is available the next day, and dated `nightly-mmddyyyy` tags let you pin a specific night's build.
|
```bash
|
||||||
|
./mvnw test
|
||||||
|
```
|
||||||
|
|
||||||
Versions are derived from Conventional Commits by [semantic-release](https://github.com/semantic-release/semantic-release); `CHANGELOG.md` is generated, never hand-edited. Releases are cut from `main` only: there are no maintenance branches.
|
Upstream fixes come in by cherry-picking commits from Floci's `main` onto a branch, which then goes through review like any other change.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
@@ -853,26 +718,26 @@ All settings are overridable through environment variables with the `FLOCI_` pre
|
|||||||
|
|
||||||
| Variable | Default | Description |
|
| Variable | Default | Description |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `FLOCI_PORT` | `4566` | Port exposed by the Floci API |
|
| `FLOCI_PORT` | `4566` | Port the runtime's API listens on |
|
||||||
| `FLOCI_DEFAULT_REGION` | `us-east-1` | Default AWS region |
|
| `FLOCI_DEFAULT_REGION` | `us-east-1` | Default AWS region |
|
||||||
| `FLOCI_DEFAULT_ACCOUNT_ID` | `000000000000` | Default AWS account ID |
|
| `FLOCI_DEFAULT_ACCOUNT_ID` | `000000000000` | Default AWS account ID |
|
||||||
| `FLOCI_BASE_URL` | `http://localhost:4566` | Base URL used when Floci returns service URLs |
|
| `FLOCI_BASE_URL` | `http://localhost:4566` | Base URL used in service URLs the runtime returns |
|
||||||
| `FLOCI_HOSTNAME` | Unset | Hostname used in returned URLs when Floci runs inside Docker Compose |
|
| `FLOCI_HOSTNAME` | Unset | Hostname used in returned URLs when the runtime runs inside Docker Compose |
|
||||||
| `FLOCI_STORAGE_MODE` | `memory` | Storage mode: `memory`, `persistent`, `hybrid`, or `wal` |
|
| `FLOCI_STORAGE_MODE` | `memory` | Storage mode: `memory`, `persistent`, `hybrid`, or `wal` |
|
||||||
| `FLOCI_STORAGE_PERSISTENT_PATH` | `./data` | Directory used for persisted state |
|
| `FLOCI_STORAGE_PERSISTENT_PATH` | `./data` | Directory used for persisted state |
|
||||||
| `FLOCI_SERVICES_LAMBDA_ECR_BASE_URI` | `public.ecr.aws` | ECR base URI used when pulling Lambda runtime images (legacy name `FLOCI_ECR_BASE_URI` still works) |
|
| `FLOCI_SERVICES_LAMBDA_ECR_BASE_URI` | `public.ecr.aws` | ECR base URI used when pulling Lambda runtime images (legacy name `FLOCI_ECR_BASE_URI` still works) |
|
||||||
| `FLOCI_SERVICES_S3_ENFORCE_AUTH` | `false` | Enforce S3 public/private read access and reject unknown signed S3 access keys |
|
| `FLOCI_SERVICES_S3_ENFORCE_AUTH` | `false` | Enforce S3 public/private read access and reject unknown signed S3 access keys |
|
||||||
|
|
||||||
Full reference: [configuration docs](https://floci.io/floci/configuration/advanced/application-yml)
|
Full reference: [`src/main/resources/application.yml`](src/main/resources/application.yml), and upstream Floci's [configuration docs](https://floci.io/floci/configuration/advanced/application-yml).
|
||||||
|
|
||||||
### Multi-container Docker Compose
|
### Multi-container Docker Compose
|
||||||
|
|
||||||
When your application runs in a different container, set `FLOCI_HOSTNAME` to the Floci service name so returned URLs, such as SQS `QueueUrl` values, resolve correctly.
|
When your application runs in a different container, set `FLOCI_HOSTNAME` to the runtime's service name so returned URLs, such as SQS `QueueUrl` values, resolve correctly.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
services:
|
services:
|
||||||
floci:
|
floci:
|
||||||
image: floci/floci:latest
|
image: floci-floci:latest
|
||||||
ports:
|
ports:
|
||||||
- "4566:4566"
|
- "4566:4566"
|
||||||
environment:
|
environment:
|
||||||
@@ -887,59 +752,6 @@ services:
|
|||||||
|
|
||||||
Without this, services may return URLs using `localhost`, which points to the wrong container from the application container.
|
Without this, services may return URLs using `localhost`, which points to the wrong container from the application container.
|
||||||
|
|
||||||
## Community
|
|
||||||
|
|
||||||
Join the Floci community on [Slack](https://join.slack.com/t/floci/shared_invite/zt-3tjn02s3q-A00kEjJ1cZxsg_imTfy6Cw) or [GitHub Discussions](https://github.com/orgs/floci-io/discussions). Feature ideas, compatibility questions, design tradeoffs, and rough proposals are welcome.
|
|
||||||
|
|
||||||
## Sponsors
|
|
||||||
|
|
||||||
Floci is independent open source, funded by the people and companies who use it.
|
|
||||||
Sponsorship buys gratitude and nothing else: every emulated service is free for
|
|
||||||
everyone, forever, and no sponsor gets features, priority, or roadmap influence
|
|
||||||
that the rest of the Flock does not.
|
|
||||||
|
|
||||||
### 🥇 Gold
|
|
||||||
|
|
||||||
Large logo with top placement in the emulator READMEs and on floci.io, plus a
|
|
||||||
mention in release notes.
|
|
||||||
|
|
||||||
[IceGuard](https://github.com/iceguard) · [Softmax](https://softmax.com/)
|
|
||||||
|
|
||||||
### 🥈 Silver
|
|
||||||
|
|
||||||
Logo in the emulator READMEs and on floci.io, plus a mention in release notes.
|
|
||||||
|
|
||||||
*Your logo here. [Become a sponsor](https://github.com/sponsors/floci-io).*
|
|
||||||
|
|
||||||
### 🥉 Community
|
|
||||||
|
|
||||||
Name in the emulator READMEs, a sponsor badge on GitHub, and our sincere thanks.
|
|
||||||
|
|
||||||
[AutoScout24](https://www.autoscout24.com) · [Nexxion AI](https://nexxion.ai/)
|
|
||||||
|
|
||||||
Every sponsor, including the Friends of the Flock who support Floci outside these
|
|
||||||
tiers, is listed in [THANKS.md](https://github.com/floci-io/.github/blob/main/THANKS.md).
|
|
||||||
|
|
||||||
**[Sponsor Floci](https://github.com/sponsors/floci-io)**
|
|
||||||
|
|
||||||
## Star History
|
|
||||||
|
|
||||||
<p align="center">
|
|
||||||
<a href="https://www.star-history.com/?repos=floci-io%2Ffloci&type=date&legend=top-left">
|
|
||||||
<picture>
|
|
||||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/chart?repos=floci-io/floci&type=date&theme=dark&legend=top-left" />
|
|
||||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/chart?repos=floci-io/floci&type=date&legend=top-left" />
|
|
||||||
<img width="600" alt="Star History Chart" src="https://api.star-history.com/chart?repos=floci-io/floci&type=date&legend=top-left" />
|
|
||||||
</picture>
|
|
||||||
</a>
|
|
||||||
</p>
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
<a href="https://github.com/floci-io/floci/graphs/contributors">
|
|
||||||
<img src="https://contrib.rocks/image?repo=floci-io/floci&max=100&columns=20" />
|
|
||||||
</a>
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
MIT. Use it however you want.
|
MIT. TheCloud's AWS runtime is a fork of [Floci](https://github.com/floci-io/floci); thanks to the Floci contributors and sponsors whose work it builds on.
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
@@ -563,8 +563,10 @@ public class AcmJsonHandler {
|
|||||||
|
|
||||||
private CertificateOptions parseOptions(JsonNode optionsNode) {
|
private CertificateOptions parseOptions(JsonNode optionsNode) {
|
||||||
if (optionsNode.isMissingNode()) return null;
|
if (optionsNode.isMissingNode()) return null;
|
||||||
String ctPref = optionsNode.path("CertificateTransparencyLoggingPreference").asText("ENABLED");
|
String ctPref = parseOptionValue(optionsNode, "CertificateTransparencyLoggingPreference");
|
||||||
return new CertificateOptions(ctPref, "DISABLED");
|
String export = parseOptionValue(optionsNode, "Export");
|
||||||
|
// An exportable public certificate is requested with Export ENABLED, and keeps it for life.
|
||||||
|
return new CertificateOptions(ctPref != null ? ctPref : "ENABLED", export != null ? export : "DISABLED");
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<CertificateStatus> parseCertificateStatuses(JsonNode node) {
|
private List<CertificateStatus> parseCertificateStatuses(JsonNode node) {
|
||||||
|
|||||||
+26
@@ -4,8 +4,10 @@ import com.fasterxml.jackson.databind.JsonNode;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||||
import io.github.hectorvent.floci.core.common.SsrfProtection;
|
import io.github.hectorvent.floci.core.common.SsrfProtection;
|
||||||
|
import io.github.hectorvent.floci.services.cognito.CognitoService;
|
||||||
import jakarta.annotation.PreDestroy;
|
import jakarta.annotation.PreDestroy;
|
||||||
import jakarta.enterprise.context.ApplicationScoped;
|
import jakarta.enterprise.context.ApplicationScoped;
|
||||||
|
import jakarta.enterprise.inject.Instance;
|
||||||
import jakarta.inject.Inject;
|
import jakarta.inject.Inject;
|
||||||
import org.apache.hc.client5.http.DnsResolver;
|
import org.apache.hc.client5.http.DnsResolver;
|
||||||
import org.apache.hc.client5.http.SystemDefaultDnsResolver;
|
import org.apache.hc.client5.http.SystemDefaultDnsResolver;
|
||||||
@@ -37,6 +39,7 @@ import java.util.Base64;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verifies the RS256 signature of a token presented to an HTTP API v2 JWT authorizer, the same
|
* Verifies the RS256 signature of a token presented to an HTTP API v2 JWT authorizer, the same
|
||||||
@@ -66,8 +69,27 @@ public class JwtSignatureVerifier implements AutoCloseable {
|
|||||||
private final CloseableHttpClient httpClient;
|
private final CloseableHttpClient httpClient;
|
||||||
private final boolean allowPrivateNetworkTargets;
|
private final boolean allowPrivateNetworkTargets;
|
||||||
private final Map<String, CachedJwks> jwksCache = new ConcurrentHashMap<>();
|
private final Map<String, CachedJwks> jwksCache = new ConcurrentHashMap<>();
|
||||||
|
private Function<String, Optional<Map<String, RSAPublicKey>>> localIssuerKeys = issuer -> Optional.empty();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An issuer that is one of this emulator's own Cognito pools is served at Floci's base URL, which
|
||||||
|
* is plain HTTP on a hostname such as {@code localhost} or a Compose service name, so the HTTPS
|
||||||
|
* and address rules below would refuse to fetch it. Its keys are read from the pool instead:
|
||||||
|
* they are the same keys the pool publishes at its JWKS URL.
|
||||||
|
*/
|
||||||
@Inject
|
@Inject
|
||||||
|
public JwtSignatureVerifier(ObjectMapper objectMapper, EmulatorConfig config, Instance<CognitoService> cognito) {
|
||||||
|
this(objectMapper, config);
|
||||||
|
withLocalIssuerKeys(issuer -> cognito.isResolvable()
|
||||||
|
? cognito.get().localIssuerKeys(issuer) : Optional.empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Where the keys of in-process issuers come from; package-private so tests can stand one in. */
|
||||||
|
JwtSignatureVerifier withLocalIssuerKeys(Function<String, Optional<Map<String, RSAPublicKey>>> localIssuerKeys) {
|
||||||
|
this.localIssuerKeys = localIssuerKeys;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public JwtSignatureVerifier(ObjectMapper objectMapper, EmulatorConfig config) {
|
public JwtSignatureVerifier(ObjectMapper objectMapper, EmulatorConfig config) {
|
||||||
this(objectMapper, SystemDefaultDnsResolver.INSTANCE,
|
this(objectMapper, SystemDefaultDnsResolver.INSTANCE,
|
||||||
config.security().allowPrivateJwtTargets());
|
config.security().allowPrivateJwtTargets());
|
||||||
@@ -162,6 +184,10 @@ public class JwtSignatureVerifier implements AutoCloseable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private RSAPublicKey resolveKey(String issuer, String kid) throws JwtVerificationException {
|
private RSAPublicKey resolveKey(String issuer, String kid) throws JwtVerificationException {
|
||||||
|
Optional<Map<String, RSAPublicKey>> local = localIssuerKeys.apply(issuer);
|
||||||
|
if (local.isPresent()) {
|
||||||
|
return local.get().get(kid);
|
||||||
|
}
|
||||||
CachedJwks cached = jwksCache.get(issuer);
|
CachedJwks cached = jwksCache.get(issuer);
|
||||||
if (cached != null && !cached.isExpired()) {
|
if (cached != null && !cached.isExpired()) {
|
||||||
RSAPublicKey key = cached.keysByKid().get(kid);
|
RSAPublicKey key = cached.keysByKid().get(kid);
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class AthenaJsonHandler {
|
|||||||
resultConfiguration = mapper.treeToValue(request.get("ResultConfiguration"), ResultConfiguration.class);
|
resultConfiguration = mapper.treeToValue(request.get("ResultConfiguration"), ResultConfiguration.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
String id = athenaService.startQueryExecution(query, workGroup, context, resultConfiguration);
|
String id = athenaService.startQueryExecution(query, workGroup, context, resultConfiguration, region);
|
||||||
yield Response.ok(Map.of("QueryExecutionId", id)).build();
|
yield Response.ok(Map.of("QueryExecutionId", id)).build();
|
||||||
}
|
}
|
||||||
case "GetQueryExecution" -> {
|
case "GetQueryExecution" -> {
|
||||||
@@ -62,7 +62,7 @@ public class AthenaJsonHandler {
|
|||||||
}
|
}
|
||||||
case "ListQueryExecutions" -> {
|
case "ListQueryExecutions" -> {
|
||||||
yield Response.ok(Map.of("QueryExecutionIds",
|
yield Response.ok(Map.of("QueryExecutionIds",
|
||||||
athenaService.listQueryExecutions().stream()
|
athenaService.listQueryExecutions(request.has("WorkGroup") ? request.get("WorkGroup").asText() : null).stream()
|
||||||
.map(QueryExecution::getQueryExecutionId).toList())).build();
|
.map(QueryExecution::getQueryExecutionId).toList())).build();
|
||||||
}
|
}
|
||||||
case "StopQueryExecution" -> {
|
case "StopQueryExecution" -> {
|
||||||
|
|||||||
@@ -59,6 +59,9 @@ public class AthenaService {
|
|||||||
public static final String DEFAULT_CATALOG = "AwsDataCatalog";
|
public static final String DEFAULT_CATALOG = "AwsDataCatalog";
|
||||||
private static final String DEFAULT_OUTPUT_BUCKET = "floci-athena-results";
|
private static final String DEFAULT_OUTPUT_BUCKET = "floci-athena-results";
|
||||||
private static final String DEFAULT_WORKGROUP = "primary";
|
private static final String DEFAULT_WORKGROUP = "primary";
|
||||||
|
private static final Pattern ENGINE_FAILURE = Pattern.compile("^floci-duck \\w+ returned HTTP \\d+: (\\{.*})$", Pattern.DOTALL);
|
||||||
|
private static final com.fasterxml.jackson.databind.ObjectMapper FAILURE_READER = new com.fasterxml.jackson.databind.ObjectMapper();
|
||||||
|
private static final Pattern TRAILING_SEMICOLONS = Pattern.compile("[\\s;]+$");
|
||||||
private static final String DEFAULT_ENGINE_VERSION = "Athena engine version 3";
|
private static final String DEFAULT_ENGINE_VERSION = "Athena engine version 3";
|
||||||
private static final long MIN_BYTES_SCANNED_CUTOFF_PER_QUERY = 10_000_000L;
|
private static final long MIN_BYTES_SCANNED_CUTOFF_PER_QUERY = 10_000_000L;
|
||||||
private static final String WORKGROUP_RESOURCE = "workgroup/";
|
private static final String WORKGROUP_RESOURCE = "workgroup/";
|
||||||
@@ -122,6 +125,20 @@ public class AthenaService {
|
|||||||
String workGroup,
|
String workGroup,
|
||||||
QueryExecutionContext context,
|
QueryExecutionContext context,
|
||||||
ResultConfiguration resultConfiguration) {
|
ResultConfiguration resultConfiguration) {
|
||||||
|
return startQueryExecution(query, workGroup, context, resultConfiguration, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Runs a query in a workgroup. As in AWS, the workgroup's result location applies when the
|
||||||
|
* request names none, and always when the workgroup enforces its configuration; an unknown
|
||||||
|
* workgroup is refused. A null region skips the workgroup lookup.
|
||||||
|
*/
|
||||||
|
public String startQueryExecution(String query,
|
||||||
|
String workGroup,
|
||||||
|
QueryExecutionContext context,
|
||||||
|
ResultConfiguration resultConfiguration,
|
||||||
|
String region) {
|
||||||
|
WorkGroupConfiguration workGroupConfiguration = region == null ? null : workGroupFor(region, workGroup).getConfiguration();
|
||||||
String id = UUID.randomUUID().toString();
|
String id = UUID.randomUUID().toString();
|
||||||
String database = context != null && context.getDatabase() != null ? context.getDatabase() : "default";
|
String database = context != null && context.getDatabase() != null ? context.getDatabase() : "default";
|
||||||
QueryExecutionContext resolvedContext = context != null ? context : new QueryExecutionContext();
|
QueryExecutionContext resolvedContext = context != null ? context : new QueryExecutionContext();
|
||||||
@@ -135,7 +152,7 @@ public class AthenaService {
|
|||||||
// directory prefix — the same key is written and returned to the client.
|
// directory prefix — the same key is written and returned to the client.
|
||||||
// Statements that do not return rows must not be wrapped in a result COPY.
|
// Statements that do not return rows must not be wrapped in a result COPY.
|
||||||
String outputLocation = producesResultRows(query)
|
String outputLocation = producesResultRows(query)
|
||||||
? resolveOutputLocation(resultConfiguration, id)
|
? resolveOutputLocation(resultConfiguration, workGroupConfiguration, id)
|
||||||
: null;
|
: null;
|
||||||
ResultConfiguration resolvedResult = outputLocation != null
|
ResultConfiguration resolvedResult = outputLocation != null
|
||||||
? new ResultConfiguration(outputLocation)
|
? new ResultConfiguration(outputLocation)
|
||||||
@@ -177,7 +194,7 @@ public class AthenaService {
|
|||||||
if (outputLocation != null) {
|
if (outputLocation != null) {
|
||||||
ensureOutputBucket(outputLocation);
|
ensureOutputBucket(outputLocation);
|
||||||
}
|
}
|
||||||
duckClient.execute(query, setupDdl, outputLocation);
|
duckClient.execute(withoutTrailingSemicolons(query), setupDdl, outputLocation);
|
||||||
return null;
|
return null;
|
||||||
}).onSuccess(v -> {
|
}).onSuccess(v -> {
|
||||||
markSucceeded(id, execution);
|
markSucceeded(id, execution);
|
||||||
@@ -214,6 +231,16 @@ public class AthenaService {
|
|||||||
return queryStore.scan(k -> true);
|
return queryStore.scan(k -> true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A workgroup's queries, most recent first, as ListQueryExecutions returns them. */
|
||||||
|
public List<QueryExecution> listQueryExecutions(String workGroup) {
|
||||||
|
String name = workGroup == null || workGroup.isBlank() ? DEFAULT_WORKGROUP : workGroup;
|
||||||
|
return queryStore.scan(k -> true).stream()
|
||||||
|
.filter(execution -> name.equals(execution.getWorkGroup() == null ? DEFAULT_WORKGROUP : execution.getWorkGroup()))
|
||||||
|
.sorted(Comparator.comparing((QueryExecution execution) -> execution.getStatus().getSubmissionDateTime(),
|
||||||
|
Comparator.nullsLast(Comparator.naturalOrder())).reversed())
|
||||||
|
.toList();
|
||||||
|
}
|
||||||
|
|
||||||
public void stopQueryExecution(String id) {
|
public void stopQueryExecution(String id) {
|
||||||
QueryExecution execution = getQueryExecution(id);
|
QueryExecution execution = getQueryExecution(id);
|
||||||
execution.getStatus().setState(QueryExecutionState.CANCELLED);
|
execution.getStatus().setState(QueryExecutionState.CANCELLED);
|
||||||
@@ -531,6 +558,15 @@ public class AthenaService {
|
|||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Athena accepts one statement with or without a closing semicolon. The engine wraps the
|
||||||
|
* statement in {@code COPY (...) TO ...}, where a semicolon is a syntax error, so it is
|
||||||
|
* dropped before the query is handed over.
|
||||||
|
*/
|
||||||
|
static String withoutTrailingSemicolons(String query) {
|
||||||
|
return query == null ? null : TRAILING_SEMICOLONS.matcher(query).replaceFirst("");
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean producesResultRows(String query) {
|
private static boolean producesResultRows(String query) {
|
||||||
return RESULT_STATEMENT_PATTERN.matcher(statementText(query)).find();
|
return RESULT_STATEMENT_PATTERN.matcher(statementText(query)).find();
|
||||||
}
|
}
|
||||||
@@ -576,17 +612,53 @@ public class AthenaService {
|
|||||||
|
|
||||||
private void markFailed(String id, QueryExecution execution, Throwable failure) {
|
private void markFailed(String id, QueryExecution execution, Throwable failure) {
|
||||||
execution.getStatus().setState(QueryExecutionState.FAILED);
|
execution.getStatus().setState(QueryExecutionState.FAILED);
|
||||||
execution.getStatus().setStateChangeReason(failure.getMessage());
|
execution.getStatus().setStateChangeReason(failureReason(failure.getMessage()));
|
||||||
queryStore.put(id, execution);
|
queryStore.put(id, execution);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The engine's own explanation of a failed query, as Athena reports it: without the HTTP
|
||||||
|
* envelope of the engine call, and without the echoed statement, which shows the
|
||||||
|
* internal {@code COPY ... TO} wrapper rather than the query that was sent.
|
||||||
|
*/
|
||||||
|
static String failureReason(String message) {
|
||||||
|
if (message == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
Matcher envelope = ENGINE_FAILURE.matcher(message);
|
||||||
|
if (!envelope.matches()) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String engineMessage = FAILURE_READER.readTree(envelope.group(1)).path("message").asText("");
|
||||||
|
if (engineMessage.isBlank()) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
int echo = engineMessage.indexOf("\n\nLINE ");
|
||||||
|
return (echo >= 0 ? engineMessage.substring(0, echo) : engineMessage).strip();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private record CreateDatabaseDdl(String name, boolean ifNotExists, String comment,
|
private record CreateDatabaseDdl(String name, boolean ifNotExists, String comment,
|
||||||
String location, Map<String, String> properties) {
|
String location, Map<String, String> properties) {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String resolveOutputLocation(ResultConfiguration rc, String queryId) {
|
private String resolveOutputLocation(ResultConfiguration rc, WorkGroupConfiguration workGroupConfiguration, String queryId) {
|
||||||
String base = (rc != null && rc.getOutputLocation() != null && !rc.getOutputLocation().isBlank())
|
String requested = rc != null && rc.getOutputLocation() != null && !rc.getOutputLocation().isBlank()
|
||||||
? rc.getOutputLocation()
|
? rc.getOutputLocation()
|
||||||
|
: null;
|
||||||
|
String workGroupLocation = workGroupConfiguration != null
|
||||||
|
&& workGroupConfiguration.getResultConfiguration() != null
|
||||||
|
&& workGroupConfiguration.getResultConfiguration().getOutputLocation() != null
|
||||||
|
&& !workGroupConfiguration.getResultConfiguration().getOutputLocation().isBlank()
|
||||||
|
? workGroupConfiguration.getResultConfiguration().getOutputLocation()
|
||||||
|
: null;
|
||||||
|
boolean enforced = workGroupConfiguration != null && Boolean.TRUE.equals(workGroupConfiguration.getEnforceWorkGroupConfiguration());
|
||||||
|
String base = enforced && workGroupLocation != null ? workGroupLocation
|
||||||
|
: requested != null ? requested
|
||||||
|
: workGroupLocation != null ? workGroupLocation
|
||||||
: "s3://" + DEFAULT_OUTPUT_BUCKET + "/results/";
|
: "s3://" + DEFAULT_OUTPUT_BUCKET + "/results/";
|
||||||
return base.endsWith("/") ? base + queryId + ".csv" : base + "/" + queryId + ".csv";
|
return base.endsWith("/") ? base + queryId + ".csv" : base + "/" + queryId + ".csv";
|
||||||
}
|
}
|
||||||
@@ -692,6 +764,12 @@ public class AthenaService {
|
|||||||
return engineVersion;
|
return engineVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private WorkGroup workGroupFor(String region, String name) {
|
||||||
|
return name == null || name.isBlank() || DEFAULT_WORKGROUP.equals(name)
|
||||||
|
? primaryWorkGroup(region)
|
||||||
|
: requireWorkGroup(region, name);
|
||||||
|
}
|
||||||
|
|
||||||
private WorkGroup primaryWorkGroup(String region) {
|
private WorkGroup primaryWorkGroup(String region) {
|
||||||
return workGroupStore.get(workGroupKey(region, DEFAULT_WORKGROUP)).orElseGet(() -> {
|
return workGroupStore.get(workGroupKey(region, DEFAULT_WORKGROUP)).orElseGet(() -> {
|
||||||
WorkGroup workGroup = new WorkGroup();
|
WorkGroup workGroup = new WorkGroup();
|
||||||
|
|||||||
@@ -3079,6 +3079,18 @@ public class CognitoService implements ResourceProvider {
|
|||||||
return overrideId;
|
return overrideId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The signing keys, by kid, of this emulator's own pool that {@code issuer} names exactly, so a
|
||||||
|
* JWT authorizer can verify the pool's tokens in-process; empty for every other issuer.
|
||||||
|
*/
|
||||||
|
public Optional<Map<String, RSAPublicKey>> localIssuerKeys(String issuer) {
|
||||||
|
if (issuer == null) return Optional.empty();
|
||||||
|
String trimmed = issuer.replaceAll("/+$", "");
|
||||||
|
String poolId = trimmed.substring(trimmed.lastIndexOf('/') + 1);
|
||||||
|
if (poolId.isEmpty() || !getIssuer(poolId).equals(trimmed)) return Optional.empty();
|
||||||
|
return poolStore.get(poolId).map(pool -> Map.of(getSigningKeyId(pool), getSigningPublicKey(pool)));
|
||||||
|
}
|
||||||
|
|
||||||
public String getJwksUri(String poolId) {
|
public String getJwksUri(String poolId) {
|
||||||
return getIssuer(poolId) + "/.well-known/jwks.json";
|
return getIssuer(poolId) + "/.well-known/jwks.json";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
package io.github.hectorvent.floci.services.acm;
|
||||||
|
|
||||||
|
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||||
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static io.restassured.RestAssured.given;
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.hamcrest.Matchers.notNullValue;
|
||||||
|
|
||||||
|
@QuarkusTest
|
||||||
|
class AcmExportableRequestTest {
|
||||||
|
|
||||||
|
private static final String ACM_CONTENT_TYPE = "application/x-amz-json-1.1";
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void configureRestAssured() {
|
||||||
|
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void requestCertificateKeepsTheExportOption() {
|
||||||
|
String exportable = request("{\"DomainName\":\"exportable.example.com\",\"Options\":{\"Export\":\"ENABLED\"}}");
|
||||||
|
|
||||||
|
call("DescribeCertificate", "{\"CertificateArn\":\"" + exportable + "\"}")
|
||||||
|
.statusCode(200)
|
||||||
|
.body("Certificate.Options.Export", equalTo("ENABLED"))
|
||||||
|
.body("Certificate.Options.CertificateTransparencyLoggingPreference", equalTo("ENABLED"));
|
||||||
|
|
||||||
|
call("ExportCertificate", "{\"CertificateArn\":\"" + exportable + "\",\"Passphrase\":\"c2VjcmV0\"}")
|
||||||
|
.statusCode(200)
|
||||||
|
.body("PrivateKey", notNullValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void requestCertificateWithoutExportIsNotExportable() {
|
||||||
|
String plain = request("{\"DomainName\":\"plain.example.com\",\"Options\":{\"CertificateTransparencyLoggingPreference\":\"DISABLED\"}}");
|
||||||
|
|
||||||
|
call("DescribeCertificate", "{\"CertificateArn\":\"" + plain + "\"}")
|
||||||
|
.statusCode(200)
|
||||||
|
.body("Certificate.Options.Export", equalTo("DISABLED"))
|
||||||
|
.body("Certificate.Options.CertificateTransparencyLoggingPreference", equalTo("DISABLED"));
|
||||||
|
|
||||||
|
call("ExportCertificate", "{\"CertificateArn\":\"" + plain + "\",\"Passphrase\":\"c2VjcmV0\"}")
|
||||||
|
.statusCode(400)
|
||||||
|
.body("__type", equalTo("ValidationException"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void requestCertificateRejectsAnUnknownExportValue() {
|
||||||
|
call("RequestCertificate", "{\"DomainName\":\"bad.example.com\",\"Options\":{\"Export\":\"MAYBE\"}}")
|
||||||
|
.statusCode(400)
|
||||||
|
.body("__type", equalTo("ValidationException"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String request(String body) {
|
||||||
|
return call("RequestCertificate", body).statusCode(200).extract().jsonPath().getString("CertificateArn");
|
||||||
|
}
|
||||||
|
|
||||||
|
private io.restassured.response.ValidatableResponse call(String action, String body) {
|
||||||
|
return given()
|
||||||
|
.header("X-Amz-Target", "CertificateManager." + action)
|
||||||
|
.contentType(ACM_CONTENT_TYPE)
|
||||||
|
.body(body)
|
||||||
|
.when()
|
||||||
|
.post("/")
|
||||||
|
.then();
|
||||||
|
}
|
||||||
|
}
|
||||||
+20
@@ -98,6 +98,26 @@ class JwtSignatureVerifierTest {
|
|||||||
verifier.verify(token, issuer); // does not throw
|
verifier.verify(token, issuer); // does not throw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void verifiesAnInProcessIssuerWithoutFetchingIt() throws Exception {
|
||||||
|
// Floci's own Cognito issuer: plain HTTP on a hostname, which the strict fetch rules refuse.
|
||||||
|
String localIssuer = "http://floci:4566/us-east-1_local";
|
||||||
|
strictVerifier.withLocalIssuerKeys(candidate -> candidate.equals(localIssuer)
|
||||||
|
? java.util.Optional.of(Map.of("test-key-1", publicKey)) : java.util.Optional.empty());
|
||||||
|
|
||||||
|
assertDoesNotThrow(() -> strictVerifier.verify(signToken("test-key-1", privateKey), localIssuer));
|
||||||
|
assertThrows(JwtSignatureVerifier.JwtVerificationException.class,
|
||||||
|
() -> strictVerifier.verify(signToken("other-key", privateKey), localIssuer));
|
||||||
|
KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
|
||||||
|
gen.initialize(2048);
|
||||||
|
String forged = signToken("test-key-1", (RSAPrivateKey) gen.generateKeyPair().getPrivate());
|
||||||
|
assertThrows(JwtSignatureVerifier.JwtVerificationException.class,
|
||||||
|
() -> strictVerifier.verify(forged, localIssuer));
|
||||||
|
// Any other plain-HTTP issuer still goes through the strict fetch, and is refused.
|
||||||
|
assertThrows(JwtSignatureVerifier.JwtVerificationException.class,
|
||||||
|
() -> strictVerifier.verify(signToken("test-key-1", privateKey), "http://floci:4566/us-east-1_other"));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void rejectsATokenSignedWithADifferentKey() throws Exception {
|
void rejectsATokenSignedWithADifferentKey() throws Exception {
|
||||||
KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
|
KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package io.github.hectorvent.floci.services.athena;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
class AthenaQueryTextTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void dropsTheClosingSemicolonsAthenaAccepts() {
|
||||||
|
assertEquals("SELECT * FROM orders LIMIT 10", AthenaService.withoutTrailingSemicolons("SELECT * FROM orders LIMIT 10;"));
|
||||||
|
assertEquals("SELECT 1", AthenaService.withoutTrailingSemicolons("SELECT 1 ; ;\n"));
|
||||||
|
assertEquals("SELECT ';' AS s", AthenaService.withoutTrailingSemicolons("SELECT ';' AS s"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void reportsTheEngineErrorWithoutItsEnvelopeOrTheWrappedStatement() {
|
||||||
|
String engine = "floci-duck execute returned HTTP 500: {\"status\":\"error\",\"message\":\"Catalog Error: Table with name nope does not exist!\\nDid you mean \\\"orders\\\"?\\n\\nLINE 1: COPY (SELECT * FROM nope) TO 's3://results/q.csv'\"}";
|
||||||
|
assertEquals("Catalog Error: Table with name nope does not exist!\nDid you mean \"orders\"?", AthenaService.failureReason(engine));
|
||||||
|
assertEquals("Failed to call floci-duck execute: timeout", AthenaService.failureReason("Failed to call floci-duck execute: timeout"));
|
||||||
|
}
|
||||||
|
}
|
||||||
+109
@@ -0,0 +1,109 @@
|
|||||||
|
package io.github.hectorvent.floci.services.athena;
|
||||||
|
|
||||||
|
import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
|
||||||
|
import io.quarkus.test.junit.QuarkusTest;
|
||||||
|
import org.junit.jupiter.api.BeforeAll;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import static io.restassured.RestAssured.given;
|
||||||
|
import static org.hamcrest.Matchers.equalTo;
|
||||||
|
import static org.hamcrest.Matchers.hasItem;
|
||||||
|
import static org.hamcrest.Matchers.not;
|
||||||
|
import static org.hamcrest.Matchers.startsWith;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
/** Queries belong to their workgroup: they use its result location and are listed under it. */
|
||||||
|
@QuarkusTest
|
||||||
|
class AthenaWorkGroupQueriesIntegrationTest {
|
||||||
|
|
||||||
|
private static final String CONTENT_TYPE = "application/x-amz-json-1.1";
|
||||||
|
|
||||||
|
@BeforeAll
|
||||||
|
static void configureRestAssured() {
|
||||||
|
RestAssuredJsonUtils.configureAwsContentTypes();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static io.restassured.response.ValidatableResponse athena(String action, String body) {
|
||||||
|
return given()
|
||||||
|
.header("X-Amz-Target", "AmazonAthena." + action)
|
||||||
|
.contentType(CONTENT_TYPE)
|
||||||
|
.body(body)
|
||||||
|
.when().post("/")
|
||||||
|
.then();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String workGroup(String location, boolean enforce) {
|
||||||
|
String name = "wg-" + UUID.randomUUID().toString().substring(0, 8);
|
||||||
|
athena("CreateWorkGroup", """
|
||||||
|
{"Name": "%s", "Configuration": {"ResultConfiguration": {"OutputLocation": "%s"}, "EnforceWorkGroupConfiguration": %s}}
|
||||||
|
""".formatted(name, location, enforce)).statusCode(200);
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String start(String workGroup, String outputLocation) {
|
||||||
|
String result = outputLocation == null ? "" : ", \"ResultConfiguration\": {\"OutputLocation\": \"" + outputLocation + "\"}";
|
||||||
|
return athena("StartQueryExecution", "{\"QueryString\": \"SELECT 1\", \"WorkGroup\": \"" + workGroup + "\"" + result + "}")
|
||||||
|
.statusCode(200)
|
||||||
|
.extract().jsonPath().getString("QueryExecutionId");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String outputLocation(String queryId) {
|
||||||
|
return athena("GetQueryExecution", "{\"QueryExecutionId\": \"" + queryId + "\"}")
|
||||||
|
.statusCode(200)
|
||||||
|
.body("QueryExecution.WorkGroup", not(equalTo(null)))
|
||||||
|
.extract().jsonPath().getString("QueryExecution.ResultConfiguration.OutputLocation");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void usesTheWorkGroupResultLocationWhenTheQueryNamesNone() {
|
||||||
|
String name = workGroup("s3://team-results/athena/", false);
|
||||||
|
String queryId = start(name, null);
|
||||||
|
|
||||||
|
assertEquals("s3://team-results/athena/" + queryId + ".csv", outputLocation(queryId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void aRequestedLocationWinsUnlessTheWorkGroupEnforcesItsOwn() {
|
||||||
|
String open = workGroup("s3://team-results/open/", false);
|
||||||
|
String openQuery = start(open, "s3://mine/results/");
|
||||||
|
assertEquals("s3://mine/results/" + openQuery + ".csv", outputLocation(openQuery));
|
||||||
|
|
||||||
|
String enforced = workGroup("s3://team-results/enforced/", true);
|
||||||
|
String enforcedQuery = start(enforced, "s3://mine/results/");
|
||||||
|
assertEquals("s3://team-results/enforced/" + enforcedQuery + ".csv", outputLocation(enforcedQuery));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void refusesAWorkGroupThatDoesNotExist() {
|
||||||
|
athena("StartQueryExecution", "{\"QueryString\": \"SELECT 1\", \"WorkGroup\": \"no-such-group\"}")
|
||||||
|
.statusCode(400)
|
||||||
|
.body("__type", equalTo("InvalidRequestException"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void listsOnlyTheWorkGroupQueriesNewestFirst() {
|
||||||
|
String name = workGroup("s3://team-results/listed/", false);
|
||||||
|
String first = start(name, null);
|
||||||
|
String second = start(name, null);
|
||||||
|
String elsewhere = start("primary", null);
|
||||||
|
|
||||||
|
List<String> listed = athena("ListQueryExecutions", "{\"WorkGroup\": \"" + name + "\"}")
|
||||||
|
.statusCode(200)
|
||||||
|
.extract().jsonPath().getList("QueryExecutionIds", String.class);
|
||||||
|
assertEquals(List.of(second, first), listed);
|
||||||
|
|
||||||
|
athena("ListQueryExecutions", "{}")
|
||||||
|
.statusCode(200)
|
||||||
|
.body("QueryExecutionIds", hasItem(elsewhere))
|
||||||
|
.body("QueryExecutionIds", not(hasItem(first)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void thePrimaryWorkGroupKeepsItsDefaultLocation() {
|
||||||
|
String queryId = start("primary", null);
|
||||||
|
org.hamcrest.MatcherAssert.assertThat(outputLocation(queryId), startsWith("s3://floci-athena-results/results/"));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1369,6 +1369,22 @@ class CognitoServiceTest {
|
|||||||
assertEquals("http://localhost:4566/custompool", service.getIssuer(pool.getId()));
|
assertEquals("http://localhost:4566/custompool", service.getIssuer(pool.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void localIssuerKeysServeOnlyThisEmulatorsOwnPoolIssuers() throws Exception {
|
||||||
|
UserPool pool = createPoolAndUser();
|
||||||
|
UserPoolClient client = clientWithFlows(pool, "ALLOW_USER_PASSWORD_AUTH");
|
||||||
|
String token = (String) ((Map<?, ?>) service.initiateAuth(client.getClientId(), "USER_PASSWORD_AUTH",
|
||||||
|
Map.of("USERNAME", "alice", "PASSWORD", "Perm1234!")).get("AuthenticationResult")).get("AccessToken");
|
||||||
|
String kid = MAPPER.readTree(Base64.getUrlDecoder().decode(token.split("\\.")[0])).path("kid").asText();
|
||||||
|
|
||||||
|
Map<String, java.security.interfaces.RSAPublicKey> keys = service.localIssuerKeys(service.getIssuer(pool.getId())).orElseThrow();
|
||||||
|
assertTrue(keys.containsKey(kid), "the key that signed the pool's tokens");
|
||||||
|
assertTrue(service.localIssuerKeys(service.getIssuer(pool.getId()) + "/").isPresent());
|
||||||
|
assertTrue(service.localIssuerKeys("https://cognito-idp.us-east-1.amazonaws.com/" + pool.getId()).isEmpty());
|
||||||
|
assertTrue(service.localIssuerKeys(service.getIssuer("us-east-1_missing")).isEmpty());
|
||||||
|
assertTrue(service.localIssuerKeys(null).isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
// Groups
|
// Groups
|
||||||
// =========================================================================
|
// =========================================================================
|
||||||
|
|||||||
Reference in New Issue
Block a user