From 5bcb83b932cb457ff84c01c055d2d66a30954b1c Mon Sep 17 00:00:00 2001 From: Aymen JAMAAOUI <5993228+aymenjamaaoui@users.noreply.github.com> Date: Thu, 5 Nov 2026 16:57:59 +0100 Subject: [PATCH] fix(iam): check Redshift requests on the resources they name (#7287) Under IAM enforcement, Redshift requests were checked on `*`, so a grant scoped to a cluster, a snapshot or a database user was refused, and a deny scoped to one never applied. The redshift namespace moves from NOT_COVERED to NAMESPACES in the request resources generator, with corrections where the generated rule checks the wrong resource. GetClusterCredentials now also gives the redshift:DbUser condition key, from a new generated table, to its own check and to the CreateClusterUser check that AutoCreate adds. Refs #5907 fix(redshift): act only on a snapshot of the cluster the request names A snapshot request is checked on snapshot:/ for the cluster it names, but DeleteClusterSnapshot, RestoreFromClusterSnapshot and DescribeClusterSnapshots found the snapshot by its name alone. A caller allowed on one cluster's snapshots could act on a snapshot of another cluster by naming the allowed one. A snapshot taken from another cluster than the one the request names, in SnapshotClusterIdentifier, the cluster of a SnapshotArn, or DescribeClusterSnapshots' ClusterIdentifier, is now not found. Refs #5907 chore(iam): generate the Lambda Web and Redshift condition keys into one table chore(redshift): read a restore's snapshot ARN once --- .github/workflows/iam-data-drift.yml | 8 +- .github/workflows/partition-literals.yml | 4 +- Makefile | 28 +-- docs/services/iam.md | 28 ++- .../common/IamConditionContextResolver.java | 21 +- .../core/common/IamEnforcementFilter.java | 32 ++- ...ionKeys.java => RequestConditionKeys.java} | 23 +- .../redshift/RedshiftQueryHandler.java | 35 ++- .../services/redshift/RedshiftService.java | 48 +++- .../resources/aws/iam-request-resources.json | 153 ++++++++++++- ...-keys.json => request-condition-keys.json} | 17 +- .../common/RequestResourceMembersTest.java | 46 +++- .../core/common/RequestResourcesTest.java | 20 ++ ...estResourceEnforcementIntegrationTest.java | 72 ++++++ ...dentialsIamEnforcementIntegrationTest.java | 62 +++++- .../redshift/RedshiftQueryHandlerTest.java | 64 +++++- .../redshift/RedshiftServiceTest.java | 46 ++++ tools/aws/regen_iam_request_resources.py | 66 +++++- tools/aws/regen_lambda_web_condition_keys.py | 151 ------------- tools/aws/regen_request_condition_keys.py | 208 ++++++++++++++++++ .../test_regen_lambda_web_condition_keys.py | 92 -------- .../aws/test_regen_request_condition_keys.py | 130 +++++++++++ 22 files changed, 1026 insertions(+), 328 deletions(-) rename src/main/java/io/github/hectorvent/floci/core/common/{LambdaWebConditionKeys.java => RequestConditionKeys.java} (59%) rename src/main/resources/aws/{lambda-web-condition-keys.json => request-condition-keys.json} (71%) delete mode 100644 tools/aws/regen_lambda_web_condition_keys.py create mode 100644 tools/aws/regen_request_condition_keys.py delete mode 100644 tools/aws/test_regen_lambda_web_condition_keys.py create mode 100644 tools/aws/test_regen_request_condition_keys.py diff --git a/.github/workflows/iam-data-drift.yml b/.github/workflows/iam-data-drift.yml index b944e74b01..6dbef83ec8 100644 --- a/.github/workflows/iam-data-drift.yml +++ b/.github/workflows/iam-data-drift.yml @@ -7,7 +7,7 @@ name: IAM Data Drift # operations that pass a Lambda network connector, the table of the # tagging actions operations that tag what they create need, the table of the resources each # operation's request names, the DynamoDB condition key table, the IAM condition key table, the -# S3 Control tag condition key table, and the Lambda Web condition key table. That +# S3 Control tag condition key table, and the request condition key table (Lambda Web and Redshift). That # needs the live service reference index, so unlike every other check here it can # fail without anything in the repository having changed: an AWS outage, or a namespace AWS has # retired. It therefore runs on its own, never as part of a job that ordinary changes trigger. @@ -66,9 +66,9 @@ on: - 'src/main/resources/aws/s3control-tag-condition-keys.json' - 'tools/aws/regen_s3control_tag_condition_keys.py' - 'tools/aws/test_regen_s3control_tag_condition_keys.py' - - 'src/main/resources/aws/lambda-web-condition-keys.json' - - 'tools/aws/regen_lambda_web_condition_keys.py' - - 'tools/aws/test_regen_lambda_web_condition_keys.py' + - 'src/main/resources/aws/request-condition-keys.json' + - 'tools/aws/regen_request_condition_keys.py' + - 'tools/aws/test_regen_request_condition_keys.py' - 'tools/aws/regen_partitions.py' - 'tools/aws/regen_query_services.py' - '.github/workflows/iam-data-drift.yml' diff --git a/.github/workflows/partition-literals.yml b/.github/workflows/partition-literals.yml index d57ce035d9..c121142ccf 100644 --- a/.github/workflows/partition-literals.yml +++ b/.github/workflows/partition-literals.yml @@ -114,8 +114,8 @@ jobs: - name: Check S3 Control tag condition request members run: make s3control-tag-condition-keys-check - - name: Check Lambda Web condition request members - run: make lambda-web-condition-keys-check + - name: Check request condition key members + run: make request-condition-keys-check - name: Check partitions.json against a fresh generation run: make aws-data-check diff --git a/Makefile b/Makefile index e6142d39f3..9af0de3bf2 100644 --- a/Makefile +++ b/Makefile @@ -509,8 +509,8 @@ IAM_CONDITION_KEYS_PATHS := src/main/resources/aws/iam-condition-keys.json \ S3CONTROL_TAG_CONDITION_KEYS_PATHS := src/main/resources/aws/s3control-tag-condition-keys.json \ tools/aws/regen_s3control_tag_condition_keys.py tools/aws/test_regen_s3control_tag_condition_keys.py \ tools/aws/regen_iam_tag_on_create.py $(IAM_PASSED_ROLES_GENERATOR) -LAMBDA_WEB_CONDITION_KEYS_PATHS := src/main/resources/aws/lambda-web-condition-keys.json \ - tools/aws/regen_lambda_web_condition_keys.py tools/aws/test_regen_lambda_web_condition_keys.py \ +REQUEST_CONDITION_KEYS_PATHS := src/main/resources/aws/request-condition-keys.json \ + tools/aws/regen_request_condition_keys.py tools/aws/test_regen_request_condition_keys.py \ tools/aws/regen_dynamodb_condition_keys.py tools/aws/regen_iam_tag_on_create.py $(IAM_PASSED_ROLES_GENERATOR) IAM_REQUEST_RESOURCES_PATHS := src/main/resources/aws/iam-request-resources.json \ tools/aws/regen_iam_request_resources.py $(IAM_PASSED_ROLES_GENERATOR) \ @@ -520,7 +520,7 @@ iam-data-verify: ## CI gate (online): every vendored IAM file must still match A @# Every check runs even when an earlier one fails, so one file's drift cannot hide another's @# state. Sequential steps in CI stop at the first failure, which once left the action @# resource gate unexercised while the namespace list was stale. - @namespaces=0; actions=0; authorized=0; passed=0; connectors=0; tagged=0; requested=0; dynamodb=0; conditionkeys=0; s3control=0; lambdaweb=0; \ + @namespaces=0; actions=0; authorized=0; passed=0; connectors=0; tagged=0; requested=0; dynamodb=0; conditionkeys=0; s3control=0; requestkeys=0; \ covers() { \ [ -z "$(strip $(CHANGED))" ] && return 0; \ for path in $(CHANGED); do case " $$1 " in *" $$path "*) return 0;; esac; done; \ @@ -557,12 +557,12 @@ iam-data-verify: ## CI gate (online): every vendored IAM file must still match A if covers "$(S3CONTROL_TAG_CONDITION_KEYS_PATHS)" "the S3 Control tag condition key table"; then \ $(MAKE) --no-print-directory s3control-tag-condition-keys-verify || s3control=$$?; \ fi; \ - if covers "$(LAMBDA_WEB_CONDITION_KEYS_PATHS)" "the Lambda Web condition key table"; then \ - $(MAKE) --no-print-directory lambda-web-condition-keys-verify || lambdaweb=$$?; \ + if covers "$(REQUEST_CONDITION_KEYS_PATHS)" "the request condition key table"; then \ + $(MAKE) --no-print-directory request-condition-keys-verify || requestkeys=$$?; \ fi; \ if [ $$namespaces -ne 0 ] || [ $$actions -ne 0 ] || [ $$authorized -ne 0 ] || [ $$passed -ne 0 ] \ || [ $$connectors -ne 0 ] || [ $$tagged -ne 0 ] || [ $$requested -ne 0 ] || [ $$dynamodb -ne 0 ] \ - || [ $$conditionkeys -ne 0 ] || [ $$s3control -ne 0 ] || [ $$lambdaweb -ne 0 ]; then \ + || [ $$conditionkeys -ne 0 ] || [ $$s3control -ne 0 ] || [ $$requestkeys -ne 0 ]; then \ echo ""; \ echo "error: vendored IAM data does not match upstream:"; \ if [ $$namespaces -ne 0 ]; then \ @@ -589,7 +589,7 @@ iam-data-verify: ## CI gate (online): every vendored IAM file must still match A if [ $$dynamodb -ne 0 ]; then echo " the DynamoDB condition key table"; fi; \ if [ $$conditionkeys -ne 0 ]; then echo " the IAM condition key table"; fi; \ if [ $$s3control -ne 0 ]; then echo " the S3 Control tag condition key table"; fi; \ - if [ $$lambdaweb -ne 0 ]; then echo " the Lambda Web condition key table"; fi; \ + if [ $$requestkeys -ne 0 ]; then echo " the request condition key table"; fi; \ exit 1; \ fi @@ -803,10 +803,10 @@ s3control-tag-condition-keys-check: ## Check the S3 Control tag condition reques s3control-tag-condition-keys-verify: ## Check the S3 Control tag condition action keys against AWS $(PYTHON) tools/aws/regen_s3control_tag_condition_keys.py --verify -.PHONY: lambda-web-condition-keys-sync lambda-web-condition-keys-check lambda-web-condition-keys-verify -lambda-web-condition-keys-sync: ## Regenerate the Lambda Web condition keys from AWS and botocore - $(PYTHON) tools/aws/regen_lambda_web_condition_keys.py -lambda-web-condition-keys-check: ## Check the Lambda Web condition request members against pinned botocore - $(PYTHON) tools/aws/regen_lambda_web_condition_keys.py --check -lambda-web-condition-keys-verify: ## Check the Lambda Web condition action keys against AWS - $(PYTHON) tools/aws/regen_lambda_web_condition_keys.py --verify +.PHONY: request-condition-keys-sync request-condition-keys-check request-condition-keys-verify +request-condition-keys-sync: ## Regenerate the Lambda Web and Redshift request condition keys from AWS and botocore + $(PYTHON) tools/aws/regen_request_condition_keys.py +request-condition-keys-check: ## Check the request condition key members against pinned botocore + $(PYTHON) tools/aws/regen_request_condition_keys.py --check +request-condition-keys-verify: ## Check the request condition action keys against AWS + $(PYTHON) tools/aws/regen_request_condition_keys.py --verify diff --git a/docs/services/iam.md b/docs/services/iam.md index c963821fd2..172cea70c0 100644 --- a/docs/services/iam.md +++ b/docs/services/iam.md @@ -1716,7 +1716,7 @@ Step Functions, EventBridge, Amazon Cognito user pools and identity pools, Amazo Map, ACM, CodePipeline, CodeBuild, Amazon Managed Service for Apache Flink (Kinesis Data Analytics v2), Application Auto Scaling, AWS Budgets, Cost and Usage Reports, Service Quotas, Amazon Textract, Amazon Translate, Amazon Athena, AWS Data Exports, AWS Pricing Calculator, Cost Explorer, CloudTrail, Global Accelerator, Amazon -Timestream for InfluxDB, the Amazon Redshift Data API, AWS Payment Cryptography, AWS DataSync, Amazon EMR, +Timestream for InfluxDB, Amazon Redshift, the Amazon Redshift Data API, AWS Payment Cryptography, AWS DataSync, Amazon EMR, Amazon Rekognition, IAM Identity Center, Amazon OpenSearch Service and IAM Access Analyzer 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 @@ -1781,7 +1781,18 @@ Cost Explorer's `GetAnomalyMonitors` and `GetAnomalySubscriptions` are checked o `MonitorArnList` or `SubscriptionArnList` gives, and Timestream for InfluxDB's `RebootDbCluster` on the cluster and on each member instance its `instanceIds` names. Global Accelerator's `ListCustomRoutingPortMappings` is checked on its accelerator alone, not on the -endpoint group its `EndpointGroupArn` gives, whose ARN extends the accelerator's. An EventBridge rule is on the event bus +endpoint group its `EndpointGroupArn` gives, whose ARN extends the accelerator's. Redshift's +`GetClusterCredentials` is checked on the `dbuser` its `ClusterIdentifier` and `DbUser` name, and on the +`dbname` only when its `DbName` names one, so a grant on the `dbuser` alone allows it. +`RestoreFromClusterSnapshot` is checked on the new cluster its `ClusterIdentifier` names and on the snapshot +of the cluster its `SnapshotClusterIdentifier` names, `snapshot:*/` when it names none. A snapshot taken +from another cluster than the one a request names is not found (`ClusterSnapshotNotFound`): the cluster +`DeleteClusterSnapshot`'s and `RestoreFromClusterSnapshot`'s `SnapshotClusterIdentifier` names or a +`SnapshotArn` holds, and the one `DescribeClusterSnapshots`' `ClusterIdentifier` names. So a request never acts +on a snapshot other than the one it is checked on. +Redshift's `CreateTags`, `DeleteTags` and `DescribeTags` are checked on the resource whose ARN their +`ResourceName` gives. Redshift members that hold another kind of ARN, such as an IAM role's, an SNS +topic's or an ACM certificate's, are not read as a Redshift resource. An EventBridge rule is on the event bus its request's `EventBusName` names, by name or by ARN, and on the default bus when it names none or gives a null, whose rules are `rule/`, with no bus; a bus ARN of another account, the default bus's included, names that account's rule, checked as given and as the caller's own, which @@ -2733,9 +2744,16 @@ floci populates: request, for `GetWebFunctionEndpoint`, `UpdateWebFunctionEndpoint` and `DeleteWebFunctionEndpoint`, absent when the endpoint does not exist, as on AWS. An `IamAuth` endpoint request carries it too (see [Lambda Web Functions](lambda-web-functions.md)). - The actions and request members come from `lambda-web-condition-keys.json`, which - `tools/aws/regen_lambda_web_condition_keys.py` generates from the Service Reference and pinned - botocore. Regenerate with `make lambda-web-condition-keys-sync`. + The actions and request members come from `request-condition-keys.json`, which + `tools/aws/regen_request_condition_keys.py` generates from the Service Reference and pinned + botocore. Regenerate with `make request-condition-keys-sync`. +- `redshift:DbUser`: the database user a `GetClusterCredentials` request names in `DbUser`, and the + same value for the `redshift:CreateClusterUser` check its `AutoCreate` adds, as the value is given, + so a policy can scope both actions to `dbuser:/${redshift:DbUser}`. The actions and request + members come from the same `request-condition-keys.json`, which `tools/aws/regen_request_condition_keys.py` + generates from the Service Reference and pinned botocore. Regenerate with + `make request-condition-keys-sync`. `redshift:DbName` and `redshift:DurationSeconds` are not + populated yet. **Any other condition key is absent from the request context.** A positive scalar operator without `IfExists` on an absent key makes the whole statement *not apply*: it neither matches nor diff --git a/src/main/java/io/github/hectorvent/floci/core/common/IamConditionContextResolver.java b/src/main/java/io/github/hectorvent/floci/core/common/IamConditionContextResolver.java index b285773ab3..e7caca27d0 100644 --- a/src/main/java/io/github/hectorvent/floci/core/common/IamConditionContextResolver.java +++ b/src/main/java/io/github/hectorvent/floci/core/common/IamConditionContextResolver.java @@ -156,6 +156,7 @@ public class IamConditionContextResolver { case "iam" -> iamConditionContext(action, ctx); case "logs" -> logsConditionContext(action, ctx); case "lambda" -> lambdaConditionContext(action, ctx); + case "redshift" -> redshiftConditionContext(action, ctx); default -> null; }; } @@ -267,6 +268,22 @@ public class IamConditionContextResolver { }; } + /** The {@code redshift:} keys a Redshift request carries in its own members, such as its DbUser. */ + private Map> redshiftConditionContext(String action, ContainerRequestContext ctx) { + List keys = RequestConditionKeys.requestKeys(action); + if (keys.isEmpty()) { + return null; + } + Map form = formParameters(ctx); + Map> conditions = new LinkedHashMap<>(); + for (String key : keys) { + for (String member : RequestConditionKeys.members(action, key)) { + putIfPresent(conditions, key, form.get(member)); + } + } + return conditions.isEmpty() ? null : conditions; + } + public static Map> withGlobalContext(Map> serviceContext, String resourceArn, String region, String accountId, String resourceOwnerAccountId) { @@ -350,11 +367,11 @@ public class IamConditionContextResolver { /** The authType a web function endpoint request names, and the one the endpoint has before it. */ private Map> lambdaConditionContext(String action, ContainerRequestContext ctx) { Map> conditions = new LinkedHashMap<>(); - for (String member : LambdaWebConditionKeys.members(action, REQUEST_AUTH_TYPE)) { + for (String member : RequestConditionKeys.members(action, REQUEST_AUTH_TYPE)) { PassedRoles.values(PassedRoles.jsonBody(ctx), member.split("\\.")) .forEach(value -> putIfPresent(conditions, REQUEST_AUTH_TYPE, value)); } - if (LambdaWebConditionKeys.takes(action, RESOURCE_AUTH_TYPE)) { + if (RequestConditionKeys.takes(action, RESOURCE_AUTH_TYPE)) { putIfPresent(conditions, RESOURCE_AUTH_TYPE, storedAuthType(ctx)); } return conditions.isEmpty() ? null : conditions; diff --git a/src/main/java/io/github/hectorvent/floci/core/common/IamEnforcementFilter.java b/src/main/java/io/github/hectorvent/floci/core/common/IamEnforcementFilter.java index fc0d7e5c37..8345209c5a 100644 --- a/src/main/java/io/github/hectorvent/floci/core/common/IamEnforcementFilter.java +++ b/src/main/java/io/github/hectorvent/floci/core/common/IamEnforcementFilter.java @@ -1429,7 +1429,21 @@ public class IamEnforcementFilter implements ContainerRequestFilter { ResourcePolicyDecision resourcePolicyDecision, String resourceOwnerAccountId) { authorizeAdditionalResource(authorizationHeader, action, resource, resourcePolicyDecision, - resourceOwnerAccountId, null); + resourceOwnerAccountId, null, null); + } + + /** + * Authorizes a secondary resource with the condition keys {@code requestConditions} gives, values its + * handler reads from the request {@link #filter} has authorized: GetClusterCredentials checks + * {@code redshift:CreateClusterUser} with the {@code redshift:DbUser} of its own {@code DbUser}, so a + * policy can scope it to {@code dbuser:/${redshift:DbUser}}. + */ + public void authorizeAdditionalResource( + String authorizationHeader, + String action, + String resource, + Map> requestConditions) { + authorizeAdditionalResource(authorizationHeader, action, resource, null, null, null, requestConditions); } /** @@ -1443,21 +1457,25 @@ public class IamEnforcementFilter implements ContainerRequestFilter { */ public void authorizePostObject(String authorizationHeader, String resource, String region) { authorizeAdditionalResource(authorizationHeader, "s3:PutObject", resource, null, null, - new DeniedEvent("PostObject", region)); + new DeniedEvent("PostObject", region), null); } /** A CloudTrail record to write when IAM refuses a request: its event name and its Region. */ private record DeniedEvent(String name, String region) { } - /** As the public overload; a denial is also recorded in CloudTrail when {@code deniedEvent} is given. */ + /** + * As the public overloads; a denial is also recorded in CloudTrail when {@code deniedEvent} is given, and + * {@code requestConditions}, when given, joins the condition context. + */ private void authorizeAdditionalResource( String authorizationHeader, String action, String resource, ResourcePolicyDecision resourcePolicyDecision, String resourceOwnerAccountId, - DeniedEvent deniedEvent) { + DeniedEvent deniedEvent, + Map> requestConditions) { if (!config.services().iam().enforcementEnabled()) { return; } @@ -1532,6 +1550,12 @@ public class IamEnforcementFilter implements ContainerRequestFilter { conditionContext = new HashMap<>(); callerArns.get().putPrincipalKeys(conditionContext); } + if (requestConditions != null && !requestConditions.isEmpty()) { + if (conditionContext == null) { + conditionContext = new HashMap<>(); + } + conditionContext.putAll(requestConditions); + } ResourcePolicyDecision effectiveDecision = resourcePolicyDecision; String effectiveOwnerAccountId = resourceOwnerAccountId; diff --git a/src/main/java/io/github/hectorvent/floci/core/common/LambdaWebConditionKeys.java b/src/main/java/io/github/hectorvent/floci/core/common/RequestConditionKeys.java similarity index 59% rename from src/main/java/io/github/hectorvent/floci/core/common/LambdaWebConditionKeys.java rename to src/main/java/io/github/hectorvent/floci/core/common/RequestConditionKeys.java index 260c75c3cf..183c09a4d2 100644 --- a/src/main/java/io/github/hectorvent/floci/core/common/LambdaWebConditionKeys.java +++ b/src/main/java/io/github/hectorvent/floci/core/common/RequestConditionKeys.java @@ -7,23 +7,23 @@ import java.util.ArrayList; import java.util.List; /** - * The Lambda Web Functions authType condition keys each action takes, and the request members that - * carry the request key, generated from the AWS Service Reference and pinned botocore by - * {@code tools/aws/regen_lambda_web_condition_keys.py}. + * The service condition keys each action takes that Floci reads from the request or from the resource it acts on, + * and the request members that carry them, generated from the AWS Service Reference and pinned botocore by + * {@code tools/aws/regen_request_condition_keys.py}. */ -final class LambdaWebConditionKeys { +final class RequestConditionKeys { - private static final JsonNode TABLE = VendoredResources.read("aws/lambda-web-condition-keys.json", - "Lambda Web condition keys", input -> { + private static final JsonNode TABLE = VendoredResources.read("aws/request-condition-keys.json", + "request condition keys", input -> { JsonNode document = new ObjectMapper().readTree(input); if (!document.path("actions").isObject() || document.path("actions").isEmpty() || !document.path("members").isObject() || document.path("members").isEmpty()) { - throw new IllegalStateException("Malformed Lambda Web condition key table"); + throw new IllegalStateException("Malformed request condition key table"); } return document; }); - private LambdaWebConditionKeys() {} + private RequestConditionKeys() {} static boolean takes(String action, String key) { for (JsonNode taken : TABLE.path("actions").path(action)) { @@ -40,4 +40,11 @@ final class LambdaWebConditionKeys { TABLE.path("members").path(action).path(key).forEach(member -> members.add(member.asText())); return members; } + + /** The keys a request for {@code action} carries in its own members; empty when none. */ + static List requestKeys(String action) { + List keys = new ArrayList<>(); + TABLE.path("members").path(action).properties().forEach(key -> keys.add(key.getKey())); + return keys; + } } diff --git a/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandler.java b/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandler.java index 29bf565ba6..46bbd9eee9 100644 --- a/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandler.java +++ b/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandler.java @@ -228,7 +228,7 @@ public class RedshiftQueryHandler { } case "DeleteClusterSnapshot" -> { String snapshotIdentifier = params.getFirst("SnapshotIdentifier"); - Snapshot snapshot = service.deleteSnapshot(snapshotIdentifier); + Snapshot snapshot = service.deleteSnapshot(snapshotIdentifier, params.getFirst("SnapshotClusterIdentifier")); String xml = new XmlBuilder() .start("DeleteClusterSnapshotResponse") .start("DeleteClusterSnapshotResult") @@ -246,8 +246,10 @@ public class RedshiftQueryHandler { String snapshotIdentifier = params.getFirst("SnapshotIdentifier"); String snapshotArn = params.getFirst("SnapshotArn"); String nodeType = params.getFirst("NodeType"); - Cluster cluster = service.restoreFromClusterSnapshot( - clusterIdentifier, resolveSnapshotIdentifier(snapshotIdentifier, snapshotArn, authorizationHeader), nodeType); + RestoredSnapshot snapshot = resolveSnapshot(snapshotIdentifier, + params.getFirst("SnapshotClusterIdentifier"), snapshotArn, authorizationHeader); + Cluster cluster = service.restoreFromClusterSnapshot(clusterIdentifier, snapshot.name(), + snapshot.cluster(), nodeType); String xml = new XmlBuilder() .start("RestoreFromClusterSnapshotResponse") .start("RestoreFromClusterSnapshotResult") @@ -1033,7 +1035,8 @@ public class RedshiftQueryHandler { /** * Authorizes the actions GetClusterCredentials needs besides redshift:GetClusterCredentials, which * the API reference lists for its options: redshift:JoinGroup on each group in {@code DbGroups}, - * and redshift:CreateClusterUser on the database user when {@code AutoCreate} is true. It runs + * and redshift:CreateClusterUser on the database user when {@code AutoCreate} is true, with that + * user as {@code redshift:DbUser}, which the Service Reference lists for CreateClusterUser. It runs * before the cluster lookup, so a denied caller learns nothing about the cluster. */ private void authorizeCredentialOptions(String authorizationHeader, String clusterId, String dbUser, @@ -1048,7 +1051,8 @@ public class RedshiftQueryHandler { } if (autoCreate) { iamEnforcementFilter.authorizeAdditionalResource(authorizationHeader, "redshift:CreateClusterUser", - regionResolver.buildArn("redshift", region, "dbuser:" + clusterId + "/" + dbUser)); + regionResolver.buildArn("redshift", region, "dbuser:" + clusterId + "/" + dbUser), + Map.of("redshift:DbUser", List.of(dbUser))); } } @@ -1215,8 +1219,16 @@ public class RedshiftQueryHandler { }; } - // RestoreFromClusterSnapshot accepts SnapshotIdentifier or SnapshotArn. - private String resolveSnapshotIdentifier(String snapshotIdentifier, String snapshotArn, String authorizationHeader) { + /** The snapshot a restore names: its name, and the cluster it was taken from, which the request is checked on. */ + private record RestoredSnapshot(String cluster, String name) { + } + + /** + * RestoreFromClusterSnapshot accepts SnapshotIdentifier, with SnapshotClusterIdentifier, or SnapshotArn. An ARN + * naming no cluster, or another cluster than SnapshotClusterIdentifier, names no snapshot. + */ + private RestoredSnapshot resolveSnapshot(String snapshotIdentifier, String snapshotClusterIdentifier, + String snapshotArn, String authorizationHeader) { boolean hasIdentifier = snapshotIdentifier != null && !snapshotIdentifier.isBlank(); boolean hasArn = snapshotArn != null && !snapshotArn.isBlank(); if (hasIdentifier && hasArn) { @@ -1224,7 +1236,7 @@ public class RedshiftQueryHandler { "You must specify either SnapshotIdentifier or SnapshotArn, but not both.", 400); } if (hasIdentifier) { - return snapshotIdentifier; + return new RestoredSnapshot(snapshotClusterIdentifier, snapshotIdentifier); } if (!hasArn) { throw new AwsException("InvalidParameterValue", "SnapshotIdentifier or SnapshotArn is required", 400); @@ -1247,7 +1259,12 @@ public class RedshiftQueryHandler { || !arn.region().equals(regionResolver.resolveRegionFromAuth(authorizationHeader))) { throw new AwsException("ClusterSnapshotNotFound", "Snapshot " + snapshotArn + " not found", 404); } - return resource.substring(slash + 1); + String cluster = resource.substring("snapshot:".length(), slash); + if (cluster.isBlank() || snapshotClusterIdentifier != null && !snapshotClusterIdentifier.isBlank() + && !snapshotClusterIdentifier.equals(cluster)) { + throw new AwsException("ClusterSnapshotNotFound", "Snapshot " + snapshotArn + " not found", 404); + } + return new RestoredSnapshot(cluster, resource.substring(slash + 1)); } private String buildSnapshotXml(Snapshot snapshot) { diff --git a/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftService.java b/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftService.java index 4ecddca446..08a5ccca8c 100644 --- a/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftService.java +++ b/src/main/java/io/github/hectorvent/floci/services/redshift/RedshiftService.java @@ -1078,7 +1078,7 @@ public class RedshiftService implements ManagedSecretRotator { // ClusterSnapshotAlreadyExists. Once the container teardown starts the snapshot may be the only copy. private void discardUnusedFinalSnapshot(String finalSnapshotIdentifier, RuntimeException deletionFailure) { try { - removeSnapshot(finalSnapshotIdentifier); + removeSnapshot(finalSnapshotIdentifier, null); } catch (RuntimeException cleanupFailure) { deletionFailure.addSuppressed(cleanupFailure); } @@ -1833,7 +1833,8 @@ public class RedshiftService implements ManagedSecretRotator { public List describeSnapshots(String snapshotIdentifier, String clusterIdentifier) { if (snapshotIdentifier != null && !snapshotIdentifier.isBlank()) { - Optional snapshot = findSnapshot(snapshotIdentifier); + Optional snapshot = findSnapshot(snapshotIdentifier) + .filter(found -> takenFrom(found, clusterIdentifier)); if (snapshot.isEmpty()) { throw new AwsException("ClusterSnapshotNotFound", "Snapshot " + snapshotIdentifier + " not found", 404); } @@ -1874,14 +1875,31 @@ public class RedshiftService implements ManagedSecretRotator { return findSnapshot(snapshotIdentifier); } - public Snapshot deleteSnapshot(String snapshotIdentifier) { - return withResourceLock("snapshot", snapshotIdentifier, () -> mutate(() -> removeSnapshot(snapshotIdentifier))); + /** + * Whether the snapshot was taken from the cluster a request names, or the request names none. A request naming the + * cluster a snapshot was taken from is authorized on {@code snapshot:/}, so a snapshot of another + * cluster is not acted on, as if it did not exist. + */ + private static boolean takenFrom(Snapshot snapshot, String clusterIdentifier) { + return clusterIdentifier == null || clusterIdentifier.isBlank() + || clusterIdentifier.equals(snapshot.getClusterIdentifier()); } - private Snapshot removeSnapshot(String snapshotIdentifier) { + public Snapshot deleteSnapshot(String snapshotIdentifier) { + return deleteSnapshot(snapshotIdentifier, null); + } + + /** Deletes the snapshot, which must have been taken from {@code snapshotClusterIdentifier} when one is given. */ + public Snapshot deleteSnapshot(String snapshotIdentifier, String snapshotClusterIdentifier) { + return withResourceLock("snapshot", snapshotIdentifier, + () -> mutate(() -> removeSnapshot(snapshotIdentifier, snapshotClusterIdentifier))); + } + + private Snapshot removeSnapshot(String snapshotIdentifier, String snapshotClusterIdentifier) { String copyKey = copyKey(regionResolver.getRegion(), snapshotIdentifier); Optional copyOpt = snapshotCopies.get(copyKey); - Optional snapshotOpt = copyOpt.or(() -> snapshots.get(snapshotIdentifier)); + Optional snapshotOpt = copyOpt.or(() -> snapshots.get(snapshotIdentifier)) + .filter(found -> takenFrom(found, snapshotClusterIdentifier)); if (snapshotOpt.isEmpty()) { throw new AwsException("ClusterSnapshotNotFound", "Snapshot " + snapshotIdentifier + " not found", 404); } @@ -1915,10 +1933,16 @@ public class RedshiftService implements ManagedSecretRotator { } public Cluster restoreFromClusterSnapshot(String clusterIdentifier, String snapshotIdentifier, String nodeType) { + return restoreFromClusterSnapshot(clusterIdentifier, snapshotIdentifier, null, nodeType); + } + + /** Restores the snapshot, which must have been taken from {@code snapshotClusterIdentifier} when one is given. */ + public Cluster restoreFromClusterSnapshot(String clusterIdentifier, String snapshotIdentifier, + String snapshotClusterIdentifier, String nodeType) { return withResourceLock("cluster", clusterIdentifier, () -> { ensureNoManagedRotation(clusters.accountId(), clusterIdentifier); - return withResourceLock("snapshot", snapshotIdentifier, - () -> mutate(() -> restoreSnapshot(clusterIdentifier, snapshotIdentifier, nodeType))); + return withResourceLock("snapshot", snapshotIdentifier, () -> mutate( + () -> restoreSnapshot(clusterIdentifier, snapshotIdentifier, snapshotClusterIdentifier, nodeType))); }); } @@ -1931,7 +1955,7 @@ public class RedshiftService implements ManagedSecretRotator { return withResourceLock("cluster", clusterIdentifier, () -> withResourceLock("snapshot", snapshotIdentifier, () -> { ensureNoManagedRotation(clusters.accountId(), clusterIdentifier); - Cluster cluster = restoreSnapshot(clusterIdentifier, snapshotIdentifier, nodeType); + Cluster cluster = restoreSnapshot(clusterIdentifier, snapshotIdentifier, null, nodeType); try { cluster.setClusterSubnetGroupName(clusterSubnetGroupName); if (manageMasterPassword) { @@ -1973,12 +1997,14 @@ public class RedshiftService implements ManagedSecretRotator { }); } - private Cluster restoreSnapshot(String clusterIdentifier, String snapshotIdentifier, String nodeType) { + private Cluster restoreSnapshot(String clusterIdentifier, String snapshotIdentifier, + String snapshotClusterIdentifier, String nodeType) { if (clusters.get(clusterIdentifier).isPresent()) { throw new AwsException("ClusterAlreadyExists", "Cluster " + clusterIdentifier + " already exists", 400); } - Optional snapshotOpt = findSnapshot(snapshotIdentifier); + Optional snapshotOpt = findSnapshot(snapshotIdentifier) + .filter(found -> takenFrom(found, snapshotClusterIdentifier)); if (snapshotOpt.isEmpty()) { throw new AwsException("ClusterSnapshotNotFound", "Snapshot " + snapshotIdentifier + " not found", 404); } diff --git a/src/main/resources/aws/iam-request-resources.json b/src/main/resources/aws/iam-request-resources.json index 1263a5c223..915275acfb 100644 --- a/src/main/resources/aws/iam-request-resources.json +++ b/src/main/resources/aws/iam-request-resources.json @@ -1,11 +1,11 @@ { - "_source": {"generator": "tools/aws/regen_iam_request_resources.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.118 (installed package)", "retrieved": "2026-11-04", "note": "make iam-request-resources-check re-derives every operation's resources from botocore; make iam-request-resources-verify checks every action, type and format against AWS."}, - "namespaces": {"access-analyzer": ["accessanalyzer"], "acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudtrail": ["cloudtrail"], "codebuild": ["codebuild"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "cur": ["cur"], "datasync": ["datasync"], "dynamodb": ["dynamodb"], "ecr": ["ecr"], "elasticloadbalancing": ["elb", "elbv2"], "elasticmapreduce": ["emr"], "es": ["es", "opensearch"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "globalaccelerator": ["globalaccelerator"], "kinesisanalytics": ["kinesisanalyticsv2"], "logs": ["logs"], "payment-cryptography": ["payment-cryptography"], "redshift-data": ["redshift-data"], "rekognition": ["rekognition"], "servicediscovery": ["servicediscovery"], "servicequotas": ["service-quotas"], "sso": ["sso", "sso-admin"], "states": ["stepfunctions"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "translate": ["translate"]}, + "_source": {"generator": "tools/aws/regen_iam_request_resources.py", "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.118 (installed package)", "retrieved": "2026-11-05", "note": "make iam-request-resources-check re-derives every operation's resources from botocore; make iam-request-resources-verify checks every action, type and format against AWS."}, + "namespaces": {"access-analyzer": ["accessanalyzer"], "acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudtrail": ["cloudtrail"], "codebuild": ["codebuild"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "cur": ["cur"], "datasync": ["datasync"], "dynamodb": ["dynamodb"], "ecr": ["ecr"], "elasticloadbalancing": ["elb", "elbv2"], "elasticmapreduce": ["emr"], "es": ["es", "opensearch"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "globalaccelerator": ["globalaccelerator"], "kinesisanalytics": ["kinesisanalyticsv2"], "logs": ["logs"], "payment-cryptography": ["payment-cryptography"], "redshift": ["redshift"], "redshift-data": ["redshift-data"], "rekognition": ["rekognition"], "servicediscovery": ["servicediscovery"], "servicequotas": ["service-quotas"], "sso": ["sso", "sso-admin"], "states": ["stepfunctions"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "translate": ["translate"]}, "clientsNotRead": {"kinesisanalytics": "Kinesis Data Analytics v1, SQL applications on the KinesisAnalytics_20150814 target, which Floci does not serve (it serves v2, kinesisanalyticsv2); its operations share v2's names and name their resources by other members", "payment-cryptography-data": "the Payment Cryptography data plane, REST routes such as /keys/{KeyIdentifier}/encrypt, which Floci does not serve (it serves the control plane's JSON operations); its KeyIdentifier may be an alias, read on the control plane by the handler, not by its path"}, "handBuilt": ["apigateway", "bedrock", "dsql", "dynamodb", "eks", "iam", "kinesis", "kms", "lambda", "logs", "pipes", "resource-groups", "s3", "scheduler", "secretsmanager", "sns", "sqs", "ssm", "sts"], - "notCovered": {"account": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "airflow": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "app-integrations": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "appconfig": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "appsync": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "aps": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "autoscaling": "not read yet: AWS's group and launch configuration ARNs carry an id the service mints, `autoScalingGroup::autoScalingGroupName/`, while Floci mints `autoScalingGroup:`, which other services (ECS capacity providers) read back; the mint is fixed first", "aws-marketplace": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "backup": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "batch": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "bedrock-agentcore": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "cloudformation": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "cloudfront": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "cloudhsm": "not read yet: its ARN formats end in ${CloudHsmClusterInstanceName} and ${CloudHsmBackupInstanceName}, names, while its requests give ClusterId and BackupId, ids, which the rule does not fill a name from, so nearly every operation needs a correction", "cloudwatch": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "codeartifact": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "codedeploy": "not read yet: the Service Reference gives an on-premises instance's ARN as `instance:${InstanceName}`, while the CodeDeploy permissions reference gives arn:aws:codedeploy:region:account-id:instance/instance-ID and AWS's GetOnPremisesInstance example answers instance/_, an id the service mints after the name; reading it needs that format corrected", "codeguru-reviewer": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "comprehend": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "config": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "connect": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "controlcatalog": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "controltower": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "detective": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "dlm": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "dms": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ec2": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ecs": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticache": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticbeanstalk": "not read yet: an environment's ARN carries its application's name, `environment//`, while most of its requests name it by EnvironmentName or EnvironmentId alone, so reading it needs the stored environment those find", "elasticfilesystem": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "emr-serverless": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "execute-api": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "fis": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "glue": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "guardduty": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "identitystore": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "inspector2": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "iot": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "kafka": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "lightsail": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "macie2": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "memorydb": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "mq": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "network-firewall": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "oam": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "organizations": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ram": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "rds": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "rds-data": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "redshift": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "redshift-serverless": "not read yet: its namespace, workgroup, snapshot and managed VPC endpoint ARNs end in an id the service mints, `namespace/`, while its requests name them by namespaceName, workgroupName, snapshotName and endpointName, so reading it needs the stored ARNs those find, as Redshift Data's workgroups are found", "resource-explorer-2": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "route53": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "route53resolver": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "rum": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "s3tables": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "s3vectors": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "sagemaker": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "securityhub": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "servicecatalog": "not read yet: CreatePortfolioShare, UpdatePortfolioShare and DeletePortfolioShare give in AccountId the account a portfolio is shared with, which the rule reads as the portfolio's; a portfolio or product imported from another account keeps its owner's account in its ARN while requests name it by its id alone; and AppRegistry's applications and attribute groups are named in the path", "ses": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "signin": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "sso-oauth": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "swf": "not read yet: the Service Reference gives a domain's ARN no Region, `swf:::/domain/`, while the SWF Developer Guide gives it as arn:aws:swf:Region:AccountID:/domain/DomainName, as Floci mints it; reading it needs that format corrected", "transcribe": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "transfer": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "verifiedpermissions": "not read yet: a policyStoreId may name its store by an alias, `policy-store-alias/`, which AWS authorizes as the action on the store the alias points to and GetPolicyStoreAlias on the alias, and an aliasName carries the `policy-store-alias/` its format already gives; reading it needs both", "wafv2": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint"}, + "notCovered": {"account": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "airflow": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "app-integrations": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "appconfig": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "appsync": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "aps": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "autoscaling": "not read yet: AWS's group and launch configuration ARNs carry an id the service mints, `autoScalingGroup::autoScalingGroupName/`, while Floci mints `autoScalingGroup:`, which other services (ECS capacity providers) read back; the mint is fixed first", "aws-marketplace": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "backup": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "batch": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "bedrock-agentcore": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "cloudformation": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "cloudfront": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "cloudhsm": "not read yet: its ARN formats end in ${CloudHsmClusterInstanceName} and ${CloudHsmBackupInstanceName}, names, while its requests give ClusterId and BackupId, ids, which the rule does not fill a name from, so nearly every operation needs a correction", "cloudwatch": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "codeartifact": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "codedeploy": "not read yet: the Service Reference gives an on-premises instance's ARN as `instance:${InstanceName}`, while the CodeDeploy permissions reference gives arn:aws:codedeploy:region:account-id:instance/instance-ID and AWS's GetOnPremisesInstance example answers instance/_, an id the service mints after the name; reading it needs that format corrected", "codeguru-reviewer": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "comprehend": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "config": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "connect": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "controlcatalog": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "controltower": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "detective": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "dlm": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "dms": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ec2": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ecs": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticache": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "elasticbeanstalk": "not read yet: an environment's ARN carries its application's name, `environment//`, while most of its requests name it by EnvironmentName or EnvironmentId alone, so reading it needs the stored environment those find", "elasticfilesystem": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "emr-serverless": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "execute-api": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "fis": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "glue": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "guardduty": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "identitystore": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "inspector2": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "iot": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "kafka": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "lightsail": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "macie2": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "memorydb": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "mq": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "network-firewall": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "oam": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "organizations": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "ram": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "rds": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "rds-data": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "redshift-serverless": "not read yet: its namespace, workgroup, snapshot and managed VPC endpoint ARNs end in an id the service mints, `namespace/`, while its requests name them by namespaceName, workgroupName, snapshotName and endpointName, so reading it needs the stored ARNs those find, as Redshift Data's workgroups are found", "resource-explorer-2": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "route53": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "route53resolver": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "rum": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "s3tables": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "s3vectors": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "sagemaker": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "securityhub": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "servicecatalog": "not read yet: CreatePortfolioShare, UpdatePortfolioShare and DeletePortfolioShare give in AccountId the account a portfolio is shared with, which the rule reads as the portfolio's; a portfolio or product imported from another account keeps its owner's account in its ARN while requests name it by its id alone; and AppRegistry's applications and attribute groups are named in the path", "ses": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "signin": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "sso-oauth": "REST: its requests name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST routes (regen_rest_routes.MODELS), which do not have its model yet", "swf": "not read yet: the Service Reference gives a domain's ARN no Region, `swf:::/domain/`, while the SWF Developer Guide gives it as arn:aws:swf:Region:AccountID:/domain/DomainName, as Floci mints it; reading it needs that format corrected", "transcribe": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "transfer": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint", "verifiedpermissions": "not read yet: a policyStoreId may name its store by an alias, `policy-store-alias/`, which AWS authorizes as the action on the store the alias points to and GetPolicyStoreAlias on the alias, and an aliasName carries the `policy-store-alias/` its format already gives; reading it needs both", "wafv2": "not read yet: a later batch, with the tests that show its ARNs are the ones its handlers mint"}, "otherNamespaces": ["a4b", "account-access", "acm-pca", "aco-automation", "agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifybackend", "amplifyuibuilder", "aoss", "appfabric", "appflow", "application-signals", "application-signals-mcp", "appmesh", "appmesh-preview", "apprunner", "appstream", "apptest", "arc-region-switch", "arc-zonal-shift", "artifact", "assurance", "auditmanager", "aws-external-anthropic", "b2bi", "backup-gateway", "backup-search", "bedrock-mantle", "bedrock-websearch", "billing", "billingconductor", "braket", "bugbust", "cases", "cassandra", "chatbot", "chime", "cleanrooms", "cleanrooms-ml", "cloud9", "clouddirectory", "cloudfront-keyvaluestore", "cloudsearch", "cloudshell", "cloudtrail-data", "codecatalyst", "codecommit", "codeconnections", "codeguru-profiler", "codeguru-security", "codestar-connections", "codestar-notifications", "codewhisperer", "cognito-sync", "connect-campaigns", "consoleapp", "continuum", "databrew", "dataexchange", "datapipeline", "datazone", "dax", "deadline", "devicefarm", "devops-guru", "directconnect", "docdb-elastic", "drs", "ds", "ds-data", "ebs", "ec2-instance-connect", "ecr-public", "eks-auth", "elastictranscoder", "elemental-appliances-software", "elemental-inference", "elemental-support-cases", "emr-containers", "end-user-messaging", "entityresolution", "evs", "finspace", "finspace-api", "fms", "forecast", "frauddetector", "freertos", "fsx", "gamelift", "gameliftstreams", "geo", "geo-maps", "geo-places", "geo-routes", "glacier", "grafana", "greengrass", "groundstation", "health", "health-agent", "healthlake", "honeycode", "identity-sync", "imagebuilder", "interconnect", "internetmonitor", "invoicing", "iotanalytics", "iotdeviceadvisor", "iotfleethub", "iotfleetwise", "iotjobsdata", "iotmanagedintegrations", "iotsitewise", "iottwinmaker", "iotwireless", "iq", "iq-permission", "ivs", "ivschat", "kafka-cluster", "kafkaconnect", "kendra", "kendra-ranking", "kinesisvideo", "launchwizard", "lex", "license-manager", "license-manager-linux-subscriptions", "license-manager-user-subscriptions", "lookoutequipment", "lookoutmetrics", "lookoutvision", "m2", "machinelearning", "managedblockchain", "mapcredits", "mediaconnect", "mediaconvert", "medialive", "mediapackage", "mediapackage-vod", "mediapackagev2", "mediastore", "mediatailor", "medical-imaging", "mgh", "mgn", "migrationhub-orchestrator", "mobiletargeting", "monitron", "mpa", "neptune-db", "neptune-graph", "network-security-manager", "networkflowmonitor", "networkmanager", "networkmonitor", "nimble", "notifications", "notifications-contacts", "nova-act", "observabilityadmin", "odb", "omics", "one", "opensearch", "opsworks", "osis", "outposts", "panorama", "partnercentral", "payments", "pca-connector-ad", "pca-connector-scep", "pcs", "personalize", "pi", "polly", "private-networks", "profile", "proton", "purchase-orders", "q", "qapps", "qbusiness", "qdeveloper", "qldb", "quicksight", "rbin", "rds-db", "refactor-spaces", "repostspace", "resiliencehub", "robomaker", "rolesanywhere", "route53-recovery-cluster", "route53-recovery-control-config", "route53-recovery-readiness", "route53globalresolver", "route53profiles", "rtbfabric", "s3-object-lambda", "s3-outposts", "s3express", "s3files", "sagemaker-geospatial", "sagemaker-mlflow", "savingsplans", "schemas", "scn", "sdb", "security-ir", "securityagent", "securitylake", "serverlessrepo", "shield", "signer", "simspaceweaver", "sms-voice", "snow-device-management", "social-messaging", "sqlworkbench", "ssm-contacts", "ssm-incidents", "ssm-quicksetup", "ssm-sap", "storagegateway", "supportauthz", "synthetics", "thinclient", "timestream", "tnb", "transform", "transform-custom", "trustedadvisor", "ts", "vendor-insights", "voiceid", "vpc-lattice", "vpc-lattice-svcs", "vpce", "waf", "waf-regional", "wellarchitected", "wickr", "wisdom", "workdocs", "worklink", "workmail", "workmailmessageflow", "workspaces", "workspaces-instances", "workspaces-web", "xray"], - "arnFormats": {"access-analyzer": {"Analyzer": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}", "ArchiveRule": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}/archive-rule/${RuleName}"}, "acm": {"acme-domain-validation": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-domain-validation/${AcmeDomainValidationId}", "acme-endpoint": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}", "acme-external-account-binding": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-external-account-binding/${ExternalAccountBindingId}", "certificate": "arn:${Partition}:acm:${Region}:${Account}:certificate/${CertificateId}"}, "application-autoscaling": {"ScalableTarget": "arn:${Partition}:application-autoscaling:${Region}:${Account}:scalable-target/${ResourceId}"}, "athena": {"capacity-reservation": "arn:${Partition}:athena:${Region}:${Account}:capacity-reservation/${CapacityReservationName}", "datacatalog": "arn:${Partition}:athena:${Region}:${Account}:datacatalog/${DataCatalogName}", "session": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}/session/${SessionId}", "workgroup": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}"}, "bcm-data-exports": {"billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "export": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:export/${Identifier}", "table": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:table/${Identifier}"}, "bcm-pricing-calculator": {"bill-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-estimate/${BillEstimateId}", "bill-scenario": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-scenario/${BillScenarioId}", "workload-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:workload-estimate/${WorkloadEstimateId}"}, "budgets": {"budget": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}", "budgetAction": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}/action/${ActionId}"}, "ce": {"anomalymonitor": "arn:${Partition}:ce::${Account}:anomalymonitor/${Identifier}", "anomalysubscription": "arn:${Partition}:ce::${Account}:anomalysubscription/${Identifier}", "billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "costcategory": "arn:${Partition}:ce::${Account}:costcategory/${Identifier}"}, "cloudtrail": {"channel": "arn:${Partition}:cloudtrail:${Region}:${Account}:channel/${ChannelId}", "dashboard": "arn:${Partition}:cloudtrail:${Region}:${Account}:dashboard/${DashboardName}", "eventdatastore": "arn:${Partition}:cloudtrail:${Region}:${Account}:eventdatastore/${EventDataStoreId}", "trail": "arn:${Partition}:cloudtrail:${Region}:${Account}:trail/${TrailName}"}, "codebuild": {"build": "arn:${Partition}:codebuild:${Region}:${Account}:build/${BuildId}", "build-batch": "arn:${Partition}:codebuild:${Region}:${Account}:build-batch/${BuildBatchId}", "fleet": "arn:${Partition}:codebuild:${Region}:${Account}:fleet/${FleetName}:${FleetId}", "project": "arn:${Partition}:codebuild:${Region}:${Account}:project/${ProjectName}", "report": "arn:${Partition}:codebuild:${Region}:${Account}:report/${ReportGroupName}:${ReportId}", "report-group": "arn:${Partition}:codebuild:${Region}:${Account}:report-group/${ReportGroupName}", "sandbox": "arn:${Partition}:codebuild:${Region}:${Account}:sandbox/${SandboxId}"}, "codepipeline": {"action": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}/${ActionName}", "actiontype": "arn:${Partition}:codepipeline:${Region}:${Account}:actiontype:${Owner}/${Category}/${Provider}/${Version}", "pipeline": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}", "stage": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}", "webhook": "arn:${Partition}:codepipeline:${Region}:${Account}:webhook:${WebhookName}"}, "cognito-identity": {"identitypool": "arn:${Partition}:cognito-identity:${Region}:${Account}:identitypool/${IdentityPoolId}"}, "cognito-idp": {"userpool": "arn:${Partition}:cognito-idp:${Region}:${Account}:userpool/${UserPoolId}", "webacl": "arn:${Partition}:wafv2:${Region}:${Account}:${Scope}/webacl/${Name}/${Id}"}, "cur": {"cur": "arn:${Partition}:cur:${Region}:${Account}:definition/${ReportName}"}, "datasync": {"agent": "arn:${Partition}:datasync:${Region}:${Account}:agent/${AgentId}", "discoveryjob": "arn:${Partition}:datasync:${Region}:${Account}:system/${StorageSystemId}/job/${DiscoveryJobId}", "location": "arn:${Partition}:datasync:${Region}:${Account}:location/${LocationId}", "storagesystem": "arn:${Partition}:datasync:${Region}:${Account}:system/${StorageSystemId}", "task": "arn:${Partition}:datasync:${Region}:${Account}:task/${TaskId}", "taskexecution": "arn:${Partition}:datasync:${Region}:${Account}:task/${TaskId}/execution/${ExecutionId}"}, "dynamodb": {"backup": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}/backup/${BackupName}", "export": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}/export/${ExportName}", "global-table": "arn:${Partition}:dynamodb::${Account}:global-table/${GlobalTableName}", "import": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}/import/${ImportName}", "index": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}/index/${IndexName}", "stream": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}/stream/${StreamLabel}", "table": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}"}, "ecr": {"repository": "arn:${Partition}:ecr:${Region}:${Account}:repository/${RepositoryName}"}, "elasticloadbalancing": {"listener-rule/app": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener-rule/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}/${ListenerRuleId}", "listener-rule/net": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener-rule/net/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}/${ListenerRuleId}", "listener/app": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "listener/gwy": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/gwy/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "listener/net": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/net/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "loadbalancer": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/${LoadBalancerName}", "loadbalancer/app/": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/app/${LoadBalancerName}/${LoadBalancerId}", "loadbalancer/gwy/": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/gwy/${LoadBalancerName}/${LoadBalancerId}", "loadbalancer/net/": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/net/${LoadBalancerName}/${LoadBalancerId}", "targetgroup": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:targetgroup/${TargetGroupName}/${TargetGroupId}", "truststore": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:truststore/${TrustStoreName}/${TrustStoreId}"}, "elasticmapreduce": {"cluster": "arn:${Partition}:elasticmapreduce:${Region}:${Account}:cluster/${ClusterId}", "editor": "arn:${Partition}:elasticmapreduce:${Region}:${Account}:editor/${EditorId}", "notebook-execution": "arn:${Partition}:elasticmapreduce:${Region}:${Account}:notebook-execution/${NotebookExecutionId}", "session": "arn:${Partition}:elasticmapreduce:${Region}:${Account}:cluster/${ClusterId}/session/${SessionId}", "studio": "arn:${Partition}:elasticmapreduce:${Region}:${Account}:studio/${StudioId}"}, "es": {"application": "arn:${Partition}:opensearch:${Region}:${Account}:application/${AppId}", "datasource": "arn:${Partition}:opensearch:${Region}:${Account}:datasource/${DataSourceName}", "domain": "arn:${Partition}:es:${Region}:${Account}:domain/${DomainName}", "es_role": "arn:${Partition}:iam::${Account}:role/aws-service-role/es.amazonaws.com/AWSServiceRoleForAmazonOpenSearchService", "opensearchservice_role": "arn:${Partition}:iam::${Account}:role/aws-service-role/opensearchservice.amazonaws.com/AWSServiceRoleForAmazonOpenSearchService"}, "events": {"alias": "arn:${Partition}:kms:${Region}:${Account}:alias/${Alias}", "api-destination": "arn:${Partition}:events:${Region}:${Account}:api-destination/${ApiDestinationName}", "archive": "arn:${Partition}:events:${Region}:${Account}:archive/${ArchiveName}", "connection": "arn:${Partition}:events:${Region}:${Account}:connection/${ConnectionName}", "create-snapshot": "arn:${Partition}:events:${Region}:${Account}:target/create-snapshot", "endpoint": "arn:${Partition}:events:${Region}:${Account}:endpoint/${EndpointName}", "event-bus": "arn:${Partition}:events:${Region}:${Account}:event-bus/${EventBusName}", "event-busv2": "arn:${Partition}:events:${Region}:${Account}:event-busv2/${EventBusName}/${OpaqueId}", "event-source": "arn:${Partition}:events:${Region}::event-source/${EventSourceName}", "event-sourcev2": "arn:${Partition}:events:${Region}:${Account}:event-sourcev2/${SourceType}/${EventSourceName}/${OpaqueId}", "key": "arn:${Partition}:kms:${Region}:${Account}:key/${KeyId}", "reboot-instance": "arn:${Partition}:events:${Region}:${Account}:target/reboot-instance", "replay": "arn:${Partition}:events:${Region}:${Account}:replay/${ReplayName}", "rule-on-custom-event-bus": "arn:${Partition}:events:${Region}:${Account}:rule/${EventBusName}/${RuleName}", "rule-on-default-event-bus": "arn:${Partition}:events:${Region}:${Account}:rule/${RuleName}", "stop-instance": "arn:${Partition}:events:${Region}:${Account}:target/stop-instance", "subscriber": "arn:${Partition}:events:${Region}:${Account}:subscriber/${SubscriberName}/${OpaqueId}", "terminate-instance": "arn:${Partition}:events:${Region}:${Account}:target/terminate-instance"}, "firehose": {"deliverystream": "arn:${Partition}:firehose:${Region}:${Account}:deliverystream/${DeliveryStreamName}"}, "globalaccelerator": {"accelerator": "arn:${Partition}:globalaccelerator::${Account}:accelerator/${ResourceId}", "attachment": "arn:${Partition}:globalaccelerator::${Account}:attachment/${ResourceId}", "endpointgroup": "arn:${Partition}:globalaccelerator::${Account}:accelerator/${ResourceId}/listener/${ListenerId}/endpoint-group/${EndpointGroupId}", "listener": "arn:${Partition}:globalaccelerator::${Account}:accelerator/${ResourceId}/listener/${ListenerId}"}, "kinesisanalytics": {"application": "arn:${Partition}:kinesisanalytics:${Region}:${Account}:application/${ApplicationName}"}, "logs": {"anomaly-detector": "arn:${Partition}:logs:${Region}:${Account}:anomaly-detector:${DetectorId}", "delivery": "arn:${Partition}:logs:${Region}:${Account}:delivery:${DeliveryName}", "delivery-destination": "arn:${Partition}:logs:${Region}:${Account}:delivery-destination:${DeliveryDestinationName}", "delivery-source": "arn:${Partition}:logs:${Region}:${Account}:delivery-source:${DeliverySourceName}", "destination": "arn:${Partition}:logs:${Region}:${Account}:destination:${DestinationName}", "log-group": "arn:${Partition}:logs:${Region}:${Account}:log-group:${LogGroupName}", "log-stream": "arn:${Partition}:logs:${Region}:${Account}:log-group:${LogGroupName}:log-stream:${LogStreamName}", "lookup-table": "arn:${Partition}:logs:${Region}:${Account}:lookup-table:${LookupTableName}", "scheduled-query": "arn:${Partition}:logs:${Region}:${Account}:scheduled-query:${ScheduledQueryId}"}, "payment-cryptography": {"alias": "arn:${Partition}:payment-cryptography:${Region}:${Account}:alias/${Alias}", "approval-team": "arn:${Partition}:mpa:${Region}:${Account}:approval-team/${ApprovalTeamId}", "key": "arn:${Partition}:payment-cryptography:${Region}:${Account}:key/${KeyId}"}, "redshift-data": {"cluster": "arn:${Partition}:redshift:${Region}:${Account}:cluster:${ClusterName}", "managed-workgroup": "arn:${Partition}:redshift-serverless:${Region}:${Account}:managed-workgroup/${ManagedWorkgroupId}", "workgroup": "arn:${Partition}:redshift-serverless:${Region}:${Account}:workgroup/${WorkgroupId}"}, "rekognition": {"collection": "arn:${Partition}:rekognition:${Region}:${Account}:collection/${CollectionId}", "dataset": "arn:${Partition}:rekognition:${Region}:${Account}:project/${ProjectName}/dataset/${DatasetType}/${CreationTimestamp}", "project": "arn:${Partition}:rekognition:${Region}:${Account}:project/${ProjectName}/${CreationTimestamp}", "projectversion": "arn:${Partition}:rekognition:${Region}:${Account}:project/${ProjectName}/version/${VersionName}/${CreationTimestamp}", "streamprocessor": "arn:${Partition}:rekognition:${Region}:${Account}:streamprocessor/${StreamprocessorId}"}, "servicediscovery": {"namespace": "arn:${Partition}:servicediscovery:${Region}:${Account}:namespace/${NamespaceId}", "service": "arn:${Partition}:servicediscovery:${Region}:${Account}:service/${ServiceId}"}, "servicequotas": {"quota": "arn:${Partition}:servicequotas:${Region}:${Account}:${ServiceCode}/${QuotaCode}"}, "sso": {"Account": "arn:${Partition}:sso:::account/${AccountId}", "Application": "arn:${Partition}:sso::${Account}:application/${InstanceId}/${ApplicationId}", "ApplicationProvider": "arn:${Partition}:sso::aws:applicationProvider/${ApplicationProviderId}", "Instance": "arn:${Partition}:sso:::instance/${InstanceId}", "PermissionSet": "arn:${Partition}:sso:::permissionSet/${InstanceId}/${PermissionSetId}", "TrustedTokenIssuer": "arn:${Partition}:sso::${Account}:trustedTokenIssuer/${InstanceId}/${TrustedTokenIssuerId}"}, "states": {"activity": "arn:${Partition}:states:${Region}:${Account}:activity:${ActivityName}", "execution": "arn:${Partition}:states:${Region}:${Account}:execution:${StateMachineName}:${ExecutionId}", "express": "arn:${Partition}:states:${Region}:${Account}:express:${StateMachineName}:${ExecutionId}:${ExpressId}", "labelled execution": "arn:${Partition}:states:${Region}:${Account}:execution:${StateMachineName}/${MapRunLabel}:${ExecutionId}", "labelled express": "arn:${Partition}:states:${Region}:${Account}:express:${StateMachineName}/${MapRunLabel}:${ExecutionId}:${ExpressId}", "maprun": "arn:${Partition}:states:${Region}:${Account}:mapRun:${StateMachineName}/${MapRunLabel}:${MapRunId}", "statemachine": "arn:${Partition}:states:${Region}:${Account}:stateMachine:${StateMachineName}", "statemachinealias": "arn:${Partition}:states:${Region}:${Account}:stateMachine:${StateMachineName}:${StateMachineAliasName}", "statemachineversion": "arn:${Partition}:states:${Region}:${Account}:stateMachine:${StateMachineName}:${StateMachineVersionId}"}, "textract": {"adapter": "arn:${Partition}:textract:${Region}:${Account}:/adapters/${AdapterId}", "adapterversion": "arn:${Partition}:textract:${Region}:${Account}:/adapters/${AdapterId}/versions/${AdapterVersion}"}, "timestream-influxdb": {"db-backup": "arn:${Partition}:timestream-influxdb:${Region}:${Account}:db-backup/${DbBackupId}", "db-cluster": "arn:${Partition}:timestream-influxdb:${Region}:${Account}:db-cluster/${DbClusterId}", "db-instance": "arn:${Partition}:timestream-influxdb:${Region}:${Account}:db-instance/${DbInstanceIdentifier}", "db-parameter-group": "arn:${Partition}:timestream-influxdb:${Region}:${Account}:db-parameter-group/${DbParameterGroupIdentifier}"}, "translate": {"parallel-data": "arn:${Partition}:translate:${Region}:${Account}:parallel-data/${ResourceName}", "terminology": "arn:${Partition}:translate:${Region}:${Account}:terminology/${ResourceName}"}}, + "arnFormats": {"access-analyzer": {"Analyzer": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}", "ArchiveRule": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}/archive-rule/${RuleName}"}, "acm": {"acme-domain-validation": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-domain-validation/${AcmeDomainValidationId}", "acme-endpoint": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}", "acme-external-account-binding": "arn:${Partition}:acm:${Region}:${Account}:acme-endpoint/${AcmeEndpointId}/acme-external-account-binding/${ExternalAccountBindingId}", "certificate": "arn:${Partition}:acm:${Region}:${Account}:certificate/${CertificateId}"}, "application-autoscaling": {"ScalableTarget": "arn:${Partition}:application-autoscaling:${Region}:${Account}:scalable-target/${ResourceId}"}, "athena": {"capacity-reservation": "arn:${Partition}:athena:${Region}:${Account}:capacity-reservation/${CapacityReservationName}", "datacatalog": "arn:${Partition}:athena:${Region}:${Account}:datacatalog/${DataCatalogName}", "session": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}/session/${SessionId}", "workgroup": "arn:${Partition}:athena:${Region}:${Account}:workgroup/${WorkGroupName}"}, "bcm-data-exports": {"billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "export": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:export/${Identifier}", "table": "arn:${Partition}:bcm-data-exports:${Region}:${Account}:table/${Identifier}"}, "bcm-pricing-calculator": {"bill-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-estimate/${BillEstimateId}", "bill-scenario": "arn:${Partition}:bcm-pricing-calculator::${Account}:bill-scenario/${BillScenarioId}", "workload-estimate": "arn:${Partition}:bcm-pricing-calculator::${Account}:workload-estimate/${WorkloadEstimateId}"}, "budgets": {"budget": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}", "budgetAction": "arn:${Partition}:budgets::${Account}:budget/${BudgetName}/action/${ActionId}"}, "ce": {"anomalymonitor": "arn:${Partition}:ce::${Account}:anomalymonitor/${Identifier}", "anomalysubscription": "arn:${Partition}:ce::${Account}:anomalysubscription/${Identifier}", "billingview": "arn:${Partition}:billing::${Account}:billingview/${ResourceId}", "costcategory": "arn:${Partition}:ce::${Account}:costcategory/${Identifier}"}, "cloudtrail": {"channel": "arn:${Partition}:cloudtrail:${Region}:${Account}:channel/${ChannelId}", "dashboard": "arn:${Partition}:cloudtrail:${Region}:${Account}:dashboard/${DashboardName}", "eventdatastore": "arn:${Partition}:cloudtrail:${Region}:${Account}:eventdatastore/${EventDataStoreId}", "trail": "arn:${Partition}:cloudtrail:${Region}:${Account}:trail/${TrailName}"}, "codebuild": {"build": "arn:${Partition}:codebuild:${Region}:${Account}:build/${BuildId}", "build-batch": "arn:${Partition}:codebuild:${Region}:${Account}:build-batch/${BuildBatchId}", "fleet": "arn:${Partition}:codebuild:${Region}:${Account}:fleet/${FleetName}:${FleetId}", "project": "arn:${Partition}:codebuild:${Region}:${Account}:project/${ProjectName}", "report": "arn:${Partition}:codebuild:${Region}:${Account}:report/${ReportGroupName}:${ReportId}", "report-group": "arn:${Partition}:codebuild:${Region}:${Account}:report-group/${ReportGroupName}", "sandbox": "arn:${Partition}:codebuild:${Region}:${Account}:sandbox/${SandboxId}"}, "codepipeline": {"action": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}/${ActionName}", "actiontype": "arn:${Partition}:codepipeline:${Region}:${Account}:actiontype:${Owner}/${Category}/${Provider}/${Version}", "pipeline": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}", "stage": "arn:${Partition}:codepipeline:${Region}:${Account}:${PipelineName}/${StageName}", "webhook": "arn:${Partition}:codepipeline:${Region}:${Account}:webhook:${WebhookName}"}, "cognito-identity": {"identitypool": "arn:${Partition}:cognito-identity:${Region}:${Account}:identitypool/${IdentityPoolId}"}, "cognito-idp": {"userpool": "arn:${Partition}:cognito-idp:${Region}:${Account}:userpool/${UserPoolId}", "webacl": "arn:${Partition}:wafv2:${Region}:${Account}:${Scope}/webacl/${Name}/${Id}"}, "cur": {"cur": "arn:${Partition}:cur:${Region}:${Account}:definition/${ReportName}"}, "datasync": {"agent": "arn:${Partition}:datasync:${Region}:${Account}:agent/${AgentId}", "discoveryjob": "arn:${Partition}:datasync:${Region}:${Account}:system/${StorageSystemId}/job/${DiscoveryJobId}", "location": "arn:${Partition}:datasync:${Region}:${Account}:location/${LocationId}", "storagesystem": "arn:${Partition}:datasync:${Region}:${Account}:system/${StorageSystemId}", "task": "arn:${Partition}:datasync:${Region}:${Account}:task/${TaskId}", "taskexecution": "arn:${Partition}:datasync:${Region}:${Account}:task/${TaskId}/execution/${ExecutionId}"}, "dynamodb": {"backup": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}/backup/${BackupName}", "export": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}/export/${ExportName}", "global-table": "arn:${Partition}:dynamodb::${Account}:global-table/${GlobalTableName}", "import": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}/import/${ImportName}", "index": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}/index/${IndexName}", "stream": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}/stream/${StreamLabel}", "table": "arn:${Partition}:dynamodb:${Region}:${Account}:table/${TableName}"}, "ecr": {"repository": "arn:${Partition}:ecr:${Region}:${Account}:repository/${RepositoryName}"}, "elasticloadbalancing": {"listener-rule/app": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener-rule/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}/${ListenerRuleId}", "listener-rule/net": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener-rule/net/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}/${ListenerRuleId}", "listener/app": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/app/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "listener/gwy": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/gwy/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "listener/net": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:listener/net/${LoadBalancerName}/${LoadBalancerId}/${ListenerId}", "loadbalancer": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/${LoadBalancerName}", "loadbalancer/app/": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/app/${LoadBalancerName}/${LoadBalancerId}", "loadbalancer/gwy/": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/gwy/${LoadBalancerName}/${LoadBalancerId}", "loadbalancer/net/": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:loadbalancer/net/${LoadBalancerName}/${LoadBalancerId}", "targetgroup": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:targetgroup/${TargetGroupName}/${TargetGroupId}", "truststore": "arn:${Partition}:elasticloadbalancing:${Region}:${Account}:truststore/${TrustStoreName}/${TrustStoreId}"}, "elasticmapreduce": {"cluster": "arn:${Partition}:elasticmapreduce:${Region}:${Account}:cluster/${ClusterId}", "editor": "arn:${Partition}:elasticmapreduce:${Region}:${Account}:editor/${EditorId}", "notebook-execution": "arn:${Partition}:elasticmapreduce:${Region}:${Account}:notebook-execution/${NotebookExecutionId}", "session": "arn:${Partition}:elasticmapreduce:${Region}:${Account}:cluster/${ClusterId}/session/${SessionId}", "studio": "arn:${Partition}:elasticmapreduce:${Region}:${Account}:studio/${StudioId}"}, "es": {"application": "arn:${Partition}:opensearch:${Region}:${Account}:application/${AppId}", "datasource": "arn:${Partition}:opensearch:${Region}:${Account}:datasource/${DataSourceName}", "domain": "arn:${Partition}:es:${Region}:${Account}:domain/${DomainName}", "es_role": "arn:${Partition}:iam::${Account}:role/aws-service-role/es.amazonaws.com/AWSServiceRoleForAmazonOpenSearchService", "opensearchservice_role": "arn:${Partition}:iam::${Account}:role/aws-service-role/opensearchservice.amazonaws.com/AWSServiceRoleForAmazonOpenSearchService"}, "events": {"alias": "arn:${Partition}:kms:${Region}:${Account}:alias/${Alias}", "api-destination": "arn:${Partition}:events:${Region}:${Account}:api-destination/${ApiDestinationName}", "archive": "arn:${Partition}:events:${Region}:${Account}:archive/${ArchiveName}", "connection": "arn:${Partition}:events:${Region}:${Account}:connection/${ConnectionName}", "create-snapshot": "arn:${Partition}:events:${Region}:${Account}:target/create-snapshot", "endpoint": "arn:${Partition}:events:${Region}:${Account}:endpoint/${EndpointName}", "event-bus": "arn:${Partition}:events:${Region}:${Account}:event-bus/${EventBusName}", "event-busv2": "arn:${Partition}:events:${Region}:${Account}:event-busv2/${EventBusName}/${OpaqueId}", "event-source": "arn:${Partition}:events:${Region}::event-source/${EventSourceName}", "event-sourcev2": "arn:${Partition}:events:${Region}:${Account}:event-sourcev2/${SourceType}/${EventSourceName}/${OpaqueId}", "key": "arn:${Partition}:kms:${Region}:${Account}:key/${KeyId}", "reboot-instance": "arn:${Partition}:events:${Region}:${Account}:target/reboot-instance", "replay": "arn:${Partition}:events:${Region}:${Account}:replay/${ReplayName}", "rule-on-custom-event-bus": "arn:${Partition}:events:${Region}:${Account}:rule/${EventBusName}/${RuleName}", "rule-on-default-event-bus": "arn:${Partition}:events:${Region}:${Account}:rule/${RuleName}", "stop-instance": "arn:${Partition}:events:${Region}:${Account}:target/stop-instance", "subscriber": "arn:${Partition}:events:${Region}:${Account}:subscriber/${SubscriberName}/${OpaqueId}", "terminate-instance": "arn:${Partition}:events:${Region}:${Account}:target/terminate-instance"}, "firehose": {"deliverystream": "arn:${Partition}:firehose:${Region}:${Account}:deliverystream/${DeliveryStreamName}"}, "globalaccelerator": {"accelerator": "arn:${Partition}:globalaccelerator::${Account}:accelerator/${ResourceId}", "attachment": "arn:${Partition}:globalaccelerator::${Account}:attachment/${ResourceId}", "endpointgroup": "arn:${Partition}:globalaccelerator::${Account}:accelerator/${ResourceId}/listener/${ListenerId}/endpoint-group/${EndpointGroupId}", "listener": "arn:${Partition}:globalaccelerator::${Account}:accelerator/${ResourceId}/listener/${ListenerId}"}, "kinesisanalytics": {"application": "arn:${Partition}:kinesisanalytics:${Region}:${Account}:application/${ApplicationName}"}, "logs": {"anomaly-detector": "arn:${Partition}:logs:${Region}:${Account}:anomaly-detector:${DetectorId}", "delivery": "arn:${Partition}:logs:${Region}:${Account}:delivery:${DeliveryName}", "delivery-destination": "arn:${Partition}:logs:${Region}:${Account}:delivery-destination:${DeliveryDestinationName}", "delivery-source": "arn:${Partition}:logs:${Region}:${Account}:delivery-source:${DeliverySourceName}", "destination": "arn:${Partition}:logs:${Region}:${Account}:destination:${DestinationName}", "log-group": "arn:${Partition}:logs:${Region}:${Account}:log-group:${LogGroupName}", "log-stream": "arn:${Partition}:logs:${Region}:${Account}:log-group:${LogGroupName}:log-stream:${LogStreamName}", "lookup-table": "arn:${Partition}:logs:${Region}:${Account}:lookup-table:${LookupTableName}", "scheduled-query": "arn:${Partition}:logs:${Region}:${Account}:scheduled-query:${ScheduledQueryId}"}, "payment-cryptography": {"alias": "arn:${Partition}:payment-cryptography:${Region}:${Account}:alias/${Alias}", "approval-team": "arn:${Partition}:mpa:${Region}:${Account}:approval-team/${ApprovalTeamId}", "key": "arn:${Partition}:payment-cryptography:${Region}:${Account}:key/${KeyId}"}, "redshift": {"cluster": "arn:${Partition}:redshift:${Region}:${Account}:cluster:${ClusterName}", "datashare": "arn:${Partition}:redshift:${Region}:${Account}:datashare:${ProducerClusterNamespace}/${DataShareName}", "dbgroup": "arn:${Partition}:redshift:${Region}:${Account}:dbgroup:${ClusterName}/${DbGroup}", "dbname": "arn:${Partition}:redshift:${Region}:${Account}:dbname:${ClusterName}/${DbName}", "dbuser": "arn:${Partition}:redshift:${Region}:${Account}:dbuser:${ClusterName}/${DbUser}", "eventsubscription": "arn:${Partition}:redshift:${Region}:${Account}:eventsubscription:${EventSubscriptionName}", "hsmclientcertificate": "arn:${Partition}:redshift:${Region}:${Account}:hsmclientcertificate:${HSMClientCertificateId}", "hsmconfiguration": "arn:${Partition}:redshift:${Region}:${Account}:hsmconfiguration:${HSMConfigurationId}", "integration": "arn:${Partition}:redshift:${Region}:${Account}:integration:${IntegrationIdentifier}", "namespace": "arn:${Partition}:redshift:${Region}:${Account}:namespace:${ClusterNamespace}", "parametergroup": "arn:${Partition}:redshift:${Region}:${Account}:parametergroup:${ParameterGroupName}", "qev2idcapplication": "arn:${Partition}:redshift:${Region}:${Account}:qev2idcapplication:${Qev2IdcApplicationId}", "redshiftidcapplication": "arn:${Partition}:redshift:${Region}:${Account}:redshiftidcapplication:${RedshiftIdcApplicationId}", "securitygroup": "arn:${Partition}:redshift:${Region}:${Account}:securitygroup:${SecurityGroupName}/ec2securitygroup/${Owner}/${Ec2SecurityGroupId}", "securitygroupingress-cidr": "arn:${Partition}:redshift:${Region}:${Account}:securitygroupingress:${SecurityGroupName}/cidrip/${IpRange}", "securitygroupingress-ec2securitygroup": "arn:${Partition}:redshift:${Region}:${Account}:securitygroupingress:${SecurityGroupName}/ec2securitygroup/${Owner}/${Ece2SecuritygroupId}", "snapshot": "arn:${Partition}:redshift:${Region}:${Account}:snapshot:${ClusterName}/${SnapshotName}", "snapshotcopygrant": "arn:${Partition}:redshift:${Region}:${Account}:snapshotcopygrant:${SnapshotCopyGrantName}", "snapshotschedule": "arn:${Partition}:redshift:${Region}:${Account}:snapshotschedule:${ScheduleIdentifier}", "subnetgroup": "arn:${Partition}:redshift:${Region}:${Account}:subnetgroup:${SubnetGroupName}", "usagelimit": "arn:${Partition}:redshift:${Region}:${Account}:usagelimit:${UsageLimitId}"}, "redshift-data": {"cluster": "arn:${Partition}:redshift:${Region}:${Account}:cluster:${ClusterName}", "managed-workgroup": "arn:${Partition}:redshift-serverless:${Region}:${Account}:managed-workgroup/${ManagedWorkgroupId}", "workgroup": "arn:${Partition}:redshift-serverless:${Region}:${Account}:workgroup/${WorkgroupId}"}, "rekognition": {"collection": "arn:${Partition}:rekognition:${Region}:${Account}:collection/${CollectionId}", "dataset": "arn:${Partition}:rekognition:${Region}:${Account}:project/${ProjectName}/dataset/${DatasetType}/${CreationTimestamp}", "project": "arn:${Partition}:rekognition:${Region}:${Account}:project/${ProjectName}/${CreationTimestamp}", "projectversion": "arn:${Partition}:rekognition:${Region}:${Account}:project/${ProjectName}/version/${VersionName}/${CreationTimestamp}", "streamprocessor": "arn:${Partition}:rekognition:${Region}:${Account}:streamprocessor/${StreamprocessorId}"}, "servicediscovery": {"namespace": "arn:${Partition}:servicediscovery:${Region}:${Account}:namespace/${NamespaceId}", "service": "arn:${Partition}:servicediscovery:${Region}:${Account}:service/${ServiceId}"}, "servicequotas": {"quota": "arn:${Partition}:servicequotas:${Region}:${Account}:${ServiceCode}/${QuotaCode}"}, "sso": {"Account": "arn:${Partition}:sso:::account/${AccountId}", "Application": "arn:${Partition}:sso::${Account}:application/${InstanceId}/${ApplicationId}", "ApplicationProvider": "arn:${Partition}:sso::aws:applicationProvider/${ApplicationProviderId}", "Instance": "arn:${Partition}:sso:::instance/${InstanceId}", "PermissionSet": "arn:${Partition}:sso:::permissionSet/${InstanceId}/${PermissionSetId}", "TrustedTokenIssuer": "arn:${Partition}:sso::${Account}:trustedTokenIssuer/${InstanceId}/${TrustedTokenIssuerId}"}, "states": {"activity": "arn:${Partition}:states:${Region}:${Account}:activity:${ActivityName}", "execution": "arn:${Partition}:states:${Region}:${Account}:execution:${StateMachineName}:${ExecutionId}", "express": "arn:${Partition}:states:${Region}:${Account}:express:${StateMachineName}:${ExecutionId}:${ExpressId}", "labelled execution": "arn:${Partition}:states:${Region}:${Account}:execution:${StateMachineName}/${MapRunLabel}:${ExecutionId}", "labelled express": "arn:${Partition}:states:${Region}:${Account}:express:${StateMachineName}/${MapRunLabel}:${ExecutionId}:${ExpressId}", "maprun": "arn:${Partition}:states:${Region}:${Account}:mapRun:${StateMachineName}/${MapRunLabel}:${MapRunId}", "statemachine": "arn:${Partition}:states:${Region}:${Account}:stateMachine:${StateMachineName}", "statemachinealias": "arn:${Partition}:states:${Region}:${Account}:stateMachine:${StateMachineName}:${StateMachineAliasName}", "statemachineversion": "arn:${Partition}:states:${Region}:${Account}:stateMachine:${StateMachineName}:${StateMachineVersionId}"}, "textract": {"adapter": "arn:${Partition}:textract:${Region}:${Account}:/adapters/${AdapterId}", "adapterversion": "arn:${Partition}:textract:${Region}:${Account}:/adapters/${AdapterId}/versions/${AdapterVersion}"}, "timestream-influxdb": {"db-backup": "arn:${Partition}:timestream-influxdb:${Region}:${Account}:db-backup/${DbBackupId}", "db-cluster": "arn:${Partition}:timestream-influxdb:${Region}:${Account}:db-cluster/${DbClusterId}", "db-instance": "arn:${Partition}:timestream-influxdb:${Region}:${Account}:db-instance/${DbInstanceIdentifier}", "db-parameter-group": "arn:${Partition}:timestream-influxdb:${Region}:${Account}:db-parameter-group/${DbParameterGroupIdentifier}"}, "translate": {"parallel-data": "arn:${Partition}:translate:${Region}:${Account}:parallel-data/${ResourceName}", "terminology": "arn:${Partition}:translate:${Region}:${Account}:terminology/${ResourceName}"}}, "unqualified": {"states": ["statemachine"]}, "mintedIds": {"events": ["api-destination", "connection"]}, "operations": { @@ -1234,6 +1234,151 @@ "redshift-data:ListSessions": {"action": "redshift-data:ListSessions", "types": [], "resources": []}, "redshift-data:ListStatements": {"action": "redshift-data:ListStatements", "types": [], "resources": []}, "redshift-data:ListTables": {"action": "redshift-data:ListTables", "types": ["cluster", "workgroup"], "resources": [{"types": ["cluster", "workgroup"], "arn": "SecretArn"}, {"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}, {"type": "workgroup", "fill": {}, "find": ["WorkgroupName"]}]}, + "redshift:AcceptReservedNodeExchange": {"action": "redshift:AcceptReservedNodeExchange", "types": [], "resources": []}, + "redshift:AddPartner": {"action": "redshift:AddPartner", "types": [], "resources": []}, + "redshift:AssociateDataShareConsumer": {"action": "redshift:AssociateDataShareConsumer", "types": ["datashare"], "resources": [{"types": ["datashare"], "arn": "DataShareArn"}]}, + "redshift:AuthorizeClusterSecurityGroupIngress": {"action": "redshift:AuthorizeClusterSecurityGroupIngress", "types": ["securitygroup", "securitygroupingress-ec2securitygroup"], "resources": []}, + "redshift:AuthorizeDataShare": {"action": "redshift:AuthorizeDataShare", "types": ["datashare"], "resources": [{"types": ["datashare"], "arn": "DataShareArn"}]}, + "redshift:AuthorizeEndpointAccess": {"action": "redshift:AuthorizeEndpointAccess", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:AuthorizeSnapshotAccess": {"action": "redshift:AuthorizeSnapshotAccess", "types": ["cluster", "snapshot"], "resources": [{"types": ["cluster", "snapshot"], "arn": "SnapshotArn"}, {"type": "cluster", "fill": {"ClusterName": "SnapshotClusterIdentifier"}}, {"type": "snapshot", "fill": {"ClusterName": "SnapshotClusterIdentifier", "SnapshotName": "SnapshotIdentifier"}}]}, + "redshift:BatchDeleteClusterSnapshots": {"action": "redshift:BatchDeleteClusterSnapshots", "types": ["snapshot"], "resources": []}, + "redshift:BatchModifyClusterSnapshots": {"action": "redshift:BatchModifyClusterSnapshots", "types": ["snapshot"], "resources": []}, + "redshift:CancelResize": {"action": "redshift:CancelResize", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:CopyClusterSnapshot": {"action": "redshift:CopyClusterSnapshot", "types": ["cluster", "snapshot"], "resources": [{"type": "cluster", "fill": {"ClusterName": "SourceSnapshotClusterIdentifier"}}, {"type": "snapshot", "fill": {"ClusterName": "SourceSnapshotClusterIdentifier", "SnapshotName": "SourceSnapshotIdentifier"}, "made": true}]}, + "redshift:CreateAuthenticationProfile": {"action": "redshift:CreateAuthenticationProfile", "types": [], "resources": []}, + "redshift:CreateCluster": {"action": "redshift:CreateCluster", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:CreateClusterParameterGroup": {"action": "redshift:CreateClusterParameterGroup", "types": ["parametergroup"], "resources": [{"type": "parametergroup", "fill": {"ParameterGroupName": "ParameterGroupName"}}]}, + "redshift:CreateClusterSecurityGroup": {"action": "redshift:CreateClusterSecurityGroup", "types": ["securitygroup"], "resources": [{"type": "securitygroup", "fill": {"SecurityGroupName": "ClusterSecurityGroupName"}}]}, + "redshift:CreateClusterSnapshot": {"action": "redshift:CreateClusterSnapshot", "types": ["cluster", "snapshot"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}, {"type": "snapshot", "fill": {"ClusterName": "ClusterIdentifier", "SnapshotName": "SnapshotIdentifier"}, "made": true}]}, + "redshift:CreateClusterSubnetGroup": {"action": "redshift:CreateClusterSubnetGroup", "types": ["subnetgroup"], "resources": [{"type": "subnetgroup", "fill": {"SubnetGroupName": "ClusterSubnetGroupName"}}]}, + "redshift:CreateCustomDomainAssociation": {"action": "redshift:CreateCustomDomainAssociation", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:CreateEndpointAccess": {"action": "redshift:CreateEndpointAccess", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:CreateEventSubscription": {"action": "redshift:CreateEventSubscription", "types": ["eventsubscription"], "resources": [{"type": "eventsubscription", "fill": {"EventSubscriptionName": "SubscriptionName"}}]}, + "redshift:CreateHsmClientCertificate": {"action": "redshift:CreateHsmClientCertificate", "types": ["hsmclientcertificate"], "resources": [{"type": "hsmclientcertificate", "fill": {"HSMClientCertificateId": "HsmClientCertificateIdentifier"}}]}, + "redshift:CreateHsmConfiguration": {"action": "redshift:CreateHsmConfiguration", "types": ["hsmconfiguration"], "resources": [{"type": "hsmconfiguration", "fill": {"HSMConfigurationId": "HsmConfigurationIdentifier"}}]}, + "redshift:CreateIntegration": {"action": "redshift:CreateIntegration", "types": ["integration"], "resources": [{"type": "integration", "fill": {}}]}, + "redshift:CreateQev2IdcApplication": {"action": "redshift:CreateQev2IdcApplication", "types": [], "resources": []}, + "redshift:CreateRedshiftIdcApplication": {"action": "redshift:CreateRedshiftIdcApplication", "types": [], "resources": []}, + "redshift:CreateScheduledAction": {"action": "redshift:CreateScheduledAction", "types": [], "resources": []}, + "redshift:CreateSnapshotCopyGrant": {"action": "redshift:CreateSnapshotCopyGrant", "types": ["snapshotcopygrant"], "resources": [{"type": "snapshotcopygrant", "fill": {"SnapshotCopyGrantName": "SnapshotCopyGrantName"}}]}, + "redshift:CreateSnapshotSchedule": {"action": "redshift:CreateSnapshotSchedule", "types": ["snapshotschedule"], "resources": [{"type": "snapshotschedule", "fill": {"ScheduleIdentifier": "ScheduleIdentifier"}}]}, + "redshift:CreateTags": {"action": "redshift:CreateTags", "types": ["cluster", "eventsubscription", "hsmclientcertificate", "hsmconfiguration", "integration", "parametergroup", "securitygroup", "securitygroupingress-cidr", "securitygroupingress-ec2securitygroup", "snapshot", "snapshotcopygrant", "snapshotschedule", "subnetgroup", "usagelimit"], "resources": [{"types": ["cluster", "eventsubscription", "hsmclientcertificate", "hsmconfiguration", "integration", "parametergroup", "securitygroup", "securitygroupingress-cidr", "securitygroupingress-ec2securitygroup", "snapshot", "snapshotcopygrant", "snapshotschedule", "subnetgroup", "usagelimit"], "arn": "ResourceName"}]}, + "redshift:CreateUsageLimit": {"action": "redshift:CreateUsageLimit", "types": ["cluster", "usagelimit"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}, {"type": "usagelimit", "fill": {}, "made": true}]}, + "redshift:DeauthorizeDataShare": {"action": "redshift:DeauthorizeDataShare", "types": ["datashare"], "resources": [{"types": ["datashare"], "arn": "DataShareArn"}]}, + "redshift:DeleteAuthenticationProfile": {"action": "redshift:DeleteAuthenticationProfile", "types": [], "resources": []}, + "redshift:DeleteCluster": {"action": "redshift:DeleteCluster", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DeleteClusterParameterGroup": {"action": "redshift:DeleteClusterParameterGroup", "types": ["parametergroup"], "resources": [{"type": "parametergroup", "fill": {"ParameterGroupName": "ParameterGroupName"}}]}, + "redshift:DeleteClusterSecurityGroup": {"action": "redshift:DeleteClusterSecurityGroup", "types": ["securitygroup"], "resources": [{"type": "securitygroup", "fill": {"SecurityGroupName": "ClusterSecurityGroupName"}}]}, + "redshift:DeleteClusterSnapshot": {"action": "redshift:DeleteClusterSnapshot", "types": ["cluster", "snapshot"], "resources": [{"type": "cluster", "fill": {"ClusterName": "SnapshotClusterIdentifier"}}, {"type": "snapshot", "fill": {"ClusterName": "SnapshotClusterIdentifier", "SnapshotName": "SnapshotIdentifier"}}]}, + "redshift:DeleteClusterSubnetGroup": {"action": "redshift:DeleteClusterSubnetGroup", "types": ["subnetgroup"], "resources": [{"type": "subnetgroup", "fill": {"SubnetGroupName": "ClusterSubnetGroupName"}}]}, + "redshift:DeleteCustomDomainAssociation": {"action": "redshift:DeleteCustomDomainAssociation", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DeleteEndpointAccess": {"action": "redshift:DeleteEndpointAccess", "types": [], "resources": []}, + "redshift:DeleteEventSubscription": {"action": "redshift:DeleteEventSubscription", "types": ["eventsubscription"], "resources": [{"type": "eventsubscription", "fill": {"EventSubscriptionName": "SubscriptionName"}}]}, + "redshift:DeleteHsmClientCertificate": {"action": "redshift:DeleteHsmClientCertificate", "types": ["hsmclientcertificate"], "resources": [{"type": "hsmclientcertificate", "fill": {"HSMClientCertificateId": "HsmClientCertificateIdentifier"}}]}, + "redshift:DeleteHsmConfiguration": {"action": "redshift:DeleteHsmConfiguration", "types": ["hsmconfiguration"], "resources": [{"type": "hsmconfiguration", "fill": {"HSMConfigurationId": "HsmConfigurationIdentifier"}}]}, + "redshift:DeleteIntegration": {"action": "redshift:DeleteIntegration", "types": ["integration"], "resources": [{"types": ["integration"], "arn": "IntegrationArn"}]}, + "redshift:DeletePartner": {"action": "redshift:DeletePartner", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DeleteQev2IdcApplication": {"action": "redshift:DeleteQev2IdcApplication", "types": ["qev2idcapplication"], "resources": [{"types": ["qev2idcapplication"], "arn": "Qev2IdcApplicationArn"}]}, + "redshift:DeleteRedshiftIdcApplication": {"action": "redshift:DeleteRedshiftIdcApplication", "types": ["redshiftidcapplication"], "resources": [{"types": ["redshiftidcapplication"], "arn": "RedshiftIdcApplicationArn"}]}, + "redshift:DeleteResourcePolicy": {"action": "redshift:DeleteResourcePolicy", "types": ["namespace"], "resources": [{"types": ["namespace"], "arn": "ResourceArn"}]}, + "redshift:DeleteScheduledAction": {"action": "redshift:DeleteScheduledAction", "types": [], "resources": []}, + "redshift:DeleteSnapshotCopyGrant": {"action": "redshift:DeleteSnapshotCopyGrant", "types": ["snapshotcopygrant"], "resources": [{"type": "snapshotcopygrant", "fill": {"SnapshotCopyGrantName": "SnapshotCopyGrantName"}}]}, + "redshift:DeleteSnapshotSchedule": {"action": "redshift:DeleteSnapshotSchedule", "types": ["snapshotschedule"], "resources": [{"type": "snapshotschedule", "fill": {"ScheduleIdentifier": "ScheduleIdentifier"}}]}, + "redshift:DeleteTags": {"action": "redshift:DeleteTags", "types": ["cluster", "eventsubscription", "hsmclientcertificate", "hsmconfiguration", "integration", "parametergroup", "securitygroup", "securitygroupingress-cidr", "securitygroupingress-ec2securitygroup", "snapshot", "snapshotcopygrant", "snapshotschedule", "subnetgroup", "usagelimit"], "resources": [{"types": ["cluster", "eventsubscription", "hsmclientcertificate", "hsmconfiguration", "integration", "parametergroup", "securitygroup", "securitygroupingress-cidr", "securitygroupingress-ec2securitygroup", "snapshot", "snapshotcopygrant", "snapshotschedule", "subnetgroup", "usagelimit"], "arn": "ResourceName"}]}, + "redshift:DeleteUsageLimit": {"action": "redshift:DeleteUsageLimit", "types": ["usagelimit"], "resources": [{"type": "usagelimit", "fill": {"UsageLimitId": "UsageLimitId"}}]}, + "redshift:DeregisterNamespace": {"action": "redshift:DeregisterNamespace", "types": [], "resources": []}, + "redshift:DescribeAccountAttributes": {"action": "redshift:DescribeAccountAttributes", "types": [], "resources": []}, + "redshift:DescribeAuthenticationProfiles": {"action": "redshift:DescribeAuthenticationProfiles", "types": [], "resources": []}, + "redshift:DescribeClusterDbRevisions": {"action": "redshift:DescribeClusterDbRevisions", "types": [], "resources": []}, + "redshift:DescribeClusterParameterGroups": {"action": "redshift:DescribeClusterParameterGroups", "types": [], "resources": []}, + "redshift:DescribeClusterParameters": {"action": "redshift:DescribeClusterParameters", "types": ["parametergroup"], "resources": [{"type": "parametergroup", "fill": {"ParameterGroupName": "ParameterGroupName"}}]}, + "redshift:DescribeClusterSecurityGroups": {"action": "redshift:DescribeClusterSecurityGroups", "types": [], "resources": []}, + "redshift:DescribeClusterSnapshots": {"action": "redshift:DescribeClusterSnapshots", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DescribeClusterSubnetGroups": {"action": "redshift:DescribeClusterSubnetGroups", "types": [], "resources": []}, + "redshift:DescribeClusterTracks": {"action": "redshift:DescribeClusterTracks", "types": [], "resources": []}, + "redshift:DescribeClusterVersions": {"action": "redshift:DescribeClusterVersions", "types": [], "resources": []}, + "redshift:DescribeClusters": {"action": "redshift:DescribeClusters", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DescribeCustomDomainAssociations": {"action": "redshift:DescribeCustomDomainAssociations", "types": [], "resources": []}, + "redshift:DescribeDataShares": {"action": "redshift:DescribeDataShares", "types": [], "resources": []}, + "redshift:DescribeDataSharesForConsumer": {"action": "redshift:DescribeDataSharesForConsumer", "types": [], "resources": []}, + "redshift:DescribeDataSharesForProducer": {"action": "redshift:DescribeDataSharesForProducer", "types": [], "resources": []}, + "redshift:DescribeDefaultClusterParameters": {"action": "redshift:DescribeDefaultClusterParameters", "types": [], "resources": []}, + "redshift:DescribeEndpointAccess": {"action": "redshift:DescribeEndpointAccess", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DescribeEndpointAuthorization": {"action": "redshift:DescribeEndpointAuthorization", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DescribeEventCategories": {"action": "redshift:DescribeEventCategories", "types": [], "resources": []}, + "redshift:DescribeEventSubscriptions": {"action": "redshift:DescribeEventSubscriptions", "types": [], "resources": []}, + "redshift:DescribeEvents": {"action": "redshift:DescribeEvents", "types": [], "resources": []}, + "redshift:DescribeHsmClientCertificates": {"action": "redshift:DescribeHsmClientCertificates", "types": [], "resources": []}, + "redshift:DescribeHsmConfigurations": {"action": "redshift:DescribeHsmConfigurations", "types": [], "resources": []}, + "redshift:DescribeInboundIntegrations": {"action": "redshift:DescribeInboundIntegrations", "types": [], "resources": []}, + "redshift:DescribeIntegrations": {"action": "redshift:DescribeIntegrations", "types": ["integration"], "resources": [{"types": ["integration"], "arn": "IntegrationArn"}]}, + "redshift:DescribeLoggingStatus": {"action": "redshift:DescribeLoggingStatus", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DescribeNodeConfigurationOptions": {"action": "redshift:DescribeNodeConfigurationOptions", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DescribeOrderableClusterOptions": {"action": "redshift:DescribeOrderableClusterOptions", "types": [], "resources": []}, + "redshift:DescribePartners": {"action": "redshift:DescribePartners", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DescribeQev2IdcApplications": {"action": "redshift:DescribeQev2IdcApplications", "types": [], "resources": []}, + "redshift:DescribeRedshiftIdcApplications": {"action": "redshift:DescribeRedshiftIdcApplications", "types": [], "resources": []}, + "redshift:DescribeReservedNodeExchangeStatus": {"action": "redshift:DescribeReservedNodeExchangeStatus", "types": [], "resources": []}, + "redshift:DescribeReservedNodeOfferings": {"action": "redshift:DescribeReservedNodeOfferings", "types": [], "resources": []}, + "redshift:DescribeReservedNodes": {"action": "redshift:DescribeReservedNodes", "types": [], "resources": []}, + "redshift:DescribeResize": {"action": "redshift:DescribeResize", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DescribeScheduledActions": {"action": "redshift:DescribeScheduledActions", "types": [], "resources": []}, + "redshift:DescribeSnapshotCopyGrants": {"action": "redshift:DescribeSnapshotCopyGrants", "types": [], "resources": []}, + "redshift:DescribeSnapshotSchedules": {"action": "redshift:DescribeSnapshotSchedules", "types": ["cluster", "snapshotschedule"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}, {"type": "snapshotschedule", "fill": {"ScheduleIdentifier": "ScheduleIdentifier"}}]}, + "redshift:DescribeStorage": {"action": "redshift:DescribeStorage", "types": [], "resources": []}, + "redshift:DescribeTableRestoreStatus": {"action": "redshift:DescribeTableRestoreStatus", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DescribeTags": {"action": "redshift:DescribeTags", "types": ["cluster", "eventsubscription", "hsmclientcertificate", "hsmconfiguration", "integration", "parametergroup", "securitygroup", "securitygroupingress-cidr", "securitygroupingress-ec2securitygroup", "snapshot", "snapshotcopygrant", "snapshotschedule", "subnetgroup", "usagelimit"], "resources": [{"types": ["cluster", "eventsubscription", "hsmclientcertificate", "hsmconfiguration", "integration", "parametergroup", "securitygroup", "securitygroupingress-cidr", "securitygroupingress-ec2securitygroup", "snapshot", "snapshotcopygrant", "snapshotschedule", "subnetgroup", "usagelimit"], "arn": "ResourceName"}]}, + "redshift:DescribeUsageLimits": {"action": "redshift:DescribeUsageLimits", "types": ["cluster", "usagelimit"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}, {"type": "usagelimit", "fill": {"UsageLimitId": "UsageLimitId"}}]}, + "redshift:DisableLogging": {"action": "redshift:DisableLogging", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DisableSnapshotCopy": {"action": "redshift:DisableSnapshotCopy", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:DisassociateDataShareConsumer": {"action": "redshift:DisassociateDataShareConsumer", "types": ["datashare"], "resources": [{"types": ["datashare"], "arn": "DataShareArn"}]}, + "redshift:EnableLogging": {"action": "redshift:EnableLogging", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:EnableSnapshotCopy": {"action": "redshift:EnableSnapshotCopy", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:FailoverPrimaryCompute": {"action": "redshift:FailoverPrimaryCompute", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:GetClusterCredentials": {"action": "redshift:GetClusterCredentials", "types": ["dbname", "dbuser"], "resources": [{"type": "dbname", "fill": {"ClusterName": "ClusterIdentifier", "DbName": "DbName"}, "unless": {"DbName": [null]}}, {"type": "dbuser", "fill": {"ClusterName": "ClusterIdentifier", "DbUser": "DbUser"}}]}, + "redshift:GetClusterCredentialsWithIAM": {"action": "redshift:GetClusterCredentialsWithIAM", "types": ["dbname"], "resources": [{"type": "dbname", "fill": {"ClusterName": "ClusterIdentifier", "DbName": "DbName"}}]}, + "redshift:GetIdentityCenterAuthToken": {"action": "redshift:GetIdentityCenterAuthToken", "types": ["cluster"], "resources": []}, + "redshift:GetReservedNodeExchangeConfigurationOptions": {"action": "redshift:GetReservedNodeExchangeConfigurationOptions", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:GetReservedNodeExchangeOfferings": {"action": "redshift:GetReservedNodeExchangeOfferings", "types": [], "resources": []}, + "redshift:GetResourcePolicy": {"action": "redshift:GetResourcePolicy", "types": ["namespace"], "resources": [{"types": ["namespace"], "arn": "ResourceArn"}]}, + "redshift:ListRecommendations": {"action": "redshift:ListRecommendations", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:ModifyAquaConfiguration": {"action": "redshift:ModifyAquaConfiguration", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:ModifyAuthenticationProfile": {"action": "redshift:ModifyAuthenticationProfile", "types": [], "resources": []}, + "redshift:ModifyCluster": {"action": "redshift:ModifyCluster", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:ModifyClusterDbRevision": {"action": "redshift:ModifyClusterDbRevision", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:ModifyClusterIamRoles": {"action": "redshift:ModifyClusterIamRoles", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:ModifyClusterMaintenance": {"action": "redshift:ModifyClusterMaintenance", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:ModifyClusterParameterGroup": {"action": "redshift:ModifyClusterParameterGroup", "types": ["parametergroup"], "resources": [{"type": "parametergroup", "fill": {"ParameterGroupName": "ParameterGroupName"}}]}, + "redshift:ModifyClusterSnapshot": {"action": "redshift:ModifyClusterSnapshot", "types": ["snapshot"], "resources": [{"type": "snapshot", "fill": {"SnapshotName": "SnapshotIdentifier"}}]}, + "redshift:ModifyClusterSnapshotSchedule": {"action": "redshift:ModifyClusterSnapshotSchedule", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:ModifyClusterSubnetGroup": {"action": "redshift:ModifyClusterSubnetGroup", "types": ["subnetgroup"], "resources": [{"type": "subnetgroup", "fill": {"SubnetGroupName": "ClusterSubnetGroupName"}}]}, + "redshift:ModifyCustomDomainAssociation": {"action": "redshift:ModifyCustomDomainAssociation", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:ModifyEndpointAccess": {"action": "redshift:ModifyEndpointAccess", "types": [], "resources": []}, + "redshift:ModifyEventSubscription": {"action": "redshift:ModifyEventSubscription", "types": ["eventsubscription"], "resources": [{"type": "eventsubscription", "fill": {"EventSubscriptionName": "SubscriptionName"}}]}, + "redshift:ModifyIntegration": {"action": "redshift:ModifyIntegration", "types": ["integration"], "resources": [{"types": ["integration"], "arn": "IntegrationArn"}]}, + "redshift:ModifyLakehouseConfiguration": {"action": "redshift:ModifyLakehouseConfiguration", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:ModifyQev2IdcApplication": {"action": "redshift:ModifyQev2IdcApplication", "types": ["qev2idcapplication"], "resources": [{"types": ["qev2idcapplication"], "arn": "Qev2IdcApplicationArn"}]}, + "redshift:ModifyRedshiftIdcApplication": {"action": "redshift:ModifyRedshiftIdcApplication", "types": ["redshiftidcapplication"], "resources": [{"types": ["redshiftidcapplication"], "arn": "RedshiftIdcApplicationArn"}]}, + "redshift:ModifyScheduledAction": {"action": "redshift:ModifyScheduledAction", "types": [], "resources": []}, + "redshift:ModifySnapshotCopyRetentionPeriod": {"action": "redshift:ModifySnapshotCopyRetentionPeriod", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:ModifySnapshotSchedule": {"action": "redshift:ModifySnapshotSchedule", "types": ["snapshotschedule"], "resources": [{"type": "snapshotschedule", "fill": {"ScheduleIdentifier": "ScheduleIdentifier"}}]}, + "redshift:ModifyUsageLimit": {"action": "redshift:ModifyUsageLimit", "types": ["usagelimit"], "resources": [{"type": "usagelimit", "fill": {"UsageLimitId": "UsageLimitId"}}]}, + "redshift:PauseCluster": {"action": "redshift:PauseCluster", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:PurchaseReservedNodeOffering": {"action": "redshift:PurchaseReservedNodeOffering", "types": [], "resources": []}, + "redshift:PutResourcePolicy": {"action": "redshift:PutResourcePolicy", "types": ["namespace"], "resources": [{"types": ["namespace"], "arn": "ResourceArn"}]}, + "redshift:RebootCluster": {"action": "redshift:RebootCluster", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:RegisterNamespace": {"action": "redshift:RegisterNamespace", "types": [], "resources": []}, + "redshift:RejectDataShare": {"action": "redshift:RejectDataShare", "types": ["datashare"], "resources": [{"types": ["datashare"], "arn": "DataShareArn"}]}, + "redshift:ResetClusterParameterGroup": {"action": "redshift:ResetClusterParameterGroup", "types": ["parametergroup"], "resources": [{"type": "parametergroup", "fill": {"ParameterGroupName": "ParameterGroupName"}}]}, + "redshift:ResizeCluster": {"action": "redshift:ResizeCluster", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:RestoreFromClusterSnapshot": {"action": "redshift:RestoreFromClusterSnapshot", "types": ["cluster", "snapshot"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}, {"type": "snapshot", "fill": {"ClusterName": "SnapshotClusterIdentifier", "SnapshotName": "SnapshotIdentifier"}}, {"types": ["snapshot"], "arn": "SnapshotArn"}]}, + "redshift:RestoreTableFromClusterSnapshot": {"action": "redshift:RestoreTableFromClusterSnapshot", "types": ["cluster", "snapshot"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}, {"type": "snapshot", "fill": {"ClusterName": "ClusterIdentifier", "SnapshotName": "SnapshotIdentifier"}}]}, + "redshift:ResumeCluster": {"action": "redshift:ResumeCluster", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:RevokeClusterSecurityGroupIngress": {"action": "redshift:RevokeClusterSecurityGroupIngress", "types": ["securitygroup", "securitygroupingress-ec2securitygroup"], "resources": []}, + "redshift:RevokeEndpointAccess": {"action": "redshift:RevokeEndpointAccess", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:RevokeSnapshotAccess": {"action": "redshift:RevokeSnapshotAccess", "types": ["cluster", "snapshot"], "resources": [{"types": ["cluster", "snapshot"], "arn": "SnapshotArn"}, {"type": "cluster", "fill": {"ClusterName": "SnapshotClusterIdentifier"}}, {"type": "snapshot", "fill": {"ClusterName": "SnapshotClusterIdentifier", "SnapshotName": "SnapshotIdentifier"}}]}, + "redshift:RotateEncryptionKey": {"action": "redshift:RotateEncryptionKey", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, + "redshift:UpdatePartnerStatus": {"action": "redshift:UpdatePartnerStatus", "types": ["cluster"], "resources": [{"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}]}, "rekognition:AssociateFaces": {"action": "rekognition:AssociateFaces", "types": ["collection"], "resources": [{"type": "collection", "fill": {"CollectionId": "CollectionId"}}]}, "rekognition:CompareFaces": {"action": "rekognition:CompareFaces", "types": [], "resources": []}, "rekognition:CopyProjectVersion": {"action": "rekognition:CopyProjectVersion", "types": ["project", "projectversion"], "resources": [{"types": ["project", "projectversion"], "arn": "DestinationProjectArn"}, {"types": ["project", "projectversion"], "arn": "SourceProjectArn"}, {"types": ["project", "projectversion"], "arn": "SourceProjectVersionArn"}, {"type": "projectversion", "fill": {"VersionName": "VersionName"}, "made": true}]}, diff --git a/src/main/resources/aws/lambda-web-condition-keys.json b/src/main/resources/aws/request-condition-keys.json similarity index 71% rename from src/main/resources/aws/lambda-web-condition-keys.json rename to src/main/resources/aws/request-condition-keys.json index b9c0a8b3d9..61269ea97c 100644 --- a/src/main/resources/aws/lambda-web-condition-keys.json +++ b/src/main/resources/aws/request-condition-keys.json @@ -1,9 +1,9 @@ { "_source": { - "generator": "tools/aws/regen_lambda_web_condition_keys.py", - "reference": "https://servicereference.us-east-1.amazonaws.com/v1/lambda/lambda.json", + "generator": "tools/aws/regen_request_condition_keys.py", + "reference": "https://servicereference.us-east-1.amazonaws.com/", "botocore": "botocore 1.43.118 (installed package)", - "note": "make lambda-web-condition-keys-check re-derives members from botocore; make lambda-web-condition-keys-verify checks actions against AWS." + "note": "make request-condition-keys-check re-derives members from botocore; make request-condition-keys-verify checks actions against AWS." }, "actions": { "lambda:CreateWebFunction": [ @@ -24,6 +24,12 @@ "lambda:UpdateWebFunctionEndpoint": [ "lambda:Request/WebFunctionAuthType", "lambda:Resource/WebFunctionAuthType" + ], + "redshift:CreateClusterUser": [ + "redshift:DbUser" + ], + "redshift:GetClusterCredentials": [ + "redshift:DbUser" ] }, "members": { @@ -41,6 +47,11 @@ "lambda:Request/WebFunctionAuthType": [ "authType" ] + }, + "redshift:GetClusterCredentials": { + "redshift:DbUser": [ + "DbUser" + ] } } } diff --git a/src/test/java/io/github/hectorvent/floci/core/common/RequestResourceMembersTest.java b/src/test/java/io/github/hectorvent/floci/core/common/RequestResourceMembersTest.java index e135af9667..ce23fff1a1 100644 --- a/src/test/java/io/github/hectorvent/floci/core/common/RequestResourceMembersTest.java +++ b/src/test/java/io/github/hectorvent/floci/core/common/RequestResourceMembersTest.java @@ -17,6 +17,7 @@ import org.junit.jupiter.api.TestFactory; import java.io.ByteArrayInputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.util.Collection; import java.util.HashSet; import java.util.LinkedHashMap; import java.util.List; @@ -280,10 +281,12 @@ class RequestResourceMembersTest { /** * Each resource alone, from a request naming it and nothing else, gives exactly its ARN, in the account its * account member names when it has one, with those sharing its explicit member selector, those the operation - * always names, such as a create's new resource (Cloud Map's {@code CreateService}), and those filled from the ARN - * it is read from (a permission set made in an instance); one named through another resource of its service's - * own, the ARN its service gives for that. A member the table locates in a REST request's path or query is given - * there, and a body or a form giving it another value names nothing. + * always names, such as a create's new resource (Cloud Map's {@code CreateService}), those filled from the ARN + * it is read from (a permission set made in an instance), and those a member it shares fills, their other + * variables open (Redshift's {@code DeleteClusterSnapshot} names {@code cluster:} by the + * {@code SnapshotClusterIdentifier} that also fills {@code snapshot:/}); one named through another + * resource of its service's own, the ARN its service gives for that. A member the table locates in a REST + * request's path or query is given there, and a body or a form giving it another value names nothing. */ @TestFactory Stream everyResourceOfTheTableIsReadFromAJsonBodyAndAForm() { @@ -329,14 +332,15 @@ class RequestResourceMembersTest { form.append('&').append(parameter(member)).append('=').append(encoded(sent)); }); List named = operation.getValue().stream() - .filter(other -> (other == resource || named(other) || fillsFromTheArn(other, resource) + .filter(other -> (other == resource || named(other) || sharesAMember(other, given) + || fillsFromTheArn(other, resource) || !other.find().isEmpty() && other.find().equals(resource.find()) && other.when().equals(resource.when()) && other.unless().equals(resource.unless())) && (other.endpoint() == null || resource.endpoint() == null || other.endpoint().equals(resource.endpoint()))) .map(other -> other == resource ? expected : expected( table.formats().get(namespace).get(other.types().getFirst()).format(), other, - "000000000000")) + "000000000000", given.keySet())) .distinct().toList(); StoredResourceArns stored = runningOn(namespace, arn); assertEquals(named, RequestResources.of(operation.getKey(), @@ -411,6 +415,25 @@ class RequestResourceMembersTest { }; } + /** + * Whether a request giving these members names the resource too: it fills a variable from one of them, not from + * the ARN one holds ({@link #fillsFromTheArn} decides those), and no {@code when} or {@code unless} the request's + * values fail leaves it out (each member given is {@code x}, any other absent, which a value list holds as + * {@code ""}). + */ + private static boolean sharesAMember(Resource resource, Map given) { + if (resource.arn() != null || resource.fill().values().stream() + .noneMatch(member -> given.containsKey(member) && !resource.arnOf().containsKey(member.path()))) { + return false; + } + Map values = given.entrySet().stream() + .collect(Collectors.toMap(entry -> entry.getKey().name(), Map.Entry::getValue, (a, b) -> a)); + return resource.when().entrySet().stream() + .allMatch(when -> when.getValue().contains(values.getOrDefault(when.getKey(), ""))) + && resource.unless().entrySet().stream() + .noneMatch(unless -> unless.getValue().contains(values.getOrDefault(unless.getKey(), ""))); + } + /** The value at the member's path in a body: in its list's first element, and in its field's structure. */ private static void put(ObjectNode body, Member member, String value) { if (member.field() == null) { @@ -438,10 +461,17 @@ class RequestResourceMembersTest { /** The format in the account with each variable the resource fills {@code x}, and each other open. */ private static String expected(String format, Resource resource, String account) { + return expected(format, resource, account, resource.fill().values()); + } + + /** The format in the account with each variable the resource fills from one of {@code given} {@code x}. */ + private static String expected(String format, Resource resource, String account, Collection given) { String arn = format.replace("${Partition}", "aws").replace("${Region}", "us-east-1") .replace("${Account}", account); - for (String variable : resource.fill().keySet()) { - arn = arn.replace("${" + variable + "}", "x"); + for (Map.Entry variable : resource.fill().entrySet()) { + if (given.contains(variable.getValue())) { + arn = arn.replace("${" + variable.getKey() + "}", "x"); + } } for (Map.Entry variable : resource.fixed().entrySet()) { arn = arn.replace("${" + variable.getKey() + "}", variable.getValue()); diff --git a/src/test/java/io/github/hectorvent/floci/core/common/RequestResourcesTest.java b/src/test/java/io/github/hectorvent/floci/core/common/RequestResourcesTest.java index 448eb5dd03..10c8e3226a 100644 --- a/src/test/java/io/github/hectorvent/floci/core/common/RequestResourcesTest.java +++ b/src/test/java/io/github/hectorvent/floci/core/common/RequestResourcesTest.java @@ -808,6 +808,26 @@ class RequestResourcesTest { json("{\"names\":[\"" + project + "a\",\"" + project + "b\"]}"))); } + /** + * A member two resources share names both: Redshift's {@code SnapshotClusterIdentifier} fills the cluster and the + * snapshot's cluster, the snapshot's name open when the request gives none. GetClusterCredentials' database is + * named only when its {@code DbName} is given, though {@code ClusterIdentifier} fills its cluster. + */ + @Test + void aMemberTwoResourcesShareNamesBoth() { + String redshift = "arn:aws:redshift:us-east-1:000000000000:"; + assertEquals(List.of(redshift + "cluster:prod", redshift + "snapshot:prod/backup-1"), + of("redshift:DeleteClusterSnapshot", + form("Action=DeleteClusterSnapshot&SnapshotClusterIdentifier=prod&SnapshotIdentifier=backup-1"))); + assertEquals(List.of(redshift + "cluster:prod", redshift + "snapshot:prod/*"), + of("redshift:DeleteClusterSnapshot", form("Action=DeleteClusterSnapshot&SnapshotClusterIdentifier=prod"))); + assertEquals(List.of(redshift + "dbuser:prod/analyst"), of("redshift:GetClusterCredentials", + form("Action=GetClusterCredentials&ClusterIdentifier=prod&DbUser=analyst"))); + assertEquals(List.of(redshift + "dbname:prod/dev", redshift + "dbuser:prod/analyst"), + of("redshift:GetClusterCredentials", + form("Action=GetClusterCredentials&ClusterIdentifier=prod&DbUser=analyst&DbName=dev"))); + } + @Test void aRequestNamingNoResourceOrOfANamespaceTheTableDoesNotReadIsCheckedOnStar() { assertEquals(List.of(), of("ecr:DescribeRepositories", json("{}"))); diff --git a/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestResourceEnforcementIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestResourceEnforcementIntegrationTest.java index bff7ea1940..bb68b6a00a 100644 --- a/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestResourceEnforcementIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/iam/IamRequestResourceEnforcementIntegrationTest.java @@ -1631,6 +1631,78 @@ class IamRequestResourceEnforcementIntegrationTest { } /** A monthly cost budget of the name, with a billing view ARN when one is given. */ + /** + * A Redshift parameter group is checked on {@code parametergroup:}, the ARN its handler tags it under, and a + * tag request on the ARN its {@code ResourceName} gives, a member whose name does not end in Arn. + */ + @Test + void aRedshiftParameterGroupIsCheckedOnTheArnItsHandlerMints() { + String name = "res-pg-" + suffix(); + admin("redshift").formParam("Action", "CreateClusterParameterGroup").formParam("Version", "2012-12-01") + .formParam("ParameterGroupName", name).formParam("ParameterGroupFamily", "redshift-1.0") + .formParam("Description", "d").post("/").then().statusCode(200); + cleanup.register(() -> admin("redshift").formParam("Action", "DeleteClusterParameterGroup") + .formParam("Version", "2012-12-01").formParam("ParameterGroupName", name).post("/")); + String arn = REDSHIFT + "parametergroup:" + name; + + User user = user("res-redshift-pg"); + user.policy(allowOn("redshift:CreateTags", arn) + "," + allowOn("redshift:DescribeClusterParameters", arn)); + redshiftTag(user, arn).statusCode(200); + refused(redshiftTag(user, arn + "-other"), "redshift:CreateTags"); + user.query("redshift", "DescribeClusterParameters").formParam("Version", "2012-12-01") + .formParam("ParameterGroupName", name).post("/").then().statusCode(200); + refused(user.query("redshift", "DescribeClusterParameters").formParam("Version", "2012-12-01") + .formParam("ParameterGroupName", name + "-other").post("/").then(), "redshift:DescribeClusterParameters"); + admin("redshift").formParam("Action", "DescribeTags").formParam("Version", "2012-12-01") + .formParam("ResourceName", arn).post("/").then().statusCode(200) + .body("DescribeTagsResponse.DescribeTagsResult.TaggedResources.TaggedResource.ResourceName", + equalTo(arn)); + } + + /** A Redshift cluster is checked on {@code cluster:}, before the cluster is looked up. */ + @Test + void aRedshiftClusterIsCheckedOnItsIdentifier() { + String cluster = "res-cluster-" + suffix(); + User user = user("res-redshift-cluster"); + user.policy(allowOn("redshift:DescribeClusters", REDSHIFT + "cluster:" + cluster)); + describeCluster(user, cluster).statusCode(404).body(containsString("ClusterNotFound")); + refused(describeCluster(user, cluster + "-other"), "redshift:DescribeClusters"); + } + + /** + * A restore is checked on the snapshot of the cluster its {@code SnapshotClusterIdentifier} names, the cluster the + * snapshot was taken from, and on the new cluster its {@code ClusterIdentifier} names. + */ + @Test + void aRedshiftRestoreIsCheckedOnTheSnapshotOfItsSourceCluster() { + String source = "res-source-" + suffix(); + String restored = "res-restored-" + suffix(); + User user = user("res-redshift-restore"); + user.policy(allowOn("redshift:RestoreFromClusterSnapshot", REDSHIFT + "cluster:" + restored) + "," + + allowOn("redshift:RestoreFromClusterSnapshot", REDSHIFT + "snapshot:" + source + "/snap")); + restore(user, restored, source).statusCode(404).body(containsString("ClusterSnapshotNotFound")); + + user.policy(allowOn("redshift:RestoreFromClusterSnapshot", REDSHIFT + "cluster:" + restored) + "," + + allowOn("redshift:RestoreFromClusterSnapshot", REDSHIFT + "snapshot:" + restored + "/snap")); + refused(restore(user, restored, source), "redshift:RestoreFromClusterSnapshot"); + } + + private static ValidatableResponse redshiftTag(User user, String arn) { + return user.query("redshift", "CreateTags").formParam("Version", "2012-12-01").formParam("ResourceName", arn) + .formParam("Tags.Tag.1.Key", "team").formParam("Tags.Tag.1.Value", "data").post("/").then(); + } + + private static ValidatableResponse describeCluster(User user, String cluster) { + return user.query("redshift", "DescribeClusters").formParam("Version", "2012-12-01") + .formParam("ClusterIdentifier", cluster).post("/").then(); + } + + private static ValidatableResponse restore(User user, String cluster, String snapshotCluster) { + return user.query("redshift", "RestoreFromClusterSnapshot").formParam("Version", "2012-12-01") + .formParam("ClusterIdentifier", cluster).formParam("SnapshotIdentifier", "snap") + .formParam("SnapshotClusterIdentifier", snapshotCluster).post("/").then(); + } + private static String budget(String name, String billingViewArn) { return "{\"BudgetName\":\"" + name + "\",\"BudgetType\":\"COST\",\"TimeUnit\":\"MONTHLY\",\"BudgetLimit\":" + "{\"Amount\":\"100\",\"Unit\":\"USD\"}" + (billingViewArn == null ? "" diff --git a/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftGetClusterCredentialsIamEnforcementIntegrationTest.java b/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftGetClusterCredentialsIamEnforcementIntegrationTest.java index ed799c8c5b..4a4dc542d3 100644 --- a/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftGetClusterCredentialsIamEnforcementIntegrationTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftGetClusterCredentialsIamEnforcementIntegrationTest.java @@ -117,14 +117,74 @@ class RedshiftGetClusterCredentialsIamEnforcementIntegrationTest { assertClusterNotFound(credentials(accessKeyId, cluster).formParam("AutoCreate", "false")); } + /** The Management Guide's policy grants GetClusterCredentials on one {@code dbuser} alone. */ + @Test + void getClusterCredentials_grantOnTheDbUser_passesTheIamCheckForThatUserOnly() { + String cluster = uniqueName("gcc-dbuser"); + String user = uniqueName("gcc-dbuser"); + String accessKeyId = createUser(user); + userPolicy(user, allow("redshift:GetClusterCredentials", ARN_PREFIX + "dbuser:" + cluster + "/analyst")); + + assertClusterNotFound(credentials(accessKeyId, cluster)); + assertDenied(credentials(accessKeyId, cluster, "intruder")); + } + + /** "If the DbName parameter is specified, the IAM policy must allow access to the resource dbname". */ + @Test + void getClusterCredentials_dbName_needsAGrantOnTheDatabase() { + String cluster = uniqueName("gcc-dbname"); + String user = uniqueName("gcc-dbname"); + String accessKeyId = createUser(user); + userPolicy(user, allow("redshift:GetClusterCredentials", ARN_PREFIX + "dbuser:" + cluster + "/analyst")); + assertDenied(credentials(accessKeyId, cluster).formParam("DbName", "testdb")); + + userPolicy(user, allow("redshift:GetClusterCredentials", ARN_PREFIX + "dbuser:" + cluster + "/analyst") + "," + + allow("redshift:GetClusterCredentials", ARN_PREFIX + "dbname:" + cluster + "/testdb")); + assertClusterNotFound(credentials(accessKeyId, cluster).formParam("DbName", "testdb")); + } + + /** + * The Management Guide's example 8 scopes GetClusterCredentials and CreateClusterUser to + * {@code dbuser:/${redshift:DbUser}}, the user the request names. + */ + @Test + void getClusterCredentials_dbUserPolicyVariable_coversBothActions() { + String cluster = uniqueName("gcc-variable"); + String user = uniqueName("gcc-variable"); + String accessKeyId = createUser(user); + String ownUser = ARN_PREFIX + "dbuser:" + cluster + "/${redshift:DbUser}"; + userPolicy(user, allow("redshift:GetClusterCredentials", ownUser) + "," + + allow("redshift:CreateClusterUser", ownUser)); + + assertClusterNotFound(credentials(accessKeyId, cluster).formParam("AutoCreate", "true")); + } + + /** A condition on {@code redshift:DbUser} applies to both actions, CreateClusterUser's included. */ + @Test + void getClusterCredentials_dbUserCondition_appliesToCreateClusterUser() { + String cluster = uniqueName("gcc-condition"); + String user = uniqueName("gcc-condition"); + String accessKeyId = createUser(user); + userPolicy(user, allow("redshift:GetClusterCredentials", "*") + "," + + "{\"Effect\":\"Allow\",\"Action\":\"redshift:CreateClusterUser\",\"Resource\":\"*\"," + + "\"Condition\":{\"StringEquals\":{\"redshift:DbUser\":\"analyst\"}}}"); + + assertClusterNotFound(credentials(accessKeyId, cluster).formParam("AutoCreate", "true")); + assertDenied(credentials(accessKeyId, cluster, "intruder").formParam("AutoCreate", "true")); + } + private static RequestSpecification credentials(String accessKeyId, String cluster) { + return credentials(accessKeyId, cluster, "analyst"); + } + + private static RequestSpecification credentials(String accessKeyId, String cluster, String dbUser) { return given() .header("Authorization", auth(accessKeyId, "redshift")) .contentType("application/x-www-form-urlencoded") .formParam("Action", "GetClusterCredentials") .formParam("Version", "2012-12-01") .formParam("ClusterIdentifier", cluster) - .formParam("DbUser", "analyst"); + .formParam("DbUser", dbUser); } private static void assertDenied(RequestSpecification request) { diff --git a/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandlerTest.java b/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandlerTest.java index 007b27a55a..036e9fa51b 100644 --- a/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandlerTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftQueryHandlerTest.java @@ -597,7 +597,7 @@ class RedshiftQueryHandlerTest { params.putSingle("SnapshotIdentifier", "test-snapshot"); Snapshot snapshot = new Snapshot("test-snapshot", "test-cluster", "deleted", 5439, "admin"); - when(service.deleteSnapshot("test-snapshot")).thenReturn(snapshot); + when(service.deleteSnapshot("test-snapshot", null)).thenReturn(snapshot); Response response = handler.handle("DeleteClusterSnapshot", params); assertEquals(200, response.getStatus()); @@ -619,7 +619,7 @@ class RedshiftQueryHandlerTest { cluster.setMasterUsername("admin"); cluster.setClusterStatus("available"); cluster.setEndpoint(new Endpoint("localhost", 5439)); - when(service.restoreFromClusterSnapshot("restored-cluster", "test-snapshot", "dc2.large")).thenReturn(cluster); + when(service.restoreFromClusterSnapshot("restored-cluster", "test-snapshot", null, "dc2.large")).thenReturn(cluster); Response response = handler.handle("RestoreFromClusterSnapshot", params); assertEquals(200, response.getStatus()); @@ -636,11 +636,11 @@ class RedshiftQueryHandlerTest { params.putSingle("ClusterIdentifier", "restored-cluster"); params.putSingle("SnapshotArn", "arn:aws:redshift:us-east-1:acc:snapshot:src/my-snap"); Cluster cluster = availableCluster("restored-cluster"); - when(service.restoreFromClusterSnapshot("restored-cluster", "my-snap", null)).thenReturn(cluster); + when(service.restoreFromClusterSnapshot("restored-cluster", "my-snap", "src", null)).thenReturn(cluster); Response response = handler.handle("RestoreFromClusterSnapshot", params, "auth"); assertEquals(200, response.getStatus()); - verify(service).restoreFromClusterSnapshot("restored-cluster", "my-snap", null); + verify(service).restoreFromClusterSnapshot("restored-cluster", "my-snap", "src", null); } @Test @@ -674,7 +674,7 @@ class RedshiftQueryHandlerTest { AwsException ex = assertThrows(AwsException.class, () -> handler.handle("RestoreFromClusterSnapshot", params, "auth")); assertEquals("ClusterSnapshotNotFound", ex.getErrorCode()); - verify(service, never()).restoreFromClusterSnapshot(any(), any(), any()); + verify(service, never()).restoreFromClusterSnapshot(any(), any(), any(), any()); } @Test @@ -688,7 +688,59 @@ class RedshiftQueryHandlerTest { () -> handler.handle("RestoreFromClusterSnapshot", params, "auth")); assertEquals("InvalidParameterCombination", ex.getErrorCode()); assertEquals(400, ex.getHttpStatus()); - verify(service, never()).restoreFromClusterSnapshot(any(), any(), any()); + verify(service, never()).restoreFromClusterSnapshot(any(), any(), any(), any()); + } + + /** The cluster a request is authorized on, snapshot:/, is the one its snapshot must be of. */ + @Test + void deleteClusterSnapshotPassesTheClusterItNamesTheSnapshotBy() { + MultivaluedMap params = new MultivaluedHashMap<>(); + params.putSingle("SnapshotIdentifier", "test-snapshot"); + params.putSingle("SnapshotClusterIdentifier", "prod"); + Snapshot snapshot = new Snapshot("test-snapshot", "prod", "deleted", 5439, "admin"); + when(service.deleteSnapshot("test-snapshot", "prod")).thenReturn(snapshot); + + assertEquals(200, handler.handle("DeleteClusterSnapshot", params).getStatus()); + verify(service).deleteSnapshot("test-snapshot", "prod"); + } + + @Test + void restoreFromClusterSnapshotPassesTheClusterItNamesTheSnapshotBy() { + MultivaluedMap params = new MultivaluedHashMap<>(); + params.putSingle("ClusterIdentifier", "restored-cluster"); + params.putSingle("SnapshotIdentifier", "test-snapshot"); + params.putSingle("SnapshotClusterIdentifier", "prod"); + when(service.restoreFromClusterSnapshot("restored-cluster", "test-snapshot", "prod", null)) + .thenReturn(availableCluster("restored-cluster")); + + assertEquals(200, handler.handle("RestoreFromClusterSnapshot", params, "auth").getStatus()); + verify(service).restoreFromClusterSnapshot("restored-cluster", "test-snapshot", "prod", null); + } + + @Test + void restoreFromClusterSnapshotNamingTwoClustersIsNotFound() { + MultivaluedMap params = new MultivaluedHashMap<>(); + params.putSingle("ClusterIdentifier", "restored-cluster"); + params.putSingle("SnapshotArn", "arn:aws:redshift:us-east-1:acc:snapshot:src/my-snap"); + params.putSingle("SnapshotClusterIdentifier", "other"); + + AwsException ex = assertThrows(AwsException.class, + () -> handler.handle("RestoreFromClusterSnapshot", params, "auth")); + assertEquals("ClusterSnapshotNotFound", ex.getErrorCode()); + assertEquals(404, ex.getHttpStatus()); + verify(service, never()).restoreFromClusterSnapshot(any(), any(), any(), any()); + } + + @Test + void restoreFromClusterSnapshotArnWithoutAClusterIsNotFound() { + MultivaluedMap params = new MultivaluedHashMap<>(); + params.putSingle("ClusterIdentifier", "restored-cluster"); + params.putSingle("SnapshotArn", "arn:aws:redshift:us-east-1:acc:snapshot:/my-snap"); + + AwsException ex = assertThrows(AwsException.class, + () -> handler.handle("RestoreFromClusterSnapshot", params, "auth")); + assertEquals("ClusterSnapshotNotFound", ex.getErrorCode()); + verify(service, never()).restoreFromClusterSnapshot(any(), any(), any(), any()); } @Test diff --git a/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftServiceTest.java b/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftServiceTest.java index 641eae1a7b..558e550f33 100644 --- a/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftServiceTest.java +++ b/src/test/java/io/github/hectorvent/floci/services/redshift/RedshiftServiceTest.java @@ -1749,6 +1749,52 @@ class RedshiftServiceTest { verify(clusterBackend, atLeastOnce()).flush(); } + /** + * A request is authorized on snapshot:/ for the cluster it names, so a snapshot of the same name + * taken from another cluster is not found, and nothing is restored, deleted or described. + */ + @Test + void restoreFromClusterSnapshotOfAnotherClusterIsNotFound() { + when(snapshotBackend.get("snap-1")).thenReturn(Optional.of(snapshotOf("snap-1", "protected"))); + when(clusterBackend.get("c1")).thenReturn(Optional.empty()); + + AwsException ex = assertThrows(AwsException.class, + () -> service.restoreFromClusterSnapshot("c1", "snap-1", "allowed", null)); + assertEquals("ClusterSnapshotNotFound", ex.getErrorCode()); + assertEquals(404, ex.getHttpStatus()); + verify(clusterBackend, never()).put(eq("c1"), any()); + verifyNoInteractions(cm); + } + + @Test + void deleteSnapshotOfAnotherClusterIsNotFoundAndKept() { + when(snapshotBackend.get("snap-1")).thenReturn(Optional.of(snapshotOf("snap-1", "protected"))); + + AwsException ex = assertThrows(AwsException.class, () -> service.deleteSnapshot("snap-1", "allowed")); + assertEquals("ClusterSnapshotNotFound", ex.getErrorCode()); + verify(snapshotBackend, never()).delete("snap-1"); + + service.deleteSnapshot("snap-1", "protected"); + verify(snapshotBackend).delete("snap-1"); + } + + @Test + void describeSnapshotsByIdentifierOfAnotherClusterIsNotFound() { + when(snapshotBackend.get("snap-1")).thenReturn(Optional.of(snapshotOf("snap-1", "protected"))); + + AwsException ex = assertThrows(AwsException.class, () -> service.describeSnapshots("snap-1", "allowed")); + assertEquals("ClusterSnapshotNotFound", ex.getErrorCode()); + assertEquals(1, service.describeSnapshots("snap-1", "protected").size()); + } + + private static Snapshot snapshotOf(String snapshotIdentifier, String clusterIdentifier) { + Snapshot snapshot = new Snapshot(); + snapshot.setSnapshotIdentifier(snapshotIdentifier); + snapshot.setClusterIdentifier(clusterIdentifier); + snapshot.setSnapshotType("manual"); + return snapshot; + } + @Test void restoreFromClusterSnapshotKeepsMetadataWhenProxyStopFails() { when(clusterBackend.accountId()).thenReturn("111111111111"); diff --git a/tools/aws/regen_iam_request_resources.py b/tools/aws/regen_iam_request_resources.py index bae13f4456..29c0742ce3 100644 --- a/tools/aws/regen_iam_request_resources.py +++ b/tools/aws/regen_iam_request_resources.py @@ -160,9 +160,9 @@ OUTPUT = REPO_ROOT / "src/main/resources/aws/iam-request-resources.json" NAMESPACES = ("access-analyzer", "acm", "application-autoscaling", "athena", "bcm-data-exports", "bcm-pricing-calculator", "budgets", "ce", "cloudtrail", "codebuild", "codepipeline", "cognito-identity", "cognito-idp", "cur", "datasync", "ecr", "elasticloadbalancing", "elasticmapreduce", "es", "events", - "firehose", "globalaccelerator", "kinesisanalytics", "payment-cryptography", "redshift-data", - "rekognition", "servicediscovery", "servicequotas", "sso", "states", "textract", "timestream-influxdb", - "translate") + "firehose", "globalaccelerator", "kinesisanalytics", "payment-cryptography", "redshift", + "redshift-data", "rekognition", "servicediscovery", "servicequotas", "sso", "states", "textract", + "timestream-influxdb", "translate") # SDK clients the reference lists for a namespace's operations whose requests Floci does not serve, and why: their # members are not read. @@ -257,7 +257,6 @@ NOT_COVERED: dict[str, str] = { "ram": _REST, "rds": _LATER, "rds-data": _REST, - "redshift": _LATER, "redshift-serverless": "not read yet: its namespace, workgroup, snapshot and managed VPC endpoint ARNs end in an " "id the service mints, `namespace/`, while its requests name them by namespaceName, " "workgroupName, snapshotName and endpointName, so reading it needs the stored ARNs those " @@ -534,6 +533,65 @@ CORRECTIONS: dict[str, tuple[list[dict], str]] = { "using the option ALL_PROVISIONED_ACCOUNTS to, at most, 3,500 AWS accounts', the AWS_ACCOUNT option " "provisioning it 'in a single AWS account', IAM Identity Center User Guide), read through the permission set; " "its TargetId names the account only for AWS_ACCOUNT, the handler reading a null one as none"), + "redshift:GetClusterCredentials": ([ + {"type": "dbname", "fill": {"ClusterName": "ClusterIdentifier", "DbName": "DbName"}, + "unless": {"DbName": [None]}}, + {"type": "dbuser", "fill": {"ClusterName": "ClusterIdentifier", "DbUser": "DbUser"}}, + ], "the database is checked only when the request names one ('If the DbName parameter is specified, the IAM " + "policy must allow access to the resource dbname for the specified database name'), and the Management " + "Guide's policy granting the action on a dbuser alone allows it; the rule names the database by " + "ClusterIdentifier alone when DbName is absent"), + "redshift:RestoreFromClusterSnapshot": ([ + {"type": "cluster", "fill": {"ClusterName": "ClusterIdentifier"}}, + {"type": "snapshot", "fill": {"ClusterName": "SnapshotClusterIdentifier", "SnapshotName": "SnapshotIdentifier"}}, + {"types": ["snapshot"], "arn": "SnapshotArn"}, + ], "the snapshot's cluster is SnapshotClusterIdentifier ('The name of the cluster the source snapshot was created " + "from'), not ClusterIdentifier, the cluster 'that will be created from restoring the snapshot'; its " + "DefaultIamRoleArn is an IAM role's ARN and its RedshiftIdcApplicationArn an IAM Identity Center " + "application's, never a cluster's or a snapshot's"), + **{f"redshift:{operation}": ([{"types": ["cluster", "eventsubscription", "hsmclientcertificate", "hsmconfiguration", + "integration", "parametergroup", "securitygroup", + "securitygroupingress-cidr", "securitygroupingress-ec2securitygroup", + "snapshot", "snapshotcopygrant", "snapshotschedule", "subnetgroup", + "usagelimit"], "arn": "ResourceName"}], + "the request names the resource by its ARN in ResourceName ('The Amazon Resource " + "Name (ARN) to which you want to add the tag or tags'), whose name does not end in " + "Arn") + for operation in ("CreateTags", "DeleteTags", "DescribeTags")}, + **{f"redshift:{operation}": ([{"type": kind, "fill": fill}], f"{why}, never a {kind}'s") + for operation, kind, fill, why in ( + ("CreateCluster", "cluster", {"ClusterName": "ClusterIdentifier"}, + "its DefaultIamRoleArn is an IAM role's ARN and its RedshiftIdcApplicationArn an IAM Identity Center " + "application's"), + ("CreateCustomDomainAssociation", "cluster", {"ClusterName": "ClusterIdentifier"}, + "its CustomDomainCertificateArn is an ACM certificate's ARN"), + ("CreateEventSubscription", "eventsubscription", {"EventSubscriptionName": "SubscriptionName"}, + "its SnsTopicArn is an SNS topic's ARN"), + ("CreateIntegration", "integration", {}, + "its SourceArn is the source database's ARN and its TargetArn the target data warehouse's"), + ("DescribeClusterSnapshots", "cluster", {"ClusterName": "ClusterIdentifier"}, + "its SnapshotArn is a snapshot's ARN"), + ("DescribeNodeConfigurationOptions", "cluster", {"ClusterName": "ClusterIdentifier"}, + "its SnapshotArn is a snapshot's ARN"), + ("ListRecommendations", "cluster", {"ClusterName": "ClusterIdentifier"}, + "its NamespaceArn is a namespace's ARN"), + ("ModifyClusterIamRoles", "cluster", {"ClusterName": "ClusterIdentifier"}, + "its DefaultIamRoleArn is an IAM role's ARN"), + ("ModifyCustomDomainAssociation", "cluster", {"ClusterName": "ClusterIdentifier"}, + "its CustomDomainCertificateArn is an ACM certificate's ARN"), + ("ModifyEventSubscription", "eventsubscription", {"EventSubscriptionName": "SubscriptionName"}, + "its SnsTopicArn is an SNS topic's ARN"), + ("ModifyLakehouseConfiguration", "cluster", {"ClusterName": "ClusterIdentifier"}, + "its LakehouseIdcApplicationArn is an IAM Identity Center application's ARN"))}, + **{f"redshift:{operation}": ([{"types": [kind], "arn": arn}], f"{why}, never a {kind}'s") + for operation, kind, arn, why in ( + ("AssociateDataShareConsumer", "datashare", "DataShareArn", + "its ConsumerArn is the consumer namespace's ARN"), + ("DisassociateDataShareConsumer", "datashare", "DataShareArn", + "its ConsumerArn is the consumer namespace's ARN"), + ("ModifyRedshiftIdcApplication", "redshiftidcapplication", "RedshiftIdcApplicationArn", + "its IamRoleArn is an IAM role's ARN and its AuthorizedTokenIssuerList's TrustedTokenIssuerArn a trusted " + "token issuer's"))}, } # Resource types whose ARN a request may give with a qualifier, one more `:` past its format, which their diff --git a/tools/aws/regen_lambda_web_condition_keys.py b/tools/aws/regen_lambda_web_condition_keys.py deleted file mode 100644 index 29163de8aa..0000000000 --- a/tools/aws/regen_lambda_web_condition_keys.py +++ /dev/null @@ -1,151 +0,0 @@ -#!/usr/bin/env python3 -"""Regenerate src/main/resources/aws/lambda-web-condition-keys.json from AWS's Service Reference and botocore. - -A Lambda Web Functions request is checked with the endpoint's authType as -`lambda:Request/WebFunctionAuthType`, the one the request names, and `lambda:Resource/WebFunctionAuthType`, -the one the endpoint has before the request. The table comes from two sources: - -- AWS's Service Reference for `lambda`, which gives each action's condition keys, for the action and - for each resource type it acts on: - - https://servicereference.us-east-1.amazonaws.com/v1/lambda/lambda.json - -- botocore's `lambda-web` model (Apache-2.0, https://github.com/boto/botocore, the pinned release), - which gives where each request carries the authType. - -`actions` holds every `lambda` action that takes either key, with the ones it takes. `members` holds, -for every action that takes the request key, the paths of the request members named `authType`, -dotted for a nested one. The resource key is read from the stored endpoint, so it has no member. - -The two gates split along the sources: - -- `--check` is offline and needs the pinned botocore: `members` must be exactly what botocore gives. -- `--verify` is online and stdlib-only: `actions` must be exactly what the reference gives. - -Run from anywhere in the repo: - python3 tools/aws/regen_lambda_web_condition_keys.py # rewrite the vendored file in place - python3 tools/aws/regen_lambda_web_condition_keys.py --check # offline: members match botocore - python3 tools/aws/regen_lambda_web_condition_keys.py --verify # online: actions match AWS - python3 tools/aws/regen_lambda_web_condition_keys.py --source # read a saved reference -""" -from __future__ import annotations - -import argparse -import json -import sys -import urllib.request -from pathlib import Path - -from regen_dynamodb_condition_keys import member_paths -from regen_iam_tag_on_create import _condition_keys, _resource_keys -from regen_partitions import resolve_botocore_data -from regen_query_services import latest_model_dir, load_model - -OUTPUT = Path(__file__).resolve().parents[2] / "src/main/resources/aws/lambda-web-condition-keys.json" -URL = "https://servicereference.us-east-1.amazonaws.com/v1/lambda/lambda.json" -NAMESPACE = "lambda" -MODEL = "lambda-web" -REQUEST_KEY = "lambda:Request/WebFunctionAuthType" -RESOURCE_KEY = "lambda:Resource/WebFunctionAuthType" -MEMBER = "authType" - - -def action_keys(reference: dict) -> dict[str, list[str]]: - """Every action of the namespace that takes either key, with the ones it takes.""" - resource_keys = _resource_keys([reference]) - found = {} - for action in sorted(reference["Actions"], key=lambda entry: entry["Name"]): - keys = {REQUEST_KEY, RESOURCE_KEY} & _condition_keys(NAMESPACE, action, resource_keys) - if keys: - found[f"{NAMESPACE}:{action['Name']}"] = sorted(keys) - return found - - -def request_members(model: dict, actions: dict[str, list[str]]) -> dict[str, dict[str, list[str]]]: - """For every action that takes the request key, where its request carries the value.""" - found = {} - for action, keys in sorted(actions.items()): - if REQUEST_KEY not in keys: - continue - operation = model["operations"].get(action.split(":", 1)[1]) - if operation is None or "input" not in operation: - raise ValueError(f"{action} takes {REQUEST_KEY} but botocore has no request for it") - paths = member_paths(model, operation["input"]["shape"], {MEMBER}) - if not paths: - raise ValueError(f"{action} takes {REQUEST_KEY} but its request has no {MEMBER} member") - found[action] = {REQUEST_KEY: paths} - return found - - -def render(document: dict) -> str: - return json.dumps(document, indent=2) + "\n" - - -def validate(document: dict) -> list[str]: - """Problems that make the vendored file unusable, rather than merely out of date.""" - problems = [] - for section in ("actions", "members"): - if not isinstance(document.get(section), dict) or not document[section]: - problems.append(f"{section} is missing or empty") - if problems: - return problems - if REQUEST_KEY not in document["actions"].get("lambda:CreateWebFunctionEndpoint", []): - problems.append(f"lambda:CreateWebFunctionEndpoint takes no {REQUEST_KEY}") - if RESOURCE_KEY not in document["actions"].get("lambda:GetWebFunctionEndpoint", []): - problems.append(f"lambda:GetWebFunctionEndpoint takes no {RESOURCE_KEY}") - return problems - - -def _reference(source: Path | None) -> dict: - if source is not None: - return json.loads(source.read_text(encoding="utf-8")) - request = urllib.request.Request(URL, headers={"Accept": "application/json"}) - with urllib.request.urlopen(request, timeout=30) as response: - return json.load(response) - - -def _model(botocore_data: Path | None) -> tuple[dict, str]: - data, provenance = resolve_botocore_data(botocore_data) - return load_model(latest_model_dir(data, MODEL)), provenance - - -def main(argv: list[str] | None = None) -> int: - parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) - parser.add_argument("--check", action="store_true", help="offline: members must match the pinned botocore") - parser.add_argument("--verify", action="store_true", help="online: actions must match the Service Reference") - parser.add_argument("--source", type=Path, help="a saved lambda.json Service Reference document") - parser.add_argument("--botocore-data", type=Path, help="botocore data directory") - args = parser.parse_args(argv) - - if args.check or args.verify: - document = json.loads(OUTPUT.read_text(encoding="utf-8")) - problems = validate(document) - if args.check and not problems: - model, provenance = _model(args.botocore_data) - if document["members"] != request_members(model, document["actions"]): - problems.append(f"members differ from {provenance}") - if args.verify and document.get("actions") != action_keys(_reference(args.source)): - problems.append("actions differ from the AWS Service Reference") - for problem in problems: - print(f"{OUTPUT.name}: {problem}", file=sys.stderr) - return 1 if problems else 0 - - model, provenance = _model(args.botocore_data) - actions = action_keys(_reference(args.source)) - document = {"_source": {"generator": "tools/aws/regen_lambda_web_condition_keys.py", "reference": URL, - "botocore": provenance, - "note": "make lambda-web-condition-keys-check re-derives members from botocore; " - "make lambda-web-condition-keys-verify checks actions against AWS."}, - "actions": actions, "members": request_members(model, actions)} - problems = validate(document) - if problems: - for problem in problems: - print(f"error: {problem}", file=sys.stderr) - return 1 - OUTPUT.write_text(render(document), encoding="utf-8") - print(f"wrote {OUTPUT.name} from {provenance}") - return 0 - - -if __name__ == "__main__": - sys.exit(main()) diff --git a/tools/aws/regen_request_condition_keys.py b/tools/aws/regen_request_condition_keys.py new file mode 100644 index 0000000000..11315af35a --- /dev/null +++ b/tools/aws/regen_request_condition_keys.py @@ -0,0 +1,208 @@ +#!/usr/bin/env python3 +"""Regenerate src/main/resources/aws/request-condition-keys.json from AWS's Service Reference and botocore. + +Some service condition keys take their value from the request, or from the resource the request acts on before +it. `SERVICES` names, for each namespace, the keys read and where: + +- `lambda`: a Lambda Web Functions request is checked with the endpoint's authType as + `lambda:Request/WebFunctionAuthType`, the one the request names, and `lambda:Resource/WebFunctionAuthType`, + the one the endpoint has before the request, read from the stored endpoint. +- `redshift`: a Redshift request is checked with the database user it names as `redshift:DbUser`, so a policy + can scope GetClusterCredentials and CreateClusterUser to `dbuser:/${redshift:DbUser}`. + `redshift:DbName` and `redshift:DurationSeconds` are not read yet. + +The table comes from two sources: + +- AWS's Service Reference for each namespace, which gives each action's condition keys, for the action and + for each resource type it acts on: + + https://servicereference.us-east-1.amazonaws.com/v1//.json + +- botocore's model of each namespace (Apache-2.0, https://github.com/boto/botocore, the pinned release), which + gives where each request carries the value. + +`actions` holds every action that takes a key a namespace reads, with the ones it takes. `members` holds, for +every action and key read from the request, the paths of the request members named as `SERVICES` gives, +dotted for a nested one; a Query request is read as a flat form, so its member must be top-level. A key read +from the stored resource has no member, and an action whose request does not carry the key is in +`not_in_request`, with the reason. + +The two gates split along the sources: + +- `--check` is offline and needs the pinned botocore: `members` must be exactly what botocore gives. +- `--verify` is online and stdlib-only: `actions` must be exactly what the reference gives. + +Run from anywhere in the repo: + python3 tools/aws/regen_request_condition_keys.py # rewrite the vendored file in place + python3 tools/aws/regen_request_condition_keys.py --check # offline: members match botocore + python3 tools/aws/regen_request_condition_keys.py --verify # online: actions match AWS + python3 tools/aws/regen_request_condition_keys.py --source-dir # read saved .json files +""" +from __future__ import annotations + +import argparse +import json +import sys +import urllib.request +from pathlib import Path + +from regen_dynamodb_condition_keys import member_paths +from regen_iam_tag_on_create import _condition_keys, _resource_keys +from regen_partitions import resolve_botocore_data +from regen_query_services import latest_model_dir, load_model + +OUTPUT = Path(__file__).resolve().parents[2] / "src/main/resources/aws/request-condition-keys.json" +REFERENCE = "https://servicereference.us-east-1.amazonaws.com/" +FLAT_PROTOCOLS = ("query", "ec2") + +# For each namespace: its botocore model, each key read from the request with the name of the member that +# carries it, each key read from the stored resource, and the actions that take a key their request does not +# carry, with the reason. +SERVICES = { + "lambda": { + "model": "lambda-web", + "request": {"lambda:Request/WebFunctionAuthType": "authType"}, + "stored": ("lambda:Resource/WebFunctionAuthType",), + "not_in_request": {}, + }, + "redshift": { + "model": "redshift", + "request": {"redshift:DbUser": "DbUser"}, + "stored": (), + "not_in_request": { + ("redshift:CreateClusterUser", "redshift:DbUser"): "no operation of its own: GetClusterCredentials " + "checks it when AutoCreate is true, with the DbUser " + "of its own request", + }, + }, +} + + +def url(namespace: str) -> str: + return f"{REFERENCE}v1/{namespace}/{namespace}.json" + + +def action_keys(namespace: str, reference: dict) -> dict[str, list[str]]: + """Every action of the namespace that takes a key it reads, with the ones it takes.""" + service = SERVICES[namespace] + read = set(service["request"]) | set(service["stored"]) + resource_keys = _resource_keys([reference]) + found = {} + for action in sorted(reference["Actions"], key=lambda entry: entry["Name"]): + keys = read & _condition_keys(namespace, action, resource_keys) + if keys: + found[f"{namespace}:{action['Name']}"] = sorted(keys) + return found + + +def request_members(namespace: str, model: dict, + actions: dict[str, list[str]]) -> dict[str, dict[str, list[str]]]: + """For every action of the namespace and key read from its request, where the request carries the value.""" + service = SERVICES[namespace] + flat = model.get("metadata", {}).get("protocol") in FLAT_PROTOCOLS + found = {} + for action, keys in sorted(actions.items()): + if not action.startswith(f"{namespace}:"): + continue + for key in keys: + if key not in service["request"] or (action, key) in service["not_in_request"]: + continue + name = service["request"][key] + operation = model["operations"].get(action.split(":", 1)[1]) + if operation is None or "input" not in operation: + raise ValueError(f"{action} takes {key} but botocore has no request for it") + paths = member_paths(model, operation["input"]["shape"], {name}) + if not paths: + raise ValueError(f"{action} takes {key} but its request has no {name} member") + nested = [path for path in paths if flat and "." in path] + if nested: + raise ValueError(f"{action} takes {key} from {', '.join(nested)}, which a flat form does not carry") + found.setdefault(action, {})[key] = paths + return found + + +def render(document: dict) -> str: + return json.dumps(document, indent=2) + "\n" + + +def validate(document: dict) -> list[str]: + """Problems that make the vendored file unusable, rather than merely out of date.""" + problems = [] + for section in ("actions", "members"): + if not isinstance(document.get(section), dict) or not document[section]: + problems.append(f"{section} is missing or empty") + if problems: + return problems + actions, members = document["actions"], document["members"] + if "lambda:Request/WebFunctionAuthType" not in actions.get("lambda:CreateWebFunctionEndpoint", []): + problems.append("lambda:CreateWebFunctionEndpoint takes no lambda:Request/WebFunctionAuthType") + if "lambda:Resource/WebFunctionAuthType" not in actions.get("lambda:GetWebFunctionEndpoint", []): + problems.append("lambda:GetWebFunctionEndpoint takes no lambda:Resource/WebFunctionAuthType") + if members.get("redshift:GetClusterCredentials", {}).get("redshift:DbUser") != ["DbUser"]: + problems.append("redshift:GetClusterCredentials does not read redshift:DbUser from DbUser") + return problems + + +def _reference(namespace: str, source_dir: Path | None) -> dict: + if source_dir is not None: + return json.loads((source_dir / f"{namespace}.json").read_text(encoding="utf-8")) + request = urllib.request.Request(url(namespace), headers={"Accept": "application/json"}) + with urllib.request.urlopen(request, timeout=30) as response: + return json.load(response) + + +def _actions(source_dir: Path | None) -> dict[str, list[str]]: + actions = {} + for namespace in SERVICES: + actions.update(action_keys(namespace, _reference(namespace, source_dir))) + return dict(sorted(actions.items())) + + +def _members(actions: dict[str, list[str]], botocore_data: Path | None) -> tuple[dict, str]: + data, provenance = resolve_botocore_data(botocore_data) + members = {} + for namespace, service in SERVICES.items(): + members.update(request_members(namespace, load_model(latest_model_dir(data, service["model"])), actions)) + return dict(sorted(members.items())), provenance + + +def main(argv: list[str] | None = None) -> int: + parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) + parser.add_argument("--check", action="store_true", help="offline: members must match the pinned botocore") + parser.add_argument("--verify", action="store_true", help="online: actions must match the Service Reference") + parser.add_argument("--source-dir", type=Path, help="read saved .json Service Reference files") + parser.add_argument("--botocore-data", type=Path, help="botocore data directory") + args = parser.parse_args(argv) + + if args.check or args.verify: + document = json.loads(OUTPUT.read_text(encoding="utf-8")) + problems = validate(document) + if args.check and not problems: + members, provenance = _members(document["actions"], args.botocore_data) + if document["members"] != members: + problems.append(f"members differ from {provenance}") + if args.verify and document.get("actions") != _actions(args.source_dir): + problems.append("actions differ from the AWS Service Reference") + for problem in problems: + print(f"{OUTPUT.name}: {problem}", file=sys.stderr) + return 1 if problems else 0 + + actions = _actions(args.source_dir) + members, provenance = _members(actions, args.botocore_data) + document = {"_source": {"generator": "tools/aws/regen_request_condition_keys.py", "reference": REFERENCE, + "botocore": provenance, + "note": "make request-condition-keys-check re-derives members from botocore; " + "make request-condition-keys-verify checks actions against AWS."}, + "actions": actions, "members": members} + problems = validate(document) + if problems: + for problem in problems: + print(f"error: {problem}", file=sys.stderr) + return 1 + OUTPUT.write_text(render(document), encoding="utf-8") + print(f"wrote {OUTPUT.name} from {provenance}") + return 0 + + +if __name__ == "__main__": + sys.exit(main()) diff --git a/tools/aws/test_regen_lambda_web_condition_keys.py b/tools/aws/test_regen_lambda_web_condition_keys.py deleted file mode 100644 index 9523cae82b..0000000000 --- a/tools/aws/test_regen_lambda_web_condition_keys.py +++ /dev/null @@ -1,92 +0,0 @@ -"""Action coverage and request members for the Lambda Web Functions authType condition keys.""" -import json -import subprocess - -import pytest - -from regen_lambda_web_condition_keys import OUTPUT, action_keys, request_members, validate - - -def test_resource_and_action_keys_are_combined(): - reference = {"Name": "lambda", "Resources": [{"Name": "webFunctionEndpoint", - "ConditionKeys": ["lambda:Resource/WebFunctionAuthType"]}], - "Actions": [{"Name": "UpdateWebFunctionEndpoint", - "ActionConditionKeys": ["lambda:Request/WebFunctionAuthType", "aws:TagKeys"], - "Resources": [{"Name": "webFunctionEndpoint"}]}, - {"Name": "GetWebFunction", "ActionConditionKeys": ["aws:ResourceTag/${TagKey}"]}]} - assert action_keys(reference) == {"lambda:UpdateWebFunctionEndpoint": [ - "lambda:Request/WebFunctionAuthType", "lambda:Resource/WebFunctionAuthType"]} - - -def test_a_nested_member_is_found_and_a_resource_key_has_none(): - model = {"operations": {"CreateWebFunction": {"input": {"shape": "Input"}}, - "GetWebFunctionEndpoint": {"input": {"shape": "Get"}}}, "shapes": { - "Input": {"members": {"endpointConfig": {"shape": "Config"}, "functionName": {"shape": "String"}}}, - "Config": {"members": {"authType": {"shape": "AuthType"}}}, - "Get": {"members": {"endpointName": {"shape": "String"}}}, "AuthType": {}, "String": {}}} - assert request_members(model, {"lambda:CreateWebFunction": ["lambda:Request/WebFunctionAuthType"], - "lambda:GetWebFunctionEndpoint": ["lambda:Resource/WebFunctionAuthType"]}) == { - "lambda:CreateWebFunction": {"lambda:Request/WebFunctionAuthType": ["endpointConfig.authType"]}} - - -def test_a_request_key_without_a_member_fails(): - model = {"operations": {"CreateWebFunctionEndpoint": {"input": {"shape": "Input"}}}, - "shapes": {"Input": {"members": {"endpointName": {"shape": "String"}}}, "String": {}}} - with pytest.raises(ValueError, match="no authType member"): - request_members(model, {"lambda:CreateWebFunctionEndpoint": ["lambda:Request/WebFunctionAuthType"]}) - - -def test_the_vendored_table_covers_the_endpoint_routes(): - document = json.loads(OUTPUT.read_text()) - assert validate(document) == [] - assert document["actions"]["lambda:UpdateWebFunctionEndpoint"] == [ - "lambda:Request/WebFunctionAuthType", "lambda:Resource/WebFunctionAuthType"] - assert document["members"]["lambda:CreateWebFunction"] == { - "lambda:Request/WebFunctionAuthType": ["endpointConfig.authType"]} - - -@pytest.mark.parametrize("changed", [ - "src/main/resources/aws/lambda-web-condition-keys.json", - "tools/aws/regen_lambda_web_condition_keys.py", - "tools/aws/test_regen_lambda_web_condition_keys.py", - "tools/aws/regen_dynamodb_condition_keys.py", - "tools/aws/regen_iam_tag_on_create.py", - "tools/aws/regen_iam_passed_roles.py", - "tools/aws/regen_partitions.py", - "tools/aws/regen_query_services.py", - "", -]) -def test_aggregate_gate_checks_the_table_and_its_imports(tmp_path, changed): - result = run_aggregate_gate(tmp_path, changed, fail=True) - assert "checked:lambda-web-condition-keys-verify" in result.stdout - assert result.returncode != 0 - assert "the Lambda Web condition key table" in result.stdout - - -@pytest.mark.parametrize("changed", [ - "docs/services/lambda-web-functions.md", - "src/main/resources/aws/dynamodb-condition-keys.json", - "src/main/resources/aws/lambda-web-condition-keys.json.bak", -]) -def test_aggregate_gate_does_not_check_unrelated_data(tmp_path, changed): - result = run_aggregate_gate(tmp_path, changed, fail=True) - assert "checked:lambda-web-condition-keys-verify" not in result.stdout - assert result.returncode == 0 - - -def test_aggregate_gate_accepts_a_successful_check(tmp_path): - result = run_aggregate_gate(tmp_path, "src/main/resources/aws/lambda-web-condition-keys.json", fail=False) - assert "checked:lambda-web-condition-keys-verify" in result.stdout - assert result.returncode == 0 - - -def run_aggregate_gate(tmp_path, changed, fail): - recursive_make = tmp_path / "check-gate" - recursive_make.write_text( - '#!/bin/sh\nprintf "checked:%s\\n" "$2"\n' - + ('[ "$2" != lambda-web-condition-keys-verify ]\n' if fail else 'exit 0\n')) - recursive_make.chmod(0o700) - return subprocess.run( - ["make", "--no-print-directory", "iam-data-verify", "CHANGED=" + changed, - "MAKE=" + str(recursive_make)], - cwd=OUTPUT.parents[4], capture_output=True, text=True, check=False) diff --git a/tools/aws/test_regen_request_condition_keys.py b/tools/aws/test_regen_request_condition_keys.py new file mode 100644 index 0000000000..20e78eae63 --- /dev/null +++ b/tools/aws/test_regen_request_condition_keys.py @@ -0,0 +1,130 @@ +"""Action coverage and request members for the condition keys read from requests and the resources they act on.""" +import json +import subprocess + +import pytest + +from regen_request_condition_keys import OUTPUT, action_keys, request_members, validate + + +def test_resource_and_action_keys_are_combined(): + reference = {"Name": "lambda", "Resources": [{"Name": "webFunctionEndpoint", + "ConditionKeys": ["lambda:Resource/WebFunctionAuthType"]}], + "Actions": [{"Name": "UpdateWebFunctionEndpoint", + "ActionConditionKeys": ["lambda:Request/WebFunctionAuthType", "aws:TagKeys"], + "Resources": [{"Name": "webFunctionEndpoint"}]}, + {"Name": "GetWebFunction", "ActionConditionKeys": ["aws:ResourceTag/${TagKey}"]}]} + assert action_keys("lambda", reference) == {"lambda:UpdateWebFunctionEndpoint": [ + "lambda:Request/WebFunctionAuthType", "lambda:Resource/WebFunctionAuthType"]} + + +def test_only_the_keys_a_namespace_reads_are_kept(): + reference = {"Name": "redshift", "Resources": [{"Name": "dbuser"}], + "Actions": [{"Name": "GetClusterCredentials", + "ActionConditionKeys": ["redshift:DbName", "redshift:DbUser", + "redshift:DurationSeconds"], + "Resources": [{"Name": "dbuser"}]}, + {"Name": "JoinGroup", "Resources": [{"Name": "dbgroup"}]}]} + assert action_keys("redshift", reference) == {"redshift:GetClusterCredentials": ["redshift:DbUser"]} + + +def test_a_nested_member_is_found_and_a_resource_key_has_none(): + model = {"metadata": {"protocol": "rest-json"}, + "operations": {"CreateWebFunction": {"input": {"shape": "Input"}}, + "GetWebFunctionEndpoint": {"input": {"shape": "Get"}}}, "shapes": { + "Input": {"members": {"endpointConfig": {"shape": "Config"}, "functionName": {"shape": "String"}}}, + "Config": {"members": {"authType": {"shape": "AuthType"}}}, + "Get": {"members": {"endpointName": {"shape": "String"}}}, "AuthType": {}, "String": {}}} + assert request_members("lambda", model, { + "lambda:CreateWebFunction": ["lambda:Request/WebFunctionAuthType"], + "lambda:GetWebFunctionEndpoint": ["lambda:Resource/WebFunctionAuthType"]}) == { + "lambda:CreateWebFunction": {"lambda:Request/WebFunctionAuthType": ["endpointConfig.authType"]}} + + +def test_another_namespaces_actions_are_left_to_it(): + model = {"metadata": {"protocol": "query"}, "operations": {}, "shapes": {}} + assert request_members("redshift", model, { + "lambda:CreateWebFunction": ["lambda:Request/WebFunctionAuthType"]}) == {} + + +def test_an_action_whose_request_does_not_carry_the_key_is_left_out(): + assert request_members("redshift", {"metadata": {"protocol": "query"}, "operations": {}, "shapes": {}}, + {"redshift:CreateClusterUser": ["redshift:DbUser"]}) == {} + + +def test_a_request_key_without_a_member_fails(): + model = {"metadata": {"protocol": "rest-json"}, + "operations": {"CreateWebFunctionEndpoint": {"input": {"shape": "Input"}}}, + "shapes": {"Input": {"members": {"endpointName": {"shape": "String"}}}, "String": {}}} + with pytest.raises(ValueError, match="no authType member"): + request_members("lambda", model, + {"lambda:CreateWebFunctionEndpoint": ["lambda:Request/WebFunctionAuthType"]}) + + +def test_a_nested_member_of_a_query_request_fails(): + model = {"metadata": {"protocol": "query"}, + "operations": {"GetClusterCredentials": {"input": {"shape": "Input"}}}, "shapes": { + "Input": {"members": {"User": {"shape": "User"}}}, + "User": {"members": {"DbUser": {"shape": "String"}}}, "String": {"type": "string"}}} + with pytest.raises(ValueError, match="User.DbUser, which a flat form does not carry"): + request_members("redshift", model, {"redshift:GetClusterCredentials": ["redshift:DbUser"]}) + + +def test_the_vendored_table_covers_both_namespaces(): + document = json.loads(OUTPUT.read_text()) + assert validate(document) == [] + assert document["actions"]["lambda:UpdateWebFunctionEndpoint"] == [ + "lambda:Request/WebFunctionAuthType", "lambda:Resource/WebFunctionAuthType"] + assert document["members"]["lambda:CreateWebFunction"] == { + "lambda:Request/WebFunctionAuthType": ["endpointConfig.authType"]} + assert document["actions"]["redshift:CreateClusterUser"] == ["redshift:DbUser"] + assert "redshift:CreateClusterUser" not in document["members"] + assert document["members"]["redshift:GetClusterCredentials"] == {"redshift:DbUser": ["DbUser"]} + + +@pytest.mark.parametrize("changed", [ + "src/main/resources/aws/request-condition-keys.json", + "tools/aws/regen_request_condition_keys.py", + "tools/aws/test_regen_request_condition_keys.py", + "tools/aws/regen_dynamodb_condition_keys.py", + "tools/aws/regen_iam_tag_on_create.py", + "tools/aws/regen_iam_passed_roles.py", + "tools/aws/regen_partitions.py", + "tools/aws/regen_query_services.py", + "", +]) +def test_aggregate_gate_checks_the_table_and_its_imports(tmp_path, changed): + result = run_aggregate_gate(tmp_path, changed, fail=True) + assert "checked:request-condition-keys-verify" in result.stdout + assert result.returncode != 0 + assert "the request condition key table" in result.stdout + + +@pytest.mark.parametrize("changed", [ + "docs/services/lambda-web-functions.md", + "docs/services/redshift.md", + "src/main/resources/aws/dynamodb-condition-keys.json", + "src/main/resources/aws/request-condition-keys.json.bak", +]) +def test_aggregate_gate_does_not_check_unrelated_data(tmp_path, changed): + result = run_aggregate_gate(tmp_path, changed, fail=True) + assert "checked:request-condition-keys-verify" not in result.stdout + assert result.returncode == 0 + + +def test_aggregate_gate_accepts_a_successful_check(tmp_path): + result = run_aggregate_gate(tmp_path, "src/main/resources/aws/request-condition-keys.json", fail=False) + assert "checked:request-condition-keys-verify" in result.stdout + assert result.returncode == 0 + + +def run_aggregate_gate(tmp_path, changed, fail): + recursive_make = tmp_path / "check-gate" + recursive_make.write_text( + '#!/bin/sh\nprintf "checked:%s\\n" "$2"\n' + + ('[ "$2" != request-condition-keys-verify ]\n' if fail else 'exit 0\n')) + recursive_make.chmod(0o700) + return subprocess.run( + ["make", "--no-print-directory", "iam-data-verify", "CHANGED=" + changed, + "MAKE=" + str(recursive_make)], + cwd=OUTPUT.parents[4], capture_output=True, text=True, check=False)