Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

feat(route53): add Route53 management-plane emulation (#715)

Hector Ventura3b54255d7fcd
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b405ec50e3..f037307da2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,9 +9,20 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
+- **codedeploy:** Server platform (Phase 4) — on-premises instance management (`RegisterOnPremisesInstance`, `DeregisterOnPremisesInstance`, `GetOnPremisesInstance`, `BatchGetOnPremisesInstances`, `ListOnPremisesInstances`, `AddTagsToOnPremisesInstances`, `RemoveTagsFromOnPremisesInstances`); Server AppSpec YAML parsing; EC2 and on-premises instance resolution by tag filters; full lifecycle event execution (`ApplicationStop` → `DownloadBundle` → `BeforeInstall` → `Install` → `AfterInstall` → `ApplicationStart` → `ValidateService`); SSM Run Command integration for hook script execution with graceful degradation when SSM is unavailable; per-instance `InstanceTarget` tracking in `ListDeploymentTargets`/`BatchGetDeploymentTargets`
- **elbv2:** Lambda target type — ALB listeners forward requests to Lambda functions using the full ALB→Lambda event format (`httpMethod`, `path`, `queryStringParameters`, `multiValueQueryStringParameters`, `headers`, `multiValueHeaders`, `body`, `isBase64Encoded`); Lambda→ALB response mapping (`statusCode`, `headers`, `multiValueHeaders`, `body`, `isBase64Encoded`); Lambda target groups always report as healthy in `DescribeTargetHealth` without HTTP probing
+- **eventbridge:** Archive and Replay support — `CreateArchive`, `DescribeArchive`, `UpdateArchive`, `DeleteArchive`, `ListArchives`, `StartReplay`, `DescribeReplay`, `CancelReplay`, `ListReplays`; events captured automatically to matching archives and replayed on demand ([#702](https://github.com/floci-io/floci/pull/702))
+- **route53:** Route53 Phase 1 — hosted zones with auto-created SOA + NS records, `ChangeResourceRecordSets` (CREATE/UPSERT/DELETE with atomic batch validation), `ListResourceRecordSets`, change tracking (always INSYNC), health checks (create/get/list/update/delete), and per-resource tagging via `ChangeTagsForResource` / `ListTagsForResource`
+- **scheduler:** `TagResource`, `UntagResource`, `ListTagsForResource` for schedule groups ([#700](https://github.com/floci-io/floci/pull/700))
+- **sqs, dynamodb:** TRACE-level payload logging for request and response bodies to aid debugging ([#697](https://github.com/floci-io/floci/pull/697))
- **ssm:** Run Command — `SendCommand`, `GetCommandInvocation`, `ListCommands`, `ListCommandInvocations`, `CancelCommand`, `DescribeInstanceInformation`; `UpdateInstanceInformation` (agent registration); `ec2messages` polling protocol (`GetMessages`, `AcknowledgeMessage`, `SendReply`, `FailMessage`, `DeleteMessage`, `GetEndpoint`) so the real `amazon-ssm-agent` running inside EC2 containers can register, receive commands, and report output
-- **codedeploy:** Server platform (Phase 4) — on-premises instance management (`RegisterOnPremisesInstance`, `DeregisterOnPremisesInstance`, `GetOnPremisesInstance`, `BatchGetOnPremisesInstances`, `ListOnPremisesInstances`, `AddTagsToOnPremisesInstances`, `RemoveTagsFromOnPremisesInstances`); Server AppSpec YAML parsing; EC2 and on-premises instance resolution by tag filters; full lifecycle event execution (`ApplicationStop` → `DownloadBundle` → `BeforeInstall` → `Install` → `AfterInstall` → `ApplicationStart` → `ValidateService`); SSM Run Command integration for hook script execution with graceful degradation when SSM is unavailable; per-instance `InstanceTarget` tracking in `ListDeploymentTargets`/`BatchGetDeploymentTargets`
+- **transfer:** Transfer Family management-plane API — server lifecycle (`CreateServer`, `DescribeServer`, `DeleteServer`, `ListServers`, `StartServer`, `StopServer`, `UpdateServer`), user management (`CreateUser`, `DescribeUser`, `DeleteUser`, `ListUsers`, `UpdateUser`), SSH key management (`ImportSshPublicKey`, `DeleteSshPublicKey`), and tagging (`TagResource`, `UntagResource`, `ListTagsForResource`)
+
+### Fixed
+
+- **appconfig:** use capital `"Tags"` body key in `TagResource` / `ListTagsForResource` to match AWS SDK wire format ([#704](https://github.com/floci-io/floci/pull/704))
+- **docker:** respect `DOCKER_HOST` env var and handle bare `host:port` values without a URI scheme ([#705](https://github.com/floci-io/floci/pull/705))
+- **ec2:** `AssociateRouteTable` now returns `<associationState>` in the response; `DescribeRouteTables` supports the `association.route-table-association-id` filter; `DescribeTags` correctly applies `resource-id`, `resource-type`, `key`, and `value` filters ([#706](https://github.com/floci-io/floci/pull/706))
## [1.5.12] - 2026-05-04
diff --git a/README.md b/README.md
index 81f44d65b2..b9678e0a86 100644
--- a/README.md
+++ b/README.md
@@ -116,7 +116,7 @@ flowchart LR
Router["HTTP Router\n(JAX-RS / Vert.x)"]
subgraph Stateless ["Stateless Services"]
- A["SSM · SQS · SNS\nIAM · STS · KMS\nSecrets Manager · SES\nCognito · Kinesis\nEventBridge · Scheduler · AppConfig\nCloudWatch · Step Functions\nCloudFormation · ACM\nAPI Gateway · ELB v2 · Auto Scaling\nCodeDeploy · Bedrock Runtime"]
+ A["SSM · SQS · SNS\nIAM · STS · KMS\nSecrets Manager · SES\nCognito · Kinesis\nEventBridge · Scheduler · AppConfig\nCloudWatch · Step Functions\nCloudFormation · ACM\nAPI Gateway · ELB v2 · Auto Scaling\nCodeDeploy · Bedrock Runtime · Route53"]
end
subgraph Stateful ["Stateful Services"]
@@ -251,6 +251,7 @@ All default images are configurable via environment variables, useful for pinnin
| **CodeBuild** | In-process + **real Docker containers** | Projects, report groups, source credentials; `StartBuild` runs real Docker containers, streams logs to CloudWatch, uploads artifacts to S3 via `docker cp` (works in Docker-in-Docker) |
| **CodeDeploy** | In-process + **Lambda traffic shifting** | Applications, deployment groups, deployment configs; 17 `CodeDeployDefault.*` built-ins pre-seeded; `CreateDeployment` shifts Lambda alias `RoutingConfig` weights, invokes lifecycle hooks, auto-rolls back on failure |
| **Auto Scaling** | In-process + **background reconciler** | Launch configurations, auto scaling groups with min/max/desired capacity; background loop (10 s) calls `RunInstances` / `TerminateInstances` to meet desired capacity; lifecycle hooks, scaling policies, ELB v2 target group auto-registration |
+| **Route53** | In-process | Hosted zones with auto-created SOA + NS records, resource record sets (CREATE/UPSERT/DELETE with atomic validation), change tracking (always INSYNC), health checks, and per-resource tagging |
> **Lambda, ElastiCache, RDS, MSK, ECS, EC2, EKS, OpenSearch, and CodeBuild** spin up real Docker containers and support IAM authentication and SigV4 request signing — the same auth flow as production AWS. **ECR** runs a shared `registry:2` container so the stock `docker` client can push and pull image bytes against repositories returned by the AWS-shaped control plane.
>
diff --git a/compatibility-tests/compat-opentofu/main.tf b/compatibility-tests/compat-opentofu/main.tf
index ad355679df..84ab32953e 100644
--- a/compatibility-tests/compat-opentofu/main.tf
+++ b/compatibility-tests/compat-opentofu/main.tf
@@ -218,3 +218,42 @@ output "route_table_id" {
output "security_group_id" {
value = aws_security_group.compat.id
}
+
+# ── Route53 ────────────────────────────────────────────────────────────────
+resource "aws_route53_zone" "compat" {
+ name = "floci-compat.internal"
+ force_destroy = true
+
+ tags = {
+ Environment = "compat-test"
+ }
+}
+
+resource "aws_route53_record" "app" {
+ zone_id = aws_route53_zone.compat.zone_id
+ name = "app.floci-compat.internal"
+ type = "A"
+ ttl = 300
+ records = ["10.0.1.10"]
+}
+
+resource "aws_route53_health_check" "app" {
+ fqdn = "app.floci-compat.internal"
+ port = 80
+ type = "HTTP"
+ resource_path = "/health"
+ failure_threshold = 3
+ request_interval = 30
+
+ tags = {
+ Environment = "compat-test"
+ }
+}
+
+output "zone_id" {
+ value = aws_route53_zone.compat.zone_id
+}
+
+output "health_check_id" {
+ value = aws_route53_health_check.app.id
+}
diff --git a/compatibility-tests/compat-opentofu/provider.tf b/compatibility-tests/compat-opentofu/provider.tf
index 0c248cf4ed..f56825540c 100644
--- a/compatibility-tests/compat-opentofu/provider.tf
+++ b/compatibility-tests/compat-opentofu/provider.tf
@@ -35,5 +35,6 @@ provider "aws" {
ssm = var.endpoint
secretsmanager = var.endpoint
ec2 = var.endpoint
+ route53 = var.endpoint
}
}
diff --git a/compatibility-tests/compat-opentofu/test/opentofu.bats b/compatibility-tests/compat-opentofu/test/opentofu.bats
index 532acee988..d631763c48 100644
--- a/compatibility-tests/compat-opentofu/test/opentofu.bats
+++ b/compatibility-tests/compat-opentofu/test/opentofu.bats
@@ -123,3 +123,54 @@ setup() {
assert_success
assert_output --partial '"Value": false'
}
+
+@test "OpenTofu: Route53 hosted zone created" {
+ ZONE_ID=$(aws_cmd route53 list-hosted-zones \
+ --query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
+ --output text | sed 's|/hostedzone/||')
+ [ -n "$ZONE_ID" ]
+ run aws_cmd route53 get-hosted-zone --id "$ZONE_ID"
+ assert_success
+ assert_output --partial "floci-compat.internal"
+}
+
+@test "OpenTofu: Route53 A record created" {
+ ZONE_ID=$(aws_cmd route53 list-hosted-zones \
+ --query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
+ --output text | sed 's|/hostedzone/||')
+ run aws_cmd route53 list-resource-record-sets --hosted-zone-id "$ZONE_ID"
+ assert_success
+ assert_output --partial "app.floci-compat.internal"
+ assert_output --partial "10.0.1.10"
+}
+
+@test "OpenTofu: Route53 zone has auto-created SOA and NS records" {
+ ZONE_ID=$(aws_cmd route53 list-hosted-zones \
+ --query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
+ --output text | sed 's|/hostedzone/||')
+ run aws_cmd route53 list-resource-record-sets --hosted-zone-id "$ZONE_ID"
+ assert_success
+ assert_output --partial '"SOA"'
+ assert_output --partial '"NS"'
+}
+
+@test "OpenTofu: Route53 health check created" {
+ HEALTH_CHECK_ID=$(aws_cmd route53 list-health-checks \
+ --query "HealthChecks[?HealthCheckConfig.FullyQualifiedDomainName=='app.floci-compat.internal'].Id | [0]" \
+ --output text)
+ [ -n "$HEALTH_CHECK_ID" ]
+ run aws_cmd route53 get-health-check --health-check-id "$HEALTH_CHECK_ID"
+ assert_success
+ assert_output --partial "app.floci-compat.internal"
+ assert_output --partial "HTTP"
+}
+
+@test "OpenTofu: Route53 zone tags persisted" {
+ ZONE_ID=$(aws_cmd route53 list-hosted-zones \
+ --query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
+ --output text | sed 's|/hostedzone/||')
+ run aws_cmd route53 list-tags-for-resource \
+ --resource-type hostedzone --resource-id "$ZONE_ID"
+ assert_success
+ assert_output --partial "compat-test"
+}
diff --git a/compatibility-tests/compat-terraform/main.tf b/compatibility-tests/compat-terraform/main.tf
index 1981664bb9..5ac3e2a9a1 100644
--- a/compatibility-tests/compat-terraform/main.tf
+++ b/compatibility-tests/compat-terraform/main.tf
@@ -296,3 +296,42 @@ output "route_table_id" {
output "security_group_id" {
value = aws_security_group.compat.id
}
+
+# -- Route53 -------------------------------------------------------------------
+resource "aws_route53_zone" "compat" {
+ name = "floci-compat.internal"
+ force_destroy = true
+
+ tags = {
+ Environment = "compat-test"
+ }
+}
+
+resource "aws_route53_record" "app" {
+ zone_id = aws_route53_zone.compat.zone_id
+ name = "app.floci-compat.internal"
+ type = "A"
+ ttl = 300
+ records = ["10.0.1.10"]
+}
+
+resource "aws_route53_health_check" "app" {
+ fqdn = "app.floci-compat.internal"
+ port = 80
+ type = "HTTP"
+ resource_path = "/health"
+ failure_threshold = 3
+ request_interval = 30
+
+ tags = {
+ Environment = "compat-test"
+ }
+}
+
+output "zone_id" {
+ value = aws_route53_zone.compat.zone_id
+}
+
+output "health_check_id" {
+ value = aws_route53_health_check.app.id
+}
diff --git a/compatibility-tests/compat-terraform/provider.tf b/compatibility-tests/compat-terraform/provider.tf
index 8e5df9b206..df29f496ba 100644
--- a/compatibility-tests/compat-terraform/provider.tf
+++ b/compatibility-tests/compat-terraform/provider.tf
@@ -38,5 +38,6 @@ provider "aws" {
rds = var.endpoint
cloudwatch = var.endpoint
ec2 = var.endpoint
+ route53 = var.endpoint
}
}
diff --git a/compatibility-tests/compat-terraform/test/terraform.bats b/compatibility-tests/compat-terraform/test/terraform.bats
index 09e52148b5..42c261ef22 100644
--- a/compatibility-tests/compat-terraform/test/terraform.bats
+++ b/compatibility-tests/compat-terraform/test/terraform.bats
@@ -142,3 +142,54 @@ setup() {
assert_success
assert_output --partial '"Value": false'
}
+
+@test "Terraform: Route53 hosted zone created" {
+ ZONE_ID=$(aws_cmd route53 list-hosted-zones \
+ --query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
+ --output text | sed 's|/hostedzone/||')
+ [ -n "$ZONE_ID" ]
+ run aws_cmd route53 get-hosted-zone --id "$ZONE_ID"
+ assert_success
+ assert_output --partial "floci-compat.internal"
+}
+
+@test "Terraform: Route53 A record created" {
+ ZONE_ID=$(aws_cmd route53 list-hosted-zones \
+ --query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
+ --output text | sed 's|/hostedzone/||')
+ run aws_cmd route53 list-resource-record-sets --hosted-zone-id "$ZONE_ID"
+ assert_success
+ assert_output --partial "app.floci-compat.internal"
+ assert_output --partial "10.0.1.10"
+}
+
+@test "Terraform: Route53 zone has auto-created SOA and NS records" {
+ ZONE_ID=$(aws_cmd route53 list-hosted-zones \
+ --query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
+ --output text | sed 's|/hostedzone/||')
+ run aws_cmd route53 list-resource-record-sets --hosted-zone-id "$ZONE_ID"
+ assert_success
+ assert_output --partial '"SOA"'
+ assert_output --partial '"NS"'
+}
+
+@test "Terraform: Route53 health check created" {
+ HEALTH_CHECK_ID=$(aws_cmd route53 list-health-checks \
+ --query "HealthChecks[?HealthCheckConfig.FullyQualifiedDomainName=='app.floci-compat.internal'].Id | [0]" \
+ --output text)
+ [ -n "$HEALTH_CHECK_ID" ]
+ run aws_cmd route53 get-health-check --health-check-id "$HEALTH_CHECK_ID"
+ assert_success
+ assert_output --partial "app.floci-compat.internal"
+ assert_output --partial "HTTP"
+}
+
+@test "Terraform: Route53 zone tags persisted" {
+ ZONE_ID=$(aws_cmd route53 list-hosted-zones \
+ --query "HostedZones[?Name=='floci-compat.internal.'].Id | [0]" \
+ --output text | sed 's|/hostedzone/||')
+ run aws_cmd route53 list-tags-for-resource \
+ --resource-type hostedzone --resource-id "$ZONE_ID"
+ assert_success
+ assert_output --partial "compat-test"
+}
diff --git a/docs/services/index.md b/docs/services/index.md
index 35dc67edb4..8ad01e844b 100644
--- a/docs/services/index.md
+++ b/docs/services/index.md
@@ -1,6 +1,6 @@
# Services Overview
-Floci emulates 42 AWS services on a single port (`4566`). All services use the real AWS wire protocol, your existing AWS CLI commands and SDK clients work without modification.
+Floci emulates 43 AWS services on a single port (`4566`). All services use the real AWS wire protocol, your existing AWS CLI commands and SDK clients work without modification.
This page is the canonical reference for supported service and operation counts. Some services expose separate control-plane and data-plane rows below. Other docs (and the README) should link here rather than duplicating the table.
@@ -56,6 +56,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac
| [Data Firehose](firehose.md) | `POST /` + `X-Amz-Target: Firehose_20150804.*` | JSON 1.1 | 6 |
| [CodeBuild](codebuild.md) | `POST /` + `X-Amz-Target: CodeBuild_20161006.*` | JSON 1.1 | 20 |
| [CodeDeploy](codedeploy.md) | `POST /` + `X-Amz-Target: CodeDeploy_20141006.*` | JSON 1.1 | 30 |
+| [Route53](route53.md) | `/2013-04-01/hostedzone/*`, `/2013-04-01/healthcheck/*`, `/2013-04-01/change/*` | REST XML | 17 |
**Lambda, ElastiCache, RDS, MSK, ECS, EKS, and OpenSearch** spin up real Docker containers and support IAM authentication and SigV4 request signing, the same auth flow as production AWS.
diff --git a/docs/services/route53.md b/docs/services/route53.md
new file mode 100644
index 0000000000..f5d9f16736
--- /dev/null
+++ b/docs/services/route53.md
@@ -0,0 +1,118 @@
+# Route53
+
+Route53 management-plane emulation. Supports hosted zones, resource record sets, health checks, change tracking, and tagging. Actual DNS resolution is not provided — this is a management-plane-only implementation.
+
+## Supported Operations
+
+| Operation | Method | Path |
+|---|---|---|
+| CreateHostedZone | POST | `/2013-04-01/hostedzone` |
+| GetHostedZone | GET | `/2013-04-01/hostedzone/{Id}` |
+| DeleteHostedZone | DELETE | `/2013-04-01/hostedzone/{Id}` |
+| ListHostedZones | GET | `/2013-04-01/hostedzone` |
+| ListHostedZonesByName | GET | `/2013-04-01/hostedzonesbyname` |
+| GetHostedZoneCount | GET | `/2013-04-01/hostedzonecount` |
+| ChangeResourceRecordSets | POST | `/2013-04-01/hostedzone/{Id}/rrset` |
+| ListResourceRecordSets | GET | `/2013-04-01/hostedzone/{Id}/rrset` |
+| GetChange | GET | `/2013-04-01/change/{Id}` |
+| CreateHealthCheck | POST | `/2013-04-01/healthcheck` |
+| GetHealthCheck | GET | `/2013-04-01/healthcheck/{HealthCheckId}` |
+| DeleteHealthCheck | DELETE | `/2013-04-01/healthcheck/{HealthCheckId}` |
+| ListHealthChecks | GET | `/2013-04-01/healthcheck` |
+| UpdateHealthCheck | POST | `/2013-04-01/healthcheck/{HealthCheckId}` |
+| ListTagsForResource | GET | `/2013-04-01/tags/{ResourceType}/{ResourceId}` |
+| ChangeTagsForResource | POST | `/2013-04-01/tags/{ResourceType}/{ResourceId}` |
+| GetAccountLimit | GET | `/2013-04-01/accountlimit/{Type}` |
+
+## Behavior
+
+- All changes return status `INSYNC` immediately (no async propagation simulation).
+- Every new hosted zone automatically gets SOA and NS records at the zone apex. These records cannot be deleted.
+- `DeleteHostedZone` fails with `HostedZoneNotEmpty` if the zone contains records other than the apex SOA and NS.
+- `ChangeResourceRecordSets` validates all changes atomically before applying any.
+- Supported change actions: `CREATE`, `UPSERT`, `DELETE`.
+- Hosted zone IDs are returned with the `/hostedzone/` prefix in XML responses (e.g. `/hostedzone/Z1PA6795UKMFR9`). The AWS SDK strips this prefix client-side.
+- Health check IDs are plain UUIDs without a prefix.
+- Tags are supported for both `hostedzone` and `healthcheck` resource types.
+
+## Default Nameservers
+
+New zones use these nameservers (configurable via `floci.services.route53.*`):
+
+```
+ns-1.awsdns-01.org
+ns-2.awsdns-02.net
+ns-3.awsdns-03.com
+ns-4.awsdns-04.co.uk
+```
+
+## Configuration
+
+```yaml
+floci:
+ services:
+ route53:
+ enabled: true
+ default-nameserver1: ns-1.awsdns-01.org
+ default-nameserver2: ns-2.awsdns-02.net
+ default-nameserver3: ns-3.awsdns-03.com
+ default-nameserver4: ns-4.awsdns-04.co.uk
+```
+
+## CLI Examples
+
+```bash
+export AWS_ENDPOINT_URL=http://localhost:4566
+export AWS_DEFAULT_REGION=us-east-1
+export AWS_ACCESS_KEY_ID=test
+export AWS_SECRET_ACCESS_KEY=test
+
+# Create a hosted zone
+aws route53 create-hosted-zone \
+ --name example.com \
+ --caller-reference "$(date +%s)"
+
+# List hosted zones
+aws route53 list-hosted-zones
+
+# Add an A record
+aws route53 change-resource-record-sets \
+ --hosted-zone-id Z1PA6795UKMFR9 \
+ --change-batch '{
+ "Changes": [{
+ "Action": "CREATE",
+ "ResourceRecordSet": {
+ "Name": "www.example.com.",
+ "Type": "A",
+ "TTL": 300,
+ "ResourceRecords": [{"Value": "1.2.3.4"}]
+ }
+ }]
+ }'
+
+# List records
+aws route53 list-resource-record-sets --hosted-zone-id Z1PA6795UKMFR9
+
+# Create a health check
+aws route53 create-health-check \
+ --caller-reference "hc-$(date +%s)" \
+ --health-check-config '{
+ "Type": "HTTPS",
+ "FullyQualifiedDomainName": "example.com",
+ "Port": 443,
+ "ResourcePath": "/health"
+ }'
+
+# Delete a hosted zone
+aws route53 delete-hosted-zone --id Z1PA6795UKMFR9
+```
+
+## Not Supported (Phase 2)
+
+- Reusable delegation sets
+- Traffic policies and traffic policy instances
+- VPC association (private hosted zones)
+- Query logging configs
+- DNSSEC (key signing keys, enabling/disabling)
+- `TestDNSAnswer`
+- Actual DNS resolution
diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
index 7852a17add..7d338a6c2d 100644
--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
@@ -273,6 +273,24 @@ public interface EmulatorConfig {
CodeBuildServiceConfig codebuild();
CodeDeployServiceConfig codedeploy();
AutoScalingServiceConfig autoscaling();
+ Route53ServiceConfig route53();
+ }
+
+ interface Route53ServiceConfig {
+ @WithDefault("true")
+ boolean enabled();
+
+ @WithDefault("ns-1.awsdns-01.org")
+ String defaultNameserver1();
+
+ @WithDefault("ns-2.awsdns-02.net")
+ String defaultNameserver2();
+
+ @WithDefault("ns-3.awsdns-03.com")
+ String defaultNameserver3();
+
+ @WithDefault("ns-4.awsdns-04.co.uk")
+ String defaultNameserver4();
}
interface AutoScalingServiceConfig {
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsNamespaces.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsNamespaces.java
index ec49a7a416..d8b4d1a52b 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/AwsNamespaces.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsNamespaces.java
@@ -19,6 +19,7 @@ public final class AwsNamespaces {
public static final String EC2 = "http://ec2.amazonaws.com/doc/2016-11-15/";
public static final String ELB_V2 = "https://elasticloadbalancing.amazonaws.com/doc/2015-12-01/";
public static final String AUTOSCALING = "https://autoscaling.amazonaws.com/doc/2011-01-01/";
+ public static final String ROUTE53 = "https://route53.amazonaws.com/doc/2013-04-01/";
private AwsNamespaces() {}
}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
index 24732cf0b0..724f4d5c86 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
@@ -10,6 +10,7 @@ import io.github.hectorvent.floci.services.eks.EksController;
import io.github.hectorvent.floci.services.pipes.PipesController;
import io.github.hectorvent.floci.services.lambda.LambdaController;
import io.github.hectorvent.floci.services.opensearch.OpenSearchController;
+import io.github.hectorvent.floci.services.route53.Route53Controller;
import io.github.hectorvent.floci.services.ses.SesController;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
@@ -224,7 +225,11 @@ public class ResolvedServiceCatalog {
descriptor("ec2messages", "ec2messages", config.services().ssm().enabled(), false,
null, null, 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
- Set.of("AmazonSSMMessageDeliveryService."), Set.of("ec2messages"), Set.of(), Set.of())
+ Set.of("AmazonSSMMessageDeliveryService."), Set.of("ec2messages"), Set.of(), Set.of()),
+ descriptor("route53", "route53", config.services().route53().enabled(), true,
+ "route53", config.storage().mode(), 5000L, null, ServiceProtocol.REST_XML,
+ protocols(ServiceProtocol.REST_XML),
+ Set.of(), Set.of("route53"), Set.of(), Set.of(Route53Controller.class))
));
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/route53/Route53Controller.java b/src/main/java/io/github/hectorvent/floci/services/route53/Route53Controller.java
new file mode 100644
index 0000000000..d70e445c94
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/route53/Route53Controller.java
@@ -0,0 +1,807 @@
+package io.github.hectorvent.floci.services.route53;
+
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.AwsNamespaces;
+import io.github.hectorvent.floci.core.common.XmlBuilder;
+import io.github.hectorvent.floci.core.common.XmlParser;
+import io.github.hectorvent.floci.services.route53.Route53Service.CreateZoneResult;
+import io.github.hectorvent.floci.services.route53.model.AliasTarget;
+import io.github.hectorvent.floci.services.route53.model.ChangeInfo;
+import io.github.hectorvent.floci.services.route53.model.HealthCheck;
+import io.github.hectorvent.floci.services.route53.model.HealthCheckConfig;
+import io.github.hectorvent.floci.services.route53.model.HostedZone;
+import io.github.hectorvent.floci.services.route53.model.ResourceRecord;
+import io.github.hectorvent.floci.services.route53.model.ResourceRecordSet;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.DELETE;
+import jakarta.ws.rs.DefaultValue;
+import jakarta.ws.rs.GET;
+import jakarta.ws.rs.POST;
+import jakarta.ws.rs.Path;
+import jakarta.ws.rs.PathParam;
+import jakarta.ws.rs.QueryParam;
+import jakarta.ws.rs.core.Response;
+
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamConstants;
+import javax.xml.stream.XMLStreamReader;
+import java.io.StringReader;
+import java.net.URI;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+@Path("/2013-04-01")
+public class Route53Controller {
+
+ private static final String NS = AwsNamespaces.ROUTE53;
+ private static final String XML = "application/xml";
+
+ private static final XMLInputFactory XML_FACTORY;
+
+ static {
+ XML_FACTORY = XMLInputFactory.newInstance();
+ XML_FACTORY.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, true);
+ XML_FACTORY.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
+ XML_FACTORY.setProperty(XMLInputFactory.SUPPORT_DTD, false);
+ }
+
+ @Inject
+ Route53Service service;
+
+ // ── Hosted Zones ──────────────────────────────────────────────────────────
+
+ @POST
+ @Path("/hostedzone")
+ public Response createHostedZone(String body) {
+ try {
+ String name = XmlParser.extractFirst(body, "Name", null);
+ String callerRef = XmlParser.extractFirst(body, "CallerReference", null);
+ String comment = XmlParser.extractFirst(body, "Comment", null);
+ boolean privateZone = "true".equalsIgnoreCase(
+ XmlParser.extractFirst(body, "PrivateZone", "false"));
+
+ if (name == null || callerRef == null) {
+ throw new AwsException("InvalidInput", "Name and CallerReference are required.", 400);
+ }
+
+ CreateZoneResult result = service.createHostedZone(name, callerRef, comment, privateZone);
+ String xml = new XmlBuilder()
+ .start("CreateHostedZoneResponse", NS)
+ .raw(xmlHostedZone(result.zone()))
+ .raw(xmlChangeInfo(result.change()))
+ .raw(xmlDelegationSet())
+ .end("CreateHostedZoneResponse")
+ .build();
+
+ return Response.created(URI.create("/2013-04-01/hostedzone/" + result.zone().getId()))
+ .type(XML)
+ .entity(xml)
+ .build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @GET
+ @Path("/hostedzone/{Id}")
+ public Response getHostedZone(@PathParam("Id") String id) {
+ try {
+ HostedZone zone = service.getHostedZone(id);
+ String xml = new XmlBuilder()
+ .start("GetHostedZoneResponse", NS)
+ .raw(xmlHostedZone(zone))
+ .raw(xmlDelegationSet())
+ .end("GetHostedZoneResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @DELETE
+ @Path("/hostedzone/{Id}")
+ public Response deleteHostedZone(@PathParam("Id") String id) {
+ try {
+ ChangeInfo change = service.deleteHostedZone(id);
+ String xml = new XmlBuilder()
+ .start("DeleteHostedZoneResponse", NS)
+ .raw(xmlChangeInfo(change))
+ .end("DeleteHostedZoneResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @GET
+ @Path("/hostedzone")
+ public Response listHostedZones(@QueryParam("marker") String marker,
+ @QueryParam("maxitems") @DefaultValue("100") int maxItems) {
+ try {
+ List<HostedZone> zones = service.listHostedZones(marker, maxItems);
+ long total = service.getHostedZoneCount();
+ boolean truncated = zones.size() == maxItems && zones.size() < total;
+
+ XmlBuilder xml = new XmlBuilder()
+ .start("ListHostedZonesResponse", NS)
+ .start("HostedZones");
+ for (HostedZone zone : zones) {
+ xml.raw(xmlHostedZone(zone));
+ }
+ xml.end("HostedZones")
+ .elem("Marker", marker != null ? marker : "")
+ .elem("IsTruncated", String.valueOf(truncated));
+ if (truncated && !zones.isEmpty()) {
+ xml.elem("NextMarker", zones.get(zones.size() - 1).getId());
+ }
+ xml.elem("MaxItems", String.valueOf(maxItems))
+ .end("ListHostedZonesResponse");
+
+ return Response.ok(xml.build(), XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @GET
+ @Path("/hostedzonesbyname")
+ public Response listHostedZonesByName(@QueryParam("dnsname") String dnsName,
+ @QueryParam("maxitems") @DefaultValue("100") int maxItems) {
+ try {
+ List<HostedZone> zones = service.listHostedZonesByName(dnsName, maxItems);
+ long total = service.getHostedZoneCount();
+ boolean truncated = zones.size() == maxItems && zones.size() < total;
+
+ XmlBuilder xml = new XmlBuilder()
+ .start("ListHostedZonesByNameResponse", NS)
+ .start("HostedZones");
+ for (HostedZone zone : zones) {
+ xml.raw(xmlHostedZone(zone));
+ }
+ xml.end("HostedZones")
+ .elem("IsTruncated", String.valueOf(truncated))
+ .elem("MaxItems", String.valueOf(maxItems));
+ if (dnsName != null && !dnsName.isEmpty()) {
+ xml.elem("DNSName", dnsName);
+ }
+ xml.end("ListHostedZonesByNameResponse");
+
+ return Response.ok(xml.build(), XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @GET
+ @Path("/hostedzonecount")
+ public Response getHostedZoneCount() {
+ String xml = new XmlBuilder()
+ .start("GetHostedZoneCountResponse", NS)
+ .elem("HostedZoneCount", service.getHostedZoneCount())
+ .end("GetHostedZoneCountResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ }
+
+ // ── Resource Record Sets ──────────────────────────────────────────────────
+
+ @POST
+ @Path("/hostedzone/{Id}/rrset")
+ public Response changeResourceRecordSets(@PathParam("Id") String id, String body) {
+ try {
+ String comment = XmlParser.extractFirst(body, "Comment", null);
+ List<Map<String, Object>> changes = parseChangeBatch(body);
+ ChangeInfo change = service.changeResourceRecordSets(id, changes, comment);
+ String xml = new XmlBuilder()
+ .start("ChangeResourceRecordSetsResponse", NS)
+ .raw(xmlChangeInfo(change))
+ .end("ChangeResourceRecordSetsResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @GET
+ @Path("/hostedzone/{Id}/rrset")
+ public Response listResourceRecordSets(@PathParam("Id") String id,
+ @QueryParam("name") String startName,
+ @QueryParam("type") String startType,
+ @QueryParam("maxitems") @DefaultValue("300") int maxItems) {
+ try {
+ List<ResourceRecordSet> fetched = service.listResourceRecordSets(id, startName, startType, maxItems + 1);
+ boolean truncated = fetched.size() > maxItems;
+ List<ResourceRecordSet> records = truncated ? fetched.subList(0, maxItems) : fetched;
+
+ XmlBuilder xml = new XmlBuilder()
+ .start("ListResourceRecordSetsResponse", NS)
+ .start("ResourceRecordSets");
+ for (ResourceRecordSet rrs : records) {
+ xml.raw(xmlResourceRecordSet(rrs));
+ }
+ xml.end("ResourceRecordSets")
+ .elem("IsTruncated", String.valueOf(truncated));
+ if (truncated) {
+ ResourceRecordSet next = fetched.get(maxItems);
+ xml.elem("NextRecordName", next.getName())
+ .elem("NextRecordType", next.getType());
+ }
+ xml.elem("MaxItems", String.valueOf(maxItems))
+ .end("ListResourceRecordSetsResponse");
+
+ return Response.ok(xml.build(), XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ // ── Changes ───────────────────────────────────────────────────────────────
+
+ @GET
+ @Path("/change/{Id}")
+ public Response getChange(@PathParam("Id") String id) {
+ try {
+ ChangeInfo change = service.getChange(id);
+ String xml = new XmlBuilder()
+ .start("GetChangeResponse", NS)
+ .raw(xmlChangeInfo(change))
+ .end("GetChangeResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ // ── Health Checks ─────────────────────────────────────────────────────────
+
+ @POST
+ @Path("/healthcheck")
+ public Response createHealthCheck(String body) {
+ try {
+ String callerRef = XmlParser.extractFirst(body, "CallerReference", null);
+ if (callerRef == null) {
+ throw new AwsException("InvalidInput", "CallerReference is required.", 400);
+ }
+ HealthCheckConfig cfg = parseHealthCheckConfig(body);
+ HealthCheck hc = service.createHealthCheck(callerRef, cfg);
+ String xml = new XmlBuilder()
+ .start("CreateHealthCheckResponse", NS)
+ .raw(xmlHealthCheck(hc))
+ .end("CreateHealthCheckResponse")
+ .build();
+ return Response.created(URI.create("/2013-04-01/healthcheck/" + hc.getId()))
+ .type(XML)
+ .entity(xml)
+ .build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @GET
+ @Path("/healthcheck/{HealthCheckId}")
+ public Response getHealthCheck(@PathParam("HealthCheckId") String id) {
+ try {
+ HealthCheck hc = service.getHealthCheck(id);
+ String xml = new XmlBuilder()
+ .start("GetHealthCheckResponse", NS)
+ .raw(xmlHealthCheck(hc))
+ .end("GetHealthCheckResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @DELETE
+ @Path("/healthcheck/{HealthCheckId}")
+ public Response deleteHealthCheck(@PathParam("HealthCheckId") String id) {
+ try {
+ service.deleteHealthCheck(id);
+ return Response.ok("", XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @GET
+ @Path("/healthcheck")
+ public Response listHealthChecks(@QueryParam("marker") String marker,
+ @QueryParam("maxitems") @DefaultValue("100") int maxItems) {
+ try {
+ List<HealthCheck> checks = service.listHealthChecks(marker, maxItems);
+ boolean truncated = checks.size() == maxItems;
+
+ XmlBuilder xml = new XmlBuilder()
+ .start("ListHealthChecksResponse", NS)
+ .start("HealthChecks");
+ for (HealthCheck hc : checks) {
+ xml.raw(xmlHealthCheck(hc));
+ }
+ xml.end("HealthChecks")
+ .elem("Marker", marker != null ? marker : "")
+ .elem("IsTruncated", String.valueOf(truncated))
+ .elem("MaxItems", String.valueOf(maxItems))
+ .end("ListHealthChecksResponse");
+
+ return Response.ok(xml.build(), XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @POST
+ @Path("/healthcheck/{HealthCheckId}")
+ public Response updateHealthCheck(@PathParam("HealthCheckId") String id, String body) {
+ try {
+ HealthCheckConfig cfg = parseHealthCheckConfig(body);
+ HealthCheck hc = service.updateHealthCheck(id, cfg);
+ String xml = new XmlBuilder()
+ .start("UpdateHealthCheckResponse", NS)
+ .raw(xmlHealthCheck(hc))
+ .end("UpdateHealthCheckResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ // ── Tags ──────────────────────────────────────────────────────────────────
+
+ @GET
+ @Path("/tags/{ResourceType}/{ResourceId}")
+ public Response listTagsForResource(@PathParam("ResourceType") String type,
+ @PathParam("ResourceId") String resourceId) {
+ try {
+ Map<String, String> tags = service.listTagsForResource(type, resourceId);
+ XmlBuilder xml = new XmlBuilder()
+ .start("ListTagsForResourceResponse", NS)
+ .start("ResourceTagSet")
+ .elem("ResourceType", type)
+ .elem("ResourceId", resourceId)
+ .start("Tags");
+ for (Map.Entry<String, String> entry : tags.entrySet()) {
+ xml.start("Tag")
+ .elem("Key", entry.getKey())
+ .elem("Value", entry.getValue())
+ .end("Tag");
+ }
+ xml.end("Tags").end("ResourceTagSet").end("ListTagsForResourceResponse");
+ return Response.ok(xml.build(), XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @POST
+ @Path("/tags/{ResourceType}/{ResourceId}")
+ public Response changeTagsForResource(@PathParam("ResourceType") String type,
+ @PathParam("ResourceId") String resourceId,
+ String body) {
+ try {
+ List<Map<String, String>> addTags = XmlParser.extractGroups(body, "Tag").stream()
+ .filter(g -> g.containsKey("Key"))
+ .map(g -> Map.of("Key", g.get("Key"), "Value", g.getOrDefault("Value", "")))
+ .toList();
+ List<String> removeTagKeys = parseRemoveTagKeys(body);
+ service.changeTagsForResource(type, resourceId, addTags, removeTagKeys);
+ String xml = new XmlBuilder()
+ .start("ChangeTagsForResourceResponse", NS)
+ .end("ChangeTagsForResourceResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ // ── Limits ────────────────────────────────────────────────────────────────
+
+ @GET
+ @Path("/accountlimit/{Type}")
+ public Response getAccountLimit(@PathParam("Type") String type) {
+ long value = switch (type) {
+ case "MAX_HEALTH_CHECKS_BY_OWNER" -> 200L;
+ case "MAX_HOSTED_ZONES_BY_OWNER" -> 500L;
+ case "MAX_REUSABLE_DELEGATION_SETS_BY_OWNER" -> 100L;
+ case "MAX_TRAFFIC_POLICY_INSTANCES_BY_OWNER" -> 5L;
+ case "MAX_TRAFFIC_POLICIES_BY_OWNER" -> 50L;
+ default -> 100L;
+ };
+ String xml = new XmlBuilder()
+ .start("GetAccountLimitResponse", NS)
+ .start("Limit")
+ .elem("Type", type)
+ .elem("Value", value)
+ .end("Limit")
+ .elem("Count", 0L)
+ .end("GetAccountLimitResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ }
+
+ @GET
+ @Path("/healthcheck/{HealthCheckId}/status")
+ public Response getHealthCheckStatus(@PathParam("HealthCheckId") String id) {
+ try {
+ service.getHealthCheck(id);
+ String now = Instant.now().toString();
+ String xml = new XmlBuilder()
+ .start("GetHealthCheckStatusResponse", NS)
+ .start("HealthCheckObservations")
+ .start("HealthCheckObservation")
+ .elem("IPAddress", "1.2.3.4")
+ .elem("Region", "us-east-1")
+ .start("StatusReport")
+ .elem("Status", "Success: HTTP Status Code 200, OK")
+ .elem("CheckedTime", now)
+ .end("StatusReport")
+ .end("HealthCheckObservation")
+ .end("HealthCheckObservations")
+ .end("GetHealthCheckStatusResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @GET
+ @Path("/hostedzone/{Id}/dnssec")
+ public Response getDnssec(@PathParam("Id") String id) {
+ try {
+ service.getHostedZone(id);
+ String xml = new XmlBuilder()
+ .start("GetDNSSECResponse", NS)
+ .start("Status")
+ .elem("ServeSignature", "NOT_SIGNING")
+ .elem("StatusMessage", "Zone is not signing")
+ .end("Status")
+ .start("KeySigningKeys")
+ .end("KeySigningKeys")
+ .end("GetDNSSECResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ }
+
+ @GET
+ @Path("/hostedzonelimit/{HostedZoneId}/{Type}")
+ public Response getHostedZoneLimit(@PathParam("HostedZoneId") String zoneId,
+ @PathParam("Type") String type) {
+ try {
+ service.getHostedZone(zoneId);
+ } catch (AwsException e) {
+ return xmlErrorResponse(e);
+ }
+ long value = switch (type) {
+ case "MAX_RRSETS_BY_ZONE" -> 10000L;
+ case "MAX_VPCS_ASSOCIATED_BY_ZONE" -> 100L;
+ default -> 100L;
+ };
+ String xml = new XmlBuilder()
+ .start("GetHostedZoneLimitResponse", NS)
+ .start("Limit")
+ .elem("Type", type)
+ .elem("Value", value)
+ .end("Limit")
+ .elem("Count", 0L)
+ .end("GetHostedZoneLimitResponse")
+ .build();
+ return Response.ok(xml, XML).build();
+ }
+
+ // ── XML builders ──────────────────────────────────────────────────────────
+
+ private String xmlHostedZone(HostedZone zone) {
+ return new XmlBuilder()
+ .start("HostedZone")
+ .elem("Id", "/hostedzone/" + zone.getId())
+ .elem("Name", zone.getName())
+ .elem("CallerReference", zone.getCallerReference())
+ .start("Config")
+ .elem("Comment", zone.getComment())
+ .elem("PrivateZone", String.valueOf(zone.isPrivateZone()))
+ .end("Config")
+ .elem("ResourceRecordSetCount", zone.getResourceRecordSetCount())
+ .end("HostedZone")
+ .build();
+ }
+
+ private String xmlChangeInfo(ChangeInfo change) {
+ return new XmlBuilder()
+ .start("ChangeInfo")
+ .elem("Id", "/change/" + change.getId())
+ .elem("Status", change.getStatus())
+ .elem("SubmittedAt", change.getSubmittedAt())
+ .elem("Comment", change.getComment())
+ .end("ChangeInfo")
+ .build();
+ }
+
+ private String xmlDelegationSet() {
+ XmlBuilder xml = new XmlBuilder()
+ .start("DelegationSet")
+ .start("NameServers");
+ for (String ns : service.getNameServers()) {
+ xml.elem("NameServer", ns);
+ }
+ xml.end("NameServers").end("DelegationSet");
+ return xml.build();
+ }
+
+ private String xmlResourceRecordSet(ResourceRecordSet rrs) {
+ XmlBuilder xml = new XmlBuilder()
+ .start("ResourceRecordSet")
+ .elem("Name", rrs.getName())
+ .elem("Type", rrs.getType());
+ if (rrs.getSetIdentifier() != null) xml.elem("SetIdentifier", rrs.getSetIdentifier());
+ if (rrs.getWeight() != null) xml.elem("Weight", rrs.getWeight());
+ if (rrs.getRegion() != null) xml.elem("Region", rrs.getRegion());
+ if (rrs.getFailover() != null) xml.elem("Failover", rrs.getFailover());
+ if (rrs.getTtl() != null) xml.elem("TTL", rrs.getTtl());
+ if (rrs.getRecords() != null && !rrs.getRecords().isEmpty()) {
+ xml.start("ResourceRecords");
+ for (ResourceRecord r : rrs.getRecords()) {
+ xml.start("ResourceRecord").elem("Value", r.getValue()).end("ResourceRecord");
+ }
+ xml.end("ResourceRecords");
+ }
+ if (rrs.getAliasTarget() != null) {
+ AliasTarget at = rrs.getAliasTarget();
+ xml.start("AliasTarget")
+ .elem("HostedZoneId", at.getHostedZoneId())
+ .elem("DNSName", at.getDnsName())
+ .elem("EvaluateTargetHealth", String.valueOf(at.isEvaluateTargetHealth()))
+ .end("AliasTarget");
+ }
+ if (rrs.getHealthCheckId() != null) xml.elem("HealthCheckId", rrs.getHealthCheckId());
+ xml.end("ResourceRecordSet");
+ return xml.build();
+ }
+
+ private String xmlHealthCheck(HealthCheck hc) {
+ XmlBuilder xml = new XmlBuilder()
+ .start("HealthCheck")
+ .elem("Id", hc.getId())
+ .elem("CallerReference", hc.getCallerReference());
+ if (hc.getConfig() != null) {
+ HealthCheckConfig cfg = hc.getConfig();
+ xml.start("HealthCheckConfig")
+ .elem("Type", cfg.getType())
+ .elem("IPAddress", cfg.getIpAddress())
+ .elem("Port", cfg.getPort() != null ? String.valueOf(cfg.getPort()) : null)
+ .elem("ResourcePath", cfg.getResourcePath())
+ .elem("FullyQualifiedDomainName", cfg.getFullyQualifiedDomainName())
+ .elem("RequestInterval",
+ cfg.getRequestInterval() != null ? String.valueOf(cfg.getRequestInterval()) : null)
+ .elem("FailureThreshold",
+ cfg.getFailureThreshold() != null ? String.valueOf(cfg.getFailureThreshold()) : null)
+ .end("HealthCheckConfig");
+ }
+ xml.elem("HealthCheckVersion", hc.getHealthCheckVersion())
+ .end("HealthCheck");
+ return xml.build();
+ }
+
+ private Response xmlErrorResponse(AwsException e) {
+ String xml = new XmlBuilder()
+ .start("ErrorResponse", NS)
+ .start("Error")
+ .elem("Type", "Sender")
+ .elem("Code", e.getErrorCode())
+ .elem("Message", e.getMessage())
+ .end("Error")
+ .elem("RequestId", "00000000-0000-0000-0000-000000000000")
+ .end("ErrorResponse")
+ .build();
+ return Response.status(e.getHttpStatus()).type(XML).entity(xml).build();
+ }
+
+ // ── Request parsers ───────────────────────────────────────────────────────
+
+ /**
+ * Parses the ChangeBatch XML using StAX to correctly handle multiple Change elements,
+ * each containing a ResourceRecordSet with its own set of ResourceRecord/Value children.
+ */
+ private List<Map<String, Object>> parseChangeBatch(String body) {
+ List<Map<String, Object>> result = new ArrayList<>();
+ if (body == null || body.isEmpty()) return result;
+
+ try {
+ XMLStreamReader r = XML_FACTORY.createXMLStreamReader(new StringReader(body));
+ String currentAction = null;
+ ResourceRecordSet currentRrs = null;
+ List<ResourceRecord> currentRecords = null;
+ AliasTarget currentAlias = null;
+ int depth = 0;
+ String currentElement = null;
+ boolean inChangeBatch = false;
+ boolean inChange = false;
+ boolean inRrs = false;
+ boolean inResourceRecords = false;
+ boolean inAlias = false;
+ boolean inHealthCheckConfig = false;
+
+ while (r.hasNext()) {
+ int event = r.next();
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ currentElement = r.getLocalName();
+ switch (currentElement) {
+ case "ChangeBatch" -> inChangeBatch = true;
+ case "Change" -> {
+ if (inChangeBatch) {
+ inChange = true;
+ currentAction = null;
+ currentRrs = null;
+ }
+ }
+ case "Action" -> {
+ if (inChange && !inRrs) currentAction = r.getElementText();
+ }
+ case "ResourceRecordSet" -> {
+ if (inChange) {
+ inRrs = true;
+ currentRrs = new ResourceRecordSet();
+ currentRecords = new ArrayList<>();
+ }
+ }
+ case "ResourceRecords" -> { if (inRrs) inResourceRecords = true; }
+ case "AliasTarget" -> {
+ if (inRrs) {
+ inAlias = true;
+ currentAlias = new AliasTarget();
+ }
+ }
+ case "Name" -> {
+ if (inRrs && !inAlias) {
+ String n = r.getElementText();
+ if (n != null && !n.endsWith(".")) n = n + ".";
+ if (currentRrs != null) currentRrs.setName(n);
+ }
+ }
+ case "Type" -> {
+ if (inRrs && !inAlias && !inHealthCheckConfig && currentRrs != null) {
+ currentRrs.setType(r.getElementText());
+ }
+ }
+ case "TTL" -> {
+ if (inRrs && currentRrs != null) {
+ try { currentRrs.setTtl(Long.parseLong(r.getElementText())); }
+ catch (NumberFormatException ignored) {}
+ }
+ }
+ case "Value" -> {
+ if (inResourceRecords && currentRecords != null) {
+ currentRecords.add(new ResourceRecord(r.getElementText()));
+ }
+ }
+ case "SetIdentifier" -> {
+ if (inRrs && currentRrs != null) currentRrs.setSetIdentifier(r.getElementText());
+ }
+ case "Weight" -> {
+ if (inRrs && currentRrs != null) {
+ try { currentRrs.setWeight(Long.parseLong(r.getElementText())); }
+ catch (NumberFormatException ignored) {}
+ }
+ }
+ case "Region" -> {
+ if (inRrs && !inAlias && currentRrs != null) currentRrs.setRegion(r.getElementText());
+ }
+ case "Failover" -> {
+ if (inRrs && currentRrs != null) currentRrs.setFailover(r.getElementText());
+ }
+ case "HealthCheckId" -> {
+ if (inRrs && !inHealthCheckConfig && currentRrs != null) {
+ currentRrs.setHealthCheckId(r.getElementText());
+ }
+ }
+ case "HostedZoneId" -> {
+ if (inAlias && currentAlias != null) currentAlias.setHostedZoneId(r.getElementText());
+ }
+ case "DNSName" -> {
+ if (inAlias && currentAlias != null) currentAlias.setDnsName(r.getElementText());
+ }
+ case "EvaluateTargetHealth" -> {
+ if (inAlias && currentAlias != null) {
+ currentAlias.setEvaluateTargetHealth(
+ "true".equalsIgnoreCase(r.getElementText()));
+ }
+ }
+ }
+ } else if (event == XMLStreamConstants.END_ELEMENT) {
+ switch (r.getLocalName()) {
+ case "ResourceRecords" -> inResourceRecords = false;
+ case "AliasTarget" -> {
+ if (inAlias && currentRrs != null && currentAlias != null) {
+ currentRrs.setAliasTarget(currentAlias);
+ }
+ inAlias = false;
+ currentAlias = null;
+ }
+ case "ResourceRecordSet" -> {
+ if (inRrs && currentRrs != null && currentRecords != null) {
+ if (!currentRecords.isEmpty()) currentRrs.setRecords(currentRecords);
+ }
+ inRrs = false;
+ }
+ case "Change" -> {
+ if (inChange && currentAction != null && currentRrs != null) {
+ Map<String, Object> change = new HashMap<>();
+ change.put("action", currentAction);
+ change.put("rrs", currentRrs);
+ result.add(change);
+ }
+ inChange = false;
+ currentAction = null;
+ currentRrs = null;
+ currentRecords = null;
+ }
+ }
+ }
+ }
+ r.close();
+ } catch (Exception ignored) {}
+ return result;
+ }
+
+ private HealthCheckConfig parseHealthCheckConfig(String body) {
+ HealthCheckConfig cfg = new HealthCheckConfig();
+ cfg.setType(XmlParser.extractFirst(body, "Type", null));
+ cfg.setIpAddress(XmlParser.extractFirst(body, "IPAddress", null));
+ String portStr = XmlParser.extractFirst(body, "Port", null);
+ if (portStr != null) {
+ try { cfg.setPort(Integer.parseInt(portStr)); } catch (NumberFormatException ignored) {}
+ }
+ cfg.setResourcePath(XmlParser.extractFirst(body, "ResourcePath", null));
+ cfg.setFullyQualifiedDomainName(XmlParser.extractFirst(body, "FullyQualifiedDomainName", null));
+ String riStr = XmlParser.extractFirst(body, "RequestInterval", null);
+ if (riStr != null) {
+ try { cfg.setRequestInterval(Integer.parseInt(riStr)); } catch (NumberFormatException ignored) {}
+ }
+ String ftStr = XmlParser.extractFirst(body, "FailureThreshold", null);
+ if (ftStr != null) {
+ try { cfg.setFailureThreshold(Integer.parseInt(ftStr)); } catch (NumberFormatException ignored) {}
+ }
+ return cfg;
+ }
+
+ /**
+ * Parses Key elements that appear inside a RemoveTagKeys block only.
+ * Uses StAX to avoid matching Key elements from AddTags.
+ */
+ private List<String> parseRemoveTagKeys(String body) {
+ List<String> keys = new ArrayList<>();
+ if (body == null || body.isEmpty()) return keys;
+ try {
+ XMLStreamReader r = XML_FACTORY.createXMLStreamReader(new StringReader(body));
+ boolean inRemove = false;
+ while (r.hasNext()) {
+ int event = r.next();
+ if (event == XMLStreamConstants.START_ELEMENT) {
+ if ("RemoveTagKeys".equals(r.getLocalName())) {
+ inRemove = true;
+ } else if (inRemove && "Key".equals(r.getLocalName())) {
+ keys.add(r.getElementText());
+ }
+ } else if (event == XMLStreamConstants.END_ELEMENT) {
+ if ("RemoveTagKeys".equals(r.getLocalName())) inRemove = false;
+ }
+ }
+ r.close();
+ } catch (Exception ignored) {}
+ return keys;
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/route53/Route53Service.java b/src/main/java/io/github/hectorvent/floci/services/route53/Route53Service.java
new file mode 100644
index 0000000000..70126beb28
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/route53/Route53Service.java
@@ -0,0 +1,415 @@
+package io.github.hectorvent.floci.services.route53;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import io.github.hectorvent.floci.config.EmulatorConfig;
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.storage.StorageBackend;
+import io.github.hectorvent.floci.core.storage.StorageFactory;
+import io.github.hectorvent.floci.services.route53.model.ChangeInfo;
+import io.github.hectorvent.floci.services.route53.model.HealthCheck;
+import io.github.hectorvent.floci.services.route53.model.HealthCheckConfig;
+import io.github.hectorvent.floci.services.route53.model.HostedZone;
+import io.github.hectorvent.floci.services.route53.model.ResourceRecord;
+import io.github.hectorvent.floci.services.route53.model.ResourceRecordSet;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+
+import java.security.SecureRandom;
+import java.time.Instant;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+@ApplicationScoped
+public class Route53Service {
+
+ private static final String CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+ private static final SecureRandom RANDOM = new SecureRandom();
+
+ public record CreateZoneResult(HostedZone zone, ChangeInfo change) {}
+
+ private final StorageBackend<String, HostedZone> zoneStore;
+ private final StorageBackend<String, List<ResourceRecordSet>> recordStore;
+ private final StorageBackend<String, HealthCheck> healthCheckStore;
+ private final StorageBackend<String, ChangeInfo> changeStore;
+ private final StorageBackend<String, Map<String, String>> tagStore;
+ private final List<String> nameServers;
+
+ @Inject
+ public Route53Service(StorageFactory factory, EmulatorConfig config) {
+ this.zoneStore = factory.create("route53", "route53-zones.json",
+ new TypeReference<Map<String, HostedZone>>() {});
+ this.recordStore = factory.create("route53", "route53-records.json",
+ new TypeReference<Map<String, List<ResourceRecordSet>>>() {});
+ this.healthCheckStore = factory.create("route53", "route53-health-checks.json",
+ new TypeReference<Map<String, HealthCheck>>() {});
+ this.changeStore = factory.create("route53", "route53-changes.json",
+ new TypeReference<Map<String, ChangeInfo>>() {});
+ this.tagStore = factory.create("route53", "route53-tags.json",
+ new TypeReference<Map<String, Map<String, String>>>() {});
+
+ EmulatorConfig.Route53ServiceConfig r53 = config.services().route53();
+ this.nameServers = List.of(
+ r53.defaultNameserver1(),
+ r53.defaultNameserver2(),
+ r53.defaultNameserver3(),
+ r53.defaultNameserver4()
+ );
+ }
+
+ // ── Hosted Zones ──────────────────────────────────────────────────────────
+
+ public synchronized CreateZoneResult createHostedZone(String name, String callerReference,
+ String comment, boolean privateZone) {
+ String normalizedName = normalizeName(name);
+
+ for (HostedZone existing : zoneStore.scan(k -> true)) {
+ if (existing.getCallerReference().equals(callerReference)) {
+ throw new AwsException("HostedZoneAlreadyExists",
+ "A hosted zone with caller reference " + callerReference + " already exists.", 409);
+ }
+ }
+
+ String id = generateZoneId();
+ HostedZone zone = new HostedZone(id, normalizedName, callerReference, comment, privateZone);
+ zoneStore.put(id, zone);
+ recordStore.put(id, buildDefaultRecords(normalizedName));
+ ChangeInfo change = newChange(null);
+ return new CreateZoneResult(zone, change);
+ }
+
+ public HostedZone getHostedZone(String id) {
+ HostedZone zone = zoneStore.get(id).orElseThrow(() ->
+ new AwsException("NoSuchHostedZone",
+ "No hosted zone found with ID: " + id, 404));
+ zone.setResourceRecordSetCount(recordCount(id));
+ return zone;
+ }
+
+ public synchronized ChangeInfo deleteHostedZone(String id) {
+ HostedZone zone = getHostedZone(id);
+ List<ResourceRecordSet> records = recordStore.get(id).orElse(List.of());
+ long nonDefault = records.stream()
+ .filter(r -> !isApexSoaOrNs(r, zone.getName()))
+ .count();
+ if (nonDefault > 0) {
+ throw new AwsException("HostedZoneNotEmpty",
+ "The hosted zone contains resource record sets in addition to the default NS and SOA records.", 400);
+ }
+ zoneStore.delete(id);
+ recordStore.delete(id);
+ tagStore.delete("hostedzone/" + id);
+ return newChange(null);
+ }
+
+ public List<HostedZone> listHostedZones(String marker, int maxItems) {
+ List<HostedZone> all = new ArrayList<>(zoneStore.scan(k -> true));
+ all.sort((a, b) -> a.getName().compareTo(b.getName()));
+ for (HostedZone zone : all) {
+ zone.setResourceRecordSetCount(recordCount(zone.getId()));
+ }
+ if (marker != null && !marker.isEmpty()) {
+ int idx = 0;
+ for (int i = 0; i < all.size(); i++) {
+ if (all.get(i).getId().equals(marker)) {
+ idx = i + 1;
+ break;
+ }
+ }
+ all = all.subList(idx, all.size());
+ }
+ if (maxItems > 0 && all.size() > maxItems) {
+ return all.subList(0, maxItems);
+ }
+ return all;
+ }
+
+ public List<HostedZone> listHostedZonesByName(String dnsName, int maxItems) {
+ List<HostedZone> all = new ArrayList<>(zoneStore.scan(k -> true));
+ all.sort((a, b) -> a.getName().compareTo(b.getName()));
+ for (HostedZone zone : all) {
+ zone.setResourceRecordSetCount(recordCount(zone.getId()));
+ }
+ if (dnsName != null && !dnsName.isEmpty()) {
+ String normalized = normalizeName(dnsName);
+ all = all.stream()
+ .filter(z -> z.getName().compareTo(normalized) >= 0)
+ .toList();
+ all = new ArrayList<>(all);
+ }
+ if (maxItems > 0 && all.size() > maxItems) {
+ return all.subList(0, maxItems);
+ }
+ return all;
+ }
+
+ public long getHostedZoneCount() {
+ return zoneStore.keys().size();
+ }
+
+ // ── Resource Record Sets ──────────────────────────────────────────────────
+
+ public synchronized ChangeInfo changeResourceRecordSets(String zoneId,
+ List<Map<String, Object>> changes,
+ String comment) {
+ HostedZone zone = getHostedZone(zoneId);
+ List<ResourceRecordSet> current = new ArrayList<>(
+ recordStore.get(zoneId).orElse(new ArrayList<>()));
+
+ // Validate all changes before applying any
+ for (Map<String, Object> change : changes) {
+ String action = (String) change.get("action");
+ ResourceRecordSet rrs = (ResourceRecordSet) change.get("rrs");
+ validateChange(action, rrs, current, zone.getName());
+ }
+
+ // Apply all changes
+ for (Map<String, Object> change : changes) {
+ String action = (String) change.get("action");
+ ResourceRecordSet rrs = (ResourceRecordSet) change.get("rrs");
+ applyChange(action, rrs, current);
+ }
+
+ zone.setResourceRecordSetCount(current.size());
+ zoneStore.put(zoneId, zone);
+ recordStore.put(zoneId, current);
+ return newChange(comment);
+ }
+
+ public List<ResourceRecordSet> listResourceRecordSets(String zoneId, String startName,
+ String startType, int maxItems) {
+ getHostedZone(zoneId);
+ List<ResourceRecordSet> records = new ArrayList<>(
+ recordStore.get(zoneId).orElse(List.of()));
+
+ records.sort((a, b) -> {
+ int cmp = a.getName().compareTo(b.getName());
+ if (cmp != 0) return cmp;
+ return a.getType().compareTo(b.getType());
+ });
+
+ if (startName != null && !startName.isEmpty()) {
+ String normalizedStart = normalizeName(startName);
+ final String finalStartType = startType;
+ records = records.stream()
+ .filter(r -> {
+ int cmp = r.getName().compareTo(normalizedStart);
+ if (cmp > 0) return true;
+ if (cmp == 0 && finalStartType != null && !finalStartType.isEmpty()) {
+ return r.getType().compareTo(finalStartType) >= 0;
+ }
+ return cmp == 0;
+ })
+ .toList();
+ records = new ArrayList<>(records);
+ }
+
+ if (maxItems > 0 && records.size() > maxItems) {
+ return records.subList(0, maxItems);
+ }
+ return records;
+ }
+
+ // ── Changes ───────────────────────────────────────────────────────────────
+
+ public ChangeInfo getChange(String changeId) {
+ return changeStore.get(changeId).orElseThrow(() ->
+ new AwsException("NoSuchChange",
+ "No change found with ID: " + changeId, 404));
+ }
+
+ // ── Health Checks ─────────────────────────────────────────────────────────
+
+ public synchronized HealthCheck createHealthCheck(String callerReference, HealthCheckConfig cfg) {
+ for (HealthCheck existing : healthCheckStore.scan(k -> true)) {
+ if (existing.getCallerReference().equals(callerReference)) {
+ throw new AwsException("HealthCheckAlreadyExists",
+ "A health check with caller reference " + callerReference + " already exists.", 409);
+ }
+ }
+ String id = UUID.randomUUID().toString();
+ HealthCheck hc = new HealthCheck(id, callerReference, cfg);
+ healthCheckStore.put(id, hc);
+ return hc;
+ }
+
+ public HealthCheck getHealthCheck(String id) {
+ return healthCheckStore.get(id).orElseThrow(() ->
+ new AwsException("NoSuchHealthCheck",
+ "No health check found with ID: " + id, 404));
+ }
+
+ public void deleteHealthCheck(String id) {
+ getHealthCheck(id);
+ healthCheckStore.delete(id);
+ tagStore.delete("healthcheck/" + id);
+ }
+
+ public List<HealthCheck> listHealthChecks(String marker, int maxItems) {
+ List<HealthCheck> all = new ArrayList<>(healthCheckStore.scan(k -> true));
+ if (marker != null && !marker.isEmpty()) {
+ int idx = 0;
+ for (int i = 0; i < all.size(); i++) {
+ if (all.get(i).getId().equals(marker)) {
+ idx = i + 1;
+ break;
+ }
+ }
+ all = all.subList(idx, all.size());
+ }
+ if (maxItems > 0 && all.size() > maxItems) {
+ return all.subList(0, maxItems);
+ }
+ return all;
+ }
+
+ public HealthCheck updateHealthCheck(String id, HealthCheckConfig cfg) {
+ HealthCheck hc = getHealthCheck(id);
+ hc.setConfig(cfg);
+ hc.setHealthCheckVersion(hc.getHealthCheckVersion() + 1);
+ healthCheckStore.put(id, hc);
+ return hc;
+ }
+
+ // ── Tags ──────────────────────────────────────────────────────────────────
+
+ public Map<String, String> listTagsForResource(String resourceType, String resourceId) {
+ return tagStore.get(resourceType + "/" + resourceId).orElse(Collections.emptyMap());
+ }
+
+ public void changeTagsForResource(String resourceType, String resourceId,
+ List<Map<String, String>> addTags, List<String> removeTagKeys) {
+ String key = resourceType + "/" + resourceId;
+ Map<String, String> tags = new LinkedHashMap<>(tagStore.get(key).orElse(new LinkedHashMap<>()));
+ if (removeTagKeys != null) {
+ removeTagKeys.forEach(tags::remove);
+ }
+ if (addTags != null) {
+ addTags.forEach(t -> {
+ if (t.get("Key") != null) {
+ tags.put(t.get("Key"), t.getOrDefault("Value", ""));
+ }
+ });
+ }
+ tagStore.put(key, tags);
+ }
+
+ // ── Helpers ───────────────────────────────────────────────────────────────
+
+ public List<String> getNameServers() {
+ return nameServers;
+ }
+
+ private static String normalizeName(String name) {
+ if (name == null || name.isEmpty()) return name;
+ return name.endsWith(".") ? name : name + ".";
+ }
+
+ private static String generateZoneId() {
+ StringBuilder sb = new StringBuilder("Z");
+ for (int i = 0; i < 14; i++) {
+ sb.append(CHARS.charAt(RANDOM.nextInt(CHARS.length())));
+ }
+ return sb.toString();
+ }
+
+ private static String generateChangeId() {
+ StringBuilder sb = new StringBuilder("C");
+ for (int i = 0; i < 13; i++) {
+ sb.append(CHARS.charAt(RANDOM.nextInt(CHARS.length())));
+ }
+ return sb.toString();
+ }
+
+ private ChangeInfo newChange(String comment) {
+ String id = generateChangeId();
+ ChangeInfo change = new ChangeInfo(id, Instant.now().toString(), comment);
+ changeStore.put(id, change);
+ return change;
+ }
+
+ private List<ResourceRecordSet> buildDefaultRecords(String zoneName) {
+ List<ResourceRecordSet> records = new ArrayList<>();
+
+ ResourceRecordSet soa = new ResourceRecordSet();
+ soa.setName(zoneName);
+ soa.setType("SOA");
+ soa.setTtl(900L);
+ soa.setRecords(List.of(new ResourceRecord(
+ nameServers.get(0) + " awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400")));
+ records.add(soa);
+
+ ResourceRecordSet ns = new ResourceRecordSet();
+ ns.setName(zoneName);
+ ns.setType("NS");
+ ns.setTtl(172800L);
+ ns.setRecords(nameServers.stream()
+ .map(n -> new ResourceRecord(n + "."))
+ .toList());
+ records.add(ns);
+
+ return records;
+ }
+
+ private boolean isApexSoaOrNs(ResourceRecordSet rrs, String zoneName) {
+ return rrs.getName().equals(zoneName) &&
+ ("SOA".equals(rrs.getType()) || "NS".equals(rrs.getType()));
+ }
+
+ private int recordCount(String zoneId) {
+ return recordStore.get(zoneId).map(List::size).orElse(0);
+ }
+
+ private void validateChange(String action, ResourceRecordSet rrs,
+ List<ResourceRecordSet> current, String zoneName) {
+ if ("DELETE".equals(action) && isApexSoaOrNs(rrs, zoneName)) {
+ throw new AwsException("InvalidChangeBatch",
+ "Invalid resource record set: Deleting the SOA or NS record at the zone apex is not permitted.", 400);
+ }
+ if ("CREATE".equals(action)) {
+ boolean exists = current.stream().anyMatch(r ->
+ r.getName().equals(rrs.getName()) &&
+ r.getType().equals(rrs.getType()) &&
+ equalOrNull(r.getSetIdentifier(), rrs.getSetIdentifier()));
+ if (exists) {
+ throw new AwsException("InvalidChangeBatch",
+ "Tried to create resource record set [name='" + rrs.getName() +
+ "', type='" + rrs.getType() + "'] but it already exists.", 400);
+ }
+ }
+ if ("DELETE".equals(action)) {
+ boolean found = current.stream().anyMatch(r ->
+ r.getName().equals(rrs.getName()) && r.getType().equals(rrs.getType()));
+ if (!found) {
+ throw new AwsException("InvalidChangeBatch",
+ "Tried to delete resource record set [name='" + rrs.getName() +
+ "', type='" + rrs.getType() + "'] but it was not found.", 400);
+ }
+ }
+ }
+
+ private void applyChange(String action, ResourceRecordSet rrs, List<ResourceRecordSet> current) {
+ switch (action) {
+ case "CREATE" -> current.add(rrs);
+ case "DELETE" -> current.removeIf(r ->
+ r.getName().equals(rrs.getName()) && r.getType().equals(rrs.getType()) &&
+ equalOrNull(r.getSetIdentifier(), rrs.getSetIdentifier()));
+ case "UPSERT" -> {
+ current.removeIf(r ->
+ r.getName().equals(rrs.getName()) && r.getType().equals(rrs.getType()) &&
+ equalOrNull(r.getSetIdentifier(), rrs.getSetIdentifier()));
+ current.add(rrs);
+ }
+ }
+ }
+
+ private static boolean equalOrNull(String a, String b) {
+ if (a == null && b == null) return true;
+ if (a == null || b == null) return false;
+ return a.equals(b);
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/route53/model/AliasTarget.java b/src/main/java/io/github/hectorvent/floci/services/route53/model/AliasTarget.java
new file mode 100644
index 0000000000..511e7ece8f
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/route53/model/AliasTarget.java
@@ -0,0 +1,21 @@
+package io.github.hectorvent.floci.services.route53.model;
+
+public class AliasTarget {
+
+ private String hostedZoneId;
+ private String dnsName;
+ private boolean evaluateTargetHealth;
+
+ public AliasTarget() {}
+
+ public String getHostedZoneId() { return hostedZoneId; }
+ public void setHostedZoneId(String hostedZoneId) { this.hostedZoneId = hostedZoneId; }
+
+ public String getDnsName() { return dnsName; }
+ public void setDnsName(String dnsName) { this.dnsName = dnsName; }
+
+ public boolean isEvaluateTargetHealth() { return evaluateTargetHealth; }
+ public void setEvaluateTargetHealth(boolean evaluateTargetHealth) {
+ this.evaluateTargetHealth = evaluateTargetHealth;
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/route53/model/ChangeInfo.java b/src/main/java/io/github/hectorvent/floci/services/route53/model/ChangeInfo.java
new file mode 100644
index 0000000000..14523ff1c2
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/route53/model/ChangeInfo.java
@@ -0,0 +1,30 @@
+package io.github.hectorvent.floci.services.route53.model;
+
+public class ChangeInfo {
+
+ private String id;
+ private String status;
+ private String submittedAt;
+ private String comment;
+
+ public ChangeInfo() {}
+
+ public ChangeInfo(String id, String submittedAt, String comment) {
+ this.id = id;
+ this.status = "INSYNC";
+ this.submittedAt = submittedAt;
+ this.comment = comment;
+ }
+
+ public String getId() { return id; }
+ public void setId(String id) { this.id = id; }
+
+ public String getStatus() { return status; }
+ public void setStatus(String status) { this.status = status; }
+
+ public String getSubmittedAt() { return submittedAt; }
+ public void setSubmittedAt(String submittedAt) { this.submittedAt = submittedAt; }
+
+ public String getComment() { return comment; }
+ public void setComment(String comment) { this.comment = comment; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/route53/model/HealthCheck.java b/src/main/java/io/github/hectorvent/floci/services/route53/model/HealthCheck.java
new file mode 100644
index 0000000000..9d3b288edf
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/route53/model/HealthCheck.java
@@ -0,0 +1,30 @@
+package io.github.hectorvent.floci.services.route53.model;
+
+public class HealthCheck {
+
+ private String id;
+ private String callerReference;
+ private HealthCheckConfig config;
+ private long healthCheckVersion;
+
+ public HealthCheck() {}
+
+ public HealthCheck(String id, String callerReference, HealthCheckConfig config) {
+ this.id = id;
+ this.callerReference = callerReference;
+ this.config = config;
+ this.healthCheckVersion = 1;
+ }
+
+ public String getId() { return id; }
+ public void setId(String id) { this.id = id; }
+
+ public String getCallerReference() { return callerReference; }
+ public void setCallerReference(String callerReference) { this.callerReference = callerReference; }
+
+ public HealthCheckConfig getConfig() { return config; }
+ public void setConfig(HealthCheckConfig config) { this.config = config; }
+
+ public long getHealthCheckVersion() { return healthCheckVersion; }
+ public void setHealthCheckVersion(long healthCheckVersion) { this.healthCheckVersion = healthCheckVersion; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/route53/model/HealthCheckConfig.java b/src/main/java/io/github/hectorvent/floci/services/route53/model/HealthCheckConfig.java
new file mode 100644
index 0000000000..0b9d47ddaf
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/route53/model/HealthCheckConfig.java
@@ -0,0 +1,37 @@
+package io.github.hectorvent.floci.services.route53.model;
+
+public class HealthCheckConfig {
+
+ private String type;
+ private String ipAddress;
+ private Integer port;
+ private String resourcePath;
+ private String fullyQualifiedDomainName;
+ private Integer requestInterval;
+ private Integer failureThreshold;
+
+ public HealthCheckConfig() {}
+
+ public String getType() { return type; }
+ public void setType(String type) { this.type = type; }
+
+ public String getIpAddress() { return ipAddress; }
+ public void setIpAddress(String ipAddress) { this.ipAddress = ipAddress; }
+
+ public Integer getPort() { return port; }
+ public void setPort(Integer port) { this.port = port; }
+
+ public String getResourcePath() { return resourcePath; }
+ public void setResourcePath(String resourcePath) { this.resourcePath = resourcePath; }
+
+ public String getFullyQualifiedDomainName() { return fullyQualifiedDomainName; }
+ public void setFullyQualifiedDomainName(String fullyQualifiedDomainName) {
+ this.fullyQualifiedDomainName = fullyQualifiedDomainName;
+ }
+
+ public Integer getRequestInterval() { return requestInterval; }
+ public void setRequestInterval(Integer requestInterval) { this.requestInterval = requestInterval; }
+
+ public Integer getFailureThreshold() { return failureThreshold; }
+ public void setFailureThreshold(Integer failureThreshold) { this.failureThreshold = failureThreshold; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/route53/model/HostedZone.java b/src/main/java/io/github/hectorvent/floci/services/route53/model/HostedZone.java
new file mode 100644
index 0000000000..5845dad481
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/route53/model/HostedZone.java
@@ -0,0 +1,43 @@
+package io.github.hectorvent.floci.services.route53.model;
+
+public class HostedZone {
+
+ private String id;
+ private String name;
+ private String callerReference;
+ private String comment;
+ private boolean privateZone;
+ private int resourceRecordSetCount;
+
+ public HostedZone() {}
+
+ public HostedZone(String id, String name, String callerReference,
+ String comment, boolean privateZone) {
+ this.id = id;
+ this.name = name;
+ this.callerReference = callerReference;
+ this.comment = comment;
+ this.privateZone = privateZone;
+ this.resourceRecordSetCount = 2;
+ }
+
+ public String getId() { return id; }
+ public void setId(String id) { this.id = id; }
+
+ public String getName() { return name; }
+ public void setName(String name) { this.name = name; }
+
+ public String getCallerReference() { return callerReference; }
+ public void setCallerReference(String callerReference) { this.callerReference = callerReference; }
+
+ public String getComment() { return comment; }
+ public void setComment(String comment) { this.comment = comment; }
+
+ public boolean isPrivateZone() { return privateZone; }
+ public void setPrivateZone(boolean privateZone) { this.privateZone = privateZone; }
+
+ public int getResourceRecordSetCount() { return resourceRecordSetCount; }
+ public void setResourceRecordSetCount(int resourceRecordSetCount) {
+ this.resourceRecordSetCount = resourceRecordSetCount;
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/route53/model/ResourceRecord.java b/src/main/java/io/github/hectorvent/floci/services/route53/model/ResourceRecord.java
new file mode 100644
index 0000000000..16278154da
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/route53/model/ResourceRecord.java
@@ -0,0 +1,15 @@
+package io.github.hectorvent.floci.services.route53.model;
+
+public class ResourceRecord {
+
+ private String value;
+
+ public ResourceRecord() {}
+
+ public ResourceRecord(String value) {
+ this.value = value;
+ }
+
+ public String getValue() { return value; }
+ public void setValue(String value) { this.value = value; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/route53/model/ResourceRecordSet.java b/src/main/java/io/github/hectorvent/floci/services/route53/model/ResourceRecordSet.java
new file mode 100644
index 0000000000..13f5c1c636
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/route53/model/ResourceRecordSet.java
@@ -0,0 +1,49 @@
+package io.github.hectorvent.floci.services.route53.model;
+
+import java.util.List;
+
+public class ResourceRecordSet {
+
+ private String name;
+ private String type;
+ private Long ttl;
+ private List<ResourceRecord> records;
+ private AliasTarget aliasTarget;
+ private Long weight;
+ private String region;
+ private String setIdentifier;
+ private String failover;
+ private String healthCheckId;
+
+ public ResourceRecordSet() {}
+
+ public String getName() { return name; }
+ public void setName(String name) { this.name = name; }
+
+ public String getType() { return type; }
+ public void setType(String type) { this.type = type; }
+
+ public Long getTtl() { return ttl; }
+ public void setTtl(Long ttl) { this.ttl = ttl; }
+
+ public List<ResourceRecord> getRecords() { return records; }
+ public void setRecords(List<ResourceRecord> records) { this.records = records; }
+
+ public AliasTarget getAliasTarget() { return aliasTarget; }
+ public void setAliasTarget(AliasTarget aliasTarget) { this.aliasTarget = aliasTarget; }
+
+ public Long getWeight() { return weight; }
+ public void setWeight(Long weight) { this.weight = weight; }
+
+ public String getRegion() { return region; }
+ public void setRegion(String region) { this.region = region; }
+
+ public String getSetIdentifier() { return setIdentifier; }
+ public void setSetIdentifier(String setIdentifier) { this.setIdentifier = setIdentifier; }
+
+ public String getFailover() { return failover; }
+ public void setFailover(String failover) { this.failover = failover; }
+
+ public String getHealthCheckId() { return healthCheckId; }
+ public void setHealthCheckId(String healthCheckId) { this.healthCheckId = healthCheckId; }
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 552b5db3ae..c64947c47f 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -36,6 +36,7 @@ quarkus:
- --initialize-at-run-time=io.github.hectorvent.floci.services.acm.CertificateGenerator
- --initialize-at-run-time=io.github.hectorvent.floci.services.cognito.CognitoSrpHelper
- --initialize-at-run-time=io.github.hectorvent.floci.services.ses.SesService
+ - --initialize-at-run-time=io.github.hectorvent.floci.services.route53.Route53Service
floci:
@@ -240,3 +241,5 @@ floci:
enabled: true
autoscaling:
enabled: true
+ route53:
+ enabled: true
diff --git a/src/test/java/io/github/hectorvent/floci/lifecycle/EmulatorInfoControllerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/lifecycle/EmulatorInfoControllerIntegrationTest.java
index 442e46df47..570e216f98 100644
--- a/src/test/java/io/github/hectorvent/floci/lifecycle/EmulatorInfoControllerIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/lifecycle/EmulatorInfoControllerIntegrationTest.java
@@ -57,7 +57,8 @@ class EmulatorInfoControllerIntegrationTest {
"elasticloadbalancing": "running",
"codebuild": "running",
"codedeploy": "running",
- "autoscaling": "running"
+ "autoscaling": "running",
+ "route53": "running"
}
""";
diff --git a/src/test/java/io/github/hectorvent/floci/services/route53/Route53IntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/route53/Route53IntegrationTest.java
new file mode 100644
index 0000000000..759d05f9a6
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/services/route53/Route53IntegrationTest.java
@@ -0,0 +1,486 @@
+package io.github.hectorvent.floci.services.route53;
+
+import io.quarkus.test.junit.QuarkusTest;
+import org.junit.jupiter.api.MethodOrderer;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.*;
+
+@QuarkusTest
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class Route53IntegrationTest {
+
+ private static final String XML = "application/xml";
+
+ private static String zoneId;
+ private static String changeId;
+ private static String healthCheckId;
+
+ // ── Hosted Zones ──────────────────────────────────────────────────────────
+
+ @Test
+ @Order(1)
+ void createHostedZone_returns201WithLocation() {
+ String body = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
+ <Name>example.com</Name>
+ <CallerReference>ref-001</CallerReference>
+ <HostedZoneConfig>
+ <Comment>test zone</Comment>
+ <PrivateZone>false</PrivateZone>
+ </HostedZoneConfig>
+ </CreateHostedZoneRequest>
+ """;
+
+ String locationHeader = given()
+ .contentType(XML)
+ .body(body)
+ .when().post("/2013-04-01/hostedzone")
+ .then()
+ .statusCode(201)
+ .contentType(XML)
+ .header("Location", containsString("/2013-04-01/hostedzone/Z"))
+ .body("CreateHostedZoneResponse.HostedZone.Name", equalTo("example.com."))
+ .body("CreateHostedZoneResponse.HostedZone.Id", startsWith("/hostedzone/Z"))
+ .body("CreateHostedZoneResponse.HostedZone.ResourceRecordSetCount", equalTo("2"))
+ .body("CreateHostedZoneResponse.ChangeInfo.Status", equalTo("INSYNC"))
+ .body("CreateHostedZoneResponse.ChangeInfo.Id", startsWith("/change/C"))
+ .body(containsString("ns-1.awsdns-01.org"))
+ .extract().header("Location");
+
+ // Location is an absolute URL: http://localhost:PORT/2013-04-01/hostedzone/ZXXX
+ zoneId = locationHeader.substring(locationHeader.lastIndexOf('/') + 1);
+ }
+
+ @Test
+ @Order(2)
+ void getHostedZone_returnsCreatedZone() {
+ given()
+ .when().get("/2013-04-01/hostedzone/" + zoneId)
+ .then()
+ .statusCode(200)
+ .contentType(XML)
+ .body("GetHostedZoneResponse.HostedZone.Id", equalTo("/hostedzone/" + zoneId))
+ .body("GetHostedZoneResponse.HostedZone.Name", equalTo("example.com."))
+ .body(containsString("ns-1.awsdns-01.org"));
+ }
+
+ @Test
+ @Order(3)
+ void listHostedZones_includesCreatedZone() {
+ given()
+ .when().get("/2013-04-01/hostedzone")
+ .then()
+ .statusCode(200)
+ .contentType(XML)
+ .body("ListHostedZonesResponse.IsTruncated", equalTo("false"))
+ .body(containsString("/hostedzone/" + zoneId));
+ }
+
+ @Test
+ @Order(4)
+ void listHostedZonesByName_returnsZone() {
+ given()
+ .queryParam("dnsname", "example.com.")
+ .when().get("/2013-04-01/hostedzonesbyname")
+ .then()
+ .statusCode(200)
+ .contentType(XML)
+ .body(containsString("example.com."));
+ }
+
+ @Test
+ @Order(5)
+ void getHostedZoneCount_includesZone() {
+ given()
+ .when().get("/2013-04-01/hostedzonecount")
+ .then()
+ .statusCode(200)
+ .body("GetHostedZoneCountResponse.HostedZoneCount", not(equalTo("0")));
+ }
+
+ // ── Resource Record Sets ──────────────────────────────────────────────────
+
+ @Test
+ @Order(6)
+ void listResourceRecordSets_autoCreatedSOAandNS() {
+ String body = given()
+ .when().get("/2013-04-01/hostedzone/" + zoneId + "/rrset")
+ .then()
+ .statusCode(200)
+ .contentType(XML)
+ .body("ListResourceRecordSetsResponse.IsTruncated", equalTo("false"))
+ .extract().body().asString();
+
+ assertThat(body, containsString("<Type>SOA</Type>"));
+ assertThat(body, containsString("<Type>NS</Type>"));
+ }
+
+ @Test
+ @Order(7)
+ void changeResourceRecordSets_createARecord() {
+ String body = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
+ <ChangeBatch>
+ <Changes>
+ <Change>
+ <Action>CREATE</Action>
+ <ResourceRecordSet>
+ <Name>www.example.com.</Name>
+ <Type>A</Type>
+ <TTL>300</TTL>
+ <ResourceRecords>
+ <ResourceRecord><Value>1.2.3.4</Value></ResourceRecord>
+ </ResourceRecords>
+ </ResourceRecordSet>
+ </Change>
+ </Changes>
+ </ChangeBatch>
+ </ChangeResourceRecordSetsRequest>
+ """;
+
+ String responseBody = given()
+ .contentType(XML)
+ .body(body)
+ .when().post("/2013-04-01/hostedzone/" + zoneId + "/rrset")
+ .then()
+ .statusCode(200)
+ .contentType(XML)
+ .body("ChangeResourceRecordSetsResponse.ChangeInfo.Status", equalTo("INSYNC"))
+ .body("ChangeResourceRecordSetsResponse.ChangeInfo.Id", startsWith("/change/C"))
+ .extract().body().asString();
+
+ // Extract change ID for getChange test
+ int start = responseBody.indexOf("/change/") + 8;
+ int end = responseBody.indexOf("</Id>", start);
+ if (start > 8 && end > start) {
+ changeId = responseBody.substring(start, end);
+ }
+ }
+
+ @Test
+ @Order(8)
+ void listResourceRecordSets_includesARecord() {
+ String body = given()
+ .when().get("/2013-04-01/hostedzone/" + zoneId + "/rrset")
+ .then()
+ .statusCode(200)
+ .extract().body().asString();
+
+ assertThat(body, containsString("<Type>A</Type>"));
+ assertThat(body, containsString("<Value>1.2.3.4</Value>"));
+ }
+
+ @Test
+ @Order(9)
+ void changeResourceRecordSets_deleteSOA_fails() {
+ String body = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
+ <ChangeBatch>
+ <Changes>
+ <Change>
+ <Action>DELETE</Action>
+ <ResourceRecordSet>
+ <Name>example.com.</Name>
+ <Type>SOA</Type>
+ <TTL>900</TTL>
+ <ResourceRecords>
+ <ResourceRecord><Value>ns-1.awsdns-01.org. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400</Value></ResourceRecord>
+ </ResourceRecords>
+ </ResourceRecordSet>
+ </Change>
+ </Changes>
+ </ChangeBatch>
+ </ChangeResourceRecordSetsRequest>
+ """;
+
+ given()
+ .contentType(XML)
+ .body(body)
+ .when().post("/2013-04-01/hostedzone/" + zoneId + "/rrset")
+ .then()
+ .statusCode(400)
+ .body("ErrorResponse.Error.Code", equalTo("InvalidChangeBatch"));
+ }
+
+ @Test
+ @Order(10)
+ void getChange_returnsInsync() {
+ if (changeId == null) return;
+ given()
+ .when().get("/2013-04-01/change/" + changeId)
+ .then()
+ .statusCode(200)
+ .body("GetChangeResponse.ChangeInfo.Status", equalTo("INSYNC"))
+ .body("GetChangeResponse.ChangeInfo.Id", equalTo("/change/" + changeId));
+ }
+
+ @Test
+ @Order(11)
+ void changeResourceRecordSets_deleteARecord() {
+ String body = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
+ <ChangeBatch>
+ <Changes>
+ <Change>
+ <Action>DELETE</Action>
+ <ResourceRecordSet>
+ <Name>www.example.com.</Name>
+ <Type>A</Type>
+ <TTL>300</TTL>
+ <ResourceRecords>
+ <ResourceRecord><Value>1.2.3.4</Value></ResourceRecord>
+ </ResourceRecords>
+ </ResourceRecordSet>
+ </Change>
+ </Changes>
+ </ChangeBatch>
+ </ChangeResourceRecordSetsRequest>
+ """;
+
+ given()
+ .contentType(XML)
+ .body(body)
+ .when().post("/2013-04-01/hostedzone/" + zoneId + "/rrset")
+ .then()
+ .statusCode(200)
+ .body("ChangeResourceRecordSetsResponse.ChangeInfo.Status", equalTo("INSYNC"));
+ }
+
+ @Test
+ @Order(12)
+ void deleteHostedZone_failsWhenNonDefaultRecordsExist() {
+ String createBody = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
+ <Name>nonempty.example.com</Name>
+ <CallerReference>ref-nonempty</CallerReference>
+ </CreateHostedZoneRequest>
+ """;
+
+ String loc = given()
+ .contentType(XML).body(createBody)
+ .when().post("/2013-04-01/hostedzone")
+ .then().statusCode(201)
+ .extract().header("Location");
+ String tmpId = loc.substring(loc.lastIndexOf('/') + 1);
+
+ String addRecord = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <ChangeResourceRecordSetsRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
+ <ChangeBatch>
+ <Changes>
+ <Change>
+ <Action>CREATE</Action>
+ <ResourceRecordSet>
+ <Name>sub.nonempty.example.com.</Name>
+ <Type>A</Type>
+ <TTL>60</TTL>
+ <ResourceRecords>
+ <ResourceRecord><Value>10.0.0.1</Value></ResourceRecord>
+ </ResourceRecords>
+ </ResourceRecordSet>
+ </Change>
+ </Changes>
+ </ChangeBatch>
+ </ChangeResourceRecordSetsRequest>
+ """;
+ given().contentType(XML).body(addRecord)
+ .post("/2013-04-01/hostedzone/" + tmpId + "/rrset")
+ .then().statusCode(200);
+
+ given()
+ .when().delete("/2013-04-01/hostedzone/" + tmpId)
+ .then()
+ .statusCode(400)
+ .body("ErrorResponse.Error.Code", equalTo("HostedZoneNotEmpty"));
+
+ // Cleanup
+ String deleteRecord = addRecord.replace("<Action>CREATE</Action>", "<Action>DELETE</Action>");
+ given().contentType(XML).body(deleteRecord)
+ .post("/2013-04-01/hostedzone/" + tmpId + "/rrset")
+ .then().statusCode(200);
+ given().delete("/2013-04-01/hostedzone/" + tmpId).then().statusCode(200);
+ }
+
+ @Test
+ @Order(13)
+ void deleteHostedZone_succeedsAfterRecordsRemoved() {
+ given()
+ .when().delete("/2013-04-01/hostedzone/" + zoneId)
+ .then()
+ .statusCode(200)
+ .body("DeleteHostedZoneResponse.ChangeInfo.Status", equalTo("INSYNC"));
+ }
+
+ @Test
+ @Order(14)
+ void getHostedZone_returns404AfterDelete() {
+ given()
+ .when().get("/2013-04-01/hostedzone/" + zoneId)
+ .then()
+ .statusCode(404)
+ .body("ErrorResponse.Error.Code", equalTo("NoSuchHostedZone"));
+ }
+
+ // ── Health Checks ─────────────────────────────────────────────────────────
+
+ @Test
+ @Order(15)
+ void createHealthCheck_returns201() {
+ String body = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <CreateHealthCheckRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
+ <CallerReference>hc-ref-001</CallerReference>
+ <HealthCheckConfig>
+ <Type>HTTPS</Type>
+ <FullyQualifiedDomainName>example.com</FullyQualifiedDomainName>
+ <Port>443</Port>
+ <ResourcePath>/health</ResourcePath>
+ <RequestInterval>30</RequestInterval>
+ <FailureThreshold>3</FailureThreshold>
+ </HealthCheckConfig>
+ </CreateHealthCheckRequest>
+ """;
+
+ String loc = given()
+ .contentType(XML).body(body)
+ .when().post("/2013-04-01/healthcheck")
+ .then()
+ .statusCode(201)
+ .header("Location", containsString("/2013-04-01/healthcheck/"))
+ .body("CreateHealthCheckResponse.HealthCheck.CallerReference", equalTo("hc-ref-001"))
+ .body("CreateHealthCheckResponse.HealthCheck.HealthCheckConfig.Type", equalTo("HTTPS"))
+ .body("CreateHealthCheckResponse.HealthCheck.HealthCheckVersion", equalTo("1"))
+ .extract().header("Location");
+
+ healthCheckId = loc.substring(loc.lastIndexOf('/') + 1);
+ }
+
+ @Test
+ @Order(16)
+ void getHealthCheck_returnsCreated() {
+ given()
+ .when().get("/2013-04-01/healthcheck/" + healthCheckId)
+ .then()
+ .statusCode(200)
+ .body("GetHealthCheckResponse.HealthCheck.Id", equalTo(healthCheckId))
+ .body("GetHealthCheckResponse.HealthCheck.HealthCheckConfig.Port", equalTo("443"));
+ }
+
+ @Test
+ @Order(17)
+ void listHealthChecks_includesCreated() {
+ String body = given()
+ .when().get("/2013-04-01/healthcheck")
+ .then()
+ .statusCode(200)
+ .extract().body().asString();
+
+ assertThat(body, containsString(healthCheckId));
+ }
+
+ @Test
+ @Order(18)
+ void deleteHealthCheck_returns200() {
+ given()
+ .when().delete("/2013-04-01/healthcheck/" + healthCheckId)
+ .then()
+ .statusCode(200);
+
+ given()
+ .when().get("/2013-04-01/healthcheck/" + healthCheckId)
+ .then()
+ .statusCode(404)
+ .body("ErrorResponse.Error.Code", equalTo("NoSuchHealthCheck"));
+ }
+
+ // ── Tags ──────────────────────────────────────────────────────────────────
+
+ @Test
+ @Order(19)
+ void tagging_addListRemove() {
+ String createBody = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <CreateHostedZoneRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
+ <Name>tagged.example.com</Name>
+ <CallerReference>ref-tagged</CallerReference>
+ </CreateHostedZoneRequest>
+ """;
+ String loc = given()
+ .contentType(XML).body(createBody)
+ .when().post("/2013-04-01/hostedzone")
+ .then().statusCode(201).extract().header("Location");
+ String tagZoneId = loc.substring(loc.lastIndexOf('/') + 1);
+
+ String addTagBody = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <ChangeTagsForResourceRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
+ <AddTags>
+ <Tag><Key>env</Key><Value>test</Value></Tag>
+ <Tag><Key>owner</Key><Value>floci</Value></Tag>
+ </AddTags>
+ </ChangeTagsForResourceRequest>
+ """;
+ given()
+ .contentType(XML).body(addTagBody)
+ .when().post("/2013-04-01/tags/hostedzone/" + tagZoneId)
+ .then().statusCode(200);
+
+ String listBody = given()
+ .when().get("/2013-04-01/tags/hostedzone/" + tagZoneId)
+ .then()
+ .statusCode(200)
+ .body("ListTagsForResourceResponse.ResourceTagSet.ResourceType", equalTo("hostedzone"))
+ .body("ListTagsForResourceResponse.ResourceTagSet.ResourceId", equalTo(tagZoneId))
+ .extract().body().asString();
+
+ assertThat(listBody, containsString("<Key>env</Key>"));
+ assertThat(listBody, containsString("<Key>owner</Key>"));
+
+ String removeTagBody = """
+ <?xml version="1.0" encoding="UTF-8"?>
+ <ChangeTagsForResourceRequest xmlns="https://route53.amazonaws.com/doc/2013-04-01/">
+ <RemoveTagKeys>
+ <Key>owner</Key>
+ </RemoveTagKeys>
+ </ChangeTagsForResourceRequest>
+ """;
+ given()
+ .contentType(XML).body(removeTagBody)
+ .when().post("/2013-04-01/tags/hostedzone/" + tagZoneId)
+ .then().statusCode(200);
+
+ String afterRemove = given()
+ .when().get("/2013-04-01/tags/hostedzone/" + tagZoneId)
+ .then().statusCode(200)
+ .extract().body().asString();
+
+ assertThat(afterRemove, containsString("<Key>env</Key>"));
+ assertThat(afterRemove, not(containsString("<Key>owner</Key>")));
+
+ // Cleanup
+ given().delete("/2013-04-01/hostedzone/" + tagZoneId).then().statusCode(200);
+ }
+
+ // ── Limits ────────────────────────────────────────────────────────────────
+
+ @Test
+ @Order(20)
+ void getAccountLimit_returnsValue() {
+ given()
+ .when().get("/2013-04-01/accountlimit/MAX_HOSTED_ZONES_BY_OWNER")
+ .then()
+ .statusCode(200)
+ .body("GetAccountLimitResponse.Limit.Type", equalTo("MAX_HOSTED_ZONES_BY_OWNER"))
+ .body("GetAccountLimitResponse.Limit.Value", equalTo("500"));
+ }
+}
diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml
index 42a4fabfd3..f7cd4b55de 100644
--- a/src/test/resources/application.yml
+++ b/src/test/resources/application.yml
@@ -162,3 +162,5 @@ floci:
enabled: true
autoscaling:
enabled: true
+ route53:
+ enabled: true