Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 18 additions & 19 deletions docs/services/iam.md
Original file line number Diff line number Diff line change
Expand Up @@ -2332,7 +2332,7 @@ requests retain HTTP 403 XML `AccessDenied` responses, except SNS's, which retur
action is denied. The routed protocol determines the status, not just the request's content type.

A request is checked against the resources it names. Floci builds their ARNs itself for S3,
DynamoDB, SSM, KMS, IAM, Resource Groups, EKS, API Gateway
DynamoDB, SSM, KMS, IAM, Resource Groups, API Gateway
and CloudWatch Logs. For Secrets Manager, Elastic Load Balancing, ECR,
Step Functions, EventBridge, EventBridge Scheduler, Amazon Cognito user pools and identity pools, Amazon Data Firehose, Cloud
Map, ACM, CodePipeline, CodeBuild, Amazon Managed Service for Apache Flink (Kinesis Data Analytics v2),
Expand All @@ -2341,7 +2341,7 @@ AWS Data Exports, AWS Pricing Calculator, Cost Explorer, CloudTrail, Global Acce
Timestream for InfluxDB, Amazon Redshift, the Amazon Redshift Data API, AWS Payment Cryptography, AWS DataSync, Amazon EMR,
Amazon Rekognition, IAM Identity Center, Amazon Inspector, Amazon Macie, AWS Fault Injection Service, AWS Resource
Access Manager, CloudWatch Observability Access Manager, AWS Resource Explorer, AWS Account Management, AWS Control
Catalog, Amazon OpenSearch Service, IAM Access Analyzer, AWS Security Hub, Amazon GuardDuty, Lambda, AWS Glue, Amazon SQS, Amazon SNS, Amazon Kinesis Data Streams, Amazon EventBridge Pipes, Aurora DSQL and STS they come from a table generated from AWS's Service Reference and botocore, `src/main/resources/aws/iam-request-resources.json`, which gives each
Catalog, Amazon OpenSearch Service, IAM Access Analyzer, AWS Security Hub, Amazon GuardDuty, Lambda, AWS Glue, Amazon SQS, Amazon SNS, Amazon Kinesis Data Streams, Amazon EventBridge Pipes, Aurora DSQL, STS and Amazon EKS they come from a table generated from AWS's Service Reference and botocore, `src/main/resources/aws/iam-request-resources.json`, which gives each
operation's action, the resource types that action acts on with their ARN formats, and the request
members that name them: a member holding a resource's ARN, which counts when it matches the format
of a type the action acts on, or members filling the variables of a type's format. Nothing in it is
Expand Down Expand Up @@ -2560,26 +2560,24 @@ came from. `ListQueues`, and `CancelMessageMoveTask`, whose `TaskHandle` names n
`*`, so a grant scoped to a queue, or to the account's queues, does not allow cancelling a move task: it
takes a grant on `*`.

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.
An EKS request is checked on what the generated table reads from it, in the caller's account, where
EKS looks everything up. A cluster route is checked against `cluster/<name>`, the name its path gives,
and `CreateCluster` against the cluster its body names, from a measured entry quoting the EKS user
guide's example policy for creating a cluster, as the Service Reference lists no resource type for it.
A node group, add-on or Fargate profile, whose ARN ends in an id EKS minted, is checked against the ARN
EKS holds it under, found by the names its path gives in the request's Region, or with its names open
when EKS holds none; an access entry, Pod Identity association, identity provider config or capability
is checked with the parts of its ARN the request does not give open, so a policy names it with a
wildcard, such as `access-entry/<cluster>/*`. Listing or creating them, and the other routes under a
cluster, are checked against the cluster. An EKS tagging request is checked against the ARN its
`/tags/{resourceArn}` carries, and EKS tags the resource whose ARN is that whole ARN.

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, or for EKS the cluster it tags, whatever scope
it is signed with. The ARN is
and it is checked as that service, against that ARN, 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. A service whose resources the generated table reads
whole is served there only on the routes its model gives, as AWS, which tells these services apart by hostname,
serves no other: EventBridge Scheduler, EMR Serverless, GuardDuty and Security Hub tag only on
serves no other: EventBridge Scheduler, EMR Serverless, GuardDuty, Security Hub and EKS tag only on
`/tags/{resourceArn}`, the ARN encoded, and a request on the bare `/tags`, or naming an ARN whose `/` is not
encoded, is refused with `BadRequestException` ("Invalid resource ARN") and tags nothing.

Expand Down Expand Up @@ -3538,8 +3536,9 @@ floci populates:
subscriptions, Security Hub for its hubs and configuration policies, Control Tower for its landing zones and enabled
controls, GuardDuty for its detectors and Malware Protection plans, Cloud Map for its namespaces and services, Elastic
Load Balancing for its load balancers, target groups, listeners and rules and its Classic Load Balancers, SQS for its
queues, SNS for its topics, Kinesis Data Streams for its streams and consumers, EventBridge Pipes for its pipes and
Aurora DSQL for its clusters. Tag keys differing only in case are one condition key holding every value.
queues, SNS for its topics, Kinesis Data Streams for its streams and consumers, EventBridge Pipes for its pipes,
Aurora DSQL for its clusters and EKS for its clusters, node groups, Fargate profiles, add-ons, Pod Identity
associations and access entries. Tag keys differing only in case are one condition key holding every value.
- EC2 resource keys such as a network interface's `ec2:Vpc`, `ec2:Subnet`, `ec2:AvailabilityZone` and
`ec2:NetworkInterfaceID`: for every action on a resource EC2 holds, the members of the resource the
key names, an ARN for a key the Service Reference types as one. `resourceKeys` in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@
* Map, for the tags of a namespace or a service; Elastic Load Balancing, for the tags of a load balancer, a target
* group, a listener, a rule or a Classic Load Balancer; SQS, for the tags of a queue; SNS, for the tags of a topic;
* Kinesis Data Streams, for the tags of a stream or a consumer; EventBridge Pipes, for the tags of a pipe; Aurora DSQL,
* for the tags of a cluster); looked up lazily by {@code ResourceArnBuilder} and {@code IamConditionContextResolver}
* through {@code Instance<StoredResourceArns>} for the namespace a request or an ARN is of, so IAM never depends on
* that service directly.</p>
* for the tags of a cluster; EKS, for the tags of a cluster, a node group, a Fargate profile, an add-on, a Pod Identity
* association or an access entry); looked up lazily by {@code ResourceArnBuilder} and
* {@code IamConditionContextResolver} through {@code Instance<StoredResourceArns>} for the namespace a request or an
* ARN is of, so IAM never depends on that service directly.</p>
*
* <p>Each answer is a lookup of what the service holds, asked for by an entry of the generated table ({@code find},
* {@code through}, a default, {@code forwarded}, a type's {@code resourceTagKeys}): never a fact about what an operation acts on, which the table alone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,26 @@ public synchronized Optional<Map<String, String>> retag(Cluster cluster, String
return Optional.empty();
}

/**
* The tags of the access entry of {@code cluster} in {@code account} whose ARN is {@code accessEntryArn}, read in
* place.
*/
Optional<Map<String, String>> tagsInAccount(String account, Cluster cluster, String accessEntryArn) {
String prefix = prefix(cluster);
for (String key : entries.keys()) {
if (!key.startsWith(prefix)) {
continue;
}
Optional<Map<String, String>> tags = AccountAwareStorageBackend.readInAccount(entries, account, key)
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved
.filter(stored -> accessEntryArn.equals(stored.entry().accessEntryArn()))
.map(stored -> stored.entry().tags());
if (tags.isPresent()) {
return tags;
}
}
return Optional.empty();
}

private static String prefix(Cluster cluster) {
// A recreated cluster must not inherit access entries or pagination tokens from its predecessor.
return cluster.getArn() + "/" + Objects.toString(cluster.getCreatedAt()) + "/";
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/io/floci/aws/services/eks/EksAddonService.java
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,17 @@ public synchronized Optional<Map<String, String>> retag(Cluster cluster, String
return Optional.of(tags);
}

/**
* The tags of the add-on {@code addonName} of {@code cluster} in {@code account}, read in place, if its ARN is
* {@code addonArn}.
*/
Optional<Map<String, String>> tagsInAccount(String account, Cluster cluster, String addonName, String addonArn) {
return AccountAwareStorageBackend.readInAccount(storage, account,
prefix(cluster) + addonName.toLowerCase(Locale.ROOT))
.filter(stored -> addonArn.equals(stored.addon().addonArn()))
.map(stored -> stored.addon().tags());
}

private static String prefix(Cluster cluster) {
return cluster.getArn() + "/" + Objects.toString(cluster.getCreatedAt()) + "/";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import io.floci.aws.core.common.Base64Url;
import io.floci.aws.core.common.EpochSeconds;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.storage.AccountAwareStorageBackend;
import io.floci.aws.core.storage.StorageBackend;
import io.floci.aws.core.storage.StorageFactory;
import io.floci.aws.services.eks.model.Cluster;
Expand Down Expand Up @@ -324,6 +325,17 @@ public synchronized Optional<Map<String, String>> retag(Cluster cluster, String
return Optional.of(tags);
}

/**
* The tags of the association {@code associationId} of {@code cluster} in {@code account}, read in place, if its ARN
* is {@code associationArn}.
*/
Optional<Map<String, String>> tagsInAccount(String account, Cluster cluster, String associationId,
String associationArn) {
return AccountAwareStorageBackend.readInAccount(associations, account, prefix(cluster) + associationId)
.filter(stored -> associationArn.equals(stored.association().associationArn()))
.map(stored -> stored.association().tags());
}

private static String prefix(Cluster cluster) {
String base = cluster.getArn() != null ? cluster.getArn() : cluster.getName();
return base + "/" + Objects.toString(cluster.getCreatedAt()) + "/";
Expand Down
Loading
Loading