fix(config): keep recording strategy, exclusions and recording mode on configuration recorders (#7178)

This commit is contained in:
Allen Sanborn authored and GitHub committed 2026-11-01 09:20:14 -04:00
1 parent c8dec86997
commit c024c8342c
10 files changed
+169 -7

No files matched your search

@@ -46,7 +46,7 @@ class AwsConfigAccountIsolationTest {
void recorderStartStopAndDeletionStayInTheirAccount() {
for (String account : List.of(FIRST, SECOND)) {
context.setAccountId(account);
service.putConfigurationRecorder(REGION, new ConfigurationRecorder("default", "role", null));
service.putConfigurationRecorder(REGION, new ConfigurationRecorder("default", "role", null, null));
service.putDeliveryChannel(REGION, new DeliveryChannel("default", "bucket", null, null, null, null));
}
context.setAccountId(FIRST);
@@ -43,7 +43,7 @@ class AwsConfigServicePersistenceTest {
rule("s3-public-read", "AWS", "S3_BUCKET_PUBLIC_READ_PROHIBITED"));
first.putConformancePack(REGION, "ops-pack", "s3://bucket/template.yaml", null);
first.putConfigurationRecorder(REGION, new ConfigurationRecorder("default",
"arn:aws:iam::000000000000:role/config", new RecordingGroup(true, false, null)));
"arn:aws:iam::000000000000:role/config", new RecordingGroup(true, false, null, null, null), null));
first.putDeliveryChannel(REGION,
new DeliveryChannel("default", "config-bucket", null, null, null, null));
first.tagResource(REGION, rule.configRuleArn(), List.of(Map.of("Key", "env", "Value", "prod")));
@@ -140,7 +140,7 @@ class AwsConfigServicePersistenceTest {
void aStartedRecorderIsStillRecordingAfterRestart() {
AwsConfigService first = restartedService();
first.putConfigurationRecorder(REGION, new ConfigurationRecorder("default",
"arn:aws:iam::000000000000:role/config", new RecordingGroup(true, false, null)));
"arn:aws:iam::000000000000:role/config", new RecordingGroup(true, false, null, null, null), null));
first.putDeliveryChannel(REGION,
new DeliveryChannel("default", "config-bucket", null, null, null, null));
first.startConfigurationRecorder(REGION, "default");
@@ -169,7 +169,7 @@ class AwsConfigServicePersistenceTest {
void aDeletedRecorderDoesNotComeBackRecordingAfterRestart() {
AwsConfigService first = restartedService();
ConfigurationRecorder recorder = new ConfigurationRecorder("default",
"arn:aws:iam::000000000000:role/config", new RecordingGroup(true, false, null));
"arn:aws:iam::000000000000:role/config", new RecordingGroup(true, false, null, null, null), null);
first.putConfigurationRecorder(REGION, recorder);
first.putDeliveryChannel(REGION,
new DeliveryChannel("default", "config-bucket", null, null, null, null));
@@ -332,4 +332,103 @@ class ConfigurationRecorderIntegrationTest {
.statusCode(400)
.body("__type", equalTo("NoSuchConfigurationRecorderException"));
}
@Test
@Order(16)
void recordingStrategyRoundTrips() {
given()
.header("X-Amz-Target", TARGET_PREFIX + "PutConfigurationRecorder")
.contentType(CONTENT_TYPE)
.body("""
{"ConfigurationRecorder": {"name": "default", "roleARN": "arn:aws:iam::123456789012:role/r",
"recordingGroup": {"allSupported": true, "includeGlobalResourceTypes": true,
"recordingStrategy": {"useOnly": "ALL_SUPPORTED_RESOURCE_TYPES"}}}}
""")
.when()
.post("/")
.then()
.statusCode(200);
given()
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigurationRecorders")
.contentType(CONTENT_TYPE)
.body("{}")
.when()
.post("/")
.then()
.statusCode(200)
.body("ConfigurationRecorders[0].recordingGroup.recordingStrategy.useOnly",
equalTo("ALL_SUPPORTED_RESOURCE_TYPES"))
.body("ConfigurationRecorders[0].recordingGroup.allSupported", equalTo(true));
}
@Test
@Order(17)
void exclusionsAndRecordingModeRoundTrip() {
given()
.header("X-Amz-Target", TARGET_PREFIX + "PutConfigurationRecorder")
.contentType(CONTENT_TYPE)
.body("""
{"ConfigurationRecorder": {"name": "default", "roleARN": "arn:aws:iam::123456789012:role/r",
"recordingGroup": {"allSupported": false, "includeGlobalResourceTypes": false,
"exclusionByResourceTypes": {"resourceTypes": ["AWS::EC2::Instance"]},
"recordingStrategy": {"useOnly": "EXCLUSION_BY_RESOURCE_TYPES"}},
"recordingMode": {"recordingFrequency": "DAILY",
"recordingModeOverrides": [{"description": "continuous buckets",
"resourceTypes": ["AWS::S3::Bucket"], "recordingFrequency": "CONTINUOUS"}]}}}
""")
.when()
.post("/")
.then()
.statusCode(200);
given()
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigurationRecorders")
.contentType(CONTENT_TYPE)
.body("{}")
.when()
.post("/")
.then()
.statusCode(200)
.body("ConfigurationRecorders[0].recordingGroup.exclusionByResourceTypes.resourceTypes",
contains("AWS::EC2::Instance"))
.body("ConfigurationRecorders[0].recordingGroup.recordingStrategy.useOnly",
equalTo("EXCLUSION_BY_RESOURCE_TYPES"))
.body("ConfigurationRecorders[0].recordingMode.recordingFrequency", equalTo("DAILY"))
.body("ConfigurationRecorders[0].recordingMode.recordingModeOverrides", hasSize(1))
.body("ConfigurationRecorders[0].recordingMode.recordingModeOverrides[0].description",
equalTo("continuous buckets"))
.body("ConfigurationRecorders[0].recordingMode.recordingModeOverrides[0].resourceTypes",
contains("AWS::S3::Bucket"))
.body("ConfigurationRecorders[0].recordingMode.recordingModeOverrides[0].recordingFrequency",
equalTo("CONTINUOUS"));
}
@Test
@Order(18)
void absentFieldsAreNotSynthesized() {
given()
.header("X-Amz-Target", TARGET_PREFIX + "PutConfigurationRecorder")
.contentType(CONTENT_TYPE)
.body("""
{"ConfigurationRecorder": {"name": "default", "roleARN": "arn:aws:iam::123456789012:role/r",
"recordingGroup": {"allSupported": true, "includeGlobalResourceTypes": false}}}
""")
.when()
.post("/")
.then()
.statusCode(200);
given()
.header("X-Amz-Target", TARGET_PREFIX + "DescribeConfigurationRecorders")
.contentType(CONTENT_TYPE)
.body("{}")
.when()
.post("/")
.then()
.statusCode(200)
.body("ConfigurationRecorders[0].recordingGroup", not(hasKey("recordingStrategy")))
.body("ConfigurationRecorders[0].recordingGroup", not(hasKey("exclusionByResourceTypes")))
.body("ConfigurationRecorders[0]", not(hasKey("recordingMode")));
}
}