mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(config): add the recorder arn to its status and filter by Arn (#8142)
DescribeConfigurationRecorderStatus did not return the recorder's arn, a member botocore models on ConfigurationRecorderStatus, and neither Describe call read the Arn request member both of them model. Return the arn in the status. An Arn that does not name the recorder now answers NoSuchConfigurationRecorderException, which both operations model, as a name that matches nothing already did. Given both Arn and ConfigurationRecorderNames, each must name the recorder; the model and the API reference don't say what AWS does then. A recorder saved before recorders had an ARN has no arn in its status, and no Arn finds it, until its next Put. Both Describe methods carried the same check that answers NoSuchConfigurationRecorderException for an Arn that does not name the recorder. It now lives in one private helper, as requireRule and requireAuthorizationKey do for their checks. No behaviour change. The two Arn tests called a private post helper that repeated RestAssuredJsonUtils.awsAction. They now call awsAction directly.
This commit is contained in:
1 parent
0b6a6003b0
commit
6b129de242
7 files changed
+136
-20
No files matched your search
@@ -711,8 +711,9 @@ public class AwsConfigService {
|
||||
}
|
||||
}
|
||||
|
||||
public List<ConfigurationRecorder> describeConfigurationRecorders(String region, List<String> names) {
|
||||
public List<ConfigurationRecorder> describeConfigurationRecorders(String region, List<String> names, String arn) {
|
||||
ConfigurationRecorder recorder = configurationRecorders.get(region);
|
||||
requireRecorderArn(arn, recorder);
|
||||
if (recorder == null) {
|
||||
if (names != null && !names.isEmpty()) {
|
||||
throw new AwsException("NoSuchConfigurationRecorderException",
|
||||
@@ -731,6 +732,13 @@ public class AwsConfigService {
|
||||
return List.of(recorder);
|
||||
}
|
||||
|
||||
private static void requireRecorderArn(String arn, ConfigurationRecorder recorder) {
|
||||
if (arn != null && (recorder == null || !arn.equals(recorder.arn()))) {
|
||||
throw new AwsException("NoSuchConfigurationRecorderException",
|
||||
"Cannot find configuration recorder with the specified ARN.", 400);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteConfigurationRecorder(String region, String name) {
|
||||
synchronized (lockFor(recorderLockKey(region))) {
|
||||
ConfigurationRecorder recorder = configurationRecorders.get(region);
|
||||
@@ -770,8 +778,10 @@ public class AwsConfigService {
|
||||
recorderLastStopTime.put(runtimeKey(region), now());
|
||||
}
|
||||
|
||||
public List<ConfigurationRecorderStatus> describeConfigurationRecorderStatus(String region, List<String> names) {
|
||||
public List<ConfigurationRecorderStatus> describeConfigurationRecorderStatus(String region, List<String> names,
|
||||
String arn) {
|
||||
ConfigurationRecorder recorder = configurationRecorders.get(region);
|
||||
requireRecorderArn(arn, recorder);
|
||||
if (recorder == null) {
|
||||
if (names != null && !names.isEmpty()) {
|
||||
throw new AwsException("NoSuchConfigurationRecorderException",
|
||||
@@ -788,6 +798,7 @@ public class AwsConfigService {
|
||||
}
|
||||
}
|
||||
ConfigurationRecorderStatus status = new ConfigurationRecorderStatus(
|
||||
recorder.arn(),
|
||||
recorder.name(),
|
||||
recorderRunning.getOrDefault(runtimeKey(region), false),
|
||||
recorderLastStartTime.containsKey(runtimeKey(region)) ? "SUCCESS" : "Pending",
|
||||
|
||||
@@ -202,7 +202,8 @@ public class ConfigServiceJsonHandler {
|
||||
|
||||
private Response describeConfigurationRecorders(JsonNode req, String region) {
|
||||
List<String> names = extractStringList(req, "ConfigurationRecorderNames");
|
||||
List<ConfigurationRecorder> recorders = service.describeConfigurationRecorders(region, names);
|
||||
String arn = req.path("Arn").asText(null);
|
||||
List<ConfigurationRecorder> recorders = service.describeConfigurationRecorders(region, names, arn);
|
||||
ObjectNode resp = mapper.createObjectNode();
|
||||
resp.set("ConfigurationRecorders", mapper.valueToTree(recorders));
|
||||
return Response.ok(resp).build();
|
||||
@@ -227,7 +228,8 @@ public class ConfigServiceJsonHandler {
|
||||
|
||||
private Response describeConfigurationRecorderStatus(JsonNode req, String region) {
|
||||
List<String> names = extractStringList(req, "ConfigurationRecorderNames");
|
||||
List<ConfigurationRecorderStatus> statuses = service.describeConfigurationRecorderStatus(region, names);
|
||||
String arn = req.path("Arn").asText(null);
|
||||
List<ConfigurationRecorderStatus> statuses = service.describeConfigurationRecorderStatus(region, names, arn);
|
||||
ObjectNode resp = mapper.createObjectNode();
|
||||
resp.set("ConfigurationRecordersStatus", mapper.valueToTree(statuses));
|
||||
return Response.ok(resp).build();
|
||||
|
||||
+1
@@ -9,6 +9,7 @@ import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public record ConfigurationRecorderStatus(
|
||||
@JsonProperty("arn") String arn,
|
||||
@JsonProperty("name") String name,
|
||||
@JsonProperty("recording") Boolean recording,
|
||||
@JsonProperty("lastStatus") String lastStatus,
|
||||
|
||||
Reference in new issue
Block a user