Skip to content

armgit / floci

Public Imported from GitHub
0

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

feat: adding appconfig service (#324)

Hector Venturae4d8d4472441
diff --git a/README.md b/README.md
index df4041a8e1..1de6a40e9f 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,7 @@
| EC2 (VPCs, instances, security groups) | ✅ | ⚠️ Partial |
| Native binary | ✅ ~40 MB | ❌ |
-**28 services. 1,873 automated compatibility tests. Free forever.**
+**31 services. 1,873 automated compatibility tests. Free forever.**
## Architecture Overview
@@ -66,7 +66,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 · OpenSearch\nEventBridge · Scheduler\nCloudWatch · Step Functions\nCloudFormation · ACM\nAPI Gateway · EC2"]
+ A["SSM · SQS · SNS\nIAM · STS · KMS\nSecrets Manager · SES\nCognito · Kinesis · OpenSearch\nEventBridge · Scheduler · AppConfig\nCloudWatch · Step Functions\nCloudFormation · ACM\nAPI Gateway · EC2"]
end
subgraph Stateful ["Stateful Services"]
@@ -121,6 +121,8 @@ flowchart LR
| **SES** | 14 | In-process | Send email / raw email, identity verification, DKIM attributes |
| **SES v2 (HTTP)** | 9 | In-process | REST JSON API, identities, DKIM, feedback attributes, account sending |
| **OpenSearch** | 24 | In-process | Domain CRUD, tags, versions, instance types, upgrade stubs |
+| **AppConfig** | 16 | In-process | Applications, environments, profiles, hosted configuration versions, deployments |
+| **AppConfigData** | 2 | In-process | Configuration sessions, dynamic configuration retrieval |
> **Lambda, ElastiCache, RDS, and ECS** spin up real Docker containers and support IAM authentication and SigV4 request signing — the same auth flow as production AWS.
diff --git a/compatibility-tests/sdk-test-java/pom.xml b/compatibility-tests/sdk-test-java/pom.xml
index 09e6f6e004..957fecbdf7 100644
--- a/compatibility-tests/sdk-test-java/pom.xml
+++ b/compatibility-tests/sdk-test-java/pom.xml
@@ -174,6 +174,15 @@
<groupId>software.amazon.awssdk</groupId>
<artifactId>cloudformation</artifactId>
</dependency>
+ <!-- AppConfig and AppConfigData clients -->
+ <dependency>
+ <groupId>software.amazon.awssdk</groupId>
+ <artifactId>appconfig</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>software.amazon.awssdk</groupId>
+ <artifactId>appconfigdata</artifactId>
+ </dependency>
<!-- JDBC drivers for RDS data-plane tests -->
<dependency>
<groupId>org.postgresql</groupId>
diff --git a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
index 5408701e60..a5b358284d 100644
--- a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
+++ b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
@@ -30,6 +30,8 @@ import software.amazon.awssdk.services.acm.AcmClient;
import software.amazon.awssdk.services.ec2.Ec2Client;
import software.amazon.awssdk.services.ecs.EcsClient;
import software.amazon.awssdk.services.scheduler.SchedulerClient;
+import software.amazon.awssdk.services.appconfig.AppConfigClient;
+import software.amazon.awssdk.services.appconfigdata.AppConfigDataClient;
import java.net.URI;
import java.util.UUID;
@@ -311,4 +313,20 @@ public final class TestFixtures {
.credentialsProvider(CREDENTIALS)
.build();
}
+
+ public static AppConfigClient appConfigClient() {
+ return AppConfigClient.builder()
+ .endpointOverride(ENDPOINT)
+ .region(REGION)
+ .credentialsProvider(CREDENTIALS)
+ .build();
+ }
+
+ public static AppConfigDataClient appConfigDataClient() {
+ return AppConfigDataClient.builder()
+ .endpointOverride(ENDPOINT)
+ .region(REGION)
+ .credentialsProvider(CREDENTIALS)
+ .build();
+ }
}
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppConfigTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppConfigTest.java
new file mode 100644
index 0000000000..4d1971905c
--- /dev/null
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AppConfigTest.java
@@ -0,0 +1,150 @@
+package com.floci.test;
+
+import org.junit.jupiter.api.*;
+import software.amazon.awssdk.core.SdkBytes;
+import software.amazon.awssdk.services.appconfig.AppConfigClient;
+import software.amazon.awssdk.services.appconfig.model.*;
+import software.amazon.awssdk.services.appconfigdata.AppConfigDataClient;
+import software.amazon.awssdk.services.appconfigdata.model.GetLatestConfigurationRequest;
+import software.amazon.awssdk.services.appconfigdata.model.GetLatestConfigurationResponse;
+import software.amazon.awssdk.services.appconfigdata.model.StartConfigurationSessionRequest;
+
+import java.nio.charset.StandardCharsets;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+@DisplayName("AppConfig")
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class AppConfigTest {
+
+ private static AppConfigClient appConfig;
+ private static AppConfigDataClient appConfigData;
+
+ private static String applicationId;
+ private static String environmentId;
+ private static String configurationProfileId;
+ private static String deploymentStrategyId;
+ private static String configurationToken;
+
+ @BeforeAll
+ static void setup() {
+ appConfig = TestFixtures.appConfigClient();
+ appConfigData = TestFixtures.appConfigDataClient();
+ }
+
+ @AfterAll
+ static void cleanup() {
+ if (appConfig != null) {
+ appConfig.close();
+ }
+ if (appConfigData != null) {
+ appConfigData.close();
+ }
+ }
+
+ @Test
+ @Order(1)
+ void createApplication() {
+ CreateApplicationResponse response = appConfig.createApplication(CreateApplicationRequest.builder()
+ .name(TestFixtures.uniqueName("app"))
+ .description("Test Application")
+ .build());
+
+ applicationId = response.id();
+ assertThat(applicationId).isNotNull();
+ }
+
+ @Test
+ @Order(2)
+ void createEnvironment() {
+ CreateEnvironmentResponse response = appConfig.createEnvironment(CreateEnvironmentRequest.builder()
+ .applicationId(applicationId)
+ .name("dev")
+ .build());
+
+ environmentId = response.id();
+ assertThat(environmentId).isNotNull();
+ }
+
+ @Test
+ @Order(3)
+ void createConfigurationProfile() {
+ CreateConfigurationProfileResponse response = appConfig.createConfigurationProfile(CreateConfigurationProfileRequest.builder()
+ .applicationId(applicationId)
+ .name("main-config")
+ .locationUri("hosted")
+ .type("AWS.Freeform")
+ .build());
+
+ configurationProfileId = response.id();
+ assertThat(configurationProfileId).isNotNull();
+ }
+
+ @Test
+ @Order(4)
+ void createHostedConfigurationVersion() {
+ CreateHostedConfigurationVersionResponse response = appConfig.createHostedConfigurationVersion(
+ CreateHostedConfigurationVersionRequest.builder()
+ .applicationId(applicationId)
+ .configurationProfileId(configurationProfileId)
+ .content(SdkBytes.fromString("{\"key\": \"value\"}", StandardCharsets.UTF_8))
+ .contentType("application/json")
+ .build());
+
+ assertThat(response.versionNumber()).isEqualTo(1);
+ }
+
+ @Test
+ @Order(5)
+ void createDeploymentStrategy() {
+ CreateDeploymentStrategyResponse response = appConfig.createDeploymentStrategy(CreateDeploymentStrategyRequest.builder()
+ .name("immediate")
+ .deploymentDurationInMinutes(0)
+ .finalBakeTimeInMinutes(0)
+ .growthFactor(100.0f)
+ .build());
+
+ deploymentStrategyId = response.id();
+ assertThat(deploymentStrategyId).isNotNull();
+ }
+
+ @Test
+ @Order(6)
+ void startDeployment() {
+ StartDeploymentResponse response = appConfig.startDeployment(StartDeploymentRequest.builder()
+ .applicationId(applicationId)
+ .environmentId(environmentId)
+ .configurationProfileId(configurationProfileId)
+ .configurationVersion("1")
+ .deploymentStrategyId(deploymentStrategyId)
+ .build());
+
+ assertThat(response.deploymentNumber()).isNotNull();
+ }
+
+ @Test
+ @Order(7)
+ void startConfigurationSession() {
+ var response = appConfigData.startConfigurationSession(StartConfigurationSessionRequest.builder()
+ .applicationIdentifier(applicationId)
+ .environmentIdentifier(environmentId)
+ .configurationProfileIdentifier(configurationProfileId)
+ .build());
+
+ configurationToken = response.initialConfigurationToken();
+ assertThat(configurationToken).isNotNull();
+ }
+
+ @Test
+ @Order(8)
+ void getLatestConfiguration() {
+ GetLatestConfigurationResponse response = appConfigData.getLatestConfiguration(GetLatestConfigurationRequest.builder()
+ .configurationToken(configurationToken)
+ .build());
+
+ assertThat(response.configuration().asString(StandardCharsets.UTF_8)).isEqualTo("{\"key\": \"value\"}");
+ assertThat(response.contentType()).startsWith("application/json");
+ assertThat(response.versionLabel()).isEqualTo("1");
+ assertThat(response.nextPollConfigurationToken()).isNotNull();
+ }
+}
diff --git a/docs/services/appconfig.md b/docs/services/appconfig.md
new file mode 100644
index 0000000000..7eb82a94eb
--- /dev/null
+++ b/docs/services/appconfig.md
@@ -0,0 +1,105 @@
+# AppConfig
+
+Floci supports AWS AppConfig and AppConfigData for local configuration management.
+
+## Management Plane (AppConfig)
+
+The management plane allows you to create and manage applications, environments, configuration profiles, and hosted configuration versions.
+
+### Supported Operations
+
+- `CreateApplication`
+- `GetApplication`
+- `ListApplications`
+- `DeleteApplication`
+- `CreateEnvironment`
+- `GetEnvironment`
+- `ListEnvironments`
+- `CreateConfigurationProfile`
+- `GetConfigurationProfile`
+- `ListConfigurationProfiles`
+- `CreateHostedConfigurationVersion`
+- `GetHostedConfigurationVersion`
+- `CreateDeploymentStrategy`
+- `GetDeploymentStrategy`
+- `StartDeployment`
+- `GetDeployment`
+
+## Data Plane (AppConfigData) {#data-plane}
+
+The data plane is used by applications to retrieve the active configuration for an environment and profile.
+
+### Supported Operations
+
+- `StartConfigurationSession`
+- `GetLatestConfiguration`
+
+## Example Usage
+
+### 1. Create an Application and Environment
+
+```bash
+# Create application
+aws appconfig create-application --name my-app --endpoint-url http://localhost:4566
+
+# Create environment
+aws appconfig create-environment --application-id <app-id> --name dev --endpoint-url http://localhost:4566
+```
+
+### 2. Create a Hosted Configuration
+
+```bash
+# Create configuration profile
+aws appconfig create-configuration-profile \
+ --application-id <app-id> \
+ --name my-profile \
+ --location-uri hosted \
+ --type AWS.Freeform \
+ --endpoint-url http://localhost:4566
+
+# Create hosted configuration version
+aws appconfig create-hosted-configuration-version \
+ --application-id <app-id> \
+ --configuration-profile-id <profile-id> \
+ --content "{\"foo\": \"bar\"}" \
+ --content-type application/json \
+ --endpoint-url http://localhost:4566
+```
+
+### 3. Deploy the Configuration
+
+```bash
+# Create immediate deployment strategy
+aws appconfig create-deployment-strategy \
+ --name immediate \
+ --deployment-duration-in-minutes 0 \
+ --growth-factor 100 \
+ --final-bake-time-in-minutes 0 \
+ --endpoint-url http://localhost:4566
+
+# Start deployment
+aws appconfig start-deployment \
+ --application-id <app-id> \
+ --environment-id <env-id> \
+ --configuration-profile-id <profile-id> \
+ --configuration-version 1 \
+ --deployment-strategy-id <strategy-id> \
+ --endpoint-url http://localhost:4566
+```
+
+### 4. Retrieve Configuration via Data Plane
+
+```bash
+# Start configuration session
+TOKEN=$(aws appconfigdata start-configuration-session \
+ --application-identifier <app-id> \
+ --environment-identifier <env-id> \
+ --configuration-profile-identifier <profile-id> \
+ --query "InitialConfigurationToken" --output text \
+ --endpoint-url http://localhost:4566)
+
+# Get latest configuration
+aws appconfigdata get-latest-configuration \
+ --configuration-token $TOKEN \
+ --endpoint-url http://localhost:4566
+```
diff --git a/docs/services/index.md b/docs/services/index.md
index 9b9be41aad..3116dd6885 100644
--- a/docs/services/index.md
+++ b/docs/services/index.md
@@ -35,6 +35,8 @@ Floci emulates 27 AWS services on a single port (`4566`). All services use the r
| [SES](ses.md) | `POST /` with `Action=` param | Query | 14 |
| [OpenSearch](opensearch.md) | `/2021-01-01/opensearch/...` | REST JSON | 24 |
| [EC2](ec2.md) | `POST /` with `Action=` param | EC2 Query | 61 |
+| [AppConfig](appconfig.md) | `/applications/...` | REST JSON | 12 |
+| [AppConfigData](appconfig.md#data-plane) | `/environments/...` | REST JSON | 2 |
## Common Setup
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 7a3f75b7c6..8c42b31380 100644
--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
@@ -79,6 +79,8 @@ public interface EmulatorConfig {
SecretsManagerStorageConfig secretsmanager();
AcmStorageConfig acm();
OpenSearchStorageConfig opensearch();
+ AppConfigStorageConfig appconfig();
+ AppConfigDataStorageConfig appconfigdata();
}
interface SsmStorageConfig {
@@ -152,6 +154,20 @@ public interface EmulatorConfig {
long flushIntervalMs();
}
+ interface AppConfigStorageConfig {
+ Optional<String> mode();
+
+ @WithDefault("5000")
+ long flushIntervalMs();
+ }
+
+ interface AppConfigDataStorageConfig {
+ Optional<String> mode();
+
+ @WithDefault("5000")
+ long flushIntervalMs();
+ }
+
interface WalConfig {
@WithDefault("30000")
long compactionIntervalMs();
@@ -196,6 +212,8 @@ public interface EmulatorConfig {
OpenSearchServiceConfig opensearch();
Ec2ServiceConfig ec2();
EcsServiceConfig ecs();
+ AppConfigServiceConfig appconfig();
+ AppConfigDataServiceConfig appconfigdata();
}
interface SsmServiceConfig {
@@ -438,6 +456,16 @@ public interface EmulatorConfig {
boolean enabled();
}
+ interface AppConfigServiceConfig {
+ @WithDefault("true")
+ boolean enabled();
+ }
+
+ interface AppConfigDataServiceConfig {
+ @WithDefault("true")
+ boolean enabled();
+ }
+
interface InitHooksConfig {
@WithDefault("/bin/sh")
String shellExecutable();
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ServiceEnabledFilter.java b/src/main/java/io/github/hectorvent/floci/core/common/ServiceEnabledFilter.java
index 8546b0f390..2ee815fba4 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/ServiceEnabledFilter.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/ServiceEnabledFilter.java
@@ -3,6 +3,8 @@ package io.github.hectorvent.floci.core.common;
import io.github.hectorvent.floci.services.cognito.CognitoOAuthController;
import io.github.hectorvent.floci.services.cognito.CognitoWellKnownController;
import io.github.hectorvent.floci.services.ses.SesController;
+import io.github.hectorvent.floci.services.appconfig.AppConfigController;
+import io.github.hectorvent.floci.services.appconfig.AppConfigDataController;
import jakarta.inject.Inject;
import jakarta.ws.rs.container.ContainerRequestContext;
import jakarta.ws.rs.container.ContainerRequestFilter;
@@ -96,6 +98,12 @@ public class ServiceEnabledFilter implements ContainerRequestFilter {
if (SesController.class.equals(resourceClass)) {
return "email";
}
+ if (AppConfigController.class.equals(resourceClass)) {
+ return "appconfig";
+ }
+ if (AppConfigDataController.class.equals(resourceClass)) {
+ return "appconfigdata";
+ }
return null;
}
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ServiceRegistry.java b/src/main/java/io/github/hectorvent/floci/core/common/ServiceRegistry.java
index fd307f070e..b2c0232612 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/ServiceRegistry.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/ServiceRegistry.java
@@ -53,6 +53,8 @@ public class ServiceRegistry {
case "es" -> config.services().opensearch().enabled();
case "ec2" -> config.services().ec2().enabled();
case "ecs" -> config.services().ecs().enabled();
+ case "appconfig" -> config.services().appconfig().enabled();
+ case "appconfigdata" -> config.services().appconfigdata().enabled();
default -> true;
};
}
@@ -83,6 +85,8 @@ public class ServiceRegistry {
if (config.services().acm().enabled()) enabled.add("acm");
if (config.services().ses().enabled()) enabled.add("email");
if (config.services().opensearch().enabled()) enabled.add("es");
+ if (config.services().appconfig().enabled()) enabled.add("appconfig");
+ if (config.services().appconfigdata().enabled()) enabled.add("appconfigdata");
return enabled;
}
@@ -117,6 +121,8 @@ public class ServiceRegistry {
services.put("es", status(config.services().opensearch().enabled()));
services.put("ec2", status(config.services().ec2().enabled()));
services.put("ecs", status(config.services().ecs().enabled()));
+ services.put("appconfig", status(config.services().appconfig().enabled()));
+ services.put("appconfigdata", status(config.services().appconfigdata().enabled()));
return services;
}
diff --git a/src/main/java/io/github/hectorvent/floci/core/storage/StorageFactory.java b/src/main/java/io/github/hectorvent/floci/core/storage/StorageFactory.java
index 151f6b513f..28801fcd03 100644
--- a/src/main/java/io/github/hectorvent/floci/core/storage/StorageFactory.java
+++ b/src/main/java/io/github/hectorvent/floci/core/storage/StorageFactory.java
@@ -110,6 +110,8 @@ public class StorageFactory {
case "cloudwatchmetrics" -> config.storage().services().cloudwatchmetrics().mode().orElse(globalMode);
case "secretsmanager" -> config.storage().services().secretsmanager().mode().orElse(globalMode);
case "opensearch" -> config.storage().services().opensearch().mode().orElse(globalMode);
+ case "appconfig" -> config.storage().services().appconfig().mode().orElse(globalMode);
+ case "appconfigdata" -> config.storage().services().appconfigdata().mode().orElse(globalMode);
default -> globalMode;
};
}
@@ -124,6 +126,8 @@ public class StorageFactory {
case "cloudwatchmetrics" -> config.storage().services().cloudwatchmetrics().flushIntervalMs();
case "secretsmanager" -> config.storage().services().secretsmanager().flushIntervalMs();
case "opensearch" -> config.storage().services().opensearch().flushIntervalMs();
+ case "appconfig" -> config.storage().services().appconfig().flushIntervalMs();
+ case "appconfigdata" -> config.storage().services().appconfigdata().flushIntervalMs();
default -> 5000L;
};
}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigController.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigController.java
new file mode 100644
index 0000000000..038ef51c43
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigController.java
@@ -0,0 +1,187 @@
+package io.github.hectorvent.floci.services.appconfig;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.services.appconfig.model.*;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.*;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.jboss.logging.Logger;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+@Path("/")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class AppConfigController {
+ private static final Logger LOG = Logger.getLogger(AppConfigController.class);
+
+ private final AppConfigService service;
+ private final ObjectMapper objectMapper;
+
+ @Inject
+ public AppConfigController(AppConfigService service, ObjectMapper objectMapper) {
+ this.service = service;
+ this.objectMapper = objectMapper;
+ }
+
+ // ──────────────────────────── Application ────────────────────────────
+
+ @POST
+ @Path("/applications")
+ public Response createApplication(String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> request = objectMapper.readValue(body, Map.class);
+ Application app = service.createApplication(request);
+ return Response.status(201).entity(app).build();
+ }
+
+ @GET
+ @Path("/applications/{id}")
+ public Response getApplication(@PathParam("id") String id) {
+ return Response.ok(service.getApplication(id)).build();
+ }
+
+ @GET
+ @Path("/applications")
+ public Response listApplications() {
+ List<Application> apps = service.listApplications();
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode items = root.putArray("Items");
+ apps.forEach(items::addPOJO);
+ return Response.ok(root).build();
+ }
+
+ @DELETE
+ @Path("/applications/{id}")
+ public Response deleteApplication(@PathParam("id") String id) {
+ service.deleteApplication(id);
+ return Response.noContent().build();
+ }
+
+ // ──────────────────────────── Environment ────────────────────────────
+
+ @POST
+ @Path("/applications/{appId}/environments")
+ public Response createEnvironment(@PathParam("appId") String appId, String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> request = objectMapper.readValue(body, Map.class);
+ Environment env = service.createEnvironment(appId, request);
+ return Response.status(201).entity(env).build();
+ }
+
+ @GET
+ @Path("/applications/{appId}/environments/{envId}")
+ public Response getEnvironment(@PathParam("appId") String appId, @PathParam("envId") String envId) {
+ return Response.ok(service.getEnvironment(appId, envId)).build();
+ }
+
+ @GET
+ @Path("/applications/{appId}/environments")
+ public Response listEnvironments(@PathParam("appId") String appId) {
+ List<Environment> envs = service.listEnvironments(appId);
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode items = root.putArray("Items");
+ envs.forEach(items::addPOJO);
+ return Response.ok(root).build();
+ }
+
+ // ──────────────────────────── Configuration Profile ────────────────────────────
+
+ @POST
+ @Path("/applications/{appId}/configurationprofiles")
+ public Response createConfigurationProfile(@PathParam("appId") String appId, String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> request = objectMapper.readValue(body, Map.class);
+ ConfigurationProfile profile = service.createConfigurationProfile(appId, request);
+ return Response.status(201).entity(profile).build();
+ }
+
+ @GET
+ @Path("/applications/{appId}/configurationprofiles/{profileId}")
+ public Response getConfigurationProfile(@PathParam("appId") String appId, @PathParam("profileId") String profileId) {
+ return Response.ok(service.getConfigurationProfile(appId, profileId)).build();
+ }
+
+ @GET
+ @Path("/applications/{appId}/configurationprofiles")
+ public Response listConfigurationProfiles(@PathParam("appId") String appId) {
+ List<ConfigurationProfile> profiles = service.listConfigurationProfiles(appId);
+ ObjectNode root = objectMapper.createObjectNode();
+ ArrayNode items = root.putArray("Items");
+ profiles.forEach(items::addPOJO);
+ return Response.ok(root).build();
+ }
+
+ // ──────────────────────────── Hosted Configuration Version ────────────────────────────
+
+ @POST
+ @Path("/applications/{appId}/configurationprofiles/{profileId}/hostedconfigurationversions")
+ @Consumes(MediaType.WILDCARD)
+ public Response createHostedConfigurationVersion(@PathParam("appId") String appId,
+ @PathParam("profileId") String profileId,
+ @HeaderParam("Content-Type") String contentType,
+ @HeaderParam("Description") String description,
+ byte[] content) {
+ HostedConfigurationVersion version = service.createHostedConfigurationVersion(appId, profileId, content, contentType, description);
+ return versionResponse(version, 201);
+ }
+
+ @GET
+ @Path("/applications/{appId}/configurationprofiles/{profileId}/hostedconfigurationversions/{versionNumber}")
+ public Response getHostedConfigurationVersion(@PathParam("appId") String appId,
+ @PathParam("profileId") String profileId,
+ @PathParam("versionNumber") int versionNumber) {
+ HostedConfigurationVersion version = service.getHostedConfigurationVersion(appId, profileId, versionNumber);
+ return versionResponse(version, 200);
+ }
+
+ private Response versionResponse(HostedConfigurationVersion v, int status) {
+ Response.ResponseBuilder rb = Response.status(status).entity(v.getContent());
+ rb.header("Application-Id", v.getApplicationId());
+ rb.header("Configuration-Profile-Id", v.getConfigurationProfileId());
+ rb.header("Version-Number", v.getVersionNumber());
+ rb.header("Content-Type", v.getContentType());
+ if (v.getDescription() != null) rb.header("Description", v.getDescription());
+ return rb.build();
+ }
+
+ // ──────────────────────────── Deployment Strategy ────────────────────────────
+
+ @POST
+ @Path("/deploymentstrategies")
+ public Response createDeploymentStrategy(String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> request = objectMapper.readValue(body, Map.class);
+ DeploymentStrategy strategy = service.createDeploymentStrategy(request);
+ return Response.status(201).entity(strategy).build();
+ }
+
+ @GET
+ @Path("/deploymentstrategies/{id}")
+ public Response getDeploymentStrategy(@PathParam("id") String id) {
+ return Response.ok(service.getDeploymentStrategy(id)).build();
+ }
+
+ // ──────────────────────────── Deployment ────────────────────────────
+
+ @POST
+ @Path("/applications/{appId}/environments/{envId}/deployments")
+ public Response startDeployment(@PathParam("appId") String appId, @PathParam("envId") String envId, String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> request = objectMapper.readValue(body, Map.class);
+ Deployment deployment = service.startDeployment(appId, envId, request);
+ return Response.status(201).entity(deployment).build();
+ }
+
+ @GET
+ @Path("/applications/{appId}/environments/{envId}/deployments/{deploymentNumber}")
+ public Response getDeployment(@PathParam("appId") String appId, @PathParam("envId") String envId, @PathParam("deploymentNumber") int deploymentNumber) {
+ return Response.ok(service.getDeployment(appId, envId, deploymentNumber)).build();
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigDataController.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigDataController.java
new file mode 100644
index 0000000000..51e8526bf0
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigDataController.java
@@ -0,0 +1,49 @@
+package io.github.hectorvent.floci.services.appconfig;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import io.github.hectorvent.floci.services.appconfig.AppConfigDataService.ConfigurationData;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.*;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+import org.jboss.logging.Logger;
+
+import java.io.IOException;
+import java.util.Map;
+
+@Path("/")
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class AppConfigDataController {
+ private static final Logger LOG = Logger.getLogger(AppConfigDataController.class);
+
+ private final AppConfigDataService service;
+ private final ObjectMapper objectMapper;
+
+ @Inject
+ public AppConfigDataController(AppConfigDataService service, ObjectMapper objectMapper) {
+ this.service = service;
+ this.objectMapper = objectMapper;
+ }
+
+ @POST
+ @Path("/configurationsessions")
+ public Response startConfigurationSession(String body) throws IOException {
+ @SuppressWarnings("unchecked")
+ Map<String, Object> request = objectMapper.readValue(body, Map.class);
+ String token = service.startConfigurationSession(request);
+ return Response.status(201).entity(Map.of("InitialConfigurationToken", token)).build();
+ }
+
+ @GET
+ @Path("/configuration")
+ public Response getLatestConfiguration(@QueryParam("configuration_token") String token) {
+ ConfigurationData data = service.getLatestConfiguration(token);
+ return Response.ok(data.content())
+ .header("Content-Type", data.contentType())
+ .header("Version-Label", data.configurationVersion())
+ .header("Next-Poll-Configuration-Token", data.nextPollConfigurationToken())
+ .header("Next-Poll-Interval-In-Seconds", 15)
+ .build();
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigDataService.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigDataService.java
new file mode 100644
index 0000000000..f8244d6ed4
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigDataService.java
@@ -0,0 +1,80 @@
+package io.github.hectorvent.floci.services.appconfig;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+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.appconfig.model.ConfigurationSession;
+import io.github.hectorvent.floci.services.appconfig.model.HostedConfigurationVersion;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import org.jboss.logging.Logger;
+
+import java.util.Map;
+import java.util.UUID;
+
+@ApplicationScoped
+public class AppConfigDataService {
+ private static final Logger LOG = Logger.getLogger(AppConfigDataService.class);
+
+ private final StorageBackend<String, ConfigurationSession> sessionStore;
+ private final AppConfigService appConfigService;
+
+ @Inject
+ public AppConfigDataService(StorageFactory storageFactory, AppConfigService appConfigService) {
+ this.sessionStore = storageFactory.create("appconfigdata", "appconfigdata-sessions.json", new TypeReference<>() {});
+ this.appConfigService = appConfigService;
+ }
+
+ public String startConfigurationSession(Map<String, Object> request) {
+ String appId = (String) request.get("ApplicationIdentifier");
+ String envId = (String) request.get("EnvironmentIdentifier");
+ String profileId = (String) request.get("ConfigurationProfileIdentifier");
+
+ // Validate resources exist
+ appConfigService.getEnvironment(appId, envId);
+ appConfigService.getConfigurationProfile(appId, profileId);
+
+ ConfigurationSession session = new ConfigurationSession();
+ session.setId(UUID.randomUUID().toString());
+ session.setApplicationId(appId);
+ session.setEnvironmentId(envId);
+ session.setConfigurationProfileId(profileId);
+ session.setRequiredMinimumPollIntervalInSeconds((Integer) request.getOrDefault("RequiredMinimumPollIntervalInSeconds", 15));
+ session.setCurrentToken(UUID.randomUUID().toString());
+
+ sessionStore.put(session.getCurrentToken(), session);
+ LOG.infov("Started AppConfigData session {0} for app {1}, env {2}, profile {3}", session.getId(), appId, envId, profileId);
+ return session.getCurrentToken();
+ }
+
+ public ConfigurationData getLatestConfiguration(String token) {
+ ConfigurationSession session = sessionStore.get(token)
+ .orElseThrow(() -> new AwsException("BadRequestException", "Invalid configuration token", 400));
+
+ String activeVersion = appConfigService.getActiveVersion(session.getEnvironmentId(), session.getConfigurationProfileId());
+
+ HostedConfigurationVersion version = null;
+ if (activeVersion != null) {
+ try {
+ version = appConfigService.getHostedConfigurationVersion(session.getApplicationId(), session.getConfigurationProfileId(), Integer.parseInt(activeVersion));
+ } catch (Exception e) {
+ LOG.warnv("Active version {0} not found for session {1}", activeVersion, session.getId());
+ }
+ }
+
+ // Generate next token
+ String nextToken = UUID.randomUUID().toString();
+ session.setCurrentToken(nextToken);
+ sessionStore.delete(token); // Old token is invalid
+ sessionStore.put(nextToken, session);
+
+ byte[] content = (version != null) ? version.getContent() : new byte[0];
+ String contentType = (version != null) ? version.getContentType() : "application/octet-stream";
+ String versionLabel = (version != null) ? String.valueOf(version.getVersionNumber()) : "";
+
+ return new ConfigurationData(content, contentType, versionLabel, nextToken);
+ }
+
+ public record ConfigurationData(byte[] content, String contentType, String configurationVersion, String nextPollConfigurationToken) {}
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigService.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigService.java
new file mode 100644
index 0000000000..ac2da68cd0
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/AppConfigService.java
@@ -0,0 +1,201 @@
+package io.github.hectorvent.floci.services.appconfig;
+
+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.appconfig.model.*;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import org.jboss.logging.Logger;
+
+import java.util.*;
+
+@ApplicationScoped
+public class AppConfigService {
+ private static final Logger LOG = Logger.getLogger(AppConfigService.class);
+
+ private final StorageBackend<String, Application> applicationStore;
+ private final StorageBackend<String, Environment> environmentStore;
+ private final StorageBackend<String, ConfigurationProfile> profileStore;
+ private final StorageBackend<String, DeploymentStrategy> strategyStore;
+ private final StorageBackend<String, HostedConfigurationVersion> versionStore;
+ private final StorageBackend<String, Deployment> deploymentStore;
+ private final StorageBackend<String, String> activeConfigStore; // envId::profileId -> versionNumber
+
+ @Inject
+ public AppConfigService(StorageFactory storageFactory, EmulatorConfig config) {
+ this.applicationStore = storageFactory.create("appconfig", "appconfig-applications.json", new TypeReference<>() {});
+ this.environmentStore = storageFactory.create("appconfig", "appconfig-environments.json", new TypeReference<>() {});
+ this.profileStore = storageFactory.create("appconfig", "appconfig-profiles.json", new TypeReference<>() {});
+ this.strategyStore = storageFactory.create("appconfig", "appconfig-strategies.json", new TypeReference<>() {});
+ this.versionStore = storageFactory.create("appconfig", "appconfig-versions.json", new TypeReference<>() {});
+ this.deploymentStore = storageFactory.create("appconfig", "appconfig-deployments.json", new TypeReference<>() {});
+ this.activeConfigStore = storageFactory.create("appconfig", "appconfig-active-configs.json", new TypeReference<>() {});
+ }
+
+ // ──────────────────────────── Application ────────────────────────────
+
+ public Application createApplication(Map<String, Object> request) {
+ Application app = new Application();
+ app.setId(shortId(7));
+ app.setName((String) request.get("Name"));
+ app.setDescription((String) request.get("Description"));
+ applicationStore.put(app.getId(), app);
+ return app;
+ }
+
+ public Application getApplication(String id) {
+ return applicationStore.get(id).orElseThrow(() -> new AwsException("ResourceNotFoundException", "Application not found", 404));
+ }
+
+ public List<Application> listApplications() {
+ return applicationStore.scan(k -> true);
+ }
+
+ public void deleteApplication(String id) {
+ applicationStore.delete(id);
+ }
+
+ // ──────────────────────────── Environment ────────────────────────────
+
+ public Environment createEnvironment(String appId, Map<String, Object> request) {
+ getApplication(appId);
+ Environment env = new Environment();
+ env.setId(shortId(7));
+ env.setApplicationId(appId);
+ env.setName((String) request.get("Name"));
+ env.setDescription((String) request.get("Description"));
+ env.setState("READY");
+ environmentStore.put(env.getId(), env);
+ return env;
+ }
+
+ public Environment getEnvironment(String appId, String envId) {
+ Environment env = environmentStore.get(envId).orElseThrow(() -> new AwsException("ResourceNotFoundException", "Environment not found", 404));
+ if (!env.getApplicationId().equals(appId)) throw new AwsException("ResourceNotFoundException", "Environment not found in this application", 404);
+ return env;
+ }
+
+ public List<Environment> listEnvironments(String appId) {
+ return environmentStore.scan(k -> true).stream()
+ .filter(e -> e.getApplicationId().equals(appId))
+ .toList();
+ }
+
+ // ──────────────────────────── Configuration Profile ────────────────────────────
+
+ public ConfigurationProfile createConfigurationProfile(String appId, Map<String, Object> request) {
+ getApplication(appId);
+ ConfigurationProfile profile = new ConfigurationProfile();
+ profile.setId(shortId(7));
+ profile.setApplicationId(appId);
+ profile.setName((String) request.get("Name"));
+ profile.setDescription((String) request.get("Description"));
+ profile.setLocationUri((String) request.get("LocationUri"));
+ profile.setType((String) request.get("Type"));
+ profileStore.put(profile.getId(), profile);
+ return profile;
+ }
+
+ public ConfigurationProfile getConfigurationProfile(String appId, String profileId) {
+ ConfigurationProfile profile = profileStore.get(profileId).orElseThrow(() -> new AwsException("ResourceNotFoundException", "Configuration profile not found", 404));
+ if (!profile.getApplicationId().equals(appId)) throw new AwsException("ResourceNotFoundException", "Profile not found in this application", 404);
+ return profile;
+ }
+
+ public List<ConfigurationProfile> listConfigurationProfiles(String appId) {
+ return profileStore.scan(k -> true).stream()
+ .filter(p -> p.getApplicationId().equals(appId))
+ .toList();
+ }
+
+ // ──────────────────────────── Hosted Configuration Version ────────────────────────────
+
+ public HostedConfigurationVersion createHostedConfigurationVersion(String appId, String profileId, byte[] content, String contentType, String description) {
+ getConfigurationProfile(appId, profileId);
+ String prefix = appId + "::" + profileId + "::";
+ int nextVersion = versionStore.scan(k -> k.startsWith(prefix))
+ .stream().mapToInt(HostedConfigurationVersion::getVersionNumber).max().orElse(0) + 1;
+
+ HostedConfigurationVersion version = new HostedConfigurationVersion();
+ version.setApplicationId(appId);
+ version.setConfigurationProfileId(profileId);
+ version.setVersionNumber(nextVersion);
+ version.setContent(content);
+ version.setContentType(contentType);
+ version.setDescription(description);
+
+ versionStore.put(prefix + nextVersion, version);
+ return version;
+ }
+
+ public HostedConfigurationVersion getHostedConfigurationVersion(String appId, String profileId, int versionNumber) {
+ return versionStore.get(appId + "::" + profileId + "::" + versionNumber)
+ .orElseThrow(() -> new AwsException("ResourceNotFoundException", "Hosted configuration version not found", 404));
+ }
+
+ // ──────────────────────────── Deployment Strategy ────────────────────────────
+
+ public DeploymentStrategy createDeploymentStrategy(Map<String, Object> request) {
+ DeploymentStrategy strategy = new DeploymentStrategy();
+ strategy.setId(shortId(7));
+ strategy.setName((String) request.get("Name"));
+ strategy.setDescription((String) request.get("Description"));
+ strategy.setDeploymentDurationInMinutes((Integer) request.getOrDefault("DeploymentDurationInMinutes", 0));
+ strategy.setGrowthFactor(((Number) request.getOrDefault("GrowthFactor", 100.0f)).floatValue());
+ strategy.setFinalBakeTimeInMinutes((Integer) request.getOrDefault("FinalBakeTimeInMinutes", 0));
+ strategy.setGrowthType((String) request.getOrDefault("GrowthType", "LINEAR"));
+ strategy.setReplicateTo((String) request.getOrDefault("ReplicateTo", "NONE"));
+ strategyStore.put(strategy.getId(), strategy);
+ return strategy;
+ }
+
+ public DeploymentStrategy getDeploymentStrategy(String id) {
+ return strategyStore.get(id).orElseThrow(() -> new AwsException("ResourceNotFoundException", "Deployment strategy not found", 404));
+ }
+
+ // ──────────────────────────── Deployment ────────────────────────────
+
+ public Deployment startDeployment(String appId, String envId, Map<String, Object> request) {
+ getEnvironment(appId, envId);
+ String profileId = (String) request.get("ConfigurationProfileId");
+ String version = (String) request.get("ConfigurationVersion");
+ String strategyId = (String) request.get("DeploymentStrategyId");
+
+ getConfigurationProfile(appId, profileId);
+ getDeploymentStrategy(strategyId);
+
+ Deployment deployment = new Deployment();
+ deployment.setApplicationId(appId);
+ deployment.setEnvironmentId(envId);
+ deployment.setConfigurationProfileId(profileId);
+ deployment.setConfigurationVersion(version);
+ deployment.setDeploymentStrategyId(strategyId);
+ deployment.setDeploymentNumber(deploymentStore.keys().size() + 1);
+ deployment.setState("COMPLETE"); // Synchronous immediate deployment
+ deployment.setDescription((String) request.get("Description"));
+
+ deploymentStore.put(appId + "::" + envId + "::" + deployment.getDeploymentNumber(), deployment);
+
+ // Update active configuration
+ activeConfigStore.put(envId + "::" + profileId, version);
+
+ LOG.infov("Started deployment for app {0}, env {1}, profile {2}, version {3}. State: COMPLETE", appId, envId, profileId, version);
+ return deployment;
+ }
+
+ public Deployment getDeployment(String appId, String envId, int deploymentNumber) {
+ return deploymentStore.get(appId + "::" + envId + "::" + deploymentNumber)
+ .orElseThrow(() -> new AwsException("ResourceNotFoundException", "Deployment not found", 404));
+ }
+
+ public String getActiveVersion(String envId, String profileId) {
+ return activeConfigStore.get(envId + "::" + profileId).orElse(null);
+ }
+
+ private static String shortId(int length) {
+ return UUID.randomUUID().toString().replace("-", "").substring(0, length);
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/model/Application.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/Application.java
new file mode 100644
index 0000000000..2e0fb8667a
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/Application.java
@@ -0,0 +1,27 @@
+package io.github.hectorvent.floci.services.appconfig.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Application {
+ @JsonProperty("Id")
+ private String id;
+ @JsonProperty("Name")
+ private String name;
+ @JsonProperty("Description")
+ private String description;
+
+ public Application() {}
+
+ 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 getDescription() { return description; }
+ public void setDescription(String description) { this.description = description; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/model/ConfigurationProfile.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/ConfigurationProfile.java
new file mode 100644
index 0000000000..ef7d6fa722
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/ConfigurationProfile.java
@@ -0,0 +1,42 @@
+package io.github.hectorvent.floci.services.appconfig.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ConfigurationProfile {
+ @JsonProperty("Id")
+ private String id;
+ @JsonProperty("ApplicationId")
+ private String applicationId;
+ @JsonProperty("Name")
+ private String name;
+ @JsonProperty("Description")
+ private String description;
+ @JsonProperty("LocationUri")
+ private String locationUri;
+ @JsonProperty("Type")
+ private String type; // AWS.AppConfig.FeatureFlags, AWS.Freeform
+
+ public ConfigurationProfile() {}
+
+ public String getId() { return id; }
+ public void setId(String id) { this.id = id; }
+
+ public String getApplicationId() { return applicationId; }
+ public void setApplicationId(String applicationId) { this.applicationId = applicationId; }
+
+ public String getName() { return name; }
+ public void setName(String name) { this.name = name; }
+
+ public String getDescription() { return description; }
+ public void setDescription(String description) { this.description = description; }
+
+ public String getLocationUri() { return locationUri; }
+ public void setLocationUri(String locationUri) { this.locationUri = locationUri; }
+
+ public String getType() { return type; }
+ public void setType(String type) { this.type = type; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/model/ConfigurationSession.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/ConfigurationSession.java
new file mode 100644
index 0000000000..0dd601a69a
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/ConfigurationSession.java
@@ -0,0 +1,39 @@
+package io.github.hectorvent.floci.services.appconfig.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ConfigurationSession {
+ private String id;
+ private String applicationId;
+ private String environmentId;
+ private String configurationProfileId;
+ private int requiredMinimumPollIntervalInSeconds;
+ private String currentToken;
+ private String lastConfigurationVersion;
+
+ public ConfigurationSession() {}
+
+ public String getId() { return id; }
+ public void setId(String id) { this.id = id; }
+
+ public String getApplicationId() { return applicationId; }
+ public void setApplicationId(String applicationId) { this.applicationId = applicationId; }
+
+ public String getEnvironmentId() { return environmentId; }
+ public void setEnvironmentId(String environmentId) { this.environmentId = environmentId; }
+
+ public String getConfigurationProfileId() { return configurationProfileId; }
+ public void setConfigurationProfileId(String configurationProfileId) { this.configurationProfileId = configurationProfileId; }
+
+ public int getRequiredMinimumPollIntervalInSeconds() { return requiredMinimumPollIntervalInSeconds; }
+ public void setRequiredMinimumPollIntervalInSeconds(int requiredMinimumPollIntervalInSeconds) { this.requiredMinimumPollIntervalInSeconds = requiredMinimumPollIntervalInSeconds; }
+
+ public String getCurrentToken() { return currentToken; }
+ public void setCurrentToken(String currentToken) { this.currentToken = currentToken; }
+
+ public String getLastConfigurationVersion() { return lastConfigurationVersion; }
+ public void setLastConfigurationVersion(String lastConfigurationVersion) { this.lastConfigurationVersion = lastConfigurationVersion; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/model/Deployment.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/Deployment.java
new file mode 100644
index 0000000000..ac7abfa480
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/Deployment.java
@@ -0,0 +1,57 @@
+package io.github.hectorvent.floci.services.appconfig.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Deployment {
+ @JsonProperty("ApplicationId")
+ private String applicationId;
+ @JsonProperty("EnvironmentId")
+ private String environmentId;
+ @JsonProperty("ConfigurationProfileId")
+ private String configurationProfileId;
+ @JsonProperty("DeploymentNumber")
+ private int deploymentNumber;
+ @JsonProperty("ConfigurationName")
+ private String configurationName;
+ @JsonProperty("ConfigurationVersion")
+ private String configurationVersion;
+ @JsonProperty("DeploymentStrategyId")
+ private String deploymentStrategyId;
+ @JsonProperty("State")
+ private String state; // BAKING, VALIDATING, DEPLOYING, COMPLETE, ROLLING_BACK, ROLLED_BACK
+ @JsonProperty("Description")
+ private String description;
+
+ public Deployment() {}
+
+ public String getApplicationId() { return applicationId; }
+ public void setApplicationId(String applicationId) { this.applicationId = applicationId; }
+
+ public String getEnvironmentId() { return environmentId; }
+ public void setEnvironmentId(String environmentId) { this.environmentId = environmentId; }
+
+ public String getConfigurationProfileId() { return configurationProfileId; }
+ public void setConfigurationProfileId(String configurationProfileId) { this.configurationProfileId = configurationProfileId; }
+
+ public int getDeploymentNumber() { return deploymentNumber; }
+ public void setDeploymentNumber(int deploymentNumber) { this.deploymentNumber = deploymentNumber; }
+
+ public String getConfigurationName() { return configurationName; }
+ public void setConfigurationName(String configurationName) { this.configurationName = configurationName; }
+
+ public String getConfigurationVersion() { return configurationVersion; }
+ public void setConfigurationVersion(String configurationVersion) { this.configurationVersion = configurationVersion; }
+
+ public String getDeploymentStrategyId() { return deploymentStrategyId; }
+ public void setDeploymentStrategyId(String deploymentStrategyId) { this.deploymentStrategyId = deploymentStrategyId; }
+
+ public String getState() { return state; }
+ public void setState(String state) { this.state = state; }
+
+ public String getDescription() { return description; }
+ public void setDescription(String description) { this.description = description; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/model/DeploymentStrategy.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/DeploymentStrategy.java
new file mode 100644
index 0000000000..31ce7425d7
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/DeploymentStrategy.java
@@ -0,0 +1,52 @@
+package io.github.hectorvent.floci.services.appconfig.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class DeploymentStrategy {
+ @JsonProperty("Id")
+ private String id;
+ @JsonProperty("Name")
+ private String name;
+ @JsonProperty("Description")
+ private String description;
+ @JsonProperty("DeploymentDurationInMinutes")
+ private int deploymentDurationInMinutes;
+ @JsonProperty("GrowthFactor")
+ private float growthFactor;
+ @JsonProperty("FinalBakeTimeInMinutes")
+ private int finalBakeTimeInMinutes;
+ @JsonProperty("GrowthType")
+ private String growthType; // LINEAR, EXPONENTIAL
+ @JsonProperty("ReplicateTo")
+ private String replicateTo; // NONE, SSM_DOCUMENT
+
+ public DeploymentStrategy() {}
+
+ 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 getDescription() { return description; }
+ public void setDescription(String description) { this.description = description; }
+
+ public int getDeploymentDurationInMinutes() { return deploymentDurationInMinutes; }
+ public void setDeploymentDurationInMinutes(int deploymentDurationInMinutes) { this.deploymentDurationInMinutes = deploymentDurationInMinutes; }
+
+ public float getGrowthFactor() { return growthFactor; }
+ public void setGrowthFactor(float growthFactor) { this.growthFactor = growthFactor; }
+
+ public int getFinalBakeTimeInMinutes() { return finalBakeTimeInMinutes; }
+ public void setFinalBakeTimeInMinutes(int finalBakeTimeInMinutes) { this.finalBakeTimeInMinutes = finalBakeTimeInMinutes; }
+
+ public String getGrowthType() { return growthType; }
+ public void setGrowthType(String growthType) { this.growthType = growthType; }
+
+ public String getReplicateTo() { return replicateTo; }
+ public void setReplicateTo(String replicateTo) { this.replicateTo = replicateTo; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/model/Environment.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/Environment.java
new file mode 100644
index 0000000000..6742fadf58
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/Environment.java
@@ -0,0 +1,37 @@
+package io.github.hectorvent.floci.services.appconfig.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class Environment {
+ @JsonProperty("Id")
+ private String id;
+ @JsonProperty("ApplicationId")
+ private String applicationId;
+ @JsonProperty("Name")
+ private String name;
+ @JsonProperty("Description")
+ private String description;
+ @JsonProperty("State")
+ private String state; // READY, DEPLOYING, ROLLING_BACK, ROLLED_BACK
+
+ public Environment() {}
+
+ public String getId() { return id; }
+ public void setId(String id) { this.id = id; }
+
+ public String getApplicationId() { return applicationId; }
+ public void setApplicationId(String applicationId) { this.applicationId = applicationId; }
+
+ public String getName() { return name; }
+ public void setName(String name) { this.name = name; }
+
+ public String getDescription() { return description; }
+ public void setDescription(String description) { this.description = description; }
+
+ public String getState() { return state; }
+ public void setState(String state) { this.state = state; }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/appconfig/model/HostedConfigurationVersion.java b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/HostedConfigurationVersion.java
new file mode 100644
index 0000000000..79c2d7850c
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/appconfig/model/HostedConfigurationVersion.java
@@ -0,0 +1,42 @@
+package io.github.hectorvent.floci.services.appconfig.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import io.quarkus.runtime.annotations.RegisterForReflection;
+
+@RegisterForReflection
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class HostedConfigurationVersion {
+ @JsonProperty("ApplicationId")
+ private String applicationId;
+ @JsonProperty("ConfigurationProfileId")
+ private String configurationProfileId;
+ @JsonProperty("VersionNumber")
+ private int versionNumber;
+ @JsonProperty("Description")
+ private String description;
+ @JsonProperty("Content")
+ private byte[] content;
+ @JsonProperty("ContentType")
+ private String contentType;
+
+ public HostedConfigurationVersion() {}
+
+ public String getApplicationId() { return applicationId; }
+ public void setApplicationId(String applicationId) { this.applicationId = applicationId; }
+
+ public String getConfigurationProfileId() { return configurationProfileId; }
+ public void setConfigurationProfileId(String configurationProfileId) { this.configurationProfileId = configurationProfileId; }
+
+ public int getVersionNumber() { return versionNumber; }
+ public void setVersionNumber(int versionNumber) { this.versionNumber = versionNumber; }
+
+ public String getDescription() { return description; }
+ public void setDescription(String description) { this.description = description; }
+
+ public byte[] getContent() { return content; }
+ public void setContent(byte[] content) { this.content = content; }
+
+ public String getContentType() { return contentType; }
+ public void setContentType(String contentType) { this.contentType = contentType; }
+}
diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml
index 8adc906a0f..367b4ecc65 100644
--- a/src/main/resources/application.yml
+++ b/src/main/resources/application.yml
@@ -133,3 +133,7 @@ floci:
ecs:
enabled: true
mock: false
+ appconfig:
+ enabled: true
+ appconfigdata:
+ enabled: true
diff --git a/src/test/java/io/github/hectorvent/floci/lifecycle/HealthControllerIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/lifecycle/HealthControllerIntegrationTest.java
index feee296431..4c13d49317 100644
--- a/src/test/java/io/github/hectorvent/floci/lifecycle/HealthControllerIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/lifecycle/HealthControllerIntegrationTest.java
@@ -40,7 +40,9 @@ class HealthControllerIntegrationTest {
"email": "running",
"es": "running",
"ec2": "running",
- "ecs": "running"
+ "ecs": "running",
+ "appconfig": "running",
+ "appconfigdata": "running"
},
"edition": "floci-always-free",
"version": "dev"
diff --git a/src/test/java/io/github/hectorvent/floci/services/appconfig/AppConfigIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/appconfig/AppConfigIntegrationTest.java
new file mode 100644
index 0000000000..9e0cc4db41
--- /dev/null
+++ b/src/test/java/io/github/hectorvent/floci/services/appconfig/AppConfigIntegrationTest.java
@@ -0,0 +1,125 @@
+package io.github.hectorvent.floci.services.appconfig;
+
+import io.github.hectorvent.floci.testing.RestAssuredJsonUtils;
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.http.ContentType;
+import org.junit.jupiter.api.BeforeAll;
+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.Matchers.*;
+
+@QuarkusTest
+@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
+class AppConfigIntegrationTest {
+
+ private static String appId;
+ private static String envId;
+ private static String profileId;
+ private static String strategyId;
+ private static String configToken;
+
+ @BeforeAll
+ static void setup() {
+ RestAssuredJsonUtils.configureAwsContentTypes();
+ }
+
+ @Test @Order(1)
+ void createApplication() {
+ appId = given()
+ .contentType(ContentType.JSON)
+ .body("{\"Name\": \"test-app\", \"Description\": \"Test App\"}")
+ .when().post("/applications")
+ .then()
+ .statusCode(201)
+ .body("Name", equalTo("test-app"))
+ .extract().path("Id");
+ }
+
+ @Test @Order(2)
+ void createEnvironment() {
+ envId = given()
+ .contentType(ContentType.JSON)
+ .body("{\"Name\": \"test-env\"}")
+ .when().post("/applications/" + appId + "/environments")
+ .then()
+ .statusCode(201)
+ .body("Name", equalTo("test-env"))
+ .extract().path("Id");
+ }
+
+ @Test @Order(3)
+ void createConfigurationProfile() {
+ profileId = given()
+ .contentType(ContentType.JSON)
+ .body("{\"Name\": \"test-profile\", \"LocationUri\": \"hosted\", \"Type\": \"AWS.Freeform\"}")
+ .when().post("/applications/" + appId + "/configurationprofiles")
+ .then()
+ .statusCode(201)
+ .body("Name", equalTo("test-profile"))
+ .extract().path("Id");
+ }
+
+ @Test @Order(4)
+ void createHostedConfigurationVersion() {
+ given()
+ .header("Content-Type", "application/json")
+ .header("Description", "v1")
+ .body("{\"foo\": \"bar\"}".getBytes())
+ .when().post("/applications/" + appId + "/configurationprofiles/" + profileId + "/hostedconfigurationversions")
+ .then()
+ .statusCode(201)
+ .header("Version-Number", equalTo("1"));
+ }
+
+ @Test @Order(5)
+ void createDeploymentStrategy() {
+ strategyId = given()
+ .contentType(ContentType.JSON)
+ .body("{\"Name\": \"immediate\", \"DeploymentDurationInMinutes\": 0, \"GrowthFactor\": 100, \"FinalBakeTimeInMinutes\": 0}")
+ .when().post("/deploymentstrategies")
+ .then()
+ .statusCode(201)
+ .body("Name", equalTo("immediate"))
+ .extract().path("Id");
+ }
+
+ @Test @Order(6)
+ void startDeployment() {
+ given()
+ .contentType(ContentType.JSON)
+ .body("{\"ConfigurationProfileId\": \"" + profileId + "\", \"ConfigurationVersion\": \"1\", \"DeploymentStrategyId\": \"" + strategyId + "\"}")
+ .when().post("/applications/" + appId + "/environments/" + envId + "/deployments")
+ .then()
+ .statusCode(201)
+ .body("State", equalTo("COMPLETE"));
+ }
+
+ @Test @Order(7)
+ void startConfigurationSession() {
+ configToken = given()
+ .contentType(ContentType.JSON)
+ .body("{\"ApplicationIdentifier\": \"" + appId + "\", \"EnvironmentIdentifier\": \"" + envId + "\", \"ConfigurationProfileIdentifier\": \"" + profileId + "\"}")
+ .when().post("/configurationsessions")
+ .then()
+ .statusCode(201)
+ .body("InitialConfigurationToken", notNullValue())
+ .extract().path("InitialConfigurationToken");
+ }
+
+ @Test @Order(8)
+ void getLatestConfiguration() {
+ given()
+ .queryParam("configuration_token", configToken)
+ .when().get("/configuration")
+ .then()
+ .statusCode(200)
+ .header("Content-Type", startsWith("application/json"))
+ .header("Version-Label", equalTo("1"))
+ .header("Next-Poll-Configuration-Token", notNullValue())
+ .body("foo", equalTo("bar"));
+ }
+}
diff --git a/src/test/resources/application.yml b/src/test/resources/application.yml
index 8248591d6a..a0aa6f870c 100644
--- a/src/test/resources/application.yml
+++ b/src/test/resources/application.yml
@@ -105,4 +105,8 @@ floci:
enabled: true
ecs:
enabled: true
- mock: true
\ No newline at end of file
+ mock: true
+ appconfig:
+ enabled: true
+ appconfigdata:
+ enabled: true
\ No newline at end of file