Skip to content

armgit / floci

Public Imported from GitHub
0

Light, fluffy, and always free - The AWS Local Emulator alternative

fix(iam): check EKS's REST routes and roles, and routes with a trailing slash (#6323)

Priamo Germosenec5597eb5cc2
diff --git a/docs/services/iam.md b/docs/services/iam.md
index 4f9afd60cf..663427e3de 100644
--- a/docs/services/iam.md
+++ b/docs/services/iam.md
@@ -1348,10 +1348,17 @@ the status, not just the request's content type.
A REST request is authorized as the operation of the route it reached. An `X-Amz-Target` header, a
Query `Action` field or a `smithy-protocol` header on it does not change the action it is checked
as, and its path is matched still percent-encoded, as the router matches it, so an encoded `/`
-inside a parameter cannot make the route's rule miss.
+inside a parameter cannot make the route's rule miss. A trailing `/` is dropped first, as the router
+drops it, so `POST /clusters/` is checked as `POST /clusters`. An S3 path keeps it, since an S3 key
+may end in a slash, as a folder marker's does, and S3's rules already take a bucket's one trailing
+slash.
The REST routes mapped to an action are those of S3, Lambda, API Gateway, SES v2, RDS Data,
-Kinesis, EventBridge Scheduler, EventBridge Pipes and Aurora DSQL. In Lambda that is every route of the function
+Kinesis, EKS, EventBridge Scheduler, EventBridge Pipes and Aurora DSQL. In EKS that is every route,
+including those Floci does not serve yet, each checked as the action of its own name, except an
+access entry's access policy routes: Floci takes the entry's principal as the rest of the path, so a
+`GET` or `DELETE` there reads or deletes an entry and is checked as `eks:DescribeAccessEntry` or
+`eks:DeleteAccessEntry`. In Lambda that is every route of the function
API, MicroVMs and network connectors, including those Floci does not serve yet, and the Web
Functions routes, each checked as the action of its own name except `InvokeWithResponseStream`
(checked as `lambda:InvokeFunction`) and `GetLayerVersionByArn` (`lambda:GetLayerVersion`). AWS also
@@ -1383,8 +1390,22 @@ layer version its `Arn` names, its number read the same way. A Lambda tagging re
connector of that ARN's Region and name, whatever account the ARN names, as Lambda looks it up, and
an event source mapping's ARN as written.
+An EKS request is checked in the caller's account, where EKS looks everything up. A cluster route is
+checked against the ARN EKS holds the cluster under, or `cluster/<name>` in the request's Region for
+a cluster it does not hold, and `CreateCluster` against the cluster its body names, as the EKS user
+guide's example policy for creating a cluster grants it. A node group, Fargate profile, add-on,
+access entry or Pod Identity association route is checked against the ARN EKS holds that resource
+under, which ends in an id the request does not carry, so a policy names it with a wildcard, such as
+`nodegroup/<cluster>/<name>/*`; listing or creating them, and the other routes under a cluster, are
+checked against the cluster. A name holding an encoded `/` is read as one name, as EKS reads it.
+`DescribeUpdate` is checked against the add-on the update was made to, since the updates Floci keeps
+are its add-ons' and EKS returns one whether or not the request names its add-on, and otherwise
+against the cluster. An EKS tagging request is checked against the caller's own cluster named after
+the ARN's last `/`, whatever the ARN names before it, as EKS looks it up.
+
The shared tagging routes, `/tags` and `/v1/tags`, hand a request to the service its ARN names,
-and it is checked as that service, against that ARN, whatever scope it is signed with. The ARN is
+and it is checked as that service, against that ARN, or for EKS the cluster it tags, whatever scope
+it is signed with. The ARN is
the one after `/tags/` or `/v1/tags/`, the body's `resourceArn` on `POST /tags`, and the
`resourceArn` query parameter on the other bare routes.
@@ -1498,6 +1519,15 @@ role each passes:
`events.amazonaws.com`. **EventBridge Scheduler:** `CreateSchedule` and `UpdateSchedule` pass the
target's `RoleArn` to `scheduler.amazonaws.com`. **EventBridge Pipes:** `CreatePipe` and
`UpdatePipe` pass `RoleArn` to `pipes.amazonaws.com`.
+- **EKS:** `CreateCluster` passes `roleArn`, `CreateNodegroup` `nodeRole`, `CreateFargateProfile`
+ `podExecutionRoleArn`, and `CreateAddon` and `UpdateAddon` `serviceAccountRoleArn` and each of
+ their `podIdentityAssociations`' `roleArn`, to `eks.amazonaws.com`. `CreatePodIdentityAssociation`
+ and `UpdatePodIdentityAssociation` pass `roleArn` to `pods.eks.amazonaws.com`, but not
+ `targetRoleArn`, which the association's role assumes. `CreateAccessEntry` passes `principalArn`
+ to `ec2.amazonaws.com` when its `type` is `EC2_LINUX` or `EC2_WINDOWS`: "If you create an access
+ entry with type EC2_LINUX or EC2_WINDOWS, the IAM principal creating the access entry must have
+ the iam:PassRole permission." AWS also checks it for `CreateCapability`, `UpdateCapability`,
+ `RegisterCluster` and `UpdateClusterConfig`, which Floci does not serve.
- **CloudFormation:** `CreateStack`, `UpdateStack`, `DeleteStack`, `CreateChangeSet` and
`ContinueUpdateRollback` pass `RoleARN` to `cloudformation.amazonaws.com` when the request names
one. `CreateStackSet` and `UpdateStackSet` pass `AdministrationRoleARN`, or, for a self-managed
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/PassedRoles.java b/src/main/java/io/github/hectorvent/floci/core/common/PassedRoles.java
index c5c63593b8..3f1cdc5878 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/PassedRoles.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/PassedRoles.java
@@ -53,6 +53,17 @@ import java.util.regex.Pattern;
* you must grant your user permission to pass the role to Amazon ECS"), task roles to
* {@code ecs-tasks.amazonaws.com}.
*
+ * <p>An EKS request passes the cluster's {@code roleArn}, a node group's {@code nodeRole}, a Fargate
+ * profile's {@code podExecutionRoleArn}, and an add-on's service account role and the role of each Pod
+ * Identity association it makes, to {@code eks.amazonaws.com}. A Pod Identity association passes its
+ * {@code roleArn} to {@code pods.eks.amazonaws.com}: the EKS user guide has "The IAM principal that is
+ * creating the association must have iam:PassRole." Its target role is not passed but assumed with the
+ * association's role: "Pod Identity then automatically performs two role assumptions in sequence: first
+ * assuming the EKS Pod Identity role, then using those credentials to assume the Target IAM Role." An
+ * access entry passes its principal to {@code ec2.amazonaws.com} for the node types alone: "If you create
+ * an access entry with type EC2_LINUX or EC2_WINDOWS, the IAM principal creating the access entry must
+ * have the iam:PassRole permission."
+ *
* <p>A CloudFormation stack's service role is checked where a request names it, and not on later
* operations that reuse it: CloudFormation "uses this role even if the users don't have permission
* to pass it". A self-managed StackSet that names no administration role passes the default one:
@@ -89,6 +100,8 @@ final class PassedRoles {
private static final String EVENTS = ServicePrincipals.of("events");
private static final String SCHEDULER = ServicePrincipals.of("scheduler");
private static final String PIPES = ServicePrincipals.of("pipes");
+ private static final String EKS = ServicePrincipals.of("eks");
+ private static final String EKS_PODS = ServicePrincipals.of("pods.eks");
private static final String CLOUDFORMATION = ServicePrincipals.of("cloudformation");
private static final String AUTOSCALING = ServicePrincipals.of("autoscaling");
private static final String APPLICATION_AUTOSCALING = ServicePrincipals.of("application-autoscaling");
@@ -169,6 +182,13 @@ final class PassedRoles {
case "events:PutTargets" -> fromJson(ctx, EVENTS, "Targets", "[]", "RoleArn");
case "scheduler:CreateSchedule", "scheduler:UpdateSchedule" -> fromJson(ctx, SCHEDULER, "Target", "RoleArn");
case "pipes:CreatePipe", "pipes:UpdatePipe" -> fromJson(ctx, PIPES, "RoleArn");
+ case "eks:CreateCluster" -> fromJson(ctx, EKS, "roleArn");
+ case "eks:CreateNodegroup" -> fromJson(ctx, EKS, "nodeRole");
+ case "eks:CreateFargateProfile" -> fromJson(ctx, EKS, "podExecutionRoleArn");
+ case "eks:CreateAddon", "eks:UpdateAddon" -> eksAddonRoles(jsonBody(ctx));
+ case "eks:CreatePodIdentityAssociation", "eks:UpdatePodIdentityAssociation" ->
+ fromJson(ctx, EKS_PODS, "roleArn");
+ case "eks:CreateAccessEntry" -> eksNodeAccessEntry(jsonBody(ctx));
case "lambda:CreateMicrovmImage", "lambda:UpdateMicrovmImage" -> fromJson(ctx, LAMBDA, "buildRoleArn");
case "lambda:RunMicrovm" -> fromJson(ctx, LAMBDA, "executionRoleArn");
case "lambda:CreateNetworkConnector", "lambda:UpdateNetworkConnector" -> fromJson(ctx, LAMBDA, "OperatorRole");
@@ -256,6 +276,20 @@ final class PassedRoles {
return passed(arns, service);
}
+ /** An EKS add-on's service account role and the role of each Pod Identity association it makes. */
+ private static List<PassedRole> eksAddonRoles(JsonNode body) {
+ List<String> roles = new ArrayList<>(values(body, "serviceAccountRoleArn"));
+ roles.addAll(values(body, "podIdentityAssociations", "[]", "roleArn"));
+ return passed(roles, EKS);
+ }
+
+ /** An EKS access entry's principal, when its type is one whose nodes run as that role. */
+ private static List<PassedRole> eksNodeAccessEntry(JsonNode body) {
+ List<String> type = values(body, "type");
+ return type.contains("EC2_LINUX") || type.contains("EC2_WINDOWS")
+ ? passed(values(body, "principalArn"), EC2) : List.of();
+ }
+
/**
* The administration role a StackSet operation passes: the one it names, or else, unless the
* StackSet uses service-managed permissions, the default one. An update goes by the StackSet's
diff --git a/src/main/java/io/github/hectorvent/floci/services/eks/EksAddonService.java b/src/main/java/io/github/hectorvent/floci/services/eks/EksAddonService.java
index af81b4bee8..29198071c7 100644
--- a/src/main/java/io/github/hectorvent/floci/services/eks/EksAddonService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/eks/EksAddonService.java
@@ -343,13 +343,7 @@ public class EksAddonService {
}
public Update describeUpdate(Cluster cluster, String updateId, String addonName) {
- requireActiveCluster(cluster);
- if (updateId == null || updateId.isBlank()) {
- throw new AwsException("InvalidParameterException", "updateId is required", 400);
- }
- StoredUpdate stored = updatesStorage.get(prefix(cluster) + updateId)
- .orElseThrow(() -> new AwsException("ResourceNotFoundException",
- "No update: " + updateId + " found for cluster: " + cluster.getName(), 404));
+ StoredUpdate stored = storedUpdate(cluster, updateId);
if (addonName != null && !addonName.isBlank()
&& stored.addonName() != null && !stored.addonName().equalsIgnoreCase(addonName.trim())) {
throw new AwsException("ResourceNotFoundException",
@@ -358,6 +352,24 @@ public class EksAddonService {
return stored.update();
}
+ /**
+ * The name of the add-on the update {@code updateId} was made to, looked up as {@link #describeUpdate} looks
+ * it up, which returns the update whether or not the request names its add-on.
+ */
+ public String updateAddonName(Cluster cluster, String updateId) {
+ return storedUpdate(cluster, updateId).addonName();
+ }
+
+ private StoredUpdate storedUpdate(Cluster cluster, String updateId) {
+ requireActiveCluster(cluster);
+ if (updateId == null || updateId.isBlank()) {
+ throw new AwsException("InvalidParameterException", "updateId is required", 400);
+ }
+ return updatesStorage.get(prefix(cluster) + updateId)
+ .orElseThrow(() -> new AwsException("ResourceNotFoundException",
+ "No update: " + updateId + " found for cluster: " + cluster.getName(), 404));
+ }
+
public AddonVersionsPage describeAddonVersions(String addonName, String kubernetesVersion,
Integer maxResults, String nextToken,
List<String> publishers, List<String> types, List<String> owners) {
diff --git a/src/main/java/io/github/hectorvent/floci/services/eks/EksService.java b/src/main/java/io/github/hectorvent/floci/services/eks/EksService.java
index fea594f840..6feb748815 100644
--- a/src/main/java/io/github/hectorvent/floci/services/eks/EksService.java
+++ b/src/main/java/io/github/hectorvent/floci/services/eks/EksService.java
@@ -742,6 +742,37 @@ public class EksService implements TagHandler, ResourceProvider, Ec2InstanceLaun
? aware.getForAccount(accountId, name) : storage.get(name);
}
+ /**
+ * The ARN of what an EKS route names in the caller's account, looked up as its handler looks it up: the
+ * cluster {@code clusterName} when {@code collection} is null, or else the node group, Fargate profile,
+ * add-on, access entry or Pod Identity association {@code name} in that cluster, by the route's
+ * collection segment, or for the update {@code name} the add-on it was made to. Empty when there is none,
+ * or the handler would refuse the lookup.
+ */
+ public Optional<String> findResourceArn(String clusterName, String collection, String name) {
+ Optional<Cluster> cluster = storage.get(clusterName);
+ if (cluster.isEmpty() || collection == null) {
+ return cluster.map(Cluster::getArn);
+ }
+ try {
+ return Optional.ofNullable(switch (collection) {
+ case "node-groups" -> describeNodeGroup(clusterName, name).getNodegroupArn();
+ case "fargate-profiles" -> describeFargateProfile(clusterName, name).getFargateProfileArn();
+ case "addons" -> addons.describe(cluster.get(), name).addonArn();
+ case "access-entries" -> accessEntries.describe(cluster.get(), name).accessEntryArn();
+ case "pod-identity-associations" -> podIdentityAssociations.describe(cluster.get(), name).associationArn();
+ case "updates" -> {
+ String addon = addons.updateAddonName(cluster.get(), name);
+ yield addon == null ? null : addons.describe(cluster.get(), addon).addonArn();
+ }
+ default -> null;
+ });
+ } catch (AwsException expected) {
+ // The handler answers this lookup with the same error, so the route names no resource to act on.
+ return Optional.empty();
+ }
+ }
+
public Cluster describeCluster(String name) {
Cluster cluster = storage.get(name)
.orElseThrow(() -> new AwsException("ResourceNotFoundException",
diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/IamActionRegistry.java b/src/main/java/io/github/hectorvent/floci/services/iam/IamActionRegistry.java
index 2602da4231..c1b30693f5 100644
--- a/src/main/java/io/github/hectorvent/floci/services/iam/IamActionRegistry.java
+++ b/src/main/java/io/github/hectorvent/floci/services/iam/IamActionRegistry.java
@@ -287,6 +287,88 @@ public class IamActionRegistry {
rule("pipes", "POST", "^/tags(/.+)?$", "pipes:TagResource"),
rule("pipes", "DELETE", "^/tags(/.+)?$", "pipes:UntagResource"),
+ // ── EKS ────────────────────────────────────────────────────────────────
+ // Floci takes an access entry's principal ARN whole, slashes included, so a GET or DELETE under an
+ // entry is DescribeAccessEntry or DeleteAccessEntry: the entry's access policy routes, which Floci
+ // does not serve, run as those and are checked as those.
+ rule("eks", "GET", "^/clusters/[^/]+/access-entries/.+$", "eks:DescribeAccessEntry"),
+ rule("eks", "DELETE", "^/clusters/[^/]+/access-entries/.+$", "eks:DeleteAccessEntry"),
+ rule("eks", "POST", "^/clusters/[^/]+/access-entries/.+/access-policies$", "eks:AssociateAccessPolicy"),
+ rule("eks", "POST", "^/clusters/[^/]+/access-entries/.+$", "eks:UpdateAccessEntry"),
+ rule("eks", "GET", "^/clusters/[^/]+/access-entries$", "eks:ListAccessEntries"),
+ rule("eks", "POST", "^/clusters/[^/]+/access-entries$", "eks:CreateAccessEntry"),
+ rule("eks", "GET", "^/clusters$", "eks:ListClusters"),
+ rule("eks", "POST", "^/clusters$", "eks:CreateCluster"),
+ rule("eks", "GET", "^/clusters/[^/]+$", "eks:DescribeCluster"),
+ rule("eks", "DELETE", "^/clusters/[^/]+$", "eks:DeleteCluster"),
+ rule("eks", "POST", "^/clusters/[^/]+/update-config$", "eks:UpdateClusterConfig"),
+ rule("eks", "POST", "^/clusters/[^/]+/encryption-config/associate$", "eks:AssociateEncryptionConfig"),
+ rule("eks", "GET", "^/clusters/[^/]+/updates$", "eks:ListUpdates"),
+ rule("eks", "POST", "^/clusters/[^/]+/updates$", "eks:UpdateClusterVersion"),
+ rule("eks", "GET", "^/clusters/[^/]+/updates/[^/]+$", "eks:DescribeUpdate"),
+ rule("eks", "POST", "^/clusters/[^/]+/updates/[^/]+/cancel-update$", "eks:CancelUpdate"),
+ rule("eks", "GET", "^/clusters/[^/]+/node-groups$", "eks:ListNodegroups"),
+ rule("eks", "POST", "^/clusters/[^/]+/node-groups$", "eks:CreateNodegroup"),
+ rule("eks", "GET", "^/clusters/[^/]+/node-groups/[^/]+$", "eks:DescribeNodegroup"),
+ rule("eks", "DELETE", "^/clusters/[^/]+/node-groups/[^/]+$", "eks:DeleteNodegroup"),
+ rule("eks", "POST", "^/clusters/[^/]+/node-groups/[^/]+/update-config$", "eks:UpdateNodegroupConfig"),
+ rule("eks", "POST", "^/clusters/[^/]+/node-groups/[^/]+/update-version$", "eks:UpdateNodegroupVersion"),
+ rule("eks", "GET", "^/clusters/[^/]+/fargate-profiles$", "eks:ListFargateProfiles"),
+ rule("eks", "POST", "^/clusters/[^/]+/fargate-profiles$", "eks:CreateFargateProfile"),
+ rule("eks", "GET", "^/clusters/[^/]+/fargate-profiles/[^/]+$", "eks:DescribeFargateProfile"),
+ rule("eks", "DELETE", "^/clusters/[^/]+/fargate-profiles/[^/]+$", "eks:DeleteFargateProfile"),
+ rule("eks", "GET", "^/clusters/[^/]+/addons$", "eks:ListAddons"),
+ rule("eks", "POST", "^/clusters/[^/]+/addons$", "eks:CreateAddon"),
+ rule("eks", "GET", "^/clusters/[^/]+/addons/[^/]+$", "eks:DescribeAddon"),
+ rule("eks", "DELETE", "^/clusters/[^/]+/addons/[^/]+$", "eks:DeleteAddon"),
+ rule("eks", "POST", "^/clusters/[^/]+/addons/[^/]+/update$", "eks:UpdateAddon"),
+ rule("eks", "GET", "^/addons/supported-versions$", "eks:DescribeAddonVersions"),
+ rule("eks", "GET", "^/addons/configuration-schemas$", "eks:DescribeAddonConfiguration"),
+ rule("eks", "GET", "^/clusters/[^/]+/pod-identity-associations$", "eks:ListPodIdentityAssociations"),
+ rule("eks", "POST", "^/clusters/[^/]+/pod-identity-associations$", "eks:CreatePodIdentityAssociation"),
+ rule("eks", "GET", "^/clusters/[^/]+/pod-identity-associations/[^/]+$",
+ "eks:DescribePodIdentityAssociation"),
+ rule("eks", "POST", "^/clusters/[^/]+/pod-identity-associations/[^/]+$",
+ "eks:UpdatePodIdentityAssociation"),
+ rule("eks", "DELETE", "^/clusters/[^/]+/pod-identity-associations/[^/]+$",
+ "eks:DeletePodIdentityAssociation"),
+ rule("eks", "GET", "^/clusters/[^/]+/identity-provider-configs$", "eks:ListIdentityProviderConfigs"),
+ rule("eks", "POST", "^/clusters/[^/]+/identity-provider-configs/associate$",
+ "eks:AssociateIdentityProviderConfig"),
+ rule("eks", "POST", "^/clusters/[^/]+/identity-provider-configs/describe$",
+ "eks:DescribeIdentityProviderConfig"),
+ rule("eks", "POST", "^/clusters/[^/]+/identity-provider-configs/disassociate$",
+ "eks:DisassociateIdentityProviderConfig"),
+ rule("eks", "POST", "^/clusters/[^/]+/insights$", "eks:ListInsights"),
+ rule("eks", "GET", "^/clusters/[^/]+/insights/[^/]+$", "eks:DescribeInsight"),
+ rule("eks", "GET", "^/clusters/[^/]+/insights-refresh$", "eks:DescribeInsightsRefresh"),
+ rule("eks", "POST", "^/clusters/[^/]+/insights-refresh$", "eks:StartInsightsRefresh"),
+ rule("eks", "GET", "^/clusters/[^/]+/capabilities$", "eks:ListCapabilities"),
+ rule("eks", "POST", "^/clusters/[^/]+/capabilities$", "eks:CreateCapability"),
+ rule("eks", "GET", "^/clusters/[^/]+/capabilities/[^/]+$", "eks:DescribeCapability"),
+ rule("eks", "POST", "^/clusters/[^/]+/capabilities/[^/]+$", "eks:UpdateCapability"),
+ rule("eks", "DELETE", "^/clusters/[^/]+/capabilities/[^/]+$", "eks:DeleteCapability"),
+ rule("eks", "GET", "^/clusters/[^/]+/certificate-authorities$", "eks:ListCertificateAuthorities"),
+ rule("eks", "POST", "^/clusters/[^/]+/certificate-authorities$", "eks:CreateCertificateAuthority"),
+ rule("eks", "GET", "^/clusters/[^/]+/certificate-authorities/[^/]+$",
+ "eks:DescribeCertificateAuthority"),
+ rule("eks", "DELETE", "^/clusters/[^/]+/certificate-authorities/[^/]+$",
+ "eks:DeleteCertificateAuthority"),
+ rule("eks", "POST", "^/clusters/[^/]+/certificate-authorities/[^/]+/activate$",
+ "eks:ActivateCertificateAuthority"),
+ rule("eks", "GET", "^/access-policies$", "eks:ListAccessPolicies"),
+ rule("eks", "GET", "^/cluster-versions$", "eks:DescribeClusterVersions"),
+ rule("eks", "POST", "^/cluster-registrations$", "eks:RegisterCluster"),
+ rule("eks", "DELETE", "^/cluster-registrations/[^/]+$", "eks:DeregisterCluster"),
+ rule("eks", "GET", "^/eks-anywhere-subscriptions$", "eks:ListEksAnywhereSubscriptions"),
+ rule("eks", "POST", "^/eks-anywhere-subscriptions$", "eks:CreateEksAnywhereSubscription"),
+ rule("eks", "GET", "^/eks-anywhere-subscriptions/[^/]+$", "eks:DescribeEksAnywhereSubscription"),
+ rule("eks", "POST", "^/eks-anywhere-subscriptions/[^/]+$", "eks:UpdateEksAnywhereSubscription"),
+ rule("eks", "DELETE", "^/eks-anywhere-subscriptions/[^/]+$", "eks:DeleteEksAnywhereSubscription"),
+ rule("eks", "GET", "^/tags(/.+)?$", "eks:ListTagsForResource"),
+ rule("eks", "POST", "^/tags(/.+)?$", "eks:TagResource"),
+ rule("eks", "DELETE", "^/tags(/.+)?$", "eks:UntagResource"),
+
// ── SES v2 ─────────────────────────────────────────────────────────────
// SES v1 is a Query API and resolves from its Action like any other; v2 is REST-JSON under
// /v2/email, so every operation needs its own rule. One rule per operation in the SES v2
@@ -494,7 +576,9 @@ public class IamActionRegistry {
*/
public String resolveRoute(String credentialScope, ContainerRequestContext ctx) {
String method = ctx.getMethod().toUpperCase();
- String path = rawPath(ctx.getUriInfo());
+ // An S3 key may end in a slash, PUT /bucket// writes the key "/", and S3's rules already take a
+ // bucket's one trailing slash, so an S3 path is matched as sent.
+ String path = "s3".equals(credentialScope) ? rawPath(ctx.getUriInfo()) : routedPath(ctx.getUriInfo());
// S3 sub-resource override: the URL path alone doesn't distinguish
// s3:GetObjectAcl / s3:PutObjectAcl from s3:GetObject / s3:PutObject
@@ -531,6 +615,19 @@ public class IamActionRegistry {
return path.startsWith("/") ? path : "/" + path;
}
+ /**
+ * {@link #rawPath} without a trailing slash: the router matches {@code /clusters/} as {@code /clusters},
+ * so a rule ending at the route's last segment has to match it too, or the request would pass as an
+ * unknown action.
+ */
+ static String routedPath(UriInfo uriInfo) {
+ String path = rawPath(uriInfo);
+ while (path.length() > 1 && path.endsWith("/")) {
+ path = path.substring(0, path.length() - 1);
+ }
+ return path;
+ }
+
/**
* Returns the Query action from GET query parameters or the POST form body, preserving the
* entity stream. Both use the controller's Action-first, Operation-second rule; a POST URL
diff --git a/src/main/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilder.java b/src/main/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilder.java
index e12b7c9056..9ac4371d9d 100644
--- a/src/main/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilder.java
+++ b/src/main/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilder.java
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.core.common.AwsRegions;
import io.github.hectorvent.floci.core.common.ServicePrincipals;
import io.github.hectorvent.floci.core.common.SigV4CredentialScope;
import io.github.hectorvent.floci.services.cloudwatch.logs.LogGroupTagTarget;
+import io.github.hectorvent.floci.services.eks.EksService;
import io.github.hectorvent.floci.services.lambda.LambdaArnUtils;
import io.github.hectorvent.floci.services.lambda.durable.DurableTokens;
import io.github.hectorvent.floci.services.lambdamicrovms.LambdaMicrovmsService;
@@ -67,15 +68,25 @@ public class ResourceArnBuilder {
private final Instance<SecretsManagerService> secretsManagerService;
/** Looked up lazily for the same reason, to read the image a MicroVM runs. */
private final Instance<LambdaMicrovmsService> microvmsService;
+ /** Looked up lazily for the same reason, to read the ARN an EKS cluster or what it holds is stored under. */
+ private final Instance<EksService> eksService;
@Inject
public ResourceArnBuilder(ObjectMapper objectMapper, Instance<IamService> iamService,
Instance<SecretsManagerService> secretsManagerService,
- Instance<LambdaMicrovmsService> microvmsService) {
+ Instance<LambdaMicrovmsService> microvmsService,
+ Instance<EksService> eksService) {
this.objectMapper = objectMapper;
this.iamService = iamService;
this.secretsManagerService = secretsManagerService;
this.microvmsService = microvmsService;
+ this.eksService = eksService;
+ }
+
+ public ResourceArnBuilder(ObjectMapper objectMapper, Instance<IamService> iamService,
+ Instance<SecretsManagerService> secretsManagerService,
+ Instance<LambdaMicrovmsService> microvmsService) {
+ this(objectMapper, iamService, secretsManagerService, microvmsService, null);
}
public ResourceArnBuilder(ObjectMapper objectMapper, Instance<IamService> iamService,
@@ -131,6 +142,7 @@ public class ResourceArnBuilder {
case "scheduler" -> List.of(buildSchedulerArn(path, ctx, region, accountId, partition));
case "pipes" -> List.of(buildPipesArn(path, ctx, region, accountId, partition));
case "dsql" -> List.of(buildDsqlArn(path, ctx, region, accountId, partition));
+ case "eks" -> List.of(buildEksArn(path, ctx, region, accountId));
default -> List.of("*");
};
}
@@ -1018,6 +1030,88 @@ public class ResourceArnBuilder {
return taggedResource(ctx);
}
+ /**
+ * The resource of an EKS route, as the Service Reference gives it, in the caller's account, where EKS
+ * looks everything up. A cluster is the ARN EKS holds it under, or for one it holds none of, the ARN a
+ * create mints in the request's Region; {@code CreateCluster} is checked against the cluster its body
+ * names, as the EKS user guide's example policy for creating a cluster grants it. A node group, Fargate
+ * profile, add-on, access entry or Pod Identity association is the ARN EKS holds it under, which ends
+ * in an id the request does not carry, or {@code *} when EKS holds none to act on; listing or creating
+ * them, and every other route under a cluster, act on the cluster. The path is split as the router
+ * splits it, before decoding, so an encoded {@code /} stays inside a name, and an access entry's
+ * principal is the rest of the path, as EKS takes it. {@code DescribeUpdate} acts on the add-on its
+ * {@code addonName} names, since the updates EKS keeps are its add-ons', and otherwise on the cluster. A
+ * tagging route acts on the caller's cluster named by what follows the ARN's last {@code /}, as EKS tags
+ * it, whatever the ARN names before that. Deregistering a cluster acts on that cluster, and an EKS
+ * Anywhere subscription route on the subscription its id names. Listing clusters, registering one, the
+ * account-wide reads, and an identity provider config or capability, which end in an id Floci does not
+ * keep, name no resource, so they are {@code *}.
+ */
+ private String buildEksArn(String path, ContainerRequestContext ctx, String region, String accountId) {
+ if (path.equals("/tags") || path.startsWith("/tags/")) {
+ String tagged = taggedArn(ctx);
+ int slash = tagged == null ? -1 : tagged.lastIndexOf('/');
+ return slash < 0 || slash == tagged.length() - 1 ? "*"
+ : eksClusterArn(tagged.substring(slash + 1), region, accountId);
+ }
+ String[] segments = IamActionRegistry.routedPath(ctx.getUriInfo()).substring(1).split("/", -1);
+ if (segments.length == 1) {
+ JsonNode body = "clusters".equals(segments[0]) && "POST".equalsIgnoreCase(ctx.getMethod())
+ ? readJsonBody(ctx) : null;
+ String cluster = body == null ? null : body.path("name").asText(null);
+ return cluster == null || cluster.isBlank() ? "*" : eksClusterArn(cluster, region, accountId);
+ }
+ String name = pathSegment(segments[1]);
+ if (name.isEmpty()) {
+ return "*";
+ }
+ return switch (segments[0]) {
+ case "clusters" -> eksClusterRouteArn(name, segments, region, accountId);
+ case "cluster-registrations" -> eksClusterArn(name, region, accountId);
+ case "eks-anywhere-subscriptions" ->
+ AwsArnUtils.Arn.of("eks", region, accountId, "eks-anywhere-subscription/" + name).toString();
+ default -> "*";
+ };
+ }
+
+ /** The resource of a route under the cluster {@code cluster}, its path split into {@code segments}. */
+ private String eksClusterRouteArn(String cluster, String[] segments, String region, String accountId) {
+ if (segments.length < 4 || segments[3].isEmpty()) {
+ return eksClusterArn(cluster, region, accountId);
+ }
+ String collection = segments[2];
+ return switch (collection) {
+ case "node-groups", "fargate-profiles", "addons", "pod-identity-associations" ->
+ eksHeldArn(cluster, collection, pathSegment(segments[3]));
+ case "access-entries" -> eksHeldArn(cluster, collection,
+ pathSegment(String.join("/", List.of(segments).subList(3, segments.length))));
+ case "updates" -> {
+ // The updates Floci keeps are its add-ons', and EKS returns one whether or not the request names
+ // its add-on, so the update is checked against the add-on it was made to.
+ Optional<String> addon = segments.length == 4 && eksService != null
+ ? eksService.get().findResourceArn(cluster, collection, pathSegment(segments[3]))
+ : Optional.empty();
+ yield addon.orElseGet(() -> eksClusterArn(cluster, region, accountId));
+ }
+ case "identity-provider-configs" ->
+ "associate".equals(segments[3]) ? eksClusterArn(cluster, region, accountId) : "*";
+ case "capabilities" -> "*";
+ default -> eksClusterArn(cluster, region, accountId);
+ };
+ }
+
+ /** The ARN EKS holds the cluster {@code name} under, or else the one a create mints in {@code region}. */
+ private String eksClusterArn(String name, String region, String accountId) {
+ Optional<String> held = eksService == null ? Optional.empty()
+ : eksService.get().findResourceArn(name, null, null);
+ return held.orElseGet(() -> AwsArnUtils.Arn.of("eks", region, accountId, "cluster/" + name).toString());
+ }
+
+ /** The ARN EKS holds {@code name} of {@code collection} in the cluster under, or {@code *} when it holds none. */
+ private String eksHeldArn(String cluster, String collection, String name) {
+ return eksService == null ? "*" : eksService.get().findResourceArn(cluster, collection, name).orElse("*");
+ }
+
/** The ARN a shared tagging route names, or {@code *} for any other route. */
private String taggedResource(ContainerRequestContext ctx) {
String arn = taggedArn(ctx);
diff --git a/src/test/java/io/github/hectorvent/floci/core/common/PassedRolesTest.java b/src/test/java/io/github/hectorvent/floci/core/common/PassedRolesTest.java
index bdbb05511b..c2c17bc7c0 100644
--- a/src/test/java/io/github/hectorvent/floci/core/common/PassedRolesTest.java
+++ b/src/test/java/io/github/hectorvent/floci/core/common/PassedRolesTest.java
@@ -205,6 +205,40 @@ class PassedRolesTest {
PassedRoles.of("lambda:UpdateNetworkConnector", json(operator), LOOKUPS));
}
+ @Test
+ void eksPassesItsClusterNodePodAndAddonRolesAndANodeAccessEntrysPrincipal() {
+ String eks = "eks.amazonaws.com";
+ assertEquals(List.of(passed("cluster", eks)), PassedRoles.of("eks:CreateCluster",
+ json("{\"name\":\"c\",\"roleArn\":\"" + ROLES + "cluster\"}"), LOOKUPS));
+ assertEquals(List.of(passed("node", eks)), PassedRoles.of("eks:CreateNodegroup",
+ json("{\"nodeRole\":\"" + ROLES + "node\"}"), LOOKUPS));
+ assertEquals(List.of(passed("fargate", eks)), PassedRoles.of("eks:CreateFargateProfile",
+ json("{\"podExecutionRoleArn\":\"" + ROLES + "fargate\"}"), LOOKUPS));
+ String addon = """
+ {"serviceAccountRoleArn":"%1$saddon","podIdentityAssociations":[
+ {"serviceAccount":"a","roleArn":"%1$spod-a"},{"serviceAccount":"b","roleArn":"%1$spod-b"}]}"""
+ .formatted(ROLES);
+ for (String action : List.of("eks:CreateAddon", "eks:UpdateAddon")) {
+ assertEquals(List.of(passed("addon", eks), passed("pod-a", eks), passed("pod-b", eks)),
+ PassedRoles.of(action, json(addon), LOOKUPS));
+ }
+ // The association's role goes to Pod Identity; its target role is assumed with it, not passed.
+ String association = "{\"roleArn\":\"" + ROLES + "pod\",\"targetRoleArn\":\"" + ROLES + "target\"}";
+ for (String action : List.of("eks:CreatePodIdentityAssociation", "eks:UpdatePodIdentityAssociation")) {
+ assertEquals(List.of(passed("pod", "pods.eks.amazonaws.com")), PassedRoles.of(action, json(association),
+ LOOKUPS));
+ }
+ // Only a node access entry passes its principal, to EC2.
+ for (String type : List.of("EC2_LINUX", "EC2_WINDOWS")) {
+ assertEquals(List.of(passed("worker", EC2)), PassedRoles.of("eks:CreateAccessEntry",
+ json("{\"principalArn\":\"" + ROLES + "worker\",\"type\":\"" + type + "\"}"), LOOKUPS));
+ }
+ assertEquals(List.of(), PassedRoles.of("eks:CreateAccessEntry",
+ json("{\"principalArn\":\"" + ROLES + "admin\",\"type\":\"STANDARD\"}"), LOOKUPS));
+ assertEquals(List.of(), PassedRoles.of("eks:CreateAccessEntry",
+ json("{\"principalArn\":\"" + ROLES + "admin\"}"), LOOKUPS));
+ }
+
@Test
void outsideEcsOnlyARoleArnIsPassed() {
assertEquals(List.of(), PassedRoles.of("states:CreateStateMachine", json("{\"roleArn\":\"sm\"}"), LOOKUPS));
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamActionRegistryTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamActionRegistryTest.java
index a22750232c..2795c33bd2 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/IamActionRegistryTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamActionRegistryTest.java
@@ -363,6 +363,46 @@ class IamActionRegistryTest {
MediaType.APPLICATION_JSON_TYPE, "{}")));
}
+ @Test
+ void aTrailingSlashIsCheckedAsTheRouteWithoutIt() {
+ // The router matches /clusters/ as /clusters, so the rule ending at the route's last segment covers it.
+ // An S3 path is matched as sent, as before: a key may end in a slash.
+ String[][] routes = {
+ {"eks", "POST", "/clusters/", "eks:CreateCluster"},
+ {"eks", "GET", "/clusters/c/node-groups/ng/", "eks:DescribeNodegroup"},
+ {"scheduler", "GET", "/schedules/", "scheduler:ListSchedules"},
+ {"pipes", "GET", "/v1/pipes/p/", "pipes:DescribePipe"},
+ {"lambda", "GET", "/2015-03-31/functions/fn/", "lambda:GetFunction"},
+ {"s3", "GET", "/bucket/", "s3:ListBucket"},
+ {"s3", "GET", "/bucket/folder/", "s3:GetObject"},
+ {"s3", "PUT", "/bucket//", "s3:PutObject"},
+ {"s3", "GET", "/bucket//", "s3:GetObject"},
+ {"s3", "DELETE", "/bucket//", "s3:DeleteObject"},
+ };
+ for (String[] route : routes) {
+ assertEquals(route[3], registry.resolveRoute(route[0], mockCtx(route[1], route[2],
+ new MultivaluedHashMap<>(), MediaType.APPLICATION_JSON_TYPE, "{}")), route[2]);
+ }
+ }
+
+ @Test
+ void anEksAccessEntryRouteTakesThePrincipalAsTheRestOfThePath() {
+ // EKS reads the principal greedily, so a GET or DELETE under an entry reads or deletes an entry.
+ String entry = "/clusters/c/access-entries/arn:aws:iam::000000000000:role/team/worker";
+ String[][] routes = {
+ {"GET", entry, "eks:DescribeAccessEntry"},
+ {"GET", entry + "/access-policies", "eks:DescribeAccessEntry"},
+ {"DELETE", entry + "/access-policies/arn:aws:eks::aws:cluster-access-policy/Admin", "eks:DeleteAccessEntry"},
+ {"POST", entry + "/access-policies", "eks:AssociateAccessPolicy"},
+ {"POST", entry, "eks:UpdateAccessEntry"},
+ {"GET", "/clusters/c/access-entries", "eks:ListAccessEntries"},
+ };
+ for (String[] route : routes) {
+ assertEquals(route[2], registry.resolveRoute("eks", mockCtx(route[0], route[1],
+ new MultivaluedHashMap<>(), MediaType.APPLICATION_JSON_TYPE, "{}")), route[1]);
+ }
+ }
+
@Test
void returnsNullForUnknownRestJsonRoute() {
ContainerRequestContext ctx = mockCtx(
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamPassRoleEnforcementIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamPassRoleEnforcementIntegrationTest.java
index 3f85c87f11..ecefb83a44 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/IamPassRoleEnforcementIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamPassRoleEnforcementIntegrationTest.java
@@ -471,6 +471,83 @@ class IamPassRoleEnforcementIntegrationTest {
user.rest("pipes").body(update).put(path).then().statusCode(200);
}
+ @Test
+ void anEksPodIdentityAssociationNeedsPassRoleOnItsRoleForPodIdentity() {
+ // Pod Identity hands the service account's pods the association role's credentials, so naming a role
+ // needs iam:PassRole on it, passed to Pod Identity rather than to EKS.
+ String role = role("eks-pod");
+ String other = role("eks-pod-other");
+ User user = user("passrole-eks-pod");
+ String path = "/clusters/" + eksCluster() + "/pod-identity-associations";
+ String create = "{\"namespace\":\"default\",\"serviceAccount\":\"app\",\"roleArn\":\"" + role + "\"}";
+ String pods = "pods.eks.amazonaws.com";
+
+ user.policy(allow("eks:CreatePodIdentityAssociation", "*") + "," + passRole(role, "eks.amazonaws.com"));
+ denied(user.rest("eks").body(create).post(path).then());
+ user.policy(allow("eks:CreatePodIdentityAssociation", "*") + "," + passRole(role, pods));
+ String id = user.rest("eks").body(create).post(path).then().statusCode(200)
+ .extract().path("association.associationId");
+
+ String update = "{\"roleArn\":\"" + other + "\"}";
+ user.policy(allow("eks:UpdatePodIdentityAssociation", "*") + "," + passRole(role, pods));
+ denied(user.rest("eks").body(update).post(path + "/" + id).then());
+ user.policy(allow("eks:UpdatePodIdentityAssociation", "*") + "," + passRole(other, pods));
+ user.rest("eks").body(update).post(path + "/" + id).then().statusCode(200);
+ }
+
+ @Test
+ void anEksClusterNodeGroupFargateProfileAndNodeAccessEntryNeedPassRoleOnTheirRoles() {
+ String clusterRole = role("eks-cluster");
+ String nodeRole = role("eks-node");
+ String podRole = role("eks-fargate");
+ User user = user("passrole-eks");
+ String eks = "eks.amazonaws.com";
+ String name = "passrole-eks-" + suffix();
+ String path = "/clusters/" + name;
+ String cluster = "{\"name\":\"" + name + "\",\"roleArn\":\"" + clusterRole
+ + "\",\"accessConfig\":{\"authenticationMode\":\"API\"}}";
+
+ user.policy(allow("eks:CreateCluster", "*"));
+ denied(user.rest("eks").body(cluster).post("/clusters").then());
+ user.policy(allow("eks:CreateCluster", "*") + "," + passRole(clusterRole, eks));
+ user.rest("eks").body(cluster).post("/clusters").then().statusCode(200);
+ cleanup.register(() -> admin("eks").delete(path));
+
+ String nodegroup = "{\"nodegroupName\":\"ng\",\"subnets\":[\"subnet-abc\"],\"nodeRole\":\"" + nodeRole + "\"}";
+ user.policy(allow("eks:CreateNodegroup", "*"));
+ denied(user.rest("eks").body(nodegroup).post(path + "/node-groups").then());
+ user.policy(allow("eks:CreateNodegroup", "*") + "," + passRole(nodeRole, eks));
+ user.rest("eks").body(nodegroup).post(path + "/node-groups").then().statusCode(200);
+ cleanup.register(() -> admin("eks").delete(path + "/node-groups/ng"));
+
+ String profile = "{\"fargateProfileName\":\"fp\",\"podExecutionRoleArn\":\"" + podRole + "\"}";
+ user.policy(allow("eks:CreateFargateProfile", "*"));
+ denied(user.rest("eks").body(profile).post(path + "/fargate-profiles").then());
+ user.policy(allow("eks:CreateFargateProfile", "*") + "," + passRole(podRole, eks));
+ user.rest("eks").body(profile).post(path + "/fargate-profiles").then().statusCode(200);
+ cleanup.register(() -> admin("eks").delete(path + "/fargate-profiles/fp"));
+
+ // A node access entry passes its role to EC2, whose instances join as it; a standard one passes nothing.
+ String node = "{\"principalArn\":\"" + nodeRole + "\",\"type\":\"EC2_LINUX\"}";
+ user.policy(allow("eks:CreateAccessEntry", "*") + "," + passRole(nodeRole, eks));
+ denied(user.rest("eks").body(node).post(path + "/access-entries").then());
+ user.policy(allow("eks:CreateAccessEntry", "*") + "," + passRole(nodeRole, "ec2.amazonaws.com"));
+ user.rest("eks").body(node).post(path + "/access-entries").then().statusCode(200);
+ user.policy(allow("eks:CreateAccessEntry", "*"));
+ user.rest("eks").body("{\"principalArn\":\"" + podRole + "\"}").post(path + "/access-entries").then()
+ .statusCode(200);
+ }
+
+ /** Creates an EKS cluster as the account's admin, removed afterwards, and returns its name. */
+ private String eksCluster() {
+ String name = "passrole-cluster-" + suffix();
+ admin("eks").contentType("application/json")
+ .body("{\"name\":\"" + name + "\",\"roleArn\":\"arn:aws:iam::" + ACCOUNT + ":role/passrole-cluster\"}")
+ .post("/clusters").then().statusCode(200);
+ cleanup.register(() -> admin("eks").delete("/clusters/" + name));
+ return name;
+ }
+
@Test
void aMicrovmImageAndANetworkConnectorNeedPassRoleOnTheRolesTheyName() {
String build = role("microvm-build");
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamRestRouteCoverageTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamRestRouteCoverageTest.java
index 767ac485f6..962167349d 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/IamRestRouteCoverageTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamRestRouteCoverageTest.java
@@ -45,15 +45,18 @@ class IamRestRouteCoverageTest {
* Operations Floci does not serve, whose request runs as another operation instead and so is checked
* as that one: S3 has no bucket metadata configuration, and {@code ?metadataConfiguration} on a
* bucket falls through to ListObjects and DeleteBucket. Checking it as the metadata table action
- * would let that action list or delete the bucket.
+ * would let that action list or delete the bucket. EKS takes an access entry's principal as the rest
+ * of the path, so an entry's access policy routes read and delete the entry of a longer principal.
*/
private static final Map<String, String> RUN_AS_ANOTHER_OPERATION = Map.of(
"GetBucketMetadataConfiguration", "s3:ListBucket",
- "DeleteBucketMetadataConfiguration", "s3:DeleteBucket");
+ "DeleteBucketMetadataConfiguration", "s3:DeleteBucket",
+ "ListAssociatedAccessPolicies", "eks:DescribeAccessEntry",
+ "DisassociateAccessPolicy", "eks:DeleteAccessEntry");
/** Models every operation of which is checked: the services whose routes the registry maps in full. */
private static final Set<String> FULLY_ROUTED_MODELS =
- Set.of("scheduler", "pipes", "lambda", "lambda-microvms", "lambda-core", "dsql");
+ Set.of("scheduler", "pipes", "eks", "lambda", "lambda-microvms", "lambda-core", "dsql");
private final IamActionRegistry registry = new IamActionRegistry();
@@ -91,7 +94,8 @@ class IamRestRouteCoverageTest {
Map.Entry<String, JsonNode> operation = operations.next();
Route route = new Route(scope, model, operation.getKey(), operation.getValue().path("method").asText(),
operation.getValue().path("requestUri").asText());
- String expected = authorized.path(scope).path(operation.getKey()).asText(scope + ":" + operation.getKey());
+ String expected = RUN_AS_ANOTHER_OPERATION.getOrDefault(operation.getKey(),
+ authorized.path(scope).path(operation.getKey()).asText(scope + ":" + operation.getKey()));
tests.add(DynamicTest.dynamicTest(model + " " + operation.getKey(),
() -> assertEquals(expected, resolve(route), route.toString())));
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamRestRouteEnforcementIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamRestRouteEnforcementIntegrationTest.java
index 57bc9fea6b..a357b64a04 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/IamRestRouteEnforcementIntegrationTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamRestRouteEnforcementIntegrationTest.java
@@ -12,12 +12,15 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import java.net.URI;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import static io.github.hectorvent.floci.testing.EnforcementFixtures.auth;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.containsString;
+import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
/**
@@ -109,15 +112,166 @@ class IamRestRouteEnforcementIntegrationTest {
// tagging rule does not let the request through unchecked.
String user = user("route-tags-scope");
String group = scheduleGroup("route-group-" + suffix());
- String cluster = "arn:aws:eks:us-east-1:" + ACCOUNT + ":cluster/route-cluster-" + suffix();
+ String queue = "arn:aws:batch:us-east-1:" + ACCOUNT + ":job-queue/route-queue-" + suffix();
// Nor is an ARN of a service with no tagging rule checked as the signing scope's action.
- as(user, "pipes").body(tagBody(cluster)).post("/tags").then().body(not(containsString("pipes:TagResource")));
+ as(user, "pipes").body(tagBody(queue)).post("/tags").then().body(not(containsString("pipes:TagResource")));
policy(user, allow("pipes:TagResource", "*"));
refused(as(user, "pipes").body(tagBody(group)).post("/tags").then(), "scheduler:TagResource");
refused(as(user, "sqs").body(tagBody(group)).post("/tags").then(), "scheduler:TagResource");
}
+ @Test
+ void eksRoutesAreCheckedAgainstTheClusterAndTheNodeGroupEksHolds() {
+ // Every EKS route was let through unchecked. A cluster route is checked against the cluster, and a node
+ // group route against the ARN EKS holds the node group under, which ends in an id the request does not
+ // carry, so a Deny on that node group applies where the action is allowed on every resource.
+ String user = user("route-eks");
+ String name = "route-eks-" + suffix();
+ String cluster = eksCluster(name);
+ String nodegroup = eks().body("{\"nodegroupName\":\"ng\",\"subnets\":[\"subnet-abc\"],"
+ + "\"nodeRole\":\"arn:aws:iam::" + ACCOUNT + ":role/route-node\"}")
+ .post("/clusters/" + name + "/node-groups").then().statusCode(200)
+ .extract().path("nodegroup.nodegroupArn");
+ cleanup.register(() -> eks().delete("/clusters/" + name + "/node-groups/ng"));
+
+ policy(user, allow("eks:DescribeCluster", cluster + "-other"));
+ refused(as(user, "eks").get("/clusters/" + name).then(), "eks:DescribeCluster");
+ policy(user, allow("eks:DescribeCluster", cluster));
+ as(user, "eks").get("/clusters/" + name).then().statusCode(200);
+
+ String path = "/clusters/" + name + "/node-groups/ng";
+ policy(user, allow("eks:DescribeNodegroup", "*") + "," + deny("eks:DescribeNodegroup", nodegroup));
+ refused(as(user, "eks").get(path).then(), "eks:DescribeNodegroup");
+ policy(user, allow("eks:DescribeNodegroup", cluster.replace(":cluster/", ":nodegroup/") + "/ng/*"));
+ as(user, "eks").get(path).then().statusCode(200).body("nodegroup.nodegroupArn", equalTo(nodegroup));
+ }
+
+ @Test
+ void eachResourceAnEksClusterHoldsIsCheckedAgainstTheArnEksHoldsItUnder() {
+ // Each is looked up as EKS looks it up, so a Deny on its own ARN applies where the action is allowed
+ // on every resource, and a grant on that ARN alone covers it.
+ String user = user("route-eks-held");
+ String name = "route-held-" + suffix();
+ String base = "/clusters/" + name;
+ eksCluster(name);
+ String role = EnforcementFixtures.createRole(cleanup, baseUri.getPort(), ACCOUNT, "/", "route-held-" + suffix(),
+ "{\"Version\":\"2012-10-17\",\"Statement\":[" + allow("s3:*", "*") + "]}");
+ String profile = eks().body("{\"fargateProfileName\":\"fp\",\"podExecutionRoleArn\":\"" + role + "\"}")
+ .post(base + "/fargate-profiles").then().statusCode(200)
+ .extract().path("fargateProfile.fargateProfileArn");
+ cleanup.register(() -> eks().delete(base + "/fargate-profiles/fp"));
+ String addon = eks().body("{\"addonName\":\"vpc-cni\"}").post(base + "/addons").then().statusCode(200)
+ .extract().path("addon.addonArn");
+ String update = eks().body("{}").post(base + "/addons/vpc-cni/update").then().statusCode(200)
+ .extract().path("update.id");
+ String entry = eks().body("{\"principalArn\":\"" + role + "\"}").post(base + "/access-entries").then()
+ .statusCode(200).extract().path("accessEntry.accessEntryArn");
+ String association = eks().body("{\"namespace\":\"default\",\"serviceAccount\":\"app\",\"roleArn\":\"" + role
+ + "\"}").post(base + "/pod-identity-associations").then().statusCode(200)
+ .extract().path("association.associationArn");
+ String[][] routes = {
+ {"eks:DescribeFargateProfile", base + "/fargate-profiles/fp", profile},
+ {"eks:DescribeAddon", base + "/addons/vpc-cni", addon},
+ // EKS returns an add-on's update without its addonName, so the update is its add-on's.
+ {"eks:DescribeUpdate", base + "/updates/" + update, addon},
+ {"eks:DescribeAccessEntry", base + "/access-entries/" + encoded(role), entry},
+ {"eks:DescribePodIdentityAssociation",
+ base + "/pod-identity-associations/" + association.substring(association.lastIndexOf('/') + 1),
+ association},
+ };
+ for (String[] route : routes) {
+ policy(user, allow(route[0], "*") + "," + deny(route[0], route[2]));
+ refused(as(user, "eks").urlEncodingEnabled(false).get(route[1]).then(), route[0]);
+ policy(user, allow(route[0], route[2]));
+ as(user, "eks").urlEncodingEnabled(false).get(route[1]).then().statusCode(200);
+ }
+ }
+
+ @Test
+ void anEksClusterRouteIsCheckedAgainstTheClusterEksActsOn() {
+ // EKS finds a cluster by its name alone, whatever Region a request is signed for, so a request signed
+ // for another Region is checked against the cluster it acts on.
+ String user = user("route-eks-region");
+ String name = "route-west-" + suffix();
+ String cluster = given().header("Authorization", auth(ADMIN, "us-west-2", "eks"))
+ .contentType("application/json")
+ .body("{\"name\":\"" + name + "\",\"roleArn\":\"arn:aws:iam::" + ACCOUNT + ":role/route-cluster\"}")
+ .post("/clusters").then().statusCode(200).extract().path("cluster.arn");
+ cleanup.register(() -> eks().delete("/clusters/" + name));
+
+ policy(user, allow("eks:DescribeCluster", "*") + "," + deny("eks:DescribeCluster", cluster));
+ refused(as(user, "eks").get("/clusters/" + name).then(), "eks:DescribeCluster");
+ policy(user, allow("eks:DescribeCluster", cluster));
+ as(user, "eks").get("/clusters/" + name).then().statusCode(200);
+ }
+
+ @Test
+ void anEksAccessEntrysPolicyRoutesAreCheckedAsTheEntryRoutesTheyRunAs() {
+ // EKS takes an access entry's principal as the rest of the path, so a request on an entry's access
+ // policies reads or deletes the entry of a longer principal, and is checked as that.
+ String user = user("route-eks-entry");
+ String name = "route-entry-" + suffix();
+ eksCluster(name);
+ String principal = encoded("arn:aws:iam::" + ACCOUNT + ":role/route-entry");
+ String policies = "/clusters/" + name + "/access-entries/" + principal + "/access-policies";
+ String admin = encoded("arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy");
+
+ policy(user, allow("eks:ListAssociatedAccessPolicies", "*") + "," + allow("eks:DisassociateAccessPolicy", "*"));
+ refused(as(user, "eks").urlEncodingEnabled(false).get(policies).then(), "eks:DescribeAccessEntry");
+ refused(as(user, "eks").urlEncodingEnabled(false).delete(policies + "/" + admin).then(),
+ "eks:DeleteAccessEntry");
+ // Allowed, it reaches EKS, which looks up the entry of a principal ending in /access-policies.
+ policy(user, allow("eks:DescribeAccessEntry", "*"));
+ as(user, "eks").urlEncodingEnabled(false).get(policies).then().statusCode(404)
+ .body("message", equalTo("Access entry not found"));
+ }
+
+ @Test
+ void eksTaggingIsCheckedAgainstTheCallersClusterOfThatName() {
+ // EKS tags the caller's own cluster named after the ARN's last /, whatever account the ARN names, so a
+ // grant on another account's cluster of that name does not cover it, and one on the caller's own does.
+ String user = user("route-eks-tags");
+ String cluster = eksCluster("route-tagged-" + suffix());
+ String foreign = cluster.replace(ACCOUNT, "111122223333");
+ String body = "{\"tags\":{\"team\":\"a\"}}";
+
+ policy(user, allow("eks:TagResource", foreign));
+ refused(as(user, "eks").body(body).post("/tags/" + foreign).then(), "eks:TagResource");
+ policy(user, allow("eks:TagResource", cluster));
+ as(user, "eks").body(body).post("/tags/" + foreign).then().statusCode(not(403));
+ eks().get("/tags/" + cluster).then().statusCode(200).body("tags.team", equalTo("a"));
+ }
+
+ @Test
+ void aTrailingSlashDoesNotLetARouteThroughUnchecked() {
+ // The router matches /clusters/ as /clusters, so the request is checked as the route it reaches.
+ String user = user("route-trailing-slash");
+ policy(user, allow("sqs:ListQueues", "*"));
+ refused(as(user, "eks").body("{\"name\":\"route-slash-" + suffix() + "\"}").post("/clusters/").then(),
+ "eks:CreateCluster");
+ refused(as(user, "eks").get("/clusters/").then(), "eks:ListClusters");
+ refused(as(user, "scheduler").get("/schedules/").then(), "scheduler:ListSchedules");
+ refused(as(user, "lambda").get("/2015-03-31/functions/route-fn/").then(), "lambda:GetFunction");
+ }
+
+ /** Creates an EKS cluster as the account's admin, removed afterwards, and returns its ARN. */
+ private String eksCluster(String name) {
+ String arn = eks().body("{\"name\":\"" + name + "\",\"roleArn\":\"arn:aws:iam::" + ACCOUNT
+ + ":role/route-cluster\",\"accessConfig\":{\"authenticationMode\":\"API\"}}")
+ .post("/clusters").then().statusCode(200).extract().path("cluster.arn");
+ cleanup.register(() -> eks().delete("/clusters/" + name));
+ return arn;
+ }
+
+ private static RequestSpecification eks() {
+ return given().header("Authorization", auth(ADMIN, "eks")).contentType("application/json");
+ }
+
+ private static String encoded(String value) {
+ return URLEncoder.encode(value, StandardCharsets.UTF_8);
+ }
+
private static String scheduleGroup(String name) {
return "arn:aws:scheduler:us-east-1:" + ACCOUNT + ":schedule-group/" + name;
}
diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilderTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilderTest.java
index 7cb22232cf..aee85c7515 100644
--- a/src/test/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilderTest.java
+++ b/src/test/java/io/github/hectorvent/floci/services/iam/ResourceArnBuilderTest.java
@@ -6,6 +6,7 @@ import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.common.RequestContext;
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
+import io.github.hectorvent.floci.services.eks.EksService;
import io.github.hectorvent.floci.services.iam.model.AccessKey;
import io.github.hectorvent.floci.services.iam.model.IamGroup;
import io.github.hectorvent.floci.services.iam.model.IamRole;
@@ -128,6 +129,14 @@ class ResourceArnBuilderTest {
return new ResourceArnBuilder(new ObjectMapper(), null, instance);
}
+ /** A builder reading {@code eks}, for an EKS route naming a cluster or what it holds. */
+ private static ResourceArnBuilder backedBy(EksService eks) {
+ @SuppressWarnings("unchecked")
+ Instance<EksService> instance = mock(Instance.class);
+ when(instance.get()).thenReturn(eks);
+ return new ResourceArnBuilder(new ObjectMapper(), null, null, null, instance);
+ }
+
private static IamService storeHolding(String userName, String path, String arn) {
IamUser user = new IamUser();
user.setUserName(userName);
@@ -1630,6 +1639,109 @@ class ResourceArnBuilderTest {
assertEquals("arn:aws:lambda:us-east-1:000000000000:function:my-function:1/durable-execution/run-1/0b1c", arn);
}
+ // ── EKS ──────────────────────────────────────────────────────────────────────
+
+ /** The cluster {@code held}, which EKS keeps in us-west-2 and finds by its name alone, and what it holds. */
+ private static final String HELD_CLUSTER = "arn:aws:eks:us-west-2:000000000000:cluster/held";
+ private static final String WORKER = "arn:aws:iam::000000000000:role/team/worker";
+
+ private static ResourceArnBuilder eksHolding() {
+ EksService eks = mock(EksService.class);
+ when(eks.findResourceArn(any(), any(), any())).thenReturn(Optional.empty());
+ when(eks.findResourceArn("held", null, null)).thenReturn(Optional.of(HELD_CLUSTER));
+ for (String[] held : new String[][] {
+ {"node-groups", "ng", "nodegroup/held/ng/1"}, {"node-groups", "a/b", "nodegroup/held/a/b/2"},
+ {"fargate-profiles", "fp", "fargateprofile/held/fp/3"}, {"addons", "vpc-cni", "addon/held/vpc-cni/4"},
+ {"updates", "u-1", "addon/held/vpc-cni/4"},
+ {"pod-identity-associations", "a-1", "podidentityassociation/held/a-1"},
+ {"access-entries", WORKER, "access-entry/held/role/000000000000/worker/5"},
+ {"access-entries", WORKER + "/access-policies", "access-entry/held/role/000000000000/access-policies/6"},
+ }) {
+ when(eks.findResourceArn("held", held[0], held[1]))
+ .thenReturn(Optional.of("arn:aws:eks:us-west-2:000000000000:" + held[2]));
+ }
+ return backedBy(eks);
+ }
+
+ private String eksResource(ResourceArnBuilder eks, String method, String sent) {
+ when(ctx.getMethod()).thenReturn(method);
+ request(sent);
+ return eks.build("eks", ctx, "us-east-1", ACCOUNT);
+ }
+
+ @Test
+ void anEksClusterRouteActsOnTheClusterEksHoldsOrTheOneACreateMints() {
+ ResourceArnBuilder eks = eksHolding();
+ String minted = "arn:aws:eks:us-east-1:000000000000:cluster/";
+ assertEquals(HELD_CLUSTER, eksResource(eks, "GET", "/clusters/held"));
+ assertEquals(minted + "gone", eksResource(eks, "DELETE", "/clusters/gone"));
+ for (String route : List.of("/node-groups", "/addons", "/access-entries", "/pod-identity-associations",
+ "/update-config", "/updates", "/updates/u-1/cancel-update", "/insights/i-1",
+ "/certificate-authorities/ca-1/activate", "/identity-provider-configs/associate")) {
+ assertEquals(HELD_CLUSTER, eksResource(eks, "POST", "/clusters/held" + route), route);
+ }
+ assertEquals(HELD_CLUSTER, eksResource(eks, "DELETE", "/cluster-registrations/held"));
+
+ // A create is checked against the cluster its body names; listing clusters names none.
+ setJsonBody("{\"name\":\"fresh\",\"roleArn\":\"arn:aws:iam::000000000000:role/r\"}");
+ assertEquals(minted + "fresh", eksResource(eks, "POST", "/clusters"));
+ assertEquals("*", eksResource(eks, "GET", "/clusters"));
+ }
+
+ @Test
+ void anEksRouteOnWhatAClusterHoldsActsOnTheArnEksHoldsItUnder() {
+ ResourceArnBuilder eks = eksHolding();
+ String held = "arn:aws:eks:us-west-2:000000000000:";
+ assertEquals(held + "nodegroup/held/ng/1", eksResource(eks, "GET", "/clusters/held/node-groups/ng"));
+ assertEquals(held + "nodegroup/held/ng/1",
+ eksResource(eks, "POST", "/clusters/held/node-groups/ng/update-version"));
+ // The router keeps an encoded / inside the name, and EKS looks the node group up by it.
+ assertEquals(held + "nodegroup/held/a/b/2", eksResource(eks, "GET", "/clusters/held/node-groups/a%2Fb"));
+ assertEquals(held + "fargateprofile/held/fp/3", eksResource(eks, "DELETE", "/clusters/held/fargate-profiles/fp"));
+ assertEquals(held + "addon/held/vpc-cni/4", eksResource(eks, "POST", "/clusters/held/addons/vpc-cni/update"));
+ assertEquals(held + "podidentityassociation/held/a-1",
+ eksResource(eks, "POST", "/clusters/held/pod-identity-associations/a-1"));
+ // An access entry's principal is the rest of the path, encoded or not.
+ assertEquals(held + "access-entry/held/role/000000000000/worker/5", eksResource(eks, "GET",
+ "/clusters/held/access-entries/arn%3Aaws%3Aiam%3A%3A000000000000%3Arole%2Fteam%2Fworker"));
+ assertEquals(held + "access-entry/held/role/000000000000/worker/5",
+ eksResource(eks, "DELETE", "/clusters/held/access-entries/" + WORKER));
+ assertEquals(held + "access-entry/held/role/000000000000/access-policies/6",
+ eksResource(eks, "GET", "/clusters/held/access-entries/" + WORKER + "/access-policies"));
+ // What EKS does not hold names no resource, nor do what Floci keeps no id for.
+ assertEquals("*", eksResource(eks, "GET", "/clusters/held/node-groups/other"));
+ assertEquals("*", eksResource(eks, "GET", "/clusters/gone/addons/vpc-cni"));
+ assertEquals("*", eksResource(eks, "POST", "/clusters/held/identity-provider-configs/describe"));
+ assertEquals("*", eksResource(eks, "GET", "/clusters/held/capabilities/argocd"));
+ }
+
+ @Test
+ void anEksUpdateActsOnItsAddonAndATagOnTheCallersClusterOfThatName() {
+ ResourceArnBuilder eks = eksHolding();
+ // EKS returns an add-on's update whatever add-on the request names, if any, so it acts on its own add-on.
+ String addon = "arn:aws:eks:us-west-2:000000000000:addon/held/vpc-cni/4";
+ assertEquals(addon, eksResource(eks, "GET", "/clusters/held/updates/u-1"));
+ queryParams.putSingle("addonName", "coredns");
+ assertEquals(addon, eksResource(eks, "GET", "/clusters/held/updates/u-1"));
+ queryParams.clear();
+ assertEquals(HELD_CLUSTER, eksResource(eks, "GET", "/clusters/held/updates/u-2"));
+ assertEquals(HELD_CLUSTER, eksResource(eks, "POST", "/clusters/held/updates/u-1/cancel-update"));
+
+ // EKS tags the caller's cluster named after the ARN's last /, whatever account or Region it names.
+ assertEquals(HELD_CLUSTER, eksResource(eks, "POST", "/tags/arn:aws:eks:eu-west-1:111122223333:cluster/held"));
+ queryParams.putSingle("resourceArn", "arn:aws:eks:eu-west-1:111122223333:cluster/held");
+ assertEquals(HELD_CLUSTER, eksResource(eks, "DELETE", "/tags"));
+ queryParams.clear();
+ assertEquals("*", eksResource(eks, "GET", "/tags/no-slash"));
+
+ assertEquals("arn:aws:eks:us-east-1:000000000000:eks-anywhere-subscription/sub-1",
+ eksResource(eks, "GET", "/eks-anywhere-subscriptions/sub-1"));
+ for (String route : List.of("/addons/supported-versions", "/access-policies", "/cluster-versions",
+ "/cluster-registrations", "/eks-anywhere-subscriptions")) {
+ assertEquals("*", eksResource(eks, "GET", route), route);
+ }
+ }
+
/** Stubs the request path as sent and, decoded, as {@link UriInfo#getPath()} gives it. */
private void request(String sent) {
when(uriInfo.getRequestUri()).thenReturn(URI.create("http://localhost:4566" + sent));
diff --git a/src/test/resources/aws/rest-routes.json b/src/test/resources/aws/rest-routes.json
index cbc01f8519..8f6c76e041 100644
--- a/src/test/resources/aws/rest-routes.json
+++ b/src/test/resources/aws/rest-routes.json
@@ -262,6 +262,82 @@
"UpdateCluster": {"method": "POST", "requestUri": "/cluster/{identifier}"}
}
},
+ "eks": {
+ "credentialScope": "eks",
+ "apiVersion": "2017-11-01",
+ "operations": {
+ "ActivateCertificateAuthority": {"method": "POST", "requestUri": "/clusters/{name}/certificate-authorities/{certificateAuthorityId}/activate"},
+ "AssociateAccessPolicy": {"method": "POST", "requestUri": "/clusters/{name}/access-entries/{principalArn}/access-policies"},
+ "AssociateEncryptionConfig": {"method": "POST", "requestUri": "/clusters/{name}/encryption-config/associate"},
+ "AssociateIdentityProviderConfig": {"method": "POST", "requestUri": "/clusters/{name}/identity-provider-configs/associate"},
+ "CancelUpdate": {"method": "POST", "requestUri": "/clusters/{name}/updates/{updateId}/cancel-update"},
+ "CreateAccessEntry": {"method": "POST", "requestUri": "/clusters/{name}/access-entries"},
+ "CreateAddon": {"method": "POST", "requestUri": "/clusters/{name}/addons"},
+ "CreateCapability": {"method": "POST", "requestUri": "/clusters/{name}/capabilities"},
+ "CreateCertificateAuthority": {"method": "POST", "requestUri": "/clusters/{name}/certificate-authorities"},
+ "CreateCluster": {"method": "POST", "requestUri": "/clusters"},
+ "CreateEksAnywhereSubscription": {"method": "POST", "requestUri": "/eks-anywhere-subscriptions"},
+ "CreateFargateProfile": {"method": "POST", "requestUri": "/clusters/{name}/fargate-profiles"},
+ "CreateNodegroup": {"method": "POST", "requestUri": "/clusters/{name}/node-groups"},
+ "CreatePodIdentityAssociation": {"method": "POST", "requestUri": "/clusters/{name}/pod-identity-associations"},
+ "DeleteAccessEntry": {"method": "DELETE", "requestUri": "/clusters/{name}/access-entries/{principalArn}"},
+ "DeleteAddon": {"method": "DELETE", "requestUri": "/clusters/{name}/addons/{addonName}"},
+ "DeleteCapability": {"method": "DELETE", "requestUri": "/clusters/{name}/capabilities/{capabilityName}"},
+ "DeleteCertificateAuthority": {"method": "DELETE", "requestUri": "/clusters/{name}/certificate-authorities/{certificateAuthorityId}"},
+ "DeleteCluster": {"method": "DELETE", "requestUri": "/clusters/{name}"},
+ "DeleteEksAnywhereSubscription": {"method": "DELETE", "requestUri": "/eks-anywhere-subscriptions/{id}"},
+ "DeleteFargateProfile": {"method": "DELETE", "requestUri": "/clusters/{name}/fargate-profiles/{fargateProfileName}"},
+ "DeleteNodegroup": {"method": "DELETE", "requestUri": "/clusters/{name}/node-groups/{nodegroupName}"},
+ "DeletePodIdentityAssociation": {"method": "DELETE", "requestUri": "/clusters/{name}/pod-identity-associations/{associationId}"},
+ "DeregisterCluster": {"method": "DELETE", "requestUri": "/cluster-registrations/{name}"},
+ "DescribeAccessEntry": {"method": "GET", "requestUri": "/clusters/{name}/access-entries/{principalArn}"},
+ "DescribeAddon": {"method": "GET", "requestUri": "/clusters/{name}/addons/{addonName}"},
+ "DescribeAddonConfiguration": {"method": "GET", "requestUri": "/addons/configuration-schemas"},
+ "DescribeAddonVersions": {"method": "GET", "requestUri": "/addons/supported-versions"},
+ "DescribeCapability": {"method": "GET", "requestUri": "/clusters/{name}/capabilities/{capabilityName}"},
+ "DescribeCertificateAuthority": {"method": "GET", "requestUri": "/clusters/{name}/certificate-authorities/{certificateAuthorityId}"},
+ "DescribeCluster": {"method": "GET", "requestUri": "/clusters/{name}"},
+ "DescribeClusterVersions": {"method": "GET", "requestUri": "/cluster-versions"},
+ "DescribeEksAnywhereSubscription": {"method": "GET", "requestUri": "/eks-anywhere-subscriptions/{id}"},
+ "DescribeFargateProfile": {"method": "GET", "requestUri": "/clusters/{name}/fargate-profiles/{fargateProfileName}"},
+ "DescribeIdentityProviderConfig": {"method": "POST", "requestUri": "/clusters/{name}/identity-provider-configs/describe"},
+ "DescribeInsight": {"method": "GET", "requestUri": "/clusters/{name}/insights/{id}"},
+ "DescribeInsightsRefresh": {"method": "GET", "requestUri": "/clusters/{name}/insights-refresh"},
+ "DescribeNodegroup": {"method": "GET", "requestUri": "/clusters/{name}/node-groups/{nodegroupName}"},
+ "DescribePodIdentityAssociation": {"method": "GET", "requestUri": "/clusters/{name}/pod-identity-associations/{associationId}"},
+ "DescribeUpdate": {"method": "GET", "requestUri": "/clusters/{name}/updates/{updateId}"},
+ "DisassociateAccessPolicy": {"method": "DELETE", "requestUri": "/clusters/{name}/access-entries/{principalArn}/access-policies/{policyArn}"},
+ "DisassociateIdentityProviderConfig": {"method": "POST", "requestUri": "/clusters/{name}/identity-provider-configs/disassociate"},
+ "ListAccessEntries": {"method": "GET", "requestUri": "/clusters/{name}/access-entries"},
+ "ListAccessPolicies": {"method": "GET", "requestUri": "/access-policies"},
+ "ListAddons": {"method": "GET", "requestUri": "/clusters/{name}/addons"},
+ "ListAssociatedAccessPolicies": {"method": "GET", "requestUri": "/clusters/{name}/access-entries/{principalArn}/access-policies"},
+ "ListCapabilities": {"method": "GET", "requestUri": "/clusters/{name}/capabilities"},
+ "ListCertificateAuthorities": {"method": "GET", "requestUri": "/clusters/{name}/certificate-authorities"},
+ "ListClusters": {"method": "GET", "requestUri": "/clusters"},
+ "ListEksAnywhereSubscriptions": {"method": "GET", "requestUri": "/eks-anywhere-subscriptions"},
+ "ListFargateProfiles": {"method": "GET", "requestUri": "/clusters/{name}/fargate-profiles"},
+ "ListIdentityProviderConfigs": {"method": "GET", "requestUri": "/clusters/{name}/identity-provider-configs"},
+ "ListInsights": {"method": "POST", "requestUri": "/clusters/{name}/insights"},
+ "ListNodegroups": {"method": "GET", "requestUri": "/clusters/{name}/node-groups"},
+ "ListPodIdentityAssociations": {"method": "GET", "requestUri": "/clusters/{name}/pod-identity-associations"},
+ "ListTagsForResource": {"method": "GET", "requestUri": "/tags/{resourceArn}"},
+ "ListUpdates": {"method": "GET", "requestUri": "/clusters/{name}/updates"},
+ "RegisterCluster": {"method": "POST", "requestUri": "/cluster-registrations"},
+ "StartInsightsRefresh": {"method": "POST", "requestUri": "/clusters/{name}/insights-refresh"},
+ "TagResource": {"method": "POST", "requestUri": "/tags/{resourceArn}"},
+ "UntagResource": {"method": "DELETE", "requestUri": "/tags/{resourceArn}"},
+ "UpdateAccessEntry": {"method": "POST", "requestUri": "/clusters/{name}/access-entries/{principalArn}"},
+ "UpdateAddon": {"method": "POST", "requestUri": "/clusters/{name}/addons/{addonName}/update"},
+ "UpdateCapability": {"method": "POST", "requestUri": "/clusters/{name}/capabilities/{capabilityName}"},
+ "UpdateClusterConfig": {"method": "POST", "requestUri": "/clusters/{name}/update-config"},
+ "UpdateClusterVersion": {"method": "POST", "requestUri": "/clusters/{name}/updates"},
+ "UpdateEksAnywhereSubscription": {"method": "POST", "requestUri": "/eks-anywhere-subscriptions/{id}"},
+ "UpdateNodegroupConfig": {"method": "POST", "requestUri": "/clusters/{name}/node-groups/{nodegroupName}/update-config"},
+ "UpdateNodegroupVersion": {"method": "POST", "requestUri": "/clusters/{name}/node-groups/{nodegroupName}/update-version"},
+ "UpdatePodIdentityAssociation": {"method": "POST", "requestUri": "/clusters/{name}/pod-identity-associations/{associationId}"}
+ }
+ },
"lambda": {
"credentialScope": "lambda",
"apiVersion": "2015-03-31",
diff --git a/tools/aws/regen_rest_routes.py b/tools/aws/regen_rest_routes.py
index 6637b9de7b..fc90ecc563 100644
--- a/tools/aws/regen_rest_routes.py
+++ b/tools/aws/regen_rest_routes.py
@@ -35,6 +35,7 @@ MODELS: dict[str, str] = {
"apigateway": "apigateway",
"apigatewayv2": "apigateway",
"dsql": "dsql",
+ "eks": "eks",
"lambda": "lambda",
"lambda-core": "lambda",
"lambda-microvms": "lambda",