feat(config): add AWS Config service emulation (#934)

* feat(config): add AWS Config service emulation (#913)

* docs: add AWS Config service page and align service counts across all docs

Add docs/services/config.md with all 20 supported actions, CLI examples,
and configuration reference. Add 5 services that had doc pages but were
missing from the service matrix (Textract, Pricing, Cost Explorer, CUR,
BCM Data Exports). Reconcile service count to 51 across README,
docs/index.md, and docs/services/index.md.
This commit is contained in:
Federico Mariani authored and GitHub committed 2026-05-20 17:15:38 -05:00
1 parent 9bdb5436f0
commit 96a6fa6517
23 files changed
+1590 -7

No files matched your search

@@ -312,6 +312,7 @@ public interface EmulatorConfig {
CostExplorerServiceConfig ce();
CurServiceConfig cur();
BcmDataExportsServiceConfig bcmDataExports();
ConfigServiceConfig configservice();
}
interface TransferServiceConfig {
@@ -344,6 +345,11 @@ public interface EmulatorConfig {
String defaultNameserver4();
}
interface ConfigServiceConfig {
@WithDefault("true")
boolean enabled();
}
interface AutoScalingServiceConfig {
@WithDefault("true")
boolean enabled();
@@ -14,6 +14,7 @@ import io.github.hectorvent.floci.services.glue.GlueJsonHandler;
import io.github.hectorvent.floci.services.resourcegroupstagging.ResourceGroupsTaggingJsonHandler;
import io.github.hectorvent.floci.services.bcmdataexports.BcmDataExportsJsonHandler;
import io.github.hectorvent.floci.services.ce.CostExplorerJsonHandler;
import io.github.hectorvent.floci.services.configservice.ConfigServiceJsonHandler;
import io.github.hectorvent.floci.services.cur.CurJsonHandler;
import io.github.hectorvent.floci.services.pricing.PricingJsonHandler;
import io.github.hectorvent.floci.services.textract.TextractJsonHandler;
@@ -76,6 +77,7 @@ public class AwsJson11Controller {
private final CostExplorerJsonHandler costExplorerJsonHandler;
private final CurJsonHandler curJsonHandler;
private final BcmDataExportsJsonHandler bcmDataExportsJsonHandler;
private final ConfigServiceJsonHandler configServiceJsonHandler;
@Inject
public AwsJson11Controller(ObjectMapper objectMapper, ResolvedServiceCatalog catalog,
@@ -100,7 +102,8 @@ public class AwsJson11Controller {
TranscribeJsonHandler transcribeJsonHandler,
CostExplorerJsonHandler costExplorerJsonHandler,
CurJsonHandler curJsonHandler,
BcmDataExportsJsonHandler bcmDataExportsJsonHandler) {
BcmDataExportsJsonHandler bcmDataExportsJsonHandler,
ConfigServiceJsonHandler configServiceJsonHandler) {
this.objectMapper = objectMapper;
this.catalog = catalog;
this.regionResolver = regionResolver;
@@ -129,6 +132,7 @@ public class AwsJson11Controller {
this.costExplorerJsonHandler = costExplorerJsonHandler;
this.curJsonHandler = curJsonHandler;
this.bcmDataExportsJsonHandler = bcmDataExportsJsonHandler;
this.configServiceJsonHandler = configServiceJsonHandler;
}
@POST
@@ -182,6 +186,7 @@ public class AwsJson11Controller {
case "ce" -> costExplorerJsonHandler.handle(action, request, region);
case "cur" -> curJsonHandler.handle(action, request, region);
case "bcm-data-exports" -> bcmDataExportsJsonHandler.handle(action, request, region);
case "config" -> configServiceJsonHandler.handle(action, request, region);
default -> null;
};
// catalog.matchTarget is protocol-agnostic: a JSON 1.0 target
@@ -224,6 +224,10 @@ public class ResolvedServiceCatalog {
null, null, 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("CodeDeploy_20141006."), Set.of("codedeploy"), Set.of(), Set.of()),
descriptor("config", "configservice", config.services().configservice().enabled(), true,
null, null, 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("StarlingDoveService."), Set.of("config"), Set.of(), Set.of()),
descriptor("autoscaling", "autoscaling", config.services().autoscaling().enabled(), true,
"autoscaling", config.storage().mode(), 5000L, AwsNamespaces.AUTOSCALING, ServiceProtocol.QUERY,
protocols(ServiceProtocol.QUERY),
@@ -0,0 +1,316 @@
package io.github.hectorvent.floci.services.configservice;
import io.github.hectorvent.floci.core.common.AwsArnUtils;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.services.configservice.model.ConfigRule;
import io.github.hectorvent.floci.services.configservice.model.ConfigRuleEvaluationStatus;
import io.github.hectorvent.floci.services.configservice.model.ConfigRuleSource;
import io.github.hectorvent.floci.services.configservice.model.ConfigurationRecorder;
import io.github.hectorvent.floci.services.configservice.model.ConfigurationRecorderStatus;
import io.github.hectorvent.floci.services.configservice.model.ConformancePack;
import io.github.hectorvent.floci.services.configservice.model.ConformancePackStatusDetail;
import io.github.hectorvent.floci.services.configservice.model.DeliveryChannel;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@ApplicationScoped
public class AwsConfigService {
private final RegionResolver regionResolver;
private final ConcurrentHashMap<String, ConcurrentHashMap<String, ConfigRule>> configRules = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, ConcurrentHashMap<String, ConformancePack>> conformancePacks = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, ConfigurationRecorder> configurationRecorders = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, Boolean> recorderRunning = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, Long> recorderLastStartTime = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, Long> recorderLastStopTime = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, DeliveryChannel> deliveryChannels = new ConcurrentHashMap<>();
private final ConcurrentHashMap<String, Map<String, String>> tags = new ConcurrentHashMap<>();
@Inject
public AwsConfigService(RegionResolver regionResolver) {
this.regionResolver = regionResolver;
}
// --- Config Rules ---
public ConfigRule putConfigRule(String region, String ruleName, ConfigRuleSource source) {
ConcurrentHashMap<String, ConfigRule> store = rulesFor(region);
ConfigRule existing = store.get(ruleName);
if (existing != null) {
ConfigRule updated = new ConfigRule(existing.configRuleName(), existing.configRuleArn(),
existing.configRuleId(), existing.configRuleState(), source);
store.put(ruleName, updated);
return updated;
}
String ruleId = "config-rule-" + shortId();
String ruleArn = AwsArnUtils.Arn.of("config", region, regionResolver.getAccountId(),
"config-rule/" + ruleId).toString();
ConfigRule rule = new ConfigRule(ruleName, ruleArn, ruleId, "ACTIVE", source);
store.put(ruleName, rule);
return rule;
}
public void deleteConfigRule(String region, String ruleName) {
ConcurrentHashMap<String, ConfigRule> store = rulesFor(region);
if (store.remove(ruleName) == null) {
throw new AwsException("NoSuchConfigRuleException",
"The ConfigRule provided in the request is invalid. " +
"Please check the configRule name.", 400);
}
}
public List<ConfigRule> describeConfigRules(String region, List<String> ruleNames) {
ConcurrentHashMap<String, ConfigRule> store = rulesFor(region);
if (ruleNames == null || ruleNames.isEmpty()) {
return new ArrayList<>(store.values());
}
List<ConfigRule> result = new ArrayList<>();
for (String name : ruleNames) {
ConfigRule rule = store.get(name);
if (rule != null) {
result.add(rule);
}
}
return result;
}
public List<ConfigRuleEvaluationStatus> describeConfigRuleEvaluationStatus(String region, List<String> ruleNames) {
List<ConfigRule> rules = describeConfigRules(region, ruleNames);
List<ConfigRuleEvaluationStatus> result = new ArrayList<>();
for (ConfigRule rule : rules) {
result.add(new ConfigRuleEvaluationStatus(
rule.configRuleName(),
rule.configRuleArn(),
rule.configRuleId(),
true));
}
return result;
}
public void startConfigRulesEvaluation(String region, List<String> ruleNames) {
ConcurrentHashMap<String, ConfigRule> store = rulesFor(region);
for (String name : ruleNames) {
if (!store.containsKey(name)) {
throw new AwsException("NoSuchConfigRuleException",
"The ConfigRule provided in the request is invalid. " +
"Please check the configRule name.", 400);
}
}
}
// --- Configuration Recorder ---
public void putConfigurationRecorder(String region, ConfigurationRecorder recorder) {
String name = (recorder.name() == null || recorder.name().isEmpty()) ? "default" : recorder.name();
ConfigurationRecorder stored = new ConfigurationRecorder(name, recorder.roleARN(), recorder.recordingGroup());
configurationRecorders.put(region, stored);
}
public List<ConfigurationRecorder> describeConfigurationRecorders(String region, List<String> names) {
ConfigurationRecorder recorder = configurationRecorders.get(region);
if (recorder == null) {
if (names != null && !names.isEmpty()) {
throw new AwsException("NoSuchConfigurationRecorderException",
"Cannot find configuration recorder with the specified name.", 400);
}
return Collections.emptyList();
}
if (names != null && !names.isEmpty()) {
for (String name : names) {
if (!name.equals(recorder.name())) {
throw new AwsException("NoSuchConfigurationRecorderException",
"Cannot find configuration recorder with the specified name.", 400);
}
}
}
return List.of(recorder);
}
public void startConfigurationRecorder(String region, String name) {
ConfigurationRecorder recorder = configurationRecorders.get(region);
if (recorder == null || !recorder.name().equals(name)) {
throw new AwsException("NoSuchConfigurationRecorderException",
"Cannot find configuration recorder with the specified name.", 400);
}
recorderRunning.put(region, true);
recorderLastStartTime.put(region, System.currentTimeMillis() / 1000);
}
public void stopConfigurationRecorder(String region, String name) {
ConfigurationRecorder recorder = configurationRecorders.get(region);
if (recorder == null || !recorder.name().equals(name)) {
throw new AwsException("NoSuchConfigurationRecorderException",
"Cannot find configuration recorder with the specified name.", 400);
}
recorderRunning.put(region, false);
recorderLastStopTime.put(region, System.currentTimeMillis() / 1000);
}
public List<ConfigurationRecorderStatus> describeConfigurationRecorderStatus(String region, List<String> names) {
ConfigurationRecorder recorder = configurationRecorders.get(region);
if (recorder == null) {
if (names != null && !names.isEmpty()) {
throw new AwsException("NoSuchConfigurationRecorderException",
"Cannot find configuration recorder with the specified name.", 400);
}
return Collections.emptyList();
}
if (names != null && !names.isEmpty()) {
for (String name : names) {
if (!name.equals(recorder.name())) {
throw new AwsException("NoSuchConfigurationRecorderException",
"Cannot find configuration recorder with the specified name.", 400);
}
}
}
ConfigurationRecorderStatus status = new ConfigurationRecorderStatus(
recorder.name(),
recorderRunning.getOrDefault(region, false),
recorderLastStartTime.containsKey(region) ? "SUCCESS" : "Pending",
recorderLastStartTime.get(region),
recorderLastStopTime.get(region));
return List.of(status);
}
// --- Delivery Channel ---
public void putDeliveryChannel(String region, DeliveryChannel channel) {
if (!configurationRecorders.containsKey(region)) {
throw new AwsException("NoAvailableConfigurationRecorderException",
"There are no configuration recorders available to provide the resource count.", 400);
}
String name = (channel.name() == null || channel.name().isEmpty()) ? "default" : channel.name();
DeliveryChannel stored = new DeliveryChannel(name, channel.s3BucketName(), channel.s3KeyPrefix(),
channel.s3KmsKeyArn(), channel.snsTopicARN(), channel.configSnapshotDeliveryProperties());
deliveryChannels.put(region, stored);
}
public List<DeliveryChannel> describeDeliveryChannels(String region, List<String> names) {
DeliveryChannel channel = deliveryChannels.get(region);
if (channel == null) {
if (names != null && !names.isEmpty()) {
throw new AwsException("NoSuchDeliveryChannelException",
"Cannot find delivery channel with the specified name.", 400);
}
return Collections.emptyList();
}
if (names != null && !names.isEmpty()) {
for (String name : names) {
if (!name.equals(channel.name())) {
throw new AwsException("NoSuchDeliveryChannelException",
"Cannot find delivery channel with the specified name.", 400);
}
}
}
return List.of(channel);
}
// --- Conformance Packs ---
public ConformancePack putConformancePack(String region, String packName,
String templateS3Uri, String templateBody) {
ConcurrentHashMap<String, ConformancePack> store = packsFor(region);
ConformancePack existing = store.get(packName);
if (existing != null) {
ConformancePack updated = new ConformancePack(existing.conformancePackName(), existing.conformancePackArn(),
existing.conformancePackId(), templateS3Uri, templateBody);
store.put(packName, updated);
return updated;
}
String packId = "conformance-pack-" + shortId();
String packArn = AwsArnUtils.Arn.of("config", region, regionResolver.getAccountId(),
"conformance-pack/" + packName + "/" + packId).toString();
ConformancePack pack = new ConformancePack(packName, packArn, packId, templateS3Uri, templateBody);
store.put(packName, pack);
return pack;
}
public void deleteConformancePack(String region, String packName) {
ConcurrentHashMap<String, ConformancePack> store = packsFor(region);
if (store.remove(packName) == null) {
throw new AwsException("NoSuchConformancePackException",
"Conformance pack '" + packName + "' does not exist.", 400);
}
}
public List<ConformancePack> describeConformancePacks(String region, List<String> names) {
ConcurrentHashMap<String, ConformancePack> store = packsFor(region);
if (names == null || names.isEmpty()) {
return new ArrayList<>(store.values());
}
List<ConformancePack> result = new ArrayList<>();
for (String name : names) {
ConformancePack pack = store.get(name);
if (pack == null) {
throw new AwsException("NoSuchConformancePackException",
"Conformance pack '" + name + "' does not exist.", 400);
}
result.add(pack);
}
return result;
}
public List<ConformancePackStatusDetail> describeConformancePackStatus(String region, List<String> names) {
List<ConformancePack> packs = describeConformancePacks(region, names);
List<ConformancePackStatusDetail> result = new ArrayList<>();
for (ConformancePack pack : packs) {
result.add(new ConformancePackStatusDetail(
pack.conformancePackName(),
pack.conformancePackId(),
pack.conformancePackArn(),
"CREATE_SUCCESSFUL",
System.currentTimeMillis() / 1000));
}
return result;
}
// --- Tagging ---
public void tagResource(String arn, List<Map<String, String>> tagList) {
Map<String, String> tagMap = tags.computeIfAbsent(arn, k -> new ConcurrentHashMap<>());
for (Map<String, String> t : tagList) {
tagMap.put(t.get("Key"), t.get("Value"));
}
}
public void untagResource(String arn, List<String> tagKeys) {
Map<String, String> tagMap = tags.get(arn);
if (tagMap != null) {
tagKeys.forEach(tagMap::remove);
}
}
public List<Map<String, String>> listTagsForResource(String arn) {
Map<String, String> tagMap = tags.getOrDefault(arn, Map.of());
return tagMap.entrySet().stream()
.map(e -> Map.of("Key", e.getKey(), "Value", e.getValue()))
.collect(Collectors.toList());
}
// --- Helpers ---
private ConcurrentHashMap<String, ConfigRule> rulesFor(String region) {
return configRules.computeIfAbsent(region, r -> new ConcurrentHashMap<>());
}
private ConcurrentHashMap<String, ConformancePack> packsFor(String region) {
return conformancePacks.computeIfAbsent(region, r -> new ConcurrentHashMap<>());
}
private static String shortId() {
return UUID.randomUUID().toString().replace("-", "").substring(0, 12);
}
}
@@ -0,0 +1,242 @@
package io.github.hectorvent.floci.services.configservice;
import com.fasterxml.jackson.databind.JsonNode;
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.services.configservice.model.ConfigRule;
import io.github.hectorvent.floci.services.configservice.model.ConfigRuleEvaluationStatus;
import io.github.hectorvent.floci.services.configservice.model.ConfigRuleSource;
import io.github.hectorvent.floci.services.configservice.model.ConfigurationRecorder;
import io.github.hectorvent.floci.services.configservice.model.ConfigurationRecorderStatus;
import io.github.hectorvent.floci.services.configservice.model.ConformancePack;
import io.github.hectorvent.floci.services.configservice.model.ConformancePackStatusDetail;
import io.github.hectorvent.floci.services.configservice.model.DeliveryChannel;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ApplicationScoped
public class ConfigServiceJsonHandler {
private final AwsConfigService service;
private final ObjectMapper mapper;
@Inject
public ConfigServiceJsonHandler(AwsConfigService service, ObjectMapper mapper) {
this.service = service;
this.mapper = mapper;
}
public Response handle(String action, JsonNode request, String region) throws Exception {
return switch (action) {
case "PutConfigRule" -> putConfigRule(request, region);
case "DeleteConfigRule" -> deleteConfigRule(request, region);
case "DescribeConfigRules" -> describeConfigRules(request, region);
case "DescribeComplianceByConfigRule" -> describeComplianceByConfigRule(request, region);
case "DescribeConfigRuleEvaluationStatus" -> describeConfigRuleEvaluationStatus(request, region);
case "StartConfigRulesEvaluation" -> startConfigRulesEvaluation(request, region);
case "PutConformancePack" -> putConformancePack(request, region);
case "DeleteConformancePack" -> deleteConformancePack(request, region);
case "DescribeConformancePacks" -> describeConformancePacks(request, region);
case "DescribeConformancePackStatus" -> describeConformancePackStatus(request, region);
case "PutConfigurationRecorder" -> putConfigurationRecorder(request, region);
case "DescribeConfigurationRecorders" -> describeConfigurationRecorders(request, region);
case "StartConfigurationRecorder" -> startConfigurationRecorder(request, region);
case "StopConfigurationRecorder" -> stopConfigurationRecorder(request, region);
case "DescribeConfigurationRecorderStatus" -> describeConfigurationRecorderStatus(request, region);
case "PutDeliveryChannel" -> putDeliveryChannel(request, region);
case "DescribeDeliveryChannels" -> describeDeliveryChannels(request, region);
case "TagResource" -> tagResource(request);
case "UntagResource" -> untagResource(request);
case "ListTagsForResource" -> listTagsForResource(request);
default -> throw new io.github.hectorvent.floci.core.common.AwsException(
"InvalidAction", "Could not find operation " + action, 400);
};
}
// --- Config Rules ---
private Response putConfigRule(JsonNode req, String region) {
JsonNode ruleNode = req.path("ConfigRule");
String ruleName = ruleNode.path("ConfigRuleName").asText(null);
JsonNode sourceNode = ruleNode.path("Source");
ConfigRuleSource source = new ConfigRuleSource(
sourceNode.path("Owner").asText(null),
sourceNode.path("SourceIdentifier").asText(null));
service.putConfigRule(region, ruleName, source);
return Response.ok(mapper.createObjectNode()).build();
}
private Response deleteConfigRule(JsonNode req, String region) {
String ruleName = req.path("ConfigRuleName").asText(null);
service.deleteConfigRule(region, ruleName);
return Response.ok(mapper.createObjectNode()).build();
}
private Response describeConfigRules(JsonNode req, String region) {
List<String> ruleNames = extractStringList(req, "ConfigRuleNames");
List<ConfigRule> rules = service.describeConfigRules(region, ruleNames);
ObjectNode resp = mapper.createObjectNode();
resp.set("ConfigRules", mapper.valueToTree(rules));
return Response.ok(resp).build();
}
private Response describeComplianceByConfigRule(JsonNode req, String region) {
List<String> ruleNames = extractStringList(req, "ConfigRuleNames");
List<ConfigRule> rules = service.describeConfigRules(region, ruleNames);
ObjectNode resp = mapper.createObjectNode();
ArrayNode arr = resp.putArray("ComplianceByConfigRules");
for (ConfigRule rule : rules) {
ObjectNode entry = mapper.createObjectNode();
entry.put("ConfigRuleName", rule.configRuleName());
ObjectNode compliance = mapper.createObjectNode();
compliance.put("ComplianceType", "INSUFFICIENT_DATA");
entry.set("Compliance", compliance);
arr.add(entry);
}
return Response.ok(resp).build();
}
private Response describeConfigRuleEvaluationStatus(JsonNode req, String region) {
List<String> ruleNames = extractStringList(req, "ConfigRuleNames");
List<ConfigRuleEvaluationStatus> statuses = service.describeConfigRuleEvaluationStatus(region, ruleNames);
ObjectNode resp = mapper.createObjectNode();
resp.set("ConfigRulesEvaluationStatus", mapper.valueToTree(statuses));
return Response.ok(resp).build();
}
private Response startConfigRulesEvaluation(JsonNode req, String region) {
List<String> ruleNames = extractStringList(req, "ConfigRuleNames");
service.startConfigRulesEvaluation(region, ruleNames);
return Response.ok(mapper.createObjectNode()).build();
}
// --- Configuration Recorder ---
private Response putConfigurationRecorder(JsonNode req, String region) throws Exception {
ConfigurationRecorder recorder = mapper.treeToValue(req.path("ConfigurationRecorder"), ConfigurationRecorder.class);
service.putConfigurationRecorder(region, recorder);
return Response.ok(mapper.createObjectNode()).build();
}
private Response describeConfigurationRecorders(JsonNode req, String region) {
List<String> names = extractStringList(req, "ConfigurationRecorderNames");
List<ConfigurationRecorder> recorders = service.describeConfigurationRecorders(region, names);
ObjectNode resp = mapper.createObjectNode();
resp.set("ConfigurationRecorders", mapper.valueToTree(recorders));
return Response.ok(resp).build();
}
private Response startConfigurationRecorder(JsonNode req, String region) {
String name = req.path("ConfigurationRecorderName").asText(null);
service.startConfigurationRecorder(region, name);
return Response.ok(mapper.createObjectNode()).build();
}
private Response stopConfigurationRecorder(JsonNode req, String region) {
String name = req.path("ConfigurationRecorderName").asText(null);
service.stopConfigurationRecorder(region, name);
return Response.ok(mapper.createObjectNode()).build();
}
private Response describeConfigurationRecorderStatus(JsonNode req, String region) {
List<String> names = extractStringList(req, "ConfigurationRecorderNames");
List<ConfigurationRecorderStatus> statuses = service.describeConfigurationRecorderStatus(region, names);
ObjectNode resp = mapper.createObjectNode();
resp.set("ConfigurationRecordersStatus", mapper.valueToTree(statuses));
return Response.ok(resp).build();
}
// --- Delivery Channel ---
private Response putDeliveryChannel(JsonNode req, String region) throws Exception {
DeliveryChannel channel = mapper.treeToValue(req.path("DeliveryChannel"), DeliveryChannel.class);
service.putDeliveryChannel(region, channel);
return Response.ok(mapper.createObjectNode()).build();
}
private Response describeDeliveryChannels(JsonNode req, String region) {
List<String> names = extractStringList(req, "DeliveryChannelNames");
List<DeliveryChannel> channels = service.describeDeliveryChannels(region, names);
ObjectNode resp = mapper.createObjectNode();
resp.set("DeliveryChannels", mapper.valueToTree(channels));
return Response.ok(resp).build();
}
// --- Conformance Packs ---
private Response putConformancePack(JsonNode req, String region) {
String packName = req.path("ConformancePackName").asText(null);
String templateS3Uri = req.has("TemplateS3Uri") ? req.path("TemplateS3Uri").asText(null) : null;
String templateBody = req.has("TemplateBody") ? req.path("TemplateBody").asText(null) : null;
ConformancePack pack = service.putConformancePack(region, packName, templateS3Uri, templateBody);
ObjectNode resp = mapper.createObjectNode();
resp.put("ConformancePackArn", pack.conformancePackArn());
return Response.ok(resp).build();
}
private Response deleteConformancePack(JsonNode req, String region) {
String packName = req.path("ConformancePackName").asText(null);
service.deleteConformancePack(region, packName);
return Response.ok(mapper.createObjectNode()).build();
}
private Response describeConformancePacks(JsonNode req, String region) {
List<String> names = extractStringList(req, "ConformancePackNames");
List<ConformancePack> packs = service.describeConformancePacks(region, names);
ObjectNode resp = mapper.createObjectNode();
resp.set("ConformancePackDetails", mapper.valueToTree(packs));
return Response.ok(resp).build();
}
private Response describeConformancePackStatus(JsonNode req, String region) {
List<String> names = extractStringList(req, "ConformancePackNames");
List<ConformancePackStatusDetail> statuses = service.describeConformancePackStatus(region, names);
ObjectNode resp = mapper.createObjectNode();
resp.set("ConformancePackStatusDetails", mapper.valueToTree(statuses));
return Response.ok(resp).build();
}
// --- Tagging ---
private Response tagResource(JsonNode req) {
String arn = req.path("ResourceArn").asText(null);
List<Map<String, String>> tagList = new ArrayList<>();
req.path("Tags").forEach(t -> tagList.add(Map.of(
"Key", t.path("Key").asText(),
"Value", t.path("Value").asText())));
service.tagResource(arn, tagList);
return Response.ok(mapper.createObjectNode()).build();
}
private Response untagResource(JsonNode req) {
String arn = req.path("ResourceArn").asText(null);
List<String> tagKeys = new ArrayList<>();
req.path("TagKeys").forEach(k -> tagKeys.add(k.asText()));
service.untagResource(arn, tagKeys);
return Response.ok(mapper.createObjectNode()).build();
}
private Response listTagsForResource(JsonNode req) {
String arn = req.path("ResourceArn").asText(null);
List<Map<String, String>> tagList = service.listTagsForResource(arn);
ObjectNode resp = mapper.createObjectNode();
resp.set("Tags", mapper.valueToTree(tagList));
return Response.ok(resp).build();
}
// --- Helpers ---
private List<String> extractStringList(JsonNode req, String fieldName) {
List<String> result = new ArrayList<>();
if (req.has(fieldName)) {
req.path(fieldName).forEach(n -> result.add(n.asText()));
}
return result;
}
}
@@ -0,0 +1,17 @@
package io.github.hectorvent.floci.services.configservice.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public record ConfigRule(
@JsonProperty("ConfigRuleName") String configRuleName,
@JsonProperty("ConfigRuleArn") String configRuleArn,
@JsonProperty("ConfigRuleId") String configRuleId,
@JsonProperty("ConfigRuleState") String configRuleState,
@JsonProperty("Source") ConfigRuleSource source) {
}
@@ -0,0 +1,16 @@
package io.github.hectorvent.floci.services.configservice.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public record ConfigRuleEvaluationStatus(
@JsonProperty("ConfigRuleName") String configRuleName,
@JsonProperty("ConfigRuleArn") String configRuleArn,
@JsonProperty("ConfigRuleId") String configRuleId,
@JsonProperty("FirstEvaluationStarted") Boolean firstEvaluationStarted) {
}
@@ -0,0 +1,14 @@
package io.github.hectorvent.floci.services.configservice.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public record ConfigRuleSource(
@JsonProperty("Owner") String owner,
@JsonProperty("SourceIdentifier") String sourceIdentifier) {
}
@@ -0,0 +1,13 @@
package io.github.hectorvent.floci.services.configservice.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public record ConfigSnapshotDeliveryProperties(
@JsonProperty("deliveryFrequency") String deliveryFrequency) {
}
@@ -0,0 +1,15 @@
package io.github.hectorvent.floci.services.configservice.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public record ConfigurationRecorder(
@JsonProperty("name") String name,
@JsonProperty("roleARN") String roleARN,
@JsonProperty("recordingGroup") RecordingGroup recordingGroup) {
}
@@ -0,0 +1,17 @@
package io.github.hectorvent.floci.services.configservice.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public record ConfigurationRecorderStatus(
@JsonProperty("name") String name,
@JsonProperty("recording") Boolean recording,
@JsonProperty("lastStatus") String lastStatus,
@JsonProperty("lastStartTime") Long lastStartTime,
@JsonProperty("lastStopTime") Long lastStopTime) {
}
@@ -0,0 +1,17 @@
package io.github.hectorvent.floci.services.configservice.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public record ConformancePack(
@JsonProperty("ConformancePackName") String conformancePackName,
@JsonProperty("ConformancePackArn") String conformancePackArn,
@JsonProperty("ConformancePackId") String conformancePackId,
@JsonProperty("TemplateS3Uri") String templateS3Uri,
@JsonProperty("TemplateBody") String templateBody) {
}
@@ -0,0 +1,17 @@
package io.github.hectorvent.floci.services.configservice.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public record ConformancePackStatusDetail(
@JsonProperty("ConformancePackName") String conformancePackName,
@JsonProperty("ConformancePackId") String conformancePackId,
@JsonProperty("ConformancePackArn") String conformancePackArn,
@JsonProperty("ConformancePackState") String conformancePackState,
@JsonProperty("LastUpdateRequestedTime") Long lastUpdateRequestedTime) {
}
@@ -0,0 +1,18 @@
package io.github.hectorvent.floci.services.configservice.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public record DeliveryChannel(
@JsonProperty("name") String name,
@JsonProperty("s3BucketName") String s3BucketName,
@JsonProperty("s3KeyPrefix") String s3KeyPrefix,
@JsonProperty("s3KmsKeyArn") String s3KmsKeyArn,
@JsonProperty("snsTopicARN") String snsTopicARN,
@JsonProperty("configSnapshotDeliveryProperties") ConfigSnapshotDeliveryProperties configSnapshotDeliveryProperties) {
}
@@ -0,0 +1,17 @@
package io.github.hectorvent.floci.services.configservice.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.quarkus.runtime.annotations.RegisterForReflection;
import java.util.List;
@RegisterForReflection
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
public record RecordingGroup(
@JsonProperty("allSupported") Boolean allSupported,
@JsonProperty("includeGlobalResourceTypes") Boolean includeGlobalResourceTypes,
@JsonProperty("resourceTypes") List<String> resourceTypes) {
}