feat(cloudformation): provision EKS clusters and node groups (#1368)

Inject EksService and add provision + delete handling for AWS::EKS::Cluster and
AWS::EKS::Nodegroup. Clusters are created via the EKS createCluster API
(RoleArn, ResourcesVpcConfig, version); node groups via createNodegroup under
their cluster. Ref returns the resource name; Fn::GetAtt exposes Arn (and the
cluster Endpoint). Stack deletion removes the cluster/node group.
This commit is contained in:
Hector Ventura authored and GitHub committed 2026-06-15 23:29:50 -05:00
1 parent ed102b0ed2
commit 50c768643d
4 files changed
+164 -3

No files matched your search

@@ -0,0 +1,93 @@
package io.github.hectorvent.floci.services.cloudformation;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
/**
* End-to-end check that CloudFormation provisions EKS resources for real (into EksService) rather
* than stubbing them. EKS runs in mock mode under test (floci.services.eks.mock=true), so no k3s
* container starts — the test stays Docker-free.
*/
@QuarkusTest
class CloudFormationEksIntegrationTest {
private static final String CFN_AUTH =
"AWS4-HMAC-SHA256 Credential=test/20260205/us-east-1/cloudformation/aws4_request";
@Test
void createStackProvisionsEksClusterAndNodegroup() {
String suffix = Long.toString(System.nanoTime(), 36);
String clusterName = "cfn-eks-" + suffix;
String nodegroupName = "ng-" + suffix;
String stackName = "cfn-eks-stack-" + suffix;
String template = """
{
"Resources": {
"Cluster": {
"Type": "AWS::EKS::Cluster",
"Properties": {
"Name": "%s",
"Version": "1.29",
"RoleArn": "arn:aws:iam::000000000000:role/eks-cluster-role"
}
},
"Nodes": {
"Type": "AWS::EKS::Nodegroup",
"Properties": {
"ClusterName": {"Ref": "Cluster"},
"NodegroupName": "%s",
"NodeRole": "arn:aws:iam::000000000000:role/eks-node-role",
"Subnets": ["subnet-aaaa1111", "subnet-bbbb2222"]
}
}
},
"Outputs": {
"ClusterRef": {"Value": {"Ref": "Cluster"}}
}
}
""".formatted(clusterName, nodegroupName);
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", CFN_AUTH)
.formParam("Action", "CreateStack")
.formParam("StackName", stackName)
.formParam("TemplateBody", template)
.when()
.post("/")
.then()
.statusCode(200);
given()
.contentType("application/x-www-form-urlencoded")
.header("Authorization", CFN_AUTH)
.formParam("Action", "DescribeStacks")
.formParam("StackName", stackName)
.when()
.post("/")
.then()
.statusCode(200)
.body(containsString("<StackStatus>CREATE_COMPLETE</StackStatus>"))
.body(containsString(clusterName));
// The cluster really exists in EKS (provisioned, not stubbed).
given()
.when()
.get("/clusters/" + clusterName)
.then()
.statusCode(200)
.body(containsString(clusterName));
// The nodegroup was created under it (ClusterName resolved from Ref(Cluster)).
given()
.when()
.get("/clusters/" + clusterName + "/node-groups/" + nodegroupName)
.then()
.statusCode(200)
.body(containsString(nodegroupName));
}
}
@@ -48,7 +48,7 @@ class CustomResourceProvisionerTest {
provisioner = new CloudFormationResourceProvisioner(
null, null, null, null, lambdaService, null, null, null, null, null,
null, null, null, null, null, null, mapper, store, endpoint, null, null, null, null, null, null);
null, null, null, null, null, null, mapper, store, endpoint, null, null, null, null, null, null, null);
}
private CloudFormationTemplateEngine engine() {
@@ -44,7 +44,7 @@ class RdsCfnProvisionerTest {
null, null, null, null, null, null,
mapper,
null, null, null, null, null, null, null,
rdsService);
rdsService, null);
}
private CloudFormationTemplateEngine engine() {