fix(secretsmanager): check Secrets Manager requests from the generated request resources (#8365)

Secrets Manager was built by hand in ResourceArnBuilder. It now moves out of
HAND_BUILT into NAMESPACES, so every operation's resources come from
iam-request-resources.json, and the hand builder and the enforcement filter's
routing to it are gone.

The six characters Secrets Manager mints after a secret's name come from
botocore, which documents CreateSecret's Name: "Secrets Manager automatically
adds a hyphen and six random characters after the secret name at the end of
the ARN". A new rule records them as mintedSuffixes ("-??????") and has the
create name the secret it makes by Name. The reader appends them open to a
secret Secrets Manager does not hold. An ARN given for a secret, a partial
one included, is checked on the ARN of the secret the operations read it as,
alone: SecretsManagerService resolves it through resolveStoredArn to the
caller's secret in the ARN's Region, else to the one the ARN's account holds
under that full ARN, reading only.

ARNs the table renders, and the resource a create makes that its tags are
checked on, take the request's partition for every namespace, as the
Secrets Manager builder did, so a Region Floci does not know keeps the
partition of the request.
This commit is contained in:
Priamo Germosen authored and GitHub committed 2026-11-14 19:50:46 -04:00
1 parent 4373e83af1
commit 1b14d10b1f
15 files changed
+457 -193

No files matched your search

+14 -8
View File
@@ -1922,7 +1922,7 @@ action is denied. The routed protocol determines the status, not just the reques
A request is checked against the resources it names. Floci builds their ARNs itself for S3, Lambda,
SQS, SNS, DynamoDB, Kinesis, SSM, KMS, IAM, Resource Groups, EventBridge Scheduler, EventBridge
Pipes, Aurora DSQL, EKS, API Gateway, CloudWatch Logs, Secrets Manager and STS. For Elastic Load Balancing, ECR,
Pipes, Aurora DSQL, EKS, API Gateway, CloudWatch Logs and STS. For Secrets Manager, Elastic Load Balancing, ECR,
Step Functions, EventBridge, Amazon Cognito user pools and identity pools, Amazon Data Firehose, Cloud
Map, ACM, CodePipeline, CodeBuild, Amazon Managed Service for Apache Flink (Kinesis Data Analytics v2),
Application Auto Scaling, AWS Budgets, Cost and Usage Reports, Service Quotas, Amazon Textract, Amazon Translate, Amazon Athena,
@@ -2690,13 +2690,19 @@ iam:PassRole permission."
`logs:DescribeIndexPolicies`. Its reference names none for `METRIC_EXTRACTION_POLICY`, which needs only
`logs:DescribeAccountPolicies`.
**Secrets Manager secrets.** A request that names a secret by its name, or by a partial ARN without
the random suffix, is evaluated against the stored secret's full ARN, suffix included, so a
`secret:<name>-??????` resource, the pattern the Secrets Manager User Guide documents, matches it as
it does on AWS, and a `Deny` on the full ARN applies. `CreateSecret` is evaluated against
`secret:<Name>-??????`, standing in for the suffix the secret is assigned when it is created, so a
policy scoped to a name prefix such as `secret:app/*` allows it. A name that matches no secret in the
request's account and region is evaluated as `secret:<name>`, and an ARN that matches none as given.
**Secrets Manager secrets.** Secrets Manager is read from the generated request resources. A request
that names a secret by its name, or by a partial ARN without the random suffix, is evaluated against
the stored secret's full ARN, suffix included, so a `secret:<name>-??????` resource, the pattern the
Secrets Manager User Guide documents, matches it as it does on AWS, and a `Deny` on the full ARN
applies. A secret named by an ARN of another Region, and another account's secret named by its full
ARN, are evaluated against that ARN alone, the secret Secrets Manager then reads. A secret Secrets
Manager does not hold, as `CreateSecret` names the one it makes by `Name`, is evaluated against
`secret:<name>-??????`, the hyphen and six random characters botocore documents the service adding
after the name left open, so a policy scoped to a name prefix such as `secret:app/*` allows it; an
ARN that matches none is evaluated as given and, where it names another Region or account, as the
secret of that name in the request's. An operation acting on no
resource type in the Service Authorization Reference (`ListSecrets`, `GetRandomPassword`,
`BatchGetSecretValue`) is evaluated on `*`.
**KMS keys.** A request that names a key by its id, an alias name, an alias ARN or a key ARN is
evaluated against the stored key's ARN, as the KMS API reference resolves the request's key
@@ -1176,7 +1176,7 @@ public class IamEnforcementFilter implements ContainerRequestFilter {
String region, String accountId, String akid) {
// A create tags the resource it makes, not the parent it makes it in (see RequestResources.created).
List<String> created = RequestResources.created(operation, tagging.action(), ctx,
AwsRegions.partitionFor(region), region, accountId, IamActionRegistry.pathLabels(credentialScope, ctx));
requestPartition(), region, accountId, IamActionRegistry.pathLabels(credentialScope, ctx));
List<String> made = created.isEmpty() ? resources : created;
for (TagOnCreate.TagSet set : tagging.checked()) {
Map<String, List<String>> context = TagOnCreate.conditionContext(tagging, set, operation);
@@ -1847,9 +1847,6 @@ public class IamEnforcementFilter implements ContainerRequestFilter {
if ("logs".equals(credentialScope)) {
return arnBuilder.buildLogResources(action, ctx, region, accountId, requestPartition());
}
if ("secretsmanager".equals(credentialScope)) {
return arnBuilder.buildSecretsManagerResources(action, ctx, region, accountId, requestPartition());
}
if ("kms".equals(credentialScope)) {
return arnBuilder.buildKmsResources(action, ctx, region, accountId, requestPartition());
}
@@ -1860,8 +1857,8 @@ public class IamEnforcementFilter implements ContainerRequestFilter {
|| "apigateway".equals(credentialScope)) {
return arnBuilder.buildResources(credentialScope, ctx, region, accountId, requestPartition());
}
String partition = "route53".equals(credentialScope) ? requestPartition() : AwsRegions.partitionFor(region);
return arnBuilder.buildResources(credentialScope, operation, ctx, region, accountId, partition);
// ARNs the table renders take the request's partition, which a Region Floci does not know cannot be mapped to.
return arnBuilder.buildResources(credentialScope, operation, ctx, region, accountId, requestPartition());
}
/**
@@ -48,6 +48,8 @@ final class RequestResourceMembers {
"^arn:\\$\\{Partition}:[^:]*:[^:]*:[^:]*:([A-Za-z][A-Za-z0-9-]*)(.*)$");
/** A format's resource that is a literal and one variable. */
private static final Pattern ONE_VARIABLE = Pattern.compile("[^$]*\\$\\{\\w+}");
/** A separator and the characters a service mints after a name, each {@code ?}: {@code -??????}. */
private static final Pattern MINTED_SUFFIX = Pattern.compile("[-_.]\\?+");
/** A member a REST request carries outside its body, by its name, and where: a path label or a query parameter. */
private static final Pattern LOCATED_MEMBER = Pattern.compile("[A-Za-z][A-Za-z0-9_]*");
private static final Pattern LOCATION = Pattern.compile("\\{[A-Za-z0-9_]+}|\\?[A-Za-z0-9_.-]+");
@@ -96,12 +98,15 @@ final class RequestResourceMembers {
* checks an ARN of it given with a qualifier, one more {@code :<name>} past the format, without that qualifier
* (Step Functions checks a version or an alias on its state machine's ARN); {@code minted} when its service
* follows the one variable the format ends in with an id it mints, {@code /<id>}, which the format leaves out
* (EventBridge's {@code connection/<name>/<id>}).
* (EventBridge's {@code connection/<name>/<id>}); {@code mintedSuffix} the characters its service follows the
* name that variable takes with, as IAM matches them, one {@code ?} each after the separator (a Secrets Manager
* secret's {@code -??????}), or null.
*/
record ArnFormat(String format, Pattern pattern, boolean unqualified, boolean minted, Pattern integers) {
record ArnFormat(String format, Pattern pattern, boolean unqualified, boolean minted, Pattern integers,
String mintedSuffix) {
ArnFormat(String format, Pattern pattern, boolean unqualified, boolean minted) {
this(format, pattern, unqualified, minted, null);
this(format, pattern, unqualified, minted, null, null);
}
ArnFormat(String format, Pattern pattern, boolean unqualified) {
@@ -327,6 +332,7 @@ final class RequestResourceMembers {
document.path("arnFormats").properties().forEach(namespace -> {
Set<String> unqualified = names(document.path("unqualified").path(namespace.getKey()));
Set<String> minted = names(document.path("mintedIds").path(namespace.getKey()));
JsonNode suffixes = document.path("mintedSuffixes").path(namespace.getKey());
Map<String, ArnFormat> types = new LinkedHashMap<>();
namespace.getValue().properties().forEach(type -> {
String format = type.getValue().asText("");
@@ -336,7 +342,8 @@ final class RequestResourceMembers {
}
Set<String> integers = names(document.path("integerVariables").path(namespace.getKey()).path(type.getKey()));
types.put(type.getKey(), new ArnFormat(format, pattern(format), unqualified.contains(type.getKey()),
minted.contains(type.getKey()), integers.isEmpty() ? null : pattern(format, integers)));
minted.contains(type.getKey()), integers.isEmpty() ? null : pattern(format, integers),
suffixes.path(type.getKey()).asText(null)));
});
formats.put(namespace.getKey(), Map.copyOf(types));
});
@@ -355,6 +362,18 @@ final class RequestResourceMembers {
+ namespace.getValue() + " a minted id, no types whose format ends in its one variable");
}
});
document.path("mintedSuffixes").properties().forEach(namespace -> {
Map<String, ArnFormat> types = formats.getOrDefault(namespace.getKey(), Map.of());
namespace.getValue().properties().forEach(type -> {
if (!types.containsKey(type.getKey())
|| !ONE_VARIABLE.matcher(types.get(type.getKey()).format().split(":", 6)[5]).matches()
|| !type.getValue().isTextual() || !MINTED_SUFFIX.matcher(type.getValue().asText()).matches()) {
throw new IllegalStateException(RESOURCE_NAME + " gives " + namespace.getKey() + "'s "
+ type.getKey() + " the minted suffix " + type.getValue()
+ ", no type whose format ends in its one variable or no separator and characters");
}
});
});
Map<String, Map<String, List<String>>> resourceTagKeys = new LinkedHashMap<>();
if (!document.path("resourceTagKeys").isMissingNode() && !document.path("resourceTagKeys").isObject()) {
throw new IllegalStateException(RESOURCE_NAME + " has malformed resource tag keys");
@@ -824,7 +824,8 @@ public final class RequestResources {
* <p>The service is asked for every type of the namespace, not only for the ones whose ARN carries an id it
* mints, so a service may answer for a type whose ARN it does not mint: a key an alias names is the key the
* alias points at. A type whose service follows its name with an id it mints has that id open when the service
* stores none, and any other type's is as rendered.
* stores none, one whose service follows it with characters it mints those characters open (a secret's
* {@code -??????}, as a create names the secret it makes), and any other type's is as rendered.
*/
private static String withId(String arn, RequestResourceMembers.ArnFormat format, String type,
Map<String, String> filling, StoredResourceArns stored, String region) {
@@ -834,7 +835,10 @@ public final class RequestResources {
return found.get();
}
}
return format.minted() ? arn + "/*" : arn;
if (format.minted()) {
return arn + "/*";
}
return format.mintedSuffix() != null ? arn + format.mintedSuffix() : arn;
}
/**
@@ -884,7 +888,8 @@ public final class RequestResources {
* and one of a type AWS owns ({@code awsOwned}) its account, {@code aws}, which is no caller's. One naming another
* account whose resource {@code stored} says the service acts on there (an OAM sink a link is made to, a RAM
* invitation sent to the caller) is that resource alone. When the service resolves the complete ARN to a stored
* resource in its own coordinates, that stored ARN alone is checked.
* resource, that stored ARN alone is checked: a layer version in its own coordinates, or the secret a full or
* partial ARN names in the ARN's Region, as its handler reads it.
*/
private static void addNamed(Set<String> arns, String arn, boolean awsOwned, String partition, String region,
String accountId, StoredResourceArns stored) {
@@ -23,7 +23,8 @@ import java.util.Optional;
* Redshift Serverless workgroups it runs statements on and the targets of its sessions; Payment Cryptography, for
* the key an alias names; EMR, for the clusters of its instance groups; IAM Identity Center, for the accounts its
* permission sets are provisioned to; Resource Explorer, for its default view; OAM and RAM, for the sinks,
* invitations and shares of other accounts they act on); looked up lazily by {@code ResourceArnBuilder} through {@code Instance<StoredResourceArns>}
* invitations and shares of other accounts they act on; Secrets Manager, for the secret a name or an ARN names,
* random suffix included); looked up lazily by {@code ResourceArnBuilder} through {@code Instance<StoredResourceArns>}
* for the namespace a request is of, so IAM never depends on that service directly.</p>
*
* <p>Each answer is a lookup of what the service holds, asked for by an entry of the generated table ({@code find},
@@ -45,7 +46,9 @@ public interface StoredResourceArns {
/**
* The resource resolved by an ARN in its own account and Region, without substituting the caller's
* coordinates. Empty when the service has no such resource or does not resolve ARN selectors this way.
* coordinates (a layer version), or as the service's handler reads the ARN where it reads it first as the
* caller's (a secret a full or partial ARN names, in the ARN's Region, before one another account holds under
* that full ARN). Empty when the service has no such resource or does not resolve ARN selectors this way.
* Used only for operations read by the generated request-resource table.
*/
default Optional<String> resolveStoredArn(String arn) {
@@ -24,7 +24,6 @@ import io.floci.aws.services.lambdamicrovms.LambdaMicrovmsService;
import io.floci.aws.services.s3.S3ControlArnUtils;
import io.floci.aws.services.s3.S3ObjectKeys;
import io.floci.aws.services.s3.S3ResourceArns;
import io.floci.aws.services.secretsmanager.SecretsManagerService;
import io.floci.aws.services.sqs.SqsService;
import io.quarkus.vertx.http.runtime.CurrentVertxRequest;
import io.vertx.ext.web.RoutingContext;
@@ -71,12 +70,6 @@ public class ResourceArnBuilder {
/** What a service-linked role deletion task identifier starts with; see its resolver. */
private static final String DELETION_TASK_PREFIX = "task" + ServiceLinkedRoles.PATH;
/**
* Stands in for the random suffix of a secret that {@code CreateSecret} has not made yet. Each
* {@code ?} matches the one character a {@code secret:<name>-??????} policy expects there.
*/
private static final String UNASSIGNED_SECRET_SUFFIX = "-??????";
/** Where an S3 Control tagging route carries the ARN of the resource it acts on. */
private static final String S3_CONTROL_TAGS_PREFIX = "/v20180820/tags/";
@@ -95,8 +88,6 @@ public class ResourceArnBuilder {
* which IamService itself does not depend on, and a direct injection would close that loop.
*/
private final Instance<IamService> iamService;
/** Looked up lazily for the same reason, to resolve a secret named by its name or a partial ARN. */
private final Instance<SecretsManagerService> secretsManagerService;
/** Looked up lazily for the same reason, to read the image a MicroVM runs. */
private final Instance<LambdaMicrovmsService> microvmsService;
/** Looked up lazily for the same reason, to read the ARN an EKS cluster or what it holds is stored under. */
@@ -117,7 +108,6 @@ public class ResourceArnBuilder {
@Inject
public ResourceArnBuilder(ObjectMapper objectMapper, Instance<IamService> iamService,
Instance<SecretsManagerService> secretsManagerService,
Instance<LambdaMicrovmsService> microvmsService,
Instance<EksService> eksService,
Instance<KmsService> kmsService,
@@ -125,7 +115,6 @@ public class ResourceArnBuilder {
CurrentVertxRequest currentVertxRequest) {
this.objectMapper = objectMapper;
this.iamService = iamService;
this.secretsManagerService = secretsManagerService;
this.microvmsService = microvmsService;
this.eksService = eksService;
this.kmsService = kmsService;
@@ -134,39 +123,30 @@ public class ResourceArnBuilder {
}
public ResourceArnBuilder(ObjectMapper objectMapper, Instance<IamService> iamService,
Instance<SecretsManagerService> secretsManagerService,
Instance<LambdaMicrovmsService> microvmsService,
Instance<EksService> eksService,
Instance<KmsService> kmsService,
Instance<StoredResourceArns> storedResourceArns) {
this(objectMapper, iamService, secretsManagerService, microvmsService, eksService, kmsService,
this(objectMapper, iamService, microvmsService, eksService, kmsService,
storedResourceArns, null);
}
public ResourceArnBuilder(ObjectMapper objectMapper, Instance<IamService> iamService,
Instance<SecretsManagerService> secretsManagerService,
Instance<LambdaMicrovmsService> microvmsService,
Instance<EksService> eksService,
Instance<KmsService> kmsService) {
this(objectMapper, iamService, secretsManagerService, microvmsService, eksService, kmsService, null);
this(objectMapper, iamService, microvmsService, eksService, kmsService, null);
}
public ResourceArnBuilder(ObjectMapper objectMapper, Instance<IamService> iamService,
Instance<SecretsManagerService> secretsManagerService,
Instance<LambdaMicrovmsService> microvmsService,
Instance<EksService> eksService) {
this(objectMapper, iamService, secretsManagerService, microvmsService, eksService, null);
this(objectMapper, iamService, microvmsService, eksService, null);
}
public ResourceArnBuilder(ObjectMapper objectMapper, Instance<IamService> iamService,
Instance<SecretsManagerService> secretsManagerService,
Instance<LambdaMicrovmsService> microvmsService) {
this(objectMapper, iamService, secretsManagerService, microvmsService, null);
}
public ResourceArnBuilder(ObjectMapper objectMapper, Instance<IamService> iamService,
Instance<SecretsManagerService> secretsManagerService) {
this(objectMapper, iamService, secretsManagerService, null);
this(objectMapper, iamService, microvmsService, null);
}
ResourceArnBuilder(ObjectMapper objectMapper, Instance<IamService> iamService) {
@@ -182,7 +162,7 @@ public class ResourceArnBuilder {
}
ResourceArnBuilder(ObjectMapper objectMapper, CurrentVertxRequest currentVertxRequest) {
this(objectMapper, null, null, null, null, null, null, currentVertxRequest);
this(objectMapper, null, null, null, null, null, currentVertxRequest);
}
public String build(String credentialScope, ContainerRequestContext ctx,
@@ -1844,60 +1824,6 @@ public class ResourceArnBuilder {
return AwsArnUtils.Arn.of("kinesis", region, accountId, "stream/*").toString();
}
// ── Secrets Manager ──────────────────────────────────────────────────────────
/**
* Uses the serving operation, as {@link #buildLogResources} does: {@code CreateSecret}
* names the secret in {@code Name} and every other operation in {@code SecretId}, so a field the
* handler does not read cannot choose the resource. A minted ARN takes the request's partition,
* the one the secret is created in, which a region Floci does not know cannot be mapped to.
*/
public List<String> buildSecretsManagerResources(String action, ContainerRequestContext ctx,
String region, String accountId, String partition) {
return List.of(buildSecretsManagerArn(action, ctx, region, accountId, partition));
}
/**
* A secret named by its name or a partial ARN is authorized against its full ARN, random suffix
* included, so a {@code secret:<name>-??????} policy matches it as it does on AWS. The suffix of
* the secret {@code CreateSecret} is making is not assigned until it is created.
*/
private String buildSecretsManagerArn(String action, ContainerRequestContext ctx, String region,
String accountId, String partition) {
JsonNode json = readJsonBody(ctx);
if (json != null && json.isObject()) {
if ("secretsmanager:CreateSecret".equals(action)) {
if (json.hasNonNull("Name")) {
String name = json.get("Name").asText().trim();
if (!name.isEmpty()) {
return secretArn(name + UNASSIGNED_SECRET_SUFFIX, region, accountId, partition);
}
}
} else if (json.hasNonNull("SecretId")) {
String secretId = json.get("SecretId").asText().trim();
if (!secretId.isEmpty()) {
Optional<String> stored = storedSecretArn(secretId, region, accountId);
if (AwsArnUtils.isArnFor(secretId, "secretsmanager")) {
return stored.orElse(secretId);
}
return stored.orElseGet(() -> secretArn(secretId, region, accountId, partition));
}
}
}
return secretArn("*", region, accountId, partition);
}
private Optional<String> storedSecretArn(String secretId, String region, String accountId) {
if (secretsManagerService == null) {
return Optional.empty();
}
return secretsManagerService.get().findArn(accountId, secretId, region);
}
private static String secretArn(String name, String region, String accountId, String partition) {
return new AwsArnUtils.Arn(partition, "secretsmanager", region, accountId, "secret:" + name).toString();
}
// ── KMS ──────────────────────────────────────────────────────────────────────
/**
@@ -8,6 +8,7 @@ import io.floci.aws.core.common.AwsArnUtils;
import io.floci.aws.core.common.AwsException;
import io.floci.aws.core.common.RegionResolver;
import io.floci.aws.core.common.ServicePrincipals;
import io.floci.aws.core.common.StoredResourceArns;
import io.floci.aws.core.resource.ExplorerResource;
import io.floci.aws.core.resource.ResourceProvider;
import io.floci.aws.core.resource.SupportedResourceType;
@@ -54,7 +55,7 @@ import java.util.function.Supplier;
import java.util.regex.Pattern;
@ApplicationScoped
public class SecretsManagerService implements ResourceProvider {
public class SecretsManagerService implements ResourceProvider, StoredResourceArns {
private static final Logger LOG = Logger.getLogger(SecretsManagerService.class);
@@ -494,6 +495,36 @@ public class SecretsManagerService implements ResourceProvider {
return secret;
}
@Override
public String namespace() {
return "secretsmanager";
}
/**
* What IAM asks Secrets Manager of a request's resources: the ARN, random suffix included, of the caller's secret
* a name or an ARN names, a partial one included ({@link #findArn}). Reads only.
*/
@Override
public Optional<String> find(String type, List<String> names, String region) {
return "Secret".equals(type) && names.size() == 1
? findArn(regionResolver.getAccountId(), names.getFirst(), region) : Optional.empty();
}
/**
* The secret an ARN names, a partial one included, as the operations read it ({@link #resolveSecret}): the
* caller's, in the Region the ARN names ({@link #findArn}), else the one the account the ARN names holds under
* that full ARN. Reads only.
*/
@Override
public Optional<String> resolveStoredArn(String arn) {
AwsArnUtils.Arn parsed = parseOrNull(arn);
if (parsed == null || secretNameOrNull(parsed) == null) {
return Optional.empty();
}
return findArn(regionResolver.getAccountId(), arn, parsed.region())
.or(() -> Optional.ofNullable(findByArnInAccount(arn, parsed)).map(Secret::getArn));
}
/**
* The full ARN of the secret {@code secretId} names in the given account, or empty when there is
* none, resolved in the order the operations resolve it: a name in {@code region}, or an ARN,
@@ -1,14 +1,15 @@
{
"_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-14", "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"], "account": ["account"], "acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudfront": ["cloudfront"], "cloudfront-keyvaluestore": ["cloudfront-keyvaluestore"], "cloudtrail": ["cloudtrail"], "codebuild": ["codebuild"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "controlcatalog": ["controlcatalog"], "controltower": ["controltower"], "cur": ["cur"], "datasync": ["datasync"], "dynamodb": ["dynamodb"], "ec2": ["ec2"], "ecr": ["ecr"], "ecs": ["ecs"], "elasticloadbalancing": ["elb", "elbv2"], "elasticmapreduce": ["emr"], "emr-serverless": ["emr-serverless"], "es": ["es", "opensearch"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "fis": ["fis"], "globalaccelerator": ["globalaccelerator"], "guardduty": ["guardduty"], "inspector2": ["inspector2"], "kinesisanalytics": ["kinesisanalytics", "kinesisanalyticsv2"], "lambda": ["lambda"], "logs": ["logs"], "macie2": ["macie2"], "oam": ["oam"], "payment-cryptography": ["payment-cryptography", "payment-cryptography-data"], "quicksight": ["quicksight"], "ram": ["ram"], "redshift": ["redshift"], "redshift-data": ["redshift-data"], "redshift-serverless": ["redshift-serverless"], "rekognition": ["rekognition"], "resource-explorer-2": ["resource-explorer-2"], "route53": ["route53"], "securityhub": ["securityhub"], "servicediscovery": ["servicediscovery"], "servicequotas": ["service-quotas"], "signer": ["signer", "signer-data"], "ssm": ["ssm"], "sso": ["sso", "sso-admin"], "states": ["stepfunctions"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "translate": ["translate"], "xray": ["xray"]},
"handBuilt": ["apigateway", "bedrock", "dsql", "dynamodb", "eks", "iam", "kinesis", "kms", "lambda", "logs", "pipes", "resource-groups", "s3", "scheduler", "secretsmanager", "sns", "sqs", "sts"],
"namespaces": {"access-analyzer": ["accessanalyzer"], "account": ["account"], "acm": ["acm"], "application-autoscaling": ["application-autoscaling"], "athena": ["athena"], "bcm-data-exports": ["bcm-data-exports"], "bcm-pricing-calculator": ["bcm-pricing-calculator"], "budgets": ["budgets"], "ce": ["ce"], "cloudfront": ["cloudfront"], "cloudfront-keyvaluestore": ["cloudfront-keyvaluestore"], "cloudtrail": ["cloudtrail"], "codebuild": ["codebuild"], "codepipeline": ["codepipeline"], "cognito-identity": ["cognito-identity"], "cognito-idp": ["cognito-idp"], "controlcatalog": ["controlcatalog"], "controltower": ["controltower"], "cur": ["cur"], "datasync": ["datasync"], "dynamodb": ["dynamodb"], "ec2": ["ec2"], "ecr": ["ecr"], "ecs": ["ecs"], "elasticloadbalancing": ["elb", "elbv2"], "elasticmapreduce": ["emr"], "emr-serverless": ["emr-serverless"], "es": ["es", "opensearch"], "events": ["eventbridgev2", "events"], "firehose": ["firehose"], "fis": ["fis"], "globalaccelerator": ["globalaccelerator"], "guardduty": ["guardduty"], "inspector2": ["inspector2"], "kinesisanalytics": ["kinesisanalytics", "kinesisanalyticsv2"], "lambda": ["lambda"], "logs": ["logs"], "macie2": ["macie2"], "oam": ["oam"], "payment-cryptography": ["payment-cryptography", "payment-cryptography-data"], "quicksight": ["quicksight"], "ram": ["ram"], "redshift": ["redshift"], "redshift-data": ["redshift-data"], "redshift-serverless": ["redshift-serverless"], "rekognition": ["rekognition"], "resource-explorer-2": ["resource-explorer-2"], "route53": ["route53"], "secretsmanager": ["secretsmanager"], "securityhub": ["securityhub"], "servicediscovery": ["servicediscovery"], "servicequotas": ["service-quotas"], "signer": ["signer", "signer-data"], "ssm": ["ssm"], "sso": ["sso", "sso-admin"], "states": ["stepfunctions"], "textract": ["textract"], "timestream-influxdb": ["timestream-influxdb"], "translate": ["translate"], "xray": ["xray"]},
"handBuilt": ["apigateway", "bedrock", "dsql", "dynamodb", "eks", "iam", "kinesis", "kms", "lambda", "logs", "pipes", "resource-groups", "s3", "scheduler", "sns", "sqs", "sts"],
"notCovered": {"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:<id>:autoScalingGroupName/<name>`, while Floci mints `autoScalingGroup:<name>`, 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", "cloudhsm": "not read yet: its ARN formats end in ${CloudHsmClusterInstanceName} and ${CloudHsmBackupInstanceName}, names, while its requests give ClusterId and BackupId, ids, which the rules do not fill a name from, so nearly every operation's resource would be left open", "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/<name>_<id>, 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", "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-instance-connect": "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/<application>/<name>`, 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 namLine truncated
"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", "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", "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", "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", "simspaceweaver", "sms-voice", "snow-device-management", "social-messaging", "sqlworkbench", "ssm-contacts", "ssm-incidents", "ssm-quicksetup", "ssm-sap", "ssmmessages", "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"],
"arnFormats": {"access-analyzer": {"Analyzer": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}", "ArchiveRule": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}/archive-rule/${RuleName}"}, "account": {"account": "arn:${Partition}:account::${Account}:account", "accountInOrganization": "arn:${Partition}:account::${ManagementAccountId}:account/o-${OrganizationId}/${MemberAccountId}"}, "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}", "system-table": "arn:${Partition}:athena:${Region}:${Account}:system-table/${TableName}", "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}"}, "cloudfront": {"anycast-ip-list": "arn:${Partition}:cloudfront::${Account}:anycast-ip-list/${Id}", "cache-policy": "arn:${Partition}:cloudfront::${Account}:cache-policy/${Id}", "connection-function": "arn:${Partition}:cloudfront::${Account}:connection-function/${Id}", "connection-group": "arn:${Partition}:cloudfront::${Account}:connection-group/${Id}", "continuous-deployment-policy": "arn:${Partition}:cloudfront::${Account}:continuous-deployment-policy/${Id}", "distribution": "arn:${Partition}:cloudfront::${Account}:distribution/${DistributionId}", "distribution-tenant": "arn:${Partition}:cloudfront::${Account}:distribution-tenant/${Id}", "field-level-encryption-config": "arn:${Partition}:cloudfront::${Account}:field-level-encryption-config/${Id}", "field-level-encryption-profile": "arn:${Partition}:cloudfront::${Account}:field-level-encryption-profile/${Id}", "function": "arn:${Partition}:cloudfront::${Account}:function/${Name}", "key-value-store": "arn:${Partition}:cloudfront::${Account}:key-value-store/${Name}", "origin-access-control": "arn:${Partition}:cloudfront::${Account}:origin-access-control/${Id}", "origin-access-identity": "arn:${Partition}:cloudfront::${Account}:origin-access-identity/${Id}", "origin-request-policy": "arn:${Partition}:cloudfront::${Account}:origin-request-policy/${Id}", "realtime-log-config": "arn:${Partition}:cloudfront::${Account}:realtime-log-config/${Name}", "response-headers-policy": "arn:${Partition}:cloudfront::${Account}:response-headers-policy/${Id}", "streaming-distribution": "arn:${Partition}:cloudfront::${Account}:streaming-distribution/${DistributionId}", "trust-store": "arn:${Partition}:cloudfront::${Account}:trust-store/${Id}", "vpcorigin": "arn:${Partition}:cloudfront::${Account}:vpcorigin/${Id}"}, "cloudfront-keyvaluestore": {"key-value-store": "arn:${Partition}:cloudfront::${Account}:key-value-store/${ResourceId}"}, "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:${Line truncated
"arnFormats": {"access-analyzer": {"Analyzer": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}", "ArchiveRule": "arn:${Partition}:access-analyzer:${Region}:${Account}:analyzer/${AnalyzerName}/archive-rule/${RuleName}"}, "account": {"account": "arn:${Partition}:account::${Account}:account", "accountInOrganization": "arn:${Partition}:account::${ManagementAccountId}:account/o-${OrganizationId}/${MemberAccountId}"}, "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}", "system-table": "arn:${Partition}:athena:${Region}:${Account}:system-table/${TableName}", "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}"}, "cloudfront": {"anycast-ip-list": "arn:${Partition}:cloudfront::${Account}:anycast-ip-list/${Id}", "cache-policy": "arn:${Partition}:cloudfront::${Account}:cache-policy/${Id}", "connection-function": "arn:${Partition}:cloudfront::${Account}:connection-function/${Id}", "connection-group": "arn:${Partition}:cloudfront::${Account}:connection-group/${Id}", "continuous-deployment-policy": "arn:${Partition}:cloudfront::${Account}:continuous-deployment-policy/${Id}", "distribution": "arn:${Partition}:cloudfront::${Account}:distribution/${DistributionId}", "distribution-tenant": "arn:${Partition}:cloudfront::${Account}:distribution-tenant/${Id}", "field-level-encryption-config": "arn:${Partition}:cloudfront::${Account}:field-level-encryption-config/${Id}", "field-level-encryption-profile": "arn:${Partition}:cloudfront::${Account}:field-level-encryption-profile/${Id}", "function": "arn:${Partition}:cloudfront::${Account}:function/${Name}", "key-value-store": "arn:${Partition}:cloudfront::${Account}:key-value-store/${Name}", "origin-access-control": "arn:${Partition}:cloudfront::${Account}:origin-access-control/${Id}", "origin-access-identity": "arn:${Partition}:cloudfront::${Account}:origin-access-identity/${Id}", "origin-request-policy": "arn:${Partition}:cloudfront::${Account}:origin-request-policy/${Id}", "realtime-log-config": "arn:${Partition}:cloudfront::${Account}:realtime-log-config/${Name}", "response-headers-policy": "arn:${Partition}:cloudfront::${Account}:response-headers-policy/${Id}", "streaming-distribution": "arn:${Partition}:cloudfront::${Account}:streaming-distribution/${DistributionId}", "trust-store": "arn:${Partition}:cloudfront::${Account}:trust-store/${Id}", "vpcorigin": "arn:${Partition}:cloudfront::${Account}:vpcorigin/${Id}"}, "cloudfront-keyvaluestore": {"key-value-store": "arn:${Partition}:cloudfront::${Account}:key-value-store/${ResourceId}"}, "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:${Line truncated
"resourceTagKeys": {"ec2": {"application-status-check": ["aws:ResourceTag/", "ec2:ResourceTag/"], "capacity-block": ["aws:ResourceTag/", "ec2:ResourceTag/"], "capacity-manager-data-export": ["aws:ResourceTag/", "ec2:ResourceTag/"], "capacity-reservation": ["aws:ResourceTag/", "ec2:ResourceTag/"], "capacity-reservation-cancellation-quote": ["aws:ResourceTag/", "ec2:ResourceTag/"], "capacity-reservation-fleet": ["aws:ResourceTag/", "ec2:ResourceTag/"], "capacity-reservation-modification-quote": ["aws:ResourceTag/", "ec2:ResourceTag/"], "carrier-gateway": ["aws:ResourceTag/", "ec2:ResourceTag/"], "client-vpn-endpoint": ["aws:ResourceTag/", "ec2:ResourceTag/"], "coip-pool": ["aws:ResourceTag/", "ec2:ResourceTag/"], "customer-gateway": ["aws:ResourceTag/", "ec2:ResourceTag/"], "declarative-policies-report": ["aws:ResourceTag/", "ec2:ResourceTag/"], "dedicated-host": ["aws:ResourceTag/", "ec2:ResourceTag/"], "dhcp-options": ["aws:ResourceTag/", "ec2:ResourceTag/"], "egress-only-internet-gateway": ["aws:ResourceTag/", "ec2:ResourceTag/"], "elastic-gpu": ["aws:ResourceTag/", "ec2:ResourceTag/"], "elastic-ip": ["aws:ResourceTag/", "ec2:ResourceTag/"], "export-image-task": ["aws:ResourceTag/", "ec2:ResourceTag/"], "export-instance-task": ["aws:ResourceTag/", "ec2:ResourceTag/"], "fleet": ["aws:ResourceTag/", "ec2:ResourceTag/"], "fpga-image": ["aws:ResourceTag/", "ec2:ResourceTag/"], "host-reservation": ["aws:ResourceTag/", "ec2:ResourceTag/"], "image": ["aws:ResourceTag/", "ec2:ResourceTag/"], "image-usage-report": ["aws:ResourceTag/", "ec2:ResourceTag/"], "import-image-task": ["aws:ResourceTag/", "ec2:ResourceTag/"], "import-snapshot-task": ["aws:ResourceTag/", "ec2:ResourceTag/"], "instance": ["aws:ResourceTag/", "ec2:ResourceTag/"], "instance-connect-endpoint": ["aws:ResourceTag/", "ec2:ResourceTag/"], "instance-event-window": ["aws:ResourceTag/", "ec2:ResourceTag/"], "internet-gateway": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipam": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipam-external-resource-verification-token": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipam-internet-registry-association": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipam-policy": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipam-pool": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipam-pool-allocation": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipam-prefix-list-resolver": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipam-prefix-list-resolver-target": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipam-resource-discovery": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipam-resource-discovery-association": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipam-scope": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipv4pool-ec2": ["aws:ResourceTag/", "ec2:ResourceTag/"], "ipv6pool-ec2": ["aws:ResourceTag/", "ec2:ResourceTag/"], "key-pair": ["aws:ResourceTag/", "ec2:ResourceTag/"], "launch-template": ["aws:ResourceTag/", "ec2:ResourceTag/"], "local-gateway": ["aws:ResourceTag/", "ec2:ResourceTag/"], "local-gateway-route-table": ["aws:ResourceTag/", "ec2:ResourceTag/"], "local-gateway-route-table-virtual-interface-group-association": ["aws:ResourceTag/", "ec2:ResourceTag/"], "local-gateway-route-table-vpc-association": ["aws:ResourceTag/", "ec2:ResourceTag/"], "local-gateway-virtual-interface": ["aws:ResourceTag/", "ec2:ResourceTag/"], "local-gateway-virtual-interface-group": ["aws:ResourceTag/", "ec2:ResourceTag/"], "mac-modification-task": ["aws:ResourceTag/", "ec2:ResourceTag/"], "natgateway": ["aws:ResourceTag/", "ec2:ResourceTag/"], "network-acl": ["aws:ResourceTag/", "ec2:ResourceTag/"], "network-insights-access-scope": ["aws:ResourceTag/", "ec2:ResourceTag/"], "network-insights-access-scope-analysis": ["aws:ResourceTag/", "ec2:ResourceTag/"], "network-insights-analysis": ["aws:ResourceTag/", "ec2:ResourceTag/"], "network-insights-path": ["aws:ResourceTag/", "ec2:ResourceTag/"], "network-interface": ["aws:ResourceTag/", "ec2:ResourceTag/"], "outpost-lag": ["aws:ResourceTag/", "ec2:ResourceTag/"], "placement-group": ["aws:ResourceTag/", "ec2:ResourceTag/"], "prefix-list": ["aws:ResourceTag/", "ec2:ResourceTag/"], "replace-root-volume-task": ["aws:ResourceTag/", "ec2:ResourceTag/"], "reserved-instances": ["aws:ResourceTag/", "ec2:ResourceTag/"], "route-server": ["aws:ResourceTag/", "ec2:ResourceTag/"], "route-server-endpoint": ["aws:ResourceTag/", "ec2:ResourceTag/"], "route-server-peer": ["aws:ResourceTag/", "ec2:ResourceTag/"], "route-table": ["aws:ResourceTag/", "ec2:ResourceTag/"], "secondary-interface": ["aws:ResourceTag/", "ec2:ResourceTag/"], "secondary-network": ["aws:ResourceTag/", "ec2:ResourceTag/"], "secondary-subnet": ["aws:ResourceTag/", "ec2:ResourceTag/"], "security-group": ["aws:ResourceTag/", "ec2:ResourceTag/"], "security-group-rule": ["aws:ResourceTag/", "ec2:ResourceTag/"], "snapshot": ["aws:ResourceTag/", "ec2:ResourceTag/"], "spot-fleet-request": ["aws:ResourceTag/", "ec2:ResourceTag/"], "spot-instances-request": ["aws:ResourceTag/", "Line truncated
"resourceKeys": {"ec2": {"capacity-reservation": {"ec2:AvailabilityZone": {"member": "AvailabilityZone"}, "ec2:AvailabilityZoneId": {"member": "AvailabilityZoneId"}, "ec2:CapacityReservationFleet": {"member": "CapacityReservationFleetId", "arn": "capacity-reservation-fleet"}, "ec2:EbsOptimized": {"member": "EbsOptimized"}, "ec2:EndDateType": {"member": "EndDateType"}, "ec2:EphemeralStorage": {"member": "EphemeralStorage"}, "ec2:InstanceMatchCriteria": {"member": "InstanceMatchCriteria"}, "ec2:InstanceType": {"member": "InstanceType"}, "ec2:Tenancy": {"member": "Tenancy"}}, "carrier-gateway": {"ec2:Vpc": {"member": "VpcId", "arn": "vpc"}}, "dhcp-options": {"ec2:DhcpOptionsID": {"member": "DhcpOptionsId"}}, "fpga-image": {"ec2:Owner": {"member": "OwnerId"}, "ec2:Public": {"member": "Public"}}, "image": {"ec2:ImageID": {"member": "ImageId"}, "ec2:ImageType": {"member": "ImageType"}, "ec2:Owner": {"member": "OwnerId"}, "ec2:Public": {"member": "Public"}, "ec2:RootDeviceType": {"member": "RootDeviceType"}}, "instance": {"ec2:EbsOptimized": {"member": "EbsOptimized"}, "ec2:InstanceID": {"member": "InstanceId"}, "ec2:InstanceType": {"member": "InstanceType"}, "ec2:RootDeviceType": {"member": "RootDeviceType"}}, "internet-gateway": {"ec2:InternetGatewayID": {"member": "InternetGatewayId"}}, "launch-template": {"ec2:LaunchTemplate": {"member": "LaunchTemplateId", "arn": "launch-template"}}, "network-acl": {"ec2:NetworkAclID": {"member": "NetworkAclId"}, "ec2:Vpc": {"member": "VpcId", "arn": "vpc"}}, "network-interface": {"ec2:AvailabilityZone": {"member": "AvailabilityZone"}, "ec2:NetworkInterfaceID": {"member": "NetworkInterfaceId"}, "ec2:Subnet": {"member": "SubnetId", "arn": "subnet"}, "ec2:Vpc": {"member": "VpcId", "arn": "vpc"}}, "reserved-instances": {"ec2:AvailabilityZone": {"member": "AvailabilityZone"}, "ec2:InstanceType": {"member": "InstanceType"}}, "route-table": {"ec2:RouteTableID": {"member": "RouteTableId"}, "ec2:Vpc": {"member": "VpcId", "arn": "vpc"}}, "secondary-interface": {"ec2:AvailabilityZone": {"member": "AvailabilityZone"}, "ec2:AvailabilityZoneId": {"member": "AvailabilityZoneId"}}, "security-group": {"ec2:Vpc": {"member": "VpcId", "arn": "vpc"}}, "snapshot": {"ec2:AvailabilityZone": {"member": "AvailabilityZone"}, "ec2:Encrypted": {"member": "Encrypted"}, "ec2:Owner": {"member": "OwnerId"}, "ec2:SnapshotID": {"member": "SnapshotId"}, "ec2:VolumeSize": {"member": "VolumeSize"}}, "subnet": {"ec2:AvailabilityZone": {"member": "AvailabilityZone"}, "ec2:AvailabilityZoneId": {"member": "AvailabilityZoneId"}, "ec2:SubnetID": {"member": "SubnetId"}, "ec2:Vpc": {"member": "VpcId", "arn": "vpc"}}, "transit-gateway": {"ec2:transitGatewayId": {"member": "TransitGatewayId"}}, "transit-gateway-attachment": {"ec2:transitGatewayAttachmentId": {"member": "TransitGatewayAttachmentId"}}, "transit-gateway-connect-peer": {"ec2:transitGatewayConnectPeerId": {"member": "TransitGatewayConnectPeerId"}}, "transit-gateway-metering-policy": {"ec2:transitGatewayMeteringPolicyId": {"member": "TransitGatewayMeteringPolicyId"}}, "transit-gateway-multicast-domain": {"ec2:transitGatewayMulticastDomainId": {"member": "TransitGatewayMulticastDomainId"}}, "transit-gateway-policy-table": {"ec2:transitGatewayPolicyTableId": {"member": "TransitGatewayPolicyTableId"}}, "transit-gateway-route-table": {"ec2:transitGatewayRouteTableId": {"member": "TransitGatewayRouteTableId"}}, "transit-gateway-route-table-announcement": {"ec2:transitGatewayRouteTableAnnouncementId": {"member": "TransitGatewayRouteTableAnnouncementId"}}, "volume": {"ec2:AvailabilityZone": {"member": "AvailabilityZone"}, "ec2:AvailabilityZoneId": {"member": "AvailabilityZoneId"}, "ec2:Encrypted": {"member": "Encrypted"}, "ec2:KmsKeyId": {"member": "KmsKeyId"}, "ec2:VolumeID": {"member": "VolumeId"}, "ec2:VolumeInitializationRate": {"member": "VolumeInitializationRate"}, "ec2:VolumeType": {"member": "VolumeType"}}, "vpc": {"ec2:VpcID": {"member": "VpcId"}}, "vpc-peering-connection": {"ec2:VpcPeeringConnectionID": {"member": "VpcPeeringConnectionId"}}}},
"unqualified": {"lambda": ["function"], "ssm": ["parameter"], "states": ["statemachine"]},
"mintedIds": {"events": ["api-destination", "connection"]},
"mintedSuffixes": {"secretsmanager": {"Secret": "-??????"}},
"integerVariables": {"lambda": {"layerVersion": ["LayerVersion"]}},
"forwardedActions": {"kms:Decrypt": {"type": "key", "format": "arn:${Partition}:kms:${Region}:${Account}:key/${KeyId}", "viaService": "kms:ViaService"}},
"operations": {
@@ -3458,6 +3459,32 @@
"route53:UpdateHostedZoneFeatures": {"action": "route53:UpdateHostedZoneFeatures", "types": ["hostedzone"], "resources": [{"type": "hostedzone", "fill": {"Id": "HostedZoneId"}}], "located": {"HostedZoneId": "{Id}"}},
"route53:UpdateTrafficPolicyComment": {"action": "route53:UpdateTrafficPolicyComment", "types": ["trafficpolicy"], "resources": [{"type": "trafficpolicy", "fill": {"Id": "Id"}}], "located": {"Id": "{Id}"}},
"route53:UpdateTrafficPolicyInstance": {"action": "route53:UpdateTrafficPolicyInstance", "types": ["trafficpolicyinstance"], "resources": [{"type": "trafficpolicyinstance", "fill": {"Id": "Id"}}], "located": {"Id": "{Id}"}},
"secretsmanager:AssociateCrossAccountReplica": {"action": "secretsmanager:AssociateCrossAccountReplica", "types": ["Secret"], "resources": []},
"secretsmanager:BatchGetSecretValue": {"action": "secretsmanager:BatchGetSecretValue", "types": [], "resources": []},
"secretsmanager:CancelRotateSecret": {"action": "secretsmanager:CancelRotateSecret", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:CreateSecret": {"action": "secretsmanager:CreateSecret", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "Name"}}]},
"secretsmanager:DeleteResourcePolicy": {"action": "secretsmanager:DeleteResourcePolicy", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:DeleteSecret": {"action": "secretsmanager:DeleteSecret", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:DescribeSecret": {"action": "secretsmanager:DescribeSecret", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:DisassociateCrossAccountReplica": {"action": "secretsmanager:DisassociateCrossAccountReplica", "types": ["Secret"], "resources": []},
"secretsmanager:GetRandomPassword": {"action": "secretsmanager:GetRandomPassword", "types": [], "resources": []},
"secretsmanager:GetResourcePolicy": {"action": "secretsmanager:GetResourcePolicy", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:GetSecretValue": {"action": "secretsmanager:GetSecretValue", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:ListResourcePolicies": {"action": "secretsmanager:ListResourcePolicies", "types": ["Secret"], "resources": []},
"secretsmanager:ListSecretVersionIds": {"action": "secretsmanager:ListSecretVersionIds", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:ListSecrets": {"action": "secretsmanager:ListSecrets", "types": [], "resources": []},
"secretsmanager:PutResourcePolicy": {"action": "secretsmanager:PutResourcePolicy", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:PutSecretValue": {"action": "secretsmanager:PutSecretValue", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:RemoveRegionsFromReplication": {"action": "secretsmanager:RemoveRegionsFromReplication", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:ReplicateSecretToRegions": {"action": "secretsmanager:ReplicateSecretToRegions", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:RestoreSecret": {"action": "secretsmanager:RestoreSecret", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:RotateSecret": {"action": "secretsmanager:RotateSecret", "types": ["Secret"], "resources": [{"types": ["Secret"], "arn": "ExternalSecretRotationRoleArn"}, {"types": ["Secret"], "arn": "RotationLambdaARN"}, {"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:StopReplicationToReplica": {"action": "secretsmanager:StopReplicationToReplica", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:TagResource": {"action": "secretsmanager:TagResource", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:UntagResource": {"action": "secretsmanager:UntagResource", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:UpdateSecret": {"action": "secretsmanager:UpdateSecret", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:UpdateSecretVersionStage": {"action": "secretsmanager:UpdateSecretVersionStage", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"secretsmanager:ValidateResourcePolicy": {"action": "secretsmanager:ValidateResourcePolicy", "types": ["Secret"], "resources": [{"type": "Secret", "fill": {"SecretId": "SecretId"}}]},
"securityhub:AcceptAdministratorInvitation": {"action": "securityhub:AcceptAdministratorInvitation", "types": ["hub"], "resources": [{"type": "hub", "fill": {}}]},
"securityhub:AcceptInvitation": {"action": "securityhub:AcceptInvitation", "types": ["hub"], "resources": [{"type": "hub", "fill": {}}]},
"securityhub:BatchDeleteAutomationRules": {"action": "securityhub:BatchDeleteAutomationRules", "types": ["automation-rule"], "resources": [{"types": ["automation-rule"], "arn": "AutomationRulesArns[]"}]},
@@ -29,6 +29,7 @@ import java.util.stream.Stream;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.mock;
@@ -206,6 +207,10 @@ class RequestResourceMembersTest {
assertTrue(events.get("connection").minted());
assertTrue(events.get("api-destination").minted());
assertFalse(events.get("event-bus").minted());
// A secret is followed by the six characters botocore documents Secrets Manager adding after its name.
assertEquals("-??????",
RequestResourceMembers.table().formats().get("secretsmanager").get("Secret").mintedSuffix());
assertNull(events.get("event-bus").mintedSuffix());
}
@Test
@@ -475,7 +480,9 @@ class RequestResourceMembersTest {
String arn = example(format.format());
String account = resource.account() != null ? "111122223333" : "000000000000";
String expected = resource.arn() != null || resource.through() != null || resource.byDefault() ? arn
: expected(format.format(), resource, account) + (format.minted() ? "/*" : "");
: expected(format.format(), resource, account) + (format.minted() ? "/*"
: format.mintedSuffix() != null && resource.fill().size() == 1
? format.mintedSuffix() : "");
ObjectNode body = MAPPER.createObjectNode();
StringBuilder form = new StringBuilder("Action=" + name);
Map<Member, String> values = resource.arn() != null ? Map.of(resource.arn(), arn)
@@ -23,7 +23,6 @@ import io.floci.aws.services.iam.model.InstanceProfile;
import io.floci.aws.services.iam.model.ServerCertificate;
import io.floci.aws.services.kms.KmsService;
import io.floci.aws.services.lambdamicrovms.LambdaMicrovmsService;
import io.floci.aws.services.secretsmanager.SecretsManagerService;
import io.quarkus.vertx.http.runtime.CurrentVertxRequest;
import io.vertx.core.http.HttpServerRequest;
import io.vertx.ext.web.RoutingContext;
@@ -153,14 +152,6 @@ class ResourceArnBuilderTest {
@SuppressWarnings("unchecked")
Instance<LambdaMicrovmsService> instance = mock(Instance.class);
when(instance.get()).thenReturn(microvms);
return new ResourceArnBuilder(new ObjectMapper(), null, null, instance);
}
/** A builder reading {@code secrets}, for a secret named by its name. */
private static ResourceArnBuilder backedBy(SecretsManagerService secrets) {
@SuppressWarnings("unchecked")
Instance<SecretsManagerService> instance = mock(Instance.class);
when(instance.get()).thenReturn(secrets);
return new ResourceArnBuilder(new ObjectMapper(), null, instance);
}
@@ -169,7 +160,7 @@ class ResourceArnBuilderTest {
@SuppressWarnings("unchecked")
Instance<EksService> instance = mock(Instance.class);
when(instance.get()).thenReturn(eks);
return new ResourceArnBuilder(new ObjectMapper(), null, null, null, instance);
return new ResourceArnBuilder(new ObjectMapper(), null, null, instance);
}
private static IamService storeHolding(String userName, String path, String arn) {
@@ -1305,91 +1296,104 @@ class ResourceArnBuilderTest {
// ── Secrets Manager ──────────────────────────────────────────────────────────
@Test
void secretsManagerBuildsArnFromSecretId() {
setJsonBody("{\"SecretId\":\"app/prod/database\"}");
assertEquals(List.of("arn:aws:secretsmanager:us-east-1:000000000000:secret:app/prod/database"),
builder.buildSecretsManagerResources("secretsmanager:GetSecretValue", ctx, "us-east-1",
"000000000000", "aws"));
private static final String SECRET = "arn:aws:secretsmanager:us-east-1:000000000000:secret:";
/**
* Secrets Manager as IAM asks it: the ARN of each secret it holds, by name, or by an ARN, a partial one included,
* in whatever Region or account it names.
*/
private static StoredResourceArns secretsHolding(Map<String, String> stored) {
return new StoredResourceArns() {
@Override
public String namespace() {
return "secretsmanager";
}
@Override
public Optional<String> find(String type, List<String> names, String region) {
return "Secret".equals(type) && names.size() == 1
? Optional.ofNullable(stored.get(names.getFirst())) : Optional.empty();
}
@Override
public Optional<String> resolveStoredArn(String arn) {
return Optional.ofNullable(stored.get(arn));
}
};
}
private List<String> secretsResources(ResourceArnBuilder builder, String operation, String region,
String partition) {
return builder.buildResources("secretsmanager", operation, ctx, region, ACCOUNT, partition);
}
/**
* A secret named by its name or an ARN, a partial one included, is the ARN Secrets Manager holds it under, random
* suffix included; one it does not hold has the six characters botocore documents open ({@code -??????}), and an
* ARN it does not hold is as given.
*/
@Test
void secretsManagerResolvesASecretNamedByItsNameToItsStoredArn() {
String storedArn = "arn:aws:secretsmanager:us-east-1:111122223333:secret:app/core-AbC123";
SecretsManagerService secrets = mock(SecretsManagerService.class);
when(secrets.findArn("111122223333", "app/core", "us-east-1")).thenReturn(Optional.of(storedArn));
void aSecretIsTheArnSecretsManagerHoldsItUnderOrItsNameWithTheSuffixOpen() {
String stored = SECRET + "app/core-AbC123";
ResourceArnBuilder backed = reading(secretsHolding(Map.of("app/core", stored, SECRET + "app/core", stored)));
setJsonBody("{\"SecretId\":\"app/core\"}");
List<String> arns = backedBy(secrets).buildSecretsManagerResources("secretsmanager:GetSecretValue", ctx,
"us-east-1", "111122223333", "aws");
assertEquals(List.of(storedArn), arns);
}
@Test
void secretsManagerKeepsTheNameOfASecretThatIsNotStored() {
SecretsManagerService secrets = mock(SecretsManagerService.class);
when(secrets.findArn(ACCOUNT, "app/missing", "us-east-1")).thenReturn(Optional.empty());
assertEquals(List.of(stored), secretsResources(backed, "secretsmanager:GetSecretValue", "us-east-1", "aws"));
setJsonBody("{\"SecretId\":\"" + SECRET + "app/core\"}");
assertEquals(List.of(stored), secretsResources(backed, "secretsmanager:GetSecretValue", "us-east-1", "aws"));
setJsonBody("{\"SecretId\":\"app/missing\"}");
List<String> arns = backedBy(secrets).buildSecretsManagerResources("secretsmanager:GetSecretValue", ctx,
"us-east-1", ACCOUNT, "aws");
assertEquals(List.of("arn:aws:secretsmanager:us-east-1:000000000000:secret:app/missing"), arns);
assertEquals(List.of(SECRET + "app/missing-??????"),
secretsResources(backed, "secretsmanager:DescribeSecret", "us-east-1", "aws"));
setJsonBody("{\"SecretId\":\"" + SECRET + "app/missing\"}");
assertEquals(List.of(SECRET + "app/missing"),
secretsResources(backed, "secretsmanager:DescribeSecret", "us-east-1", "aws"));
}
/**
* {@code CreateSecret} names the secret it makes by {@code Name}, its suffix not minted yet, and every other
* operation by {@code SecretId}, so a member the serving operation does not read names nothing; an operation
* acting on no resource type is checked on {@code *}.
*/
@Test
void secretsManagerResolvesAPartialArnToTheStoredArnAndKeepsAnArnThatIsNotStored() {
String partialArn = "arn:aws:secretsmanager:us-east-1:000000000000:secret:app/core";
String storedArn = partialArn + "-AbC123";
String missingArn = "arn:aws:secretsmanager:us-east-1:000000000000:secret:app/missing";
SecretsManagerService secrets = mock(SecretsManagerService.class);
when(secrets.findArn(ACCOUNT, partialArn, "us-east-1")).thenReturn(Optional.of(storedArn));
when(secrets.findArn(ACCOUNT, missingArn, "us-east-1")).thenReturn(Optional.empty());
ResourceArnBuilder backed = backedBy(secrets);
setJsonBody("{\"SecretId\":\"" + partialArn + "\"}");
assertEquals(List.of(storedArn), backed.buildSecretsManagerResources("secretsmanager:GetSecretValue", ctx,
"us-east-1", ACCOUNT, "aws"));
setJsonBody("{\"SecretId\":\"" + missingArn + "\"}");
assertEquals(List.of(missingArn), backed.buildSecretsManagerResources("secretsmanager:GetSecretValue", ctx,
"us-east-1", ACCOUNT, "aws"));
}
@Test
void secretsManagerCreateSecretBuildsArnFromNameWithAnUnassignedSuffix() {
setJsonBody("{\"Name\":\"app/core\",\"SecretString\":\"x\"}");
assertEquals(List.of("arn:aws:secretsmanager:us-east-1:000000000000:secret:app/core-??????"),
builder.buildSecretsManagerResources("secretsmanager:CreateSecret", ctx, "us-east-1", ACCOUNT,
"aws"));
}
@Test
void secretsManagerTargetsTheFieldTheServingOperationReads() {
SecretsManagerService secrets = mock(SecretsManagerService.class);
when(secrets.findArn(ACCOUNT, "app/existing", "us-east-1"))
.thenReturn(Optional.of("arn:aws:secretsmanager:us-east-1:000000000000:secret:app/existing-AbC123"));
ResourceArnBuilder backed = backedBy(secrets);
void aCreateNamesTheSecretItMakesAndEveryOtherOperationTheOneItsSecretIdNames() {
ResourceArnBuilder backed = reading(secretsHolding(Map.of("app/existing", SECRET + "app/existing-AbC123")));
setJsonBody("{\"Name\":\"app/new\",\"SecretId\":\"app/existing\",\"SecretString\":\"x\"}");
assertEquals(List.of("arn:aws:secretsmanager:us-east-1:000000000000:secret:app/new-??????"),
backed.buildSecretsManagerResources("secretsmanager:CreateSecret", ctx, "us-east-1", ACCOUNT, "aws"));
assertEquals(List.of(SECRET + "app/new-??????"),
secretsResources(backed, "secretsmanager:CreateSecret", "us-east-1", "aws"));
setJsonBody("{\"Name\":\"app/new\"}");
assertEquals(List.of("arn:aws:secretsmanager:us-east-1:000000000000:secret:*"),
backed.buildSecretsManagerResources("secretsmanager:GetSecretValue", ctx, "us-east-1", ACCOUNT,
"aws"));
assertEquals(List.of("*"), secretsResources(backed, "secretsmanager:GetSecretValue", "us-east-1", "aws"));
setJsonBody("{}");
assertEquals(List.of("*"), secretsResources(backed, "secretsmanager:ListSecrets", "us-east-1", "aws"));
}
/**
* A secret Secrets Manager holds in another Region than the request's, named by its ARN, partial or full, is the
* one its operations act on there, and so is one another account holds under the full ARN named: that ARN alone,
* no secret of its name in the request's Region or the caller's account.
*/
@Test
void aSecretHeldInAnotherRegionOrAccountIsCheckedOnItsArnAlone() {
String west = "arn:aws:secretsmanager:us-west-2:000000000000:secret:";
String stored = west + "app/core-AbC123";
String shared = "arn:aws:secretsmanager:us-east-1:111122223333:secret:app/shared-XyZ789";
ResourceArnBuilder backed = reading(secretsHolding(Map.of(west + "app/core", stored, stored, stored,
shared, shared)));
setJsonBody("{\"SecretId\":\"" + west + "app/core\"}");
assertEquals(List.of(stored), secretsResources(backed, "secretsmanager:GetSecretValue", "us-east-1", "aws"));
setJsonBody("{\"SecretId\":\"" + stored + "\"}");
assertEquals(List.of(stored), secretsResources(backed, "secretsmanager:GetSecretValue", "us-east-1", "aws"));
setJsonBody("{\"SecretId\":\"" + shared + "\"}");
assertEquals(List.of(shared), secretsResources(backed, "secretsmanager:GetSecretValue", "us-east-1", "aws"));
}
@Test
void secretsManagerMintsArnsInTheRequestPartition() {
void aSecretsArnIsInTheRequestsPartition() {
setJsonBody("{\"Name\":\"app/core\"}");
assertEquals(List.of("arn:aws-cn:secretsmanager:polygondwanaland-west-1:000000000000:secret:app/core-??????"),
builder.buildSecretsManagerResources("secretsmanager:CreateSecret", ctx, "polygondwanaland-west-1",
ACCOUNT, "aws-cn"));
setJsonBody("{\"SecretId\":\"app/core\"}");
assertEquals(List.of("arn:aws-us-gov:secretsmanager:polygondwanaland-west-1:000000000000:secret:app/core"),
builder.buildSecretsManagerResources("secretsmanager:GetSecretValue", ctx, "polygondwanaland-west-1",
ACCOUNT, "aws-us-gov"));
secretsResources(reading(secretsHolding(Map.of())), "secretsmanager:CreateSecret",
"polygondwanaland-west-1", "aws-cn"));
}
// ── KMS ──────────────────────────────────────────────────────────────────────
@@ -1404,7 +1408,7 @@ class ResourceArnBuilderTest {
@SuppressWarnings("unchecked")
Instance<KmsService> instance = mock(Instance.class);
when(instance.get()).thenReturn(kms);
return new ResourceArnBuilder(new ObjectMapper(), null, null, null, null, instance);
return new ResourceArnBuilder(new ObjectMapper(), null, null, null, instance);
}
/** A builder reading the stored ARNs of a namespace, for every request of that namespace. */
@@ -1412,7 +1416,7 @@ class ResourceArnBuilderTest {
@SuppressWarnings("unchecked")
Instance<StoredResourceArns> instance = mock(Instance.class);
when(instance.iterator()).thenAnswer(invocation -> List.of(stored).iterator());
return new ResourceArnBuilder(new ObjectMapper(), null, null, null, null, null, instance);
return new ResourceArnBuilder(new ObjectMapper(), null, null, null, null, instance);
}
/** The finder of the stored ARNs of a namespace, answering one name of one type with one ARN. */
@@ -101,6 +101,21 @@ class SecretsManagerSecretArnEnforcementIntegrationTest {
.body("__type", equalTo("AccessDeniedException"));
}
@Test
void aSecretOfAnotherRegionNamedByItsArnIsAuthorizedAgainstThatArnAlone() {
String name = "app-" + UUID.randomUUID().toString().substring(0, 8);
String arn = createSecretIn("us-west-2", name);
Session session = assumeRoleWith("""
{"Version":"2012-10-17","Statement":[
{"Effect":"Allow","Action":"secretsmanager:GetSecretValue","Resource":"%s"}]}"""
.formatted(arn));
// Signed for us-east-1, the request reads the us-west-2 secret its ARN names, and is checked on that one.
secretsCall(session, "GetSecretValue", "{\"SecretId\": \"" + arn + "\"}")
.then().statusCode(200)
.body("SecretString", equalTo("x"));
}
@Test
void createSecretIgnoresASecretIdTheHandlerDoesNotRead() {
String existing = "app-" + UUID.randomUUID().toString().substring(0, 8);
@@ -129,6 +144,17 @@ class SecretsManagerSecretArnEnforcementIntegrationTest {
"{\"SecretId\": \"" + name + "\", \"ForceDeleteWithoutRecovery\": true}").then().statusCode(200));
}
/** A secret the account creates in {@code region}, deleted after the test by its ARN; its ARN. */
private String createSecretIn(String region, String name) {
Response response = accountCall(region, "CreateSecret",
"{\"Name\": \"" + name + "\", \"SecretString\": \"x\"}");
response.then().statusCode(200);
String arn = response.path("ARN");
cleanup.register(() -> accountCall(region, "DeleteSecret",
"{\"SecretId\": \"" + arn + "\", \"ForceDeleteWithoutRecovery\": true}").then().statusCode(200));
return arn;
}
/** A session of a new role that its own account may assume, with {@code policy} inline. */
private Session assumeRoleWith(String policy) {
int port = baseUri.getPort();
@@ -139,7 +165,11 @@ class SecretsManagerSecretArnEnforcementIntegrationTest {
/** A call as the account itself, which the cleanup also makes after RestAssured's port is reset. */
private Response accountCall(String action, String body) {
return given().port(baseUri.getPort()).header("Authorization", auth(ACCOUNT, "secretsmanager"))
return accountCall("us-east-1", action, body);
}
private Response accountCall(String region, String action, String body) {
return given().port(baseUri.getPort()).header("Authorization", auth(ACCOUNT, region, "secretsmanager"))
.header("X-Amz-Target", "secretsmanager." + action)
.contentType("application/x-amz-json-1.1")
.body(body)
@@ -0,0 +1,68 @@
package io.floci.aws.services.iam;
import io.floci.aws.testing.EnforcementFixtures;
import io.floci.aws.testing.LogsAuthorizationFixtures;
import io.floci.aws.testing.PartitionCleanup;
import io.floci.aws.testing.RestAssuredJsonUtils;
import io.quarkus.test.common.http.TestHTTPResource;
import io.quarkus.test.junit.QuarkusTest;
import io.quarkus.test.junit.TestProfile;
import io.restassured.response.Response;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
import java.net.URI;
import java.util.UUID;
import static io.restassured.RestAssured.given;
/**
* In a deployment whose partition is not {@code aws}, a request in a Region Floci does not know is in the deployment's
* partition, and so is the resource it creates, which the tags the request carries are checked on: a grant scoped to
* that partition reaches the tagging of the user pool a {@code CreateUserPool} makes, an action acting on no resource
* type whose tags go on the resource it makes.
*/
@QuarkusTest
@TestProfile(LogsNoncommercialUnknownRegionAuthorizationIntegrationTest.ChinaProfile.class)
class TagOnCreateUnknownRegionPartitionIntegrationTest {
private static final String ACCOUNT = "111111111111";
private static final String REGION = "polygondwanaland-west-1";
@RegisterExtension
final PartitionCleanup cleanup = new PartitionCleanup();
@TestHTTPResource
URI endpoint;
@BeforeAll
static void configureContentTypes() {
RestAssuredJsonUtils.configureAwsContentTypes();
}
@Test
void theTagsACreateCarriesAreCheckedOnWhatItMakesInTheDeploymentsPartition() {
String name = "pool-" + UUID.randomUUID().toString().substring(0, 8);
String caller = LogsAuthorizationFixtures.user(cleanup, endpoint.getPort(), ACCOUNT, "tag-partition-",
"pools", "{\"Effect\":\"Allow\",\"Action\":\"cognito-idp:CreateUserPool\",\"Resource\":\"*\"},"
+ "{\"Effect\":\"Allow\",\"Action\":\"cognito-idp:TagResource\",\"Resource\":\"arn:aws-cn:"
+ "cognito-idp:" + REGION + ":" + ACCOUNT + ":userpool/*\"}");
Response created = cognitoCall(caller, "CreateUserPool",
"{\"PoolName\": \"" + name + "\", \"UserPoolTags\": {\"team\": \"blue\"}}");
created.then().statusCode(200);
String poolId = created.path("UserPool.Id");
cleanup.register(() -> cognitoCall(ACCOUNT, "DeleteUserPool", "{\"UserPoolId\": \"" + poolId + "\"}")
.then().statusCode(200));
}
private Response cognitoCall(String caller, String action, String body) {
return given().port(endpoint.getPort())
.header("Authorization", EnforcementFixtures.auth(caller, REGION, "cognito-idp"))
.header("X-Amz-Target", "AWSCognitoIdentityProviderService." + action)
.contentType("application/x-amz-json-1.1")
.body(body)
.when().post("/");
}
}
@@ -25,6 +25,7 @@ import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.stream.IntStream;
@@ -588,6 +589,38 @@ class SecretsManagerServiceTest {
assertFindArnNamesTheSecretTheOperationActsOn(svc, otherAccount.getArn(), REGION);
}
@Test
void anArnResolvesToTheSecretTheOperationsReadItAsTheCallersBeforeTheOneItsAccountHolds() {
AccountAwareStorageBackend<Secret> accountAware =
AccountAwareStorageBackend.inMemory("000000000000");
SecretsManagerService svc = new SecretsManagerService(accountAware, 30);
Secret otherAccount = new Secret();
otherAccount.setName("app/core");
otherAccount.setArn("arn:aws:secretsmanager:" + REGION + ":111122223333:secret:app/core-AbCdEf");
accountAware.putForAccount("111122223333", REGION + "::app/core", otherAccount);
String partialArn = "arn:aws:secretsmanager:" + REGION + ":111122223333:secret:app/core";
Secret west = svc.createSecret("app/west", "value", null, null, null, null, "eu-west-1");
assertEquals(Optional.of(otherAccount.getArn()), svc.resolveStoredArn(otherAccount.getArn()));
// The caller's own secret, a partial ARN of it in another Region included.
assertEquals(Optional.of(west.getArn()), svc.resolveStoredArn(west.getArn()));
assertEquals(Optional.of(west.getArn()),
svc.resolveStoredArn("arn:aws:secretsmanager:eu-west-1:000000000000:secret:app/west"));
assertEquals(west.getArn(), svc.describeSecret(
"arn:aws:secretsmanager:eu-west-1:000000000000:secret:app/west", REGION).getArn());
// The operations read a partial ARN, or a suffix that account holds nothing under, in the caller's account.
assertTrue(svc.resolveStoredArn(partialArn).isEmpty());
assertTrue(svc.resolveStoredArn(otherAccount.getArn().replace("AbCdEf", "XyZ789")).isEmpty());
// A name or an ARN of no secret resolves nothing.
assertTrue(svc.resolveStoredArn("app/west").isEmpty());
assertTrue(svc.resolveStoredArn("arn:aws:s3:::app/west").isEmpty());
// A secret of the caller's own named like the ARN's resource is the one the operations read the ARN as.
Secret callers = svc.createSecret("app/core-AbCdEf", "value", null, null, null, null, REGION);
assertEquals(Optional.of(callers.getArn()), svc.resolveStoredArn(otherAccount.getArn()));
assertFindArnNamesTheSecretTheOperationActsOn(svc, otherAccount.getArn(), REGION);
}
/**
* IAM authorizes {@code findArn}'s answer, or an ARN as given when it has none, so it has to name
* the secret the operation then acts on.
+85 -3
View File
@@ -258,11 +258,12 @@ NAMESPACES = ("access-analyzer", "account", "acm", "application-autoscaling", "a
"firehose", "fis", "globalaccelerator", "inspector2", "kinesisanalytics", "macie2", "oam",
"payment-cryptography", "quicksight", "ram", "redshift", "redshift-data", "redshift-serverless",
"rekognition", "resource-explorer-2", "route53", "servicediscovery", "servicequotas", "ssm", "sso",
"states", "textract", "timestream-influxdb", "translate", "signer", "xray", "securityhub", "guardduty")
"states", "textract", "timestream-influxdb", "translate", "signer", "xray", "securityhub", "guardduty",
"secretsmanager")
# The namespaces whose resources ResourceArnBuilder builds itself.
HAND_BUILT = ("apigateway", "bedrock", "dsql", "dynamodb", "eks", "iam", "kinesis", "kms", "lambda", "logs", "pipes",
"resource-groups", "s3", "scheduler", "secretsmanager", "sns", "sqs", "sts")
"resource-groups", "s3", "scheduler", "sns", "sqs", "sts")
# Operations of a namespace in `HAND_BUILT` read from the reference all the same, each with its reason.
_LOGS_DELIVERY = ("CloudWatch Logs vended-log delivery: its requests name a delivery source, destination or delivery "
@@ -470,6 +471,12 @@ ALIAS_PATTERN_RE = re.compile(r"(?:^|[|(])\^?alias/")
# its own an ARN pattern takes past that word when its service mints an id after the name (`\\/[...]+\\/[...]+$`).
MINTED_WORD_RE = re.compile(r"^([A-Za-z][A-Za-z0-9-]*)/\$\{\w+}$")
MINTED_TAIL = r"\\/(?:\[[^\]]*\][+*]|\([^()]*\)[+*]?)\\/(?:\[[^\]]*\][+*]|\([^()]*\)[+*]?)\$?$"
# A create's member documented as the name its service follows with characters it mints: "Secrets Manager automatically
# adds a hyphen and six random characters after the secret name at the end of the ARN".
DOC_MINTED_SUFFIX_RE = re.compile(r"\badds an? (?P<separator>hyphen|dash|underscore|period) and (?P<count>\w+) random "
r"characters after the (?P<word>[a-z][a-z -]*?) name at the end of the arn\b")
SEPARATORS = {"hyphen": "-", "dash": "-", "underscore": "_", "period": "."}
COUNTS = {"one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9, "ten": 10}
STEM_SUFFIX_RE = re.compile(r"(arns|arn|names|name|identifiers|identifier|ids|id|config|s)$")
# A bare member that names the resource of the type its operation acts on.
BARE = {"name", "names", "id", "ids", "identifier", "identifiers"}
@@ -2181,6 +2188,7 @@ def read_resources(operation: str, types: list[str], formats: dict[str, str], mo
resources = with_documented(operation, types, formats, models, resources)
resources = with_typed_targets(resources, formats, typed_target_fields(models, name))
resources = with_integer_members(resources, formats, models, name)
resources = with_minted_names(operation, resources, formats, models)
optional = optional_members(models, name)
resources = with_absent_arn(resources, formats, optional)
resources = with_absent_account(resources, formats, account_members(models, name), optional)
@@ -2271,6 +2279,24 @@ def with_integer_members(resources: list[dict], formats: dict[str, str], models:
return result
def with_minted_names(operation: str, resources: list[dict], formats: dict[str, str],
models: dict[str, dict]) -> list[dict]:
"""The resources, the type a create makes named by the member its documentation gives as the name its service
follows with characters it mints (`CreateSecret`'s `Name`, of the secret), its one variable filled from it."""
name = operation.split(":", 1)[1]
said = [found for model in models.values() for found in documented_minted_suffixes(model, name)]
found = []
for resource in resources:
kind = resource.get("type")
named = [member for word, _, member in said if kind is not None and named_by_word(word, formats) == kind]
variables = [v for v in VARIABLE_RE.findall(formats.get(kind or "", "")) if v not in KNOWN_VARIABLES]
if len(named) == 1 and len(variables) == 1 and resource.get("fill") == {} \
and not {"find", "when", "unless", "default"} & set(resource):
resource = dict(resource, fill={variables[0]: named[0]})
found.append(resource)
return found
def with_enum_named(operation: str, resources: list[dict], formats: dict[str, str],
models: dict[str, dict]) -> list[dict]:
"""The resources, a variable no member fills of a type named by its variables `fixed` to the one value of an enum
@@ -2689,6 +2715,7 @@ def build(documents: list[dict], provenance: str, data: Path, botocore: str) ->
for namespace in sorted(read_namespaces)}
formats = arn_formats(documents, read_namespaces)
minted = minted_types(formats, namespaces, data)
suffixes = minted_suffixes(formats, namespaces, data)
check_forwarded(authorized_by(documents))
forwarded = forwarded_actions(documents)
operations = {}
@@ -2720,6 +2747,7 @@ def build(documents: list[dict], provenance: str, data: Path, botocore: str) ->
"resourceKeys": resource_keys(documents, data, namespaces),
"unqualified": unqualified,
"mintedIds": minted,
"mintedSuffixes": suffixes,
"integerVariables": integer_variables(operations, namespaces, data),
"forwardedActions": forwarded,
"operations": operations,
@@ -2805,6 +2833,47 @@ def minted_types(formats: dict[str, dict[str, str]], namespaces: dict[str, list[
return found
def minted_suffixes(formats: dict[str, dict[str, str]], namespaces: dict[str, list[str]],
data: Path) -> dict[str, dict[str, str]]:
"""The types of each namespace whose service follows the name their one variable takes with characters it mints,
which a request naming one by its name does not give, each with those characters as IAM matches them, one `?`
each after the separator: botocore documents a create's name member so ("Secrets Manager automatically adds a
hyphen and six random characters after the secret name at the end of the ARN": `-??????`)."""
found: dict[str, dict[str, str]] = {}
for namespace in sorted(formats):
for model in load_models(data, set(namespaces.get(namespace, []))).values():
for operation in model["operations"]:
for said in documented_minted_suffixes(model, operation):
kind = named_by_word(said[0], formats[namespace])
if kind is not None:
found.setdefault(namespace, {})[kind] = said[1]
return {namespace: dict(sorted(kinds.items())) for namespace, kinds in sorted(found.items())}
def documented_minted_suffixes(model: dict, operation: str) -> list[tuple[str, str, str]]:
"""The members of a create's request documented as the name its service follows with characters it mints, each as
the type's word the documentation names, the characters as IAM matches them and the member: `("secret", "-??????",
"Name")` for Secrets Manager's `CreateSecret`."""
spec = model["operations"].get(operation)
if spec is None or "input" not in spec or not CREATING_RE.match(operation):
return []
found = []
for name, member in model["shapes"][spec["input"]["shape"]].get("members", {}).items():
said = DOC_MINTED_SUFFIX_RE.search(_lead_text(member.get("documentation")))
count = COUNTS.get(said.group("count")) if said else None
if said and count:
found.append((said.group("word").replace(" ", "-"), SEPARATORS[said.group("separator")] + "?" * count, name))
return found
def named_by_word(word: str, formats: dict[str, str]) -> str | None:
"""The one type whose format's resource is the word and one variable, after a `/` or a `:`
(`secret:${SecretId}`)."""
found = [kind for kind, arn in formats.items()
if re.fullmatch(re.escape(word) + r"[/:]\$\{\w+}", _resource(arn), re.IGNORECASE)]
return found[0] if len(found) == 1 else None
def _resource(arn_format: str) -> str:
"""The resource part of an ARN format, past its fifth colon."""
return arn_format.split(":", 5)[5]
@@ -2848,7 +2917,7 @@ def render(document: dict) -> str:
"""The document with one operation to a line."""
lines = ["{"]
for key in ("_source", "namespaces", "handBuilt", "notCovered", "otherNamespaces", "arnFormats", "resourceTagKeys",
"resourceKeys", "unqualified", "mintedIds", "integerVariables", "forwardedActions"):
"resourceKeys", "unqualified", "mintedIds", "mintedSuffixes", "integerVariables", "forwardedActions"):
lines.append(f' "{key}": {json.dumps(document[key])},')
lines.append(' "operations": {')
operations = list(document["operations"].items())
@@ -2936,6 +3005,15 @@ def validate(document: dict) -> list[str]:
for kind in kinds) for namespace, kinds in minted.items()):
problems.append("mintedIds is not resource types of each namespace the file reads whose ARN format ends in "
"its one variable")
suffixes = document.get("mintedSuffixes")
if not isinstance(suffixes, dict) or not all(
isinstance(kinds, dict) and kinds and all(
isinstance(kind, str) and kind in formats.get(namespace, {})
and ONE_VARIABLE_RE.match(_resource(formats[namespace][kind]))
and isinstance(suffix, str) and re.fullmatch(r"[-_.]\?+", suffix) for kind, suffix in kinds.items())
for namespace, kinds in suffixes.items()):
problems.append("mintedSuffixes is not resource types of each namespace the file reads whose ARN format ends "
"in its one variable, each with a separator and the characters its service mints")
for key in ("handBuilt", "otherNamespaces"):
if not isinstance(document.get(key), list) or not all(isinstance(n, str) and NAMESPACE_RE.match(n)
for n in document[key]):
@@ -3148,6 +3226,10 @@ def derive(document: dict, data: Path) -> list[str]:
if document["mintedIds"] != minted:
problems.append(f"the file gives {json.dumps(document['mintedIds'])} a minted id, botocore's ARN patterns "
f"give {json.dumps(minted)}")
suffixes = minted_suffixes(document["arnFormats"], document["namespaces"], data)
if document.get("mintedSuffixes") != suffixes:
problems.append(f"the file gives {json.dumps(document.get('mintedSuffixes'))} a minted suffix, botocore's "
f"documentation gives {json.dumps(suffixes)}")
named = sorted({use["action"] for uses, _ in FORWARDED.values() for use in uses})
if sorted(document["forwardedActions"]) != named:
problems.append(f"the file records {sorted(document['forwardedActions'])} as forwarded actions, FORWARDED "
+27 -1
View File
@@ -653,6 +653,31 @@ def test_a_type_whose_arn_shape_takes_a_segment_past_its_name_has_an_id_its_serv
assert r.build(DOCUMENTS, "test", tmp_path / "plain", "botocore test")["mintedIds"] == {}
def test_a_create_documenting_characters_its_service_mints_after_a_name_gives_them_open(isolated, tmp_path):
# Secrets Manager: "automatically adds a hyphen and six random characters after the secret name at the end of
# the ARN".
service = model({"CreateThing": {"Name": "String"}, "GetThing": {"ThingName": "String"}, "ListThings": {}})
service["shapes"]["CreateThingIn"]["members"]["Name"]["documentation"] = (
"<p>The name of the new thing.</p> <p>Svc automatically adds a hyphen and six random characters after the "
"thing name at the end of the ARN.</p>")
write_models(tmp_path, {"svc": service})
documents = [reference("svc", {"CreateThing": ["thing"], "GetThing": ["thing"], "ListThings": []},
{"thing": FORMATS["thing"]})]
document = r.build(documents, "test", tmp_path, "botocore test")
assert document["mintedSuffixes"] == {"svc": {"thing": "-??????"}}
assert document["operations"]["svc:CreateThing"]["resources"] == [{"type": "thing", "fill": {"ThingName": "Name"}}]
assert r.validate(document) == [] and r.derive(document, tmp_path) == []
document["mintedSuffixes"] = {}
assert any("minted suffix" in problem for problem in r.derive(document, tmp_path))
for bad in ({"svc": {"thing": "??????"}}, {"svc": {"group": "-??"}}, {"svc": {"thing": "-ab"}}, {"svc": {}}):
document["mintedSuffixes"] = bad
assert any("mintedSuffixes" in problem for problem in r.validate(document)), bad
# Undocumented, the thing has no suffix.
write_models(tmp_path / "plain", {"svc": model({"CreateThing": {"Name": "String"},
"GetThing": {"ThingName": "String"}, "ListThings": {}})})
assert r.build(documents, "test", tmp_path / "plain", "botocore test")["mintedSuffixes"] == {}
def test_a_type_whose_arn_is_all_an_id_its_service_mints_is_found_by_its_documented_key_or_its_name(isolated, tmp_path):
documents = [reference("svc", {"PutTarget": ["target"], "TagTarget": ["target"], "GetByResource": ["target"],
"RunOn": ["target", "group"], "RenameGroup": ["group"]},
@@ -760,7 +785,8 @@ def good_document() -> dict:
return {"namespaces": {"svc": ["svc"]}, "handBuilt": ["hand"],
"notCovered": {"later": "a later batch"},
"otherNamespaces": ["other"], "arnFormats": {"svc": {"thing": FORMATS["thing"], "group": FORMATS["group"]}},
"unqualified": {"svc": ["thing"]}, "mintedIds": {"svc": ["thing"]}, "forwardedActions": {},
"unqualified": {"svc": ["thing"]}, "mintedIds": {"svc": ["thing"]}, "mintedSuffixes": {},
"forwardedActions": {},
"operations": {
"svc:A": {"action": "svc:A", "types": ["thing"], "resources": [{"types": ["thing"], "arn": "ThingArn"}]},
"svc:B": {"action": "svc:B", "types": ["group"], "resources": [{"type": "group", "fill": {"GroupName": "Names[]"}}]},