Files
floci/mkdocs.yml
T
Priamo Germosen 7e4e3e8c50 feat(mwaa): add Amazon MWAA emulation backed by real Airflow (LocalExecutor) (#2086)
* feat(mwaa): add Amazon MWAA emulation backed by real Airflow (LocalExecutor)

Adds a new services/mwaa package following the EKS lifecycle pattern
(Controller/Service/EnvironmentManager, one Docker container-set per
resource, readiness polling) and the Neptune/ElastiCache proxy pattern
(MwaaWebProxy/MwaaProxyManager: Floci owns the host-facing port, the
backing container stays internal-only).

Each environment is backed by two real containers — postgres:16-alpine
for the metadata DB and apache/airflow:<version>-python3.12 running
LocalExecutor — with AirflowVersion genuinely selecting the image tag
(validated against a configured allow-list), unlike EKS's cosmetic-only
version field. MwaaWebProxy fronts the real Airflow webserver and
intercepts POST /aws_mwaa/cli, bridging it to a docker-exec'd `airflow`
CLI call and returning the documented {stdout, stderr} shape.

DAGs and requirements.txt sync from S3 on a poller, reusing the existing
S3Service in-process rather than a new AWS-facing surface. The Airflow
container is pointed back at Floci via LaunchedContainerAwsEnv (the same
mechanism Lambda/ECS containers already use), so a DAG's own boto3 calls
resolve against Floci instead of real AWS.

StartupScriptS3Path is supported end-to-end: fetched from S3 at create
time, injected before the container starts (create -> inject -> start,
mirroring EksClusterManager's config-injection sequencing), sourced
before migrate/scheduler/webserver so exported vars propagate. The
airflow user gets a passwordless sudo grant (verified against the real
image — sudo ships but isn't passwordless by default, and AWS's own
startup-script examples assume sudo just works), and a fixed set of
Floci-critical env vars (Fernet key, DB DSN, executor, AWS-SDK-redirection
vars) are snapshotted before and restored after the script runs, mirroring
real MWAA's reserved-environment-variable protection.

Verified end-to-end against real Docker (not just the mock=true unit
suite): environment reaches AVAILABLE, proxy pass-through and the CLI
bridge both work with real output, a DAG uploaded to S3 syncs and parses,
a second environment on a different AirflowVersion pulls a genuinely
distinct image, and delete tears down both containers/volumes and the
proxy cleanly.

45 new tests (unit + RestAssured integration, all against mock=true in
the default suite so Docker is never required for `mvnw test`); full
suite otherwise unchanged.

* fix(mwaa): hard-fail startup-script injection failures, release proxy ports on delete

Two issues from review:

copyFileIntoContainer swallowed every failure identically, including the
one case where that's wrong: a configured StartupScriptS3Path that fails
to copy into the container. The entrypoint's "if [ -f /startup.sh ]"
guard would silently skip it and the environment would reach AVAILABLE
having never applied the requested setup, contradicting the documented
intent of gating environment creation on startup-script failure (matching
real MWAA). copyFileIntoContainer now reports success/failure; the
startup-script call site checks it and throws, while DAG sync and the
best-effort sudoers grant keep their existing soft-fail behavior.

deleteEnvironment allocated a proxy port via PortAllocator on create but
never released it on delete, unlike every other service that uses
PortAllocator (Lambda, MSK, EC2, ECR) — repeated create/delete cycles
would eventually exhaust the configured proxy port range even with zero
MWAA proxies actually running.

* fix(mwaa): roll back allocated proxy port and containers on create failure

If startEnvironment() succeeded (containers running) but PortAllocator.allocate
or MwaaProxyManager.startProxy failed afterward, createEnvironment's catch
block set CREATE_FAILED without releasing the reserved port or stopping the
containers that had already started — leaking both on every such failure.

Mirrors NeptuneService.createDbCluster/rollbackDbCluster's already-proven
shape for this exact class of problem (container + proxy + port, partial
failure must roll back everything): a provisioned flag set only after every
step succeeds, and a try/finally that runs rollbackFailedCreate whenever it
doesn't — stopping the proxy (a no-op if it never started), stopping any
containers that did start (MwaaEnvironmentManager.stopEnvironment already
null-checks each container id, so it's safe for partial startup too), and
always releasing the port.

* fix(mwaa): correct CreateEnvironment error shape, namespace container names, add docs

Two items from maintainer review:

- Duplicate CreateEnvironment threw ResourceAlreadyExistsException, a shape the
  operation doesn't declare (verified against the real botocore mwaa/2020-07-01
  model: CreateEnvironment's only errors are ServiceUnavailableException,
  ValidationException, InternalServerException) — SDK clients couldn't map it.
  Now throws ValidationException.

- dbContainerName/airflowContainerName built names via raw string concatenation
  instead of routing through ContainerStorageHelper.dockerName like every other
  Docker-backed service (EKS, RDS, ...), so MWAA alone didn't participate in the
  FLOCI_DOCKER_RESOURCE_NAMESPACE convention that keeps multiple Floci instances
  sharing one Docker daemon from colliding. Both static methods now take the
  EmulatorConfig and route through the shared helper; volume names inherit the
  fix automatically since they're built by extending the container name.

Also adds docs/services/mwaa.md (mkdocs nav updated) following eks.md's
structure — operations table, mock/real mode, the web/CLI proxy, startup-script
behavior (sudo grant, reserved-variable protection), config reference, ARN
format, CLI/SDK examples, and an honest "Not Implemented" section covering the
known gaps already discussed on the PR (PluginsS3Path, cross-account container
naming, restart restoration).
2026-08-04 22:16:14 -05:00

151 lines
4.8 KiB
YAML

site_name: Floci
site_description: Fast, free, open-source local AWS emulator
site_url: https://floci.io/floci/
repo_url: https://github.com/floci-io/floci
repo_name: floci-io/floci
edit_uri: edit/main/docs/
theme:
name: material
custom_dir: overrides
logo: assets/floci-header.svg
favicon: assets/floci.svg
palette:
- media: "(prefers-color-scheme: light)"
scheme: default
primary: custom
accent: custom
toggle:
icon: material/brightness-7
name: Switch to dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: custom
accent: custom
toggle:
icon: material/brightness-4
name: Switch to light mode
features:
- navigation.tabs
- navigation.sections
- navigation.top
- navigation.instant
- search.highlight
- search.suggest
- content.code.copy
- content.code.annotate
- content.tabs.link
extra_css:
- assets/extra.css
plugins:
- search
markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences
- pymdownx.highlight:
anchor_linenums: true
- pymdownx.tabbed:
alternate_style: true
- pymdownx.inlinehilite
- tables
- attr_list
nav:
- Home: index.md
- Getting Started:
- Quick Start: getting-started/quick-start.md
- Installation: getting-started/installation.md
- AWS CLI & SDK Setup: getting-started/aws-setup.md
- Migrate from LocalStack: getting-started/migrate-from-localstack.md
- Configuration:
- Environment Variables: configuration/environment-variables.md
- Docker Images: configuration/docker-images.md
- Docker Compose: configuration/docker-compose.md
- Ports Reference: configuration/ports.md
- Multi-Account Isolation: configuration/multi-account.md
- Storage Modes: configuration/storage.md
- TLS / HTTPS: configuration/tls.md
- Initialization Hooks: configuration/initialization-hooks.md
- Advanced:
- application.yml Reference: configuration/advanced/application-yml.md
- Services:
- Overview: services/index.md
- SSM Parameter Store: services/ssm.md
- SQS: services/sqs.md
- SNS: services/sns.md
- SES: services/ses.md
- S3: services/s3.md
- DynamoDB: services/dynamodb.md
- Lambda: services/lambda.md
- API Gateway: services/api-gateway.md
- Cognito: services/cognito.md
- KMS: services/kms.md
- Kinesis: services/kinesis.md
- Secrets Manager: services/secrets-manager.md
- CloudFormation: services/cloudformation.md
- Step Functions: services/step-functions.md
- IAM: services/iam.md
- STS: services/sts.md
- ElastiCache: services/elasticache.md
- MemoryDB: services/memorydb.md
- RDS: services/rds.md
- RDS Data API: services/rds-data.md
- MSK (Kafka): services/msk.md
- Glue: services/glue.md
- Neptune: services/neptune.md
- DocumentDB: services/docdb.md
- Athena: services/athena.md
- Data Firehose: services/firehose.md
- EventBridge: services/eventbridge.md
- EventBridge Pipes: services/pipes.md
- EventBridge Scheduler: services/scheduler.md
- CloudWatch: services/cloudwatch.md
- CloudWatch RUM: services/rum.md
- ACM: services/acm.md
- ECS: services/ecs.md
- ECR: services/ecr.md
- Resource Groups Tagging API: services/resource-groups-tagging.md
- EKS: services/eks.md
- MWAA: services/mwaa.md
- OpenSearch: services/opensearch.md
- EC2: services/ec2.md
- Lightsail: services/lightsail.md
- AppConfig: services/appconfig.md
- Bedrock Runtime: services/bedrock-runtime.md
- ELB v2: services/elb.md
- Auto Scaling: services/autoscaling.md
- Elastic Beanstalk: services/elastic-beanstalk.md
- CodeBuild: services/codebuild.md
- AWS Batch: services/batch.md
- CodeDeploy: services/codedeploy.md
- CodePipeline: services/codepipeline.md
- AWS Backup: services/backup.md
- CloudTrail: services/cloudtrail.md
- CloudFront: services/cloudfront.md
- Route53: services/route53.md
- AWS Cloud Map: services/cloudmap.md
- AWS IoT Core: services/iot.md
- AppSync: services/appsync.md
- Transfer Family: services/transfer.md
- AWS Config: services/config.md
- CloudTrail: services/cloudtrail.md
- EMR: services/emr.md
- WAF v2: services/wafv2.md
- Textract: services/textract.md
- Transcribe: services/transcribe.md
- Pricing: services/pricing.md
- Cost Explorer: services/ce.md
- Cost and Usage Reports: services/cur.md
- BCM Data Exports: services/bcm-data-exports.md
- Testcontainers:
- Overview: testcontainers/index.md
- Java: testcontainers/java.md
- Node.js / TypeScript: testcontainers/nodejs.md
- Python: testcontainers/python.md
- Go: testcontainers/go.md
- Contributing: contributing.md