fix(emr): give back a cluster's security configuration and refuse an unknown one (#8422)

RunJobFlow kept the SecurityConfiguration it was given, but
DescribeCluster never wrote it out, so the cluster came back with
none, although the model's Cluster has the member. It is given back
now.

RunJobFlow also took a security configuration that was never created.
A cluster names one CreateSecurityConfiguration made, so one that does
not exist is now refused with ValidationException "Security
configuration does not exist: <name>". No source gives AWS's answer,
so the code is the one RunJobFlow refuses its other input with in
Floci, and the wording that of DescribeSecurityConfiguration and
DeleteSecurityConfiguration; emr.md says so.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-15 00:49:10 -04:00
1 parent e7767b8bac
commit 8ba3f00443
4 files changed
+47

No files matched your search

+4
View File
@@ -115,6 +115,10 @@ other state, such as `STARTING` or `BOOTSTRAPPING`. `AddInstanceFleet` gives a `
`TERMINATED` instances. As `ListInstances` "Provides information for all active Amazon EC2 instances and Amazon EC2
instances terminated in the last 30 days, up to a maximum of 2,000", a call lists at most 2,000 and gives a `Marker`
for the next; a `Marker` no call gave is refused with `InvalidRequestException`.
A cluster's `SecurityConfiguration` names one `CreateSecurityConfiguration` made, and `DescribeCluster` gives it back.
`RunJobFlow` naming one that does not exist is refused with `ValidationException` "Security configuration does not
exist: <name>"; no source gives AWS's answer, so the code is the one `RunJobFlow` refuses its other input with, and the
wording that of `DescribeSecurityConfiguration` and `DeleteSecurityConfiguration`.
A cluster has instance groups or instance fleets, never both, as "instance fleets and instance groups cannot coexist in a
cluster": `RunJobFlow` with both is refused with `ValidationException` "The RunJobFlow request can contain
InstanceFleets parameters or InstanceGroups parameters, but not both.", the API reference's own words, and
@@ -703,6 +703,9 @@ public class EmrHandler {
if (c.getServiceRole() != null) {
node.put("ServiceRole", c.getServiceRole());
}
if (c.getSecurityConfiguration() != null) {
node.put("SecurityConfiguration", c.getSecurityConfiguration());
}
node.put("NormalizedInstanceHours", c.getNormalizedInstanceHours());
if (c.getMasterPublicDnsName() != null) {
node.put("MasterPublicDnsName", EmrService.masterDnsName(c.getRegion()));
@@ -382,6 +382,13 @@ public class EmrService implements Resettable, StoredResourceArns, ContainerTear
throw new AwsException("ValidationException", "The RunJobFlow request can contain InstanceFleets"
+ " parameters or InstanceGroups parameters, but not both.", 400);
}
// A security configuration is created first and named here; no source gives AWS's answer for one that is
// not there, so the code is RunJobFlow's own for its input and the wording that of the other calls.
if (cluster.getSecurityConfiguration() != null
&& secConfigStore.get(cluster.getSecurityConfiguration()).isEmpty()) {
throw new AwsException("ValidationException",
"Security configuration does not exist: " + cluster.getSecurityConfiguration(), 400);
}
String id = "j-" + randomId(13);
cluster.setId(id);
cluster.setRegion(region);
@@ -318,6 +318,39 @@ class EmrIntegrationTest {
}
}
@Test
@Order(19)
void aClusterNamesASecurityConfigurationThatExists() {
String instances = "\"Instances\":{\"KeepJobFlowAliveWhenNoSteps\":true}";
emr("RunJobFlow", "{\"Name\":\"secured\",\"SecurityConfiguration\":\"floci-emr-missing\"," + instances + "}")
.then().statusCode(400)
.body("__type", equalTo("ValidationException"))
.body("message", equalTo("Security configuration does not exist: floci-emr-missing"));
emr("ListClusters", "{}")
.then().statusCode(200)
.body("Clusters.findAll { it.Name == 'secured' }", hasSize(0));
emr("DescribeCluster", "{\"ClusterId\":\"" + clusterId + "\"}")
.then().statusCode(200)
.body("Cluster", not(hasKey("SecurityConfiguration")));
emr("CreateSecurityConfiguration", "{\"Name\":\"floci-emr-cluster-sec\","
+ "\"SecurityConfiguration\":\"{\\\"EncryptionConfiguration\\\":{}}\"}")
.then().statusCode(200);
String secured = null;
try {
secured = emr("RunJobFlow", "{\"Name\":\"secured\",\"SecurityConfiguration\":\"floci-emr-cluster-sec\","
+ instances + "}").then().statusCode(200).extract().path("JobFlowId");
emr("DescribeCluster", "{\"ClusterId\":\"" + secured + "\"}")
.then().statusCode(200)
.body("Cluster.SecurityConfiguration", equalTo("floci-emr-cluster-sec"));
} finally {
if (secured != null) {
emr("TerminateJobFlows", "{\"JobFlowIds\":[\"" + secured + "\"]}").then().statusCode(200);
}
emr("DeleteSecurityConfiguration", "{\"Name\":\"floci-emr-cluster-sec\"}").then().statusCode(200);
}
}
@Test
@Order(12)
void tagsRoundTrip() {