mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(iam): select EC2 interface and endpoint authorization resources (#8892)
* fix(iam): select EC2 interface and endpoint authorization resources
This commit is contained in:
1 parent
c91740de85
commit
875794c538
11 files changed
+714
-18
No files matched your search
@@ -1328,6 +1328,21 @@ A repeated grant of the same permission to the same account answers the grant al
|
||||
AWS documents no duplicate error for it; this is Floci's choice. Grants are kept on the interface,
|
||||
so they go when it is deleted. `DeleteNetworkInterfacePermission` is not served.
|
||||
|
||||
#### Interface and VPC endpoint IAM resources
|
||||
|
||||
With IAM enforcement enabled, the generated request-resource catalog checks interface and VPC
|
||||
endpoint operations on their resource ARNs. Creating an interface also names its subnet and security
|
||||
groups; creating an endpoint also names its VPC, subnets, security groups and route tables.
|
||||
`ModifyVpcEndpoint` includes both added and removed resources. Tag requests recognize the interface
|
||||
ID prefix supplied by the pinned botocore model. Endpoint, attachment and endpoint-service IDs
|
||||
without a model-backed prefix remain checked on `*`.
|
||||
|
||||
`DetachNetworkInterface` resolves the attachment's instance and interface in the caller's account
|
||||
and Region, then checks both resources. An attachment that cannot be resolved uses the caller's
|
||||
`instance/*` and `network-interface/*` resources for authorization before the service reports it
|
||||
missing. `DescribeNetworkInterfaces` and `DescribeNetworkInterfacePermissions` remain checked on
|
||||
`*`. These authorization checks do not establish cross-account guest-network attachment support.
|
||||
|
||||
### Volumes
|
||||
|
||||
| Action | Description |
|
||||
|
||||
@@ -328,7 +328,8 @@ public final class RequestResources {
|
||||
for (String id : ids) {
|
||||
String arn = "*";
|
||||
for (Map.Entry<String, String> prefix : targets.prefixes().entrySet()) {
|
||||
if (id.startsWith(prefix.getValue())) {
|
||||
// A longer, uncovered resource prefix must not borrow a shorter covered type's ARN.
|
||||
if (id.startsWith(prefix.getValue()) && id.indexOf('-', prefix.getValue().length()) < 0) {
|
||||
arn = idArn(formats.get(prefix.getKey()).format(), id, partition, region, accountId);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -17425,6 +17425,31 @@ public class Ec2Service implements ContainerTeardown, ResourceProvider, Resettab
|
||||
return attachment;
|
||||
}
|
||||
|
||||
/** The endpoints of an attachment held in the caller's account and Region, without changing it. */
|
||||
List<String> networkInterfaceAttachmentArns(String region, String attachmentId) {
|
||||
if (attachmentId == null || attachmentId.isBlank()) {
|
||||
return List.of();
|
||||
}
|
||||
String account = callerAccountId();
|
||||
synchronized (attachmentTopologyLock(region)) {
|
||||
List<NetworkInterface> interfaces =
|
||||
networkInterfaces instanceof AccountAwareStorageBackend<NetworkInterface> aware
|
||||
? aware.scanForAccount(account, k -> k.startsWith(region + "::"))
|
||||
: networkInterfaces.scan(k -> k.startsWith(region + "::"));
|
||||
NetworkInterface attached = interfaces.stream()
|
||||
.filter(ni -> ni.getAttachment() != null && attachmentId.equals(ni.getAttachment().getAttachmentId()))
|
||||
.findFirst().orElse(null);
|
||||
if (attached == null) {
|
||||
return List.of();
|
||||
}
|
||||
String instanceId = attached.getAttachment().getInstanceId();
|
||||
String interfaceId = attached.getNetworkInterfaceId();
|
||||
return List.of(AwsArnUtils.Arn.of("ec2", region, account,
|
||||
"instance/" + (instanceId == null ? "*" : instanceId)).toString(),
|
||||
AwsArnUtils.Arn.of("ec2", region, account, "network-interface/" + interfaceId).toString());
|
||||
}
|
||||
}
|
||||
|
||||
/** Detaches a standalone ENI by attachment id, floci-kt9. */
|
||||
public NetworkInterfaceAttachment detachNetworkInterface(String region, String attachmentId, boolean force) {
|
||||
if (attachmentId == null || attachmentId.isBlank()) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.floci.aws.services.ec2;
|
||||
|
||||
import io.floci.aws.core.common.AwsArnUtils;
|
||||
import io.floci.aws.core.common.StoredResourceArns;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
@@ -7,7 +8,7 @@ import jakarta.inject.Inject;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/** Resolves the caller's launch-template names to their stored ID-based ARNs. */
|
||||
/** Resolves the caller's launch-template names and network-interface attachments to resource ARNs. */
|
||||
@ApplicationScoped
|
||||
public class Ec2StoredResourceArns implements StoredResourceArns {
|
||||
|
||||
@@ -23,6 +24,16 @@ public class Ec2StoredResourceArns implements StoredResourceArns {
|
||||
return "ec2";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> findByMembers(String type, List<String> names, String region) {
|
||||
if (("instance".equals(type) || "network-interface".equals(type)) && names.size() == 1) {
|
||||
return ec2.networkInterfaceAttachmentArns(region, names.getFirst()).stream()
|
||||
.filter(arn -> AwsArnUtils.parse(arn).resource().startsWith(type + "/"))
|
||||
.findFirst();
|
||||
}
|
||||
return find(type, names, region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<String> find(String type, List<String> names, String region) {
|
||||
return "launch-template".equals(type) && names.size() == 1
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
"handBuilt": ["apigateway", "bedrock", "dynamodb", "eks", "iam", "kms", "logs", "resource-groups", "s3", "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", "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 name their resources in the path, which RequestResources reads from the route a request matched in the vendored REST rLine truncated
|
||||
"otherNamespaces": ["a4b", "account-access", "acm-pca", "aco-automation", "agent-registry", "aidevops", "aiops", "airflow-serverless", "amplify", "amplifybackend", "amplifyuibuilder", "aoss", "apiportal", "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", "bcm-data-hub", "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", "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", "osm", "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}"}, "cloudformation": {"changeset": "arn:${Partition}:cloudformation:${Region}:${Account}:changeSet/${ChangeSetName}/${Id}", "generatedtemplate": "arn:${Partition}:cloudformation:${Region}:${Account}:generatedTemplate/${Id}", "resourcescan": "arn:${Partition}:cloudformation:${Region}:${Account}:resourceScan/${Id}", "stack": "arn:${Partition}:cloudformation:${Region}:${Account}:stack/${StackName}/${Id}", "stackset": "arn:${Partition}:cloudformation:${Region}:${Account}:stackset/${StackSetName}:${Id}", "stackset-target": "arn:${Partition}:cloudformation:${Region}:${Account}:stackset-target/${StackSetTarget}", "type": "arn:${Partition}:cloudformation:${Region}:${Account}:type/resource/${Type}", "typeHook": "arn:${Partition}:cloudformation:${Region}:${Account}:type/hook/${Type}"}, "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:$Line truncated
|
||||
"resourceTagKeys": {"access-analyzer": {"Analyzer": ["aws:ResourceTag/"]}, "acm": {"acme-domain-validation": ["aws:ResourceTag/"], "acme-endpoint": ["aws:ResourceTag/"], "acme-external-account-binding": ["aws:ResourceTag/"], "certificate": ["aws:ResourceTag/"]}, "application-autoscaling": {"ScalableTarget": ["aws:ResourceTag/"]}, "athena": {"capacity-reservation": ["aws:ResourceTag/"], "datacatalog": ["aws:ResourceTag/"], "session": ["aws:ResourceTag/"], "system-table": ["aws:ResourceTag/"], "workgroup": ["aws:ResourceTag/"]}, "bcm-data-exports": {"billingview": ["aws:ResourceTag/"], "export": ["aws:ResourceTag/"]}, "bcm-pricing-calculator": {"bill-scenario": ["aws:ResourceTag/"], "workload-estimate": ["aws:ResourceTag/"]}, "budgets": {"budget": ["aws:ResourceTag/"], "budgetAction": ["aws:ResourceTag/"]}, "ce": {"anomalymonitor": ["aws:ResourceTag/"], "anomalysubscription": ["aws:ResourceTag/"], "billingview": ["aws:ResourceTag/"], "costcategory": ["aws:ResourceTag/"]}, "cloudformation": {"changeset": ["aws:ResourceTag/"], "stack": ["aws:ResourceTag/"], "stackset": ["aws:ResourceTag/"]}, "cloudfront": {"anycast-ip-list": ["aws:ResourceTag/"], "connection-function": ["aws:ResourceTag/"], "connection-group": ["aws:ResourceTag/"], "distribution": ["aws:ResourceTag/"], "distribution-tenant": ["aws:ResourceTag/"], "function": ["aws:ResourceTag/"], "key-value-store": ["aws:ResourceTag/"], "streaming-distribution": ["aws:ResourceTag/"], "trust-store": ["aws:ResourceTag/"], "vpcorigin": ["aws:ResourceTag/"]}, "cloudtrail": {"channel": ["aws:ResourceTag/"], "dashboard": ["aws:ResourceTag/"], "eventdatastore": ["aws:ResourceTag/"], "trail": ["aws:ResourceTag/"]}, "codebuild": {"project": ["aws:ResourceTag/"], "report-group": ["aws:ResourceTag/"]}, "codepipeline": {"action": ["aws:ResourceTag/"], "actiontype": ["aws:ResourceTag/"], "pipeline": ["aws:ResourceTag/"], "stage": ["aws:ResourceTag/"], "webhook": ["aws:ResourceTag/"]}, "cognito-identity": {"identitypool": ["aws:ResourceTag/"]}, "cognito-idp": {"userpool": ["aws:ResourceTag/"]}, "controltower": {"EnabledBaseline": ["aws:ResourceTag/"], "EnabledControl": ["aws:ResourceTag/"], "LandingZone": ["aws:ResourceTag/"]}, "datasync": {"agent": ["aws:ResourceTag/"], "discoveryjob": ["aws:ResourceTag/"], "location": ["aws:ResourceTag/"], "storagesystem": ["aws:ResourceTag/"], "task": ["aws:ResourceTag/"], "taskexecution": ["aws:ResourceTag/"]}, "dsql": {"Cluster": ["aws:ResourceTag/"], "Stream": ["aws:ResourceTag/"]}, "dynamodb": {"index": ["aws:ResourceTag/"], "stream": ["aws:ResourceTag/"], "table": ["aws:ResourceTag/"]}, "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:ResLine 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}"}, "cloudformation": {"changeset": "arn:${Partition}:cloudformation:${Region}:${Account}:changeSet/${ChangeSetName}/${Id}", "generatedtemplate": "arn:${Partition}:cloudformation:${Region}:${Account}:generatedTemplate/${Id}", "resourcescan": "arn:${Partition}:cloudformation:${Region}:${Account}:resourceScan/${Id}", "stack": "arn:${Partition}:cloudformation:${Region}:${Account}:stack/${StackName}/${Id}", "stackset": "arn:${Partition}:cloudformation:${Region}:${Account}:stackset/${StackSetName}:${Id}", "stackset-target": "arn:${Partition}:cloudformation:${Region}:${Account}:stackset-target/${StackSetTarget}", "type": "arn:${Partition}:cloudformation:${Region}:${Account}:type/resource/${Type}", "typeHook": "arn:${Partition}:cloudformation:${Region}:${Account}:type/hook/${Type}"}, "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:$Line truncated
|
||||
"resourceTagKeys": {"access-analyzer": {"Analyzer": ["aws:ResourceTag/"]}, "acm": {"acme-domain-validation": ["aws:ResourceTag/"], "acme-endpoint": ["aws:ResourceTag/"], "acme-external-account-binding": ["aws:ResourceTag/"], "certificate": ["aws:ResourceTag/"]}, "application-autoscaling": {"ScalableTarget": ["aws:ResourceTag/"]}, "athena": {"capacity-reservation": ["aws:ResourceTag/"], "datacatalog": ["aws:ResourceTag/"], "session": ["aws:ResourceTag/"], "system-table": ["aws:ResourceTag/"], "workgroup": ["aws:ResourceTag/"]}, "bcm-data-exports": {"billingview": ["aws:ResourceTag/"], "export": ["aws:ResourceTag/"]}, "bcm-pricing-calculator": {"bill-estimate": ["aws:ResourceTag/"], "bill-scenario": ["aws:ResourceTag/"], "workload-estimate": ["aws:ResourceTag/"]}, "budgets": {"budget": ["aws:ResourceTag/"], "budgetAction": ["aws:ResourceTag/"]}, "ce": {"anomalymonitor": ["aws:ResourceTag/"], "anomalysubscription": ["aws:ResourceTag/"], "billingview": ["aws:ResourceTag/"], "costcategory": ["aws:ResourceTag/"]}, "cloudformation": {"changeset": ["aws:ResourceTag/"], "stack": ["aws:ResourceTag/"], "stackset": ["aws:ResourceTag/"]}, "cloudfront": {"anycast-ip-list": ["aws:ResourceTag/"], "connection-function": ["aws:ResourceTag/"], "connection-group": ["aws:ResourceTag/"], "distribution": ["aws:ResourceTag/"], "distribution-tenant": ["aws:ResourceTag/"], "function": ["aws:ResourceTag/"], "key-value-store": ["aws:ResourceTag/"], "streaming-distribution": ["aws:ResourceTag/"], "trust-store": ["aws:ResourceTag/"], "vpcorigin": ["aws:ResourceTag/"]}, "cloudtrail": {"channel": ["aws:ResourceTag/"], "dashboard": ["aws:ResourceTag/"], "eventdatastore": ["aws:ResourceTag/"], "trail": ["aws:ResourceTag/"]}, "codebuild": {"project": ["aws:ResourceTag/"], "report-group": ["aws:ResourceTag/"]}, "codepipeline": {"action": ["aws:ResourceTag/"], "actiontype": ["aws:ResourceTag/"], "pipeline": ["aws:ResourceTag/"], "stage": ["aws:ResourceTag/"], "webhook": ["aws:ResourceTag/"]}, "cognito-identity": {"identitypool": ["aws:ResourceTag/"]}, "cognito-idp": {"userpool": ["aws:ResourceTag/"]}, "controltower": {"EnabledBaseline": ["aws:ResourceTag/"], "EnabledControl": ["aws:ResourceTag/"], "LandingZone": ["aws:ResourceTag/"]}, "datasync": {"agent": ["aws:ResourceTag/"], "discoveryjob": ["aws:ResourceTag/"], "location": ["aws:ResourceTag/"], "storagesystem": ["aws:ResourceTag/"], "task": ["aws:ResourceTag/"], "taskexecution": ["aws:ResourceTag/"]}, "dsql": {"Cluster": ["aws:ResourceTag/"], "Stream": ["aws:ResourceTag/"]}, "dynamodb": {"index": ["aws:ResourceTag/"], "stream": ["aws:ResourceTag/"], "table": ["aws:ResourceTag/"]}, "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-rLine 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": {"ssm": ["parameter"], "states": ["statemachine"]},
|
||||
"mintedIds": {"events": ["api-destination", "connection"]},
|
||||
@@ -1528,7 +1528,7 @@
|
||||
"ec2:DetachClassicLinkVpc": {"action": "ec2:DetachClassicLinkVpc", "types": ["instance", "vpc"], "resources": [{"type": "instance", "fill": {"InstanceId": "InstanceId"}}, {"type": "vpc", "fill": {"VpcId": "VpcId"}}]},
|
||||
"ec2:DetachImageWatermark": {"action": "ec2:DetachImageWatermark", "types": ["image"], "resources": [{"type": "image", "fill": {"ImageId": "ImageId"}}]},
|
||||
"ec2:DetachInternetGateway": {"action": "ec2:DetachInternetGateway", "types": ["internet-gateway", "vpc"], "resources": [{"type": "internet-gateway", "fill": {"InternetGatewayId": "InternetGatewayId"}}, {"type": "vpc", "fill": {"VpcId": "VpcId"}}]},
|
||||
"ec2:DetachNetworkInterface": {"action": "ec2:DetachNetworkInterface", "types": ["instance", "network-interface"], "resources": []},
|
||||
"ec2:DetachNetworkInterface": {"action": "ec2:DetachNetworkInterface", "types": ["instance", "network-interface"], "resources": [{"type": "instance", "fill": {}, "find": ["AttachmentId"]}, {"type": "network-interface", "fill": {}, "find": ["AttachmentId"]}]},
|
||||
"ec2:DetachVerifiedAccessTrustProvider": {"action": "ec2:DetachVerifiedAccessTrustProvider", "types": ["verified-access-instance", "verified-access-trust-provider"], "resources": [{"type": "verified-access-instance", "fill": {"VerifiedAccessInstanceId": "VerifiedAccessInstanceId"}}, {"type": "verified-access-trust-provider", "fill": {"VerifiedAccessTrustProviderId": "VerifiedAccessTrustProviderId"}}]},
|
||||
"ec2:DetachVolume": {"action": "ec2:DetachVolume", "types": ["instance", "volume"], "resources": [{"type": "instance", "fill": {"InstanceId": "InstanceId"}}, {"type": "volume", "fill": {"VolumeId": "VolumeId"}}]},
|
||||
"ec2:DetachVpnGateway": {"action": "ec2:DetachVpnGateway", "types": ["vpc", "vpn-gateway"], "resources": [{"type": "vpc", "fill": {"VpcId": "VpcId"}}, {"type": "vpn-gateway", "fill": {"VpnGatewayId": "VpnGatewayId"}}]},
|
||||
@@ -1761,7 +1761,7 @@
|
||||
"ec2:ModifyTransitGatewayPeeringAttachment": {"action": "ec2:ModifyTransitGatewayPeeringAttachment", "types": [], "resources": []},
|
||||
"ec2:ModifyTransitGatewayPolicyTableEntry": {"action": "ec2:ModifyTransitGatewayPolicyTableEntry", "types": ["transit-gateway-policy-table", "transit-gateway-route-table"], "resources": [{"type": "transit-gateway-policy-table", "fill": {"TransitGatewayPolicyTableId": "TransitGatewayPolicyTableId"}}, {"type": "transit-gateway-route-table", "fill": {"TransitGatewayRouteTableId": "TargetRouteTableId"}}]},
|
||||
"ec2:ModifyTransitGatewayPrefixListReference": {"action": "ec2:ModifyTransitGatewayPrefixListReference", "types": ["prefix-list", "transit-gateway-attachment", "transit-gateway-route-table"], "resources": [{"type": "prefix-list", "fill": {"PrefixListId": "PrefixListId"}}, {"type": "transit-gateway-attachment", "fill": {"TransitGatewayAttachmentId": "TransitGatewayAttachmentId"}}, {"type": "transit-gateway-route-table", "fill": {"TransitGatewayRouteTableId": "TransitGatewayRouteTableId"}}]},
|
||||
"ec2:ModifyTransitGatewayVpcAttachment": {"action": "ec2:ModifyTransitGatewayVpcAttachment", "types": ["subnet", "transit-gateway-attachment"], "resources": [{"type": "subnet", "fill": {"SubnetId": "AddSubnetIds[]"}}, {"type": "transit-gateway-attachment", "fill": {"TransitGatewayAttachmentId": "TransitGatewayAttachmentId"}}], "ec2Query": {"AddSubnetIds[]": "AddSubnetIds"}},
|
||||
"ec2:ModifyTransitGatewayVpcAttachment": {"action": "ec2:ModifyTransitGatewayVpcAttachment", "types": ["subnet", "transit-gateway-attachment"], "resources": [{"type": "subnet", "fill": {"SubnetId": "AddSubnetIds[]"}}, {"type": "transit-gateway-attachment", "fill": {"TransitGatewayAttachmentId": "TransitGatewayAttachmentId"}}, {"type": "subnet", "fill": {"SubnetId": "RemoveSubnetIds[]"}}], "ec2Query": {"AddSubnetIds[]": "AddSubnetIds", "RemoveSubnetIds[]": "RemoveSubnetIds"}},
|
||||
"ec2:ModifyVerifiedAccessEndpoint": {"action": "ec2:ModifyVerifiedAccessEndpoint", "types": ["subnet", "verified-access-endpoint", "verified-access-group"], "resources": [{"type": "verified-access-endpoint", "fill": {"VerifiedAccessEndpointId": "VerifiedAccessEndpointId"}}, {"type": "verified-access-group", "fill": {"VerifiedAccessGroupId": "VerifiedAccessGroupId"}}]},
|
||||
"ec2:ModifyVerifiedAccessEndpointPolicy": {"action": "ec2:ModifyVerifiedAccessEndpointPolicy", "types": ["verified-access-endpoint"], "resources": [{"types": ["verified-access-endpoint"], "arn": "SseSpecification.KmsKeyArn"}, {"type": "verified-access-endpoint", "fill": {"VerifiedAccessEndpointId": "VerifiedAccessEndpointId"}}]},
|
||||
"ec2:ModifyVerifiedAccessGroup": {"action": "ec2:ModifyVerifiedAccessGroup", "types": ["verified-access-group", "verified-access-instance"], "resources": [{"type": "verified-access-group", "fill": {"VerifiedAccessGroupId": "VerifiedAccessGroupId"}}, {"type": "verified-access-instance", "fill": {"VerifiedAccessInstanceId": "VerifiedAccessInstanceId"}}]},
|
||||
@@ -1775,7 +1775,7 @@
|
||||
"ec2:ModifyVpcBlockPublicAccessExclusion": {"action": "ec2:ModifyVpcBlockPublicAccessExclusion", "types": ["vpc-block-public-access-exclusion"], "resources": [{"type": "vpc-block-public-access-exclusion", "fill": {"VpcBlockPublicAccessExclusionId": "ExclusionId"}}]},
|
||||
"ec2:ModifyVpcBlockPublicAccessOptions": {"action": "ec2:ModifyVpcBlockPublicAccessOptions", "types": [], "resources": []},
|
||||
"ec2:ModifyVpcEncryptionControl": {"action": "ec2:ModifyVpcEncryptionControl", "types": ["vpc-encryption-control"], "resources": [{"type": "vpc-encryption-control", "fill": {"VpcEncryptionControlId": "VpcEncryptionControlId"}}]},
|
||||
"ec2:ModifyVpcEndpoint": {"action": "ec2:ModifyVpcEndpoint", "types": ["route-table", "security-group", "subnet", "vpc-endpoint"], "resources": [{"type": "route-table", "fill": {"RouteTableId": "AddRouteTableIds[]"}}, {"type": "security-group", "fill": {"SecurityGroupId": "AddSecurityGroupIds[]"}}, {"type": "subnet", "fill": {"SubnetId": "AddSubnetIds[]"}}, {"type": "vpc-endpoint", "fill": {"VpcEndpointId": "VpcEndpointId"}}], "ec2Query": {"AddRouteTableIds[]": "AddRouteTableId", "AddSubnetIds[]": "AddSubnetId", "AddSecurityGroupIds[]": "AddSecurityGroupId"}},
|
||||
"ec2:ModifyVpcEndpoint": {"action": "ec2:ModifyVpcEndpoint", "types": ["route-table", "security-group", "subnet", "vpc-endpoint"], "resources": [{"type": "route-table", "fill": {"RouteTableId": "AddRouteTableIds[]"}}, {"type": "security-group", "fill": {"SecurityGroupId": "AddSecurityGroupIds[]"}}, {"type": "subnet", "fill": {"SubnetId": "AddSubnetIds[]"}}, {"type": "vpc-endpoint", "fill": {"VpcEndpointId": "VpcEndpointId"}}, {"type": "route-table", "fill": {"RouteTableId": "RemoveRouteTableIds[]"}}, {"type": "security-group", "fill": {"SecurityGroupId": "RemoveSecurityGroupIds[]"}}, {"type": "subnet", "fill": {"SubnetId": "RemoveSubnetIds[]"}}], "ec2Query": {"AddRouteTableIds[]": "AddRouteTableId", "RemoveRouteTableIds[]": "RemoveRouteTableId", "AddSubnetIds[]": "AddSubnetId", "RemoveSubnetIds[]": "RemoveSubnetId", "AddSecurityGroupIds[]": "AddSecurityGroupId", "RemoveSecurityGroupIds[]": "RemoveSecurityGroupId"}},
|
||||
"ec2:ModifyVpcEndpointConnectionNotification": {"action": "ec2:ModifyVpcEndpointConnectionNotification", "types": ["vpc-endpoint", "vpc-endpoint-service"], "resources": [{"types": ["vpc-endpoint", "vpc-endpoint-service"], "arn": "ConnectionNotificationArn"}, {"types": ["vpc-endpoint", "vpc-endpoint-service"], "through": "ConnectionNotificationId"}]},
|
||||
"ec2:ModifyVpcEndpointPayerResponsibility": {"action": "ec2:ModifyVpcEndpointPayerResponsibility", "types": ["vpc-endpoint-service"], "resources": [{"type": "vpc-endpoint-service", "fill": {"VpcEndpointServiceId": "ServiceId"}}]},
|
||||
"ec2:ModifyVpcEndpointServiceConfiguration": {"action": "ec2:ModifyVpcEndpointServiceConfiguration", "types": ["vpc-endpoint-service"], "resources": [{"types": ["vpc-endpoint-service"], "arn": "AddGatewayLoadBalancerArns[]"}, {"types": ["vpc-endpoint-service"], "arn": "AddNetworkLoadBalancerArns[]"}, {"types": ["vpc-endpoint-service"], "arn": "RemoveGatewayLoadBalancerArns[]"}, {"types": ["vpc-endpoint-service"], "arn": "RemoveNetworkLoadBalancerArns[]"}, {"type": "vpc-endpoint-service", "fill": {"VpcEndpointServiceId": "ServiceId"}}], "ec2Query": {"AddNetworkLoadBalancerArns[]": "AddNetworkLoadBalancerArn", "RemoveNetworkLoadBalancerArns[]": "RemoveNetworkLoadBalancerArn", "AddGatewayLoadBalancerArns[]": "AddGatewayLoadBalancerArn", "RemoveGatewayLoadBalancerArns[]": "RemoveGatewayLoadBalancerArn"}},
|
||||
@@ -2383,6 +2383,7 @@
|
||||
"events:RemovePermission": {"action": "events:RemovePermission", "types": [], "resources": []},
|
||||
"events:RemoveTargets": {"action": "events:RemoveTargets", "types": ["rule-on-custom-event-bus", "rule-on-default-event-bus"], "resources": [{"type": "rule-on-custom-event-bus", "fill": {"EventBusName": "EventBusName", "RuleName": "Rule"}, "arnOf": {"EventBusName": "event-bus"}, "unlessDefault": {"EventBusName": "event-bus"}}, {"type": "rule-on-default-event-bus", "fill": {"RuleName": "Rule"}, "whenDefault": {"EventBusName": "event-bus"}, "arnOf": {"EventBusName": "event-bus"}}]},
|
||||
"events:RevokeResource": {"action": "events:RevokeResource", "types": ["event-busv2"], "resources": [{"types": ["event-busv2"], "arn": "Arn"}]},
|
||||
"events:RotateWebhookCredentials": {"action": "events:RotateWebhookCredentials", "types": ["event-sourcev2"], "resources": []},
|
||||
"events:StartReplay": {"action": "events:StartReplay", "types": ["archive", "event-bus", "replay"], "resources": [{"types": ["archive", "event-bus", "replay"], "arn": "Destination.Arn"}, {"types": ["archive", "event-bus", "replay"], "arn": "Destination.FilterArns[]"}, {"types": ["archive", "event-bus", "replay"], "arn": "EventSourceArn"}, {"type": "replay", "fill": {"ReplayName": "ReplayName"}, "made": true}]},
|
||||
"events:TagResource": {"action": "events:TagResource", "types": ["event-bus", "event-busv2", "event-sourcev2", "rule-on-custom-event-bus", "rule-on-default-event-bus", "subscriber"], "resources": [{"types": ["event-busv2", "event-sourcev2", "subscriber"], "arn": "ResourceArn", "endpoint": "eventsv2"}, {"types": ["event-bus", "event-busv2", "event-sourcev2", "rule-on-custom-event-bus", "rule-on-default-event-bus", "subscriber"], "arn": "ResourceARN", "endpoint": "events"}]},
|
||||
"events:TestEventPattern": {"action": "events:TestEventPattern", "types": [], "resources": []},
|
||||
@@ -4245,9 +4246,10 @@
|
||||
"route53:AssociateVPCWithHostedZone": {"action": "route53:AssociateVPCWithHostedZone", "types": ["hostedzone"], "resources": [{"type": "hostedzone", "fill": {"Id": "HostedZoneId"}}], "located": {"HostedZoneId": "{Id}"}},
|
||||
"route53:ChangeCidrCollection": {"action": "route53:ChangeCidrCollection", "types": ["cidrcollection"], "resources": [{"type": "cidrcollection", "fill": {"Id": "Id"}}], "located": {"Id": "{CidrCollectionId}"}},
|
||||
"route53:ChangeResourceRecordSets": {"action": "route53:ChangeResourceRecordSets", "types": ["hostedzone"], "resources": [{"type": "hostedzone", "fill": {"Id": "HostedZoneId"}}], "located": {"HostedZoneId": "{Id}"}},
|
||||
"route53:ChangeTagsForResource": {"action": "route53:ChangeTagsForResource", "types": ["healthcheck", "hostedzone"], "resources": [{"type": "healthcheck", "fill": {"Id": "ResourceId"}, "when": {"ResourceType": ["healthcheck"]}}, {"type": "hostedzone", "fill": {"Id": "ResourceId"}, "when": {"ResourceType": ["hostedzone"]}}], "located": {"ResourceId": "{ResourceId}", "ResourceType": "{ResourceType}"}},
|
||||
"route53:ChangeTagsForResource": {"action": "route53:ChangeTagsForResource", "types": ["healthcheck", "healthchecksource", "hostedzone"], "resources": [{"type": "healthcheck", "fill": {"Id": "ResourceId"}, "when": {"ResourceType": ["healthcheck"]}}, {"type": "hostedzone", "fill": {"Id": "ResourceId"}, "when": {"ResourceType": ["hostedzone"]}}], "located": {"ResourceId": "{ResourceId}", "ResourceType": "{ResourceType}"}},
|
||||
"route53:CreateCidrCollection": {"action": "route53:CreateCidrCollection", "types": [], "resources": [], "makes": [{"type": "cidrcollection", "fill": {}}]},
|
||||
"route53:CreateHealthCheck": {"action": "route53:CreateHealthCheck", "types": [], "resources": [], "makes": [{"type": "healthcheck", "fill": {}}]},
|
||||
"route53:CreateHealthCheckSource": {"action": "route53:CreateHealthCheckSource", "types": ["healthchecksource"], "resources": [{"type": "healthchecksource", "fill": {}}]},
|
||||
"route53:CreateHostedZone": {"action": "route53:CreateHostedZone", "types": [], "resources": [], "makes": [{"type": "hostedzone", "fill": {}}]},
|
||||
"route53:CreateKeySigningKey": {"action": "route53:CreateKeySigningKey", "types": ["hostedzone"], "resources": []},
|
||||
"route53:CreateQueryLoggingConfig": {"action": "route53:CreateQueryLoggingConfig", "types": ["hostedzone"], "resources": []},
|
||||
@@ -4260,6 +4262,7 @@
|
||||
"route53:DeactivateKeySigningKey": {"action": "route53:DeactivateKeySigningKey", "types": ["hostedzone"], "resources": [{"type": "hostedzone", "fill": {"Id": "HostedZoneId"}}], "located": {"HostedZoneId": "{HostedZoneId}"}},
|
||||
"route53:DeleteCidrCollection": {"action": "route53:DeleteCidrCollection", "types": ["cidrcollection"], "resources": [{"type": "cidrcollection", "fill": {"Id": "Id"}}], "located": {"Id": "{CidrCollectionId}"}},
|
||||
"route53:DeleteHealthCheck": {"action": "route53:DeleteHealthCheck", "types": ["healthcheck"], "resources": [{"type": "healthcheck", "fill": {"Id": "HealthCheckId"}}], "located": {"HealthCheckId": "{HealthCheckId}"}},
|
||||
"route53:DeleteHealthCheckSource": {"action": "route53:DeleteHealthCheckSource", "types": ["healthchecksource"], "resources": []},
|
||||
"route53:DeleteHostedZone": {"action": "route53:DeleteHostedZone", "types": ["hostedzone"], "resources": [{"type": "hostedzone", "fill": {"Id": "Id"}}], "located": {"Id": "{Id}"}},
|
||||
"route53:DeleteKeySigningKey": {"action": "route53:DeleteKeySigningKey", "types": ["hostedzone"], "resources": [{"type": "hostedzone", "fill": {"Id": "HostedZoneId"}}], "located": {"HostedZoneId": "{HostedZoneId}"}},
|
||||
"route53:DeleteQueryLoggingConfig": {"action": "route53:DeleteQueryLoggingConfig", "types": ["queryloggingconfig"], "resources": [{"type": "queryloggingconfig", "fill": {"Id": "Id"}}], "located": {"Id": "{Id}"}},
|
||||
@@ -4279,6 +4282,7 @@
|
||||
"route53:GetHealthCheck": {"action": "route53:GetHealthCheck", "types": ["healthcheck"], "resources": [{"type": "healthcheck", "fill": {"Id": "HealthCheckId"}}], "located": {"HealthCheckId": "{HealthCheckId}"}},
|
||||
"route53:GetHealthCheckCount": {"action": "route53:GetHealthCheckCount", "types": [], "resources": []},
|
||||
"route53:GetHealthCheckLastFailureReason": {"action": "route53:GetHealthCheckLastFailureReason", "types": ["healthcheck"], "resources": [{"type": "healthcheck", "fill": {"Id": "HealthCheckId"}}], "located": {"HealthCheckId": "{HealthCheckId}"}},
|
||||
"route53:GetHealthCheckSource": {"action": "route53:GetHealthCheckSource", "types": ["healthchecksource"], "resources": []},
|
||||
"route53:GetHealthCheckStatus": {"action": "route53:GetHealthCheckStatus", "types": ["healthcheck"], "resources": [{"type": "healthcheck", "fill": {"Id": "HealthCheckId"}}], "located": {"HealthCheckId": "{HealthCheckId}"}},
|
||||
"route53:GetHostedZone": {"action": "route53:GetHostedZone", "types": ["hostedzone"], "resources": [{"type": "hostedzone", "fill": {"Id": "Id"}}], "located": {"Id": "{Id}"}},
|
||||
"route53:GetHostedZoneCount": {"action": "route53:GetHostedZoneCount", "types": [], "resources": []},
|
||||
@@ -4293,7 +4297,9 @@
|
||||
"route53:ListCidrCollections": {"action": "route53:ListCidrCollections", "types": [], "resources": []},
|
||||
"route53:ListCidrLocations": {"action": "route53:ListCidrLocations", "types": ["cidrcollection"], "resources": [{"type": "cidrcollection", "fill": {"Id": "CollectionId"}}], "located": {"CollectionId": "{CidrCollectionId}"}},
|
||||
"route53:ListGeoLocations": {"action": "route53:ListGeoLocations", "types": [], "resources": []},
|
||||
"route53:ListHealthCheckSources": {"action": "route53:ListHealthCheckSources", "types": [], "resources": []},
|
||||
"route53:ListHealthChecks": {"action": "route53:ListHealthChecks", "types": [], "resources": []},
|
||||
"route53:ListHealthChecksBySource": {"action": "route53:ListHealthChecksBySource", "types": ["healthchecksource"], "resources": []},
|
||||
"route53:ListHostedZones": {"action": "route53:ListHostedZones", "types": [], "resources": []},
|
||||
"route53:ListHostedZonesByName": {"action": "route53:ListHostedZonesByName", "types": [], "resources": []},
|
||||
"route53:ListHostedZonesByVPC": {"action": "route53:ListHostedZonesByVPC", "types": [], "resources": []},
|
||||
@@ -4301,8 +4307,8 @@
|
||||
"route53:ListResourceRecordSetProtections": {"action": "route53:ListResourceRecordSetProtections", "types": ["hostedzone"], "resources": []},
|
||||
"route53:ListResourceRecordSets": {"action": "route53:ListResourceRecordSets", "types": ["hostedzone"], "resources": [{"type": "hostedzone", "fill": {"Id": "HostedZoneId"}}], "located": {"HostedZoneId": "{Id}"}},
|
||||
"route53:ListReusableDelegationSets": {"action": "route53:ListReusableDelegationSets", "types": [], "resources": []},
|
||||
"route53:ListTagsForResource": {"action": "route53:ListTagsForResource", "types": ["healthcheck", "hostedzone"], "resources": [{"type": "healthcheck", "fill": {"Id": "ResourceId"}, "when": {"ResourceType": ["healthcheck"]}}, {"type": "hostedzone", "fill": {"Id": "ResourceId"}, "when": {"ResourceType": ["hostedzone"]}}], "located": {"ResourceId": "{ResourceId}", "ResourceType": "{ResourceType}"}},
|
||||
"route53:ListTagsForResources": {"action": "route53:ListTagsForResources", "types": ["healthcheck", "hostedzone"], "resources": []},
|
||||
"route53:ListTagsForResource": {"action": "route53:ListTagsForResource", "types": ["healthcheck", "healthchecksource", "hostedzone"], "resources": [{"type": "healthcheck", "fill": {"Id": "ResourceId"}, "when": {"ResourceType": ["healthcheck"]}}, {"type": "hostedzone", "fill": {"Id": "ResourceId"}, "when": {"ResourceType": ["hostedzone"]}}], "located": {"ResourceId": "{ResourceId}", "ResourceType": "{ResourceType}"}},
|
||||
"route53:ListTagsForResources": {"action": "route53:ListTagsForResources", "types": ["healthcheck", "healthchecksource", "hostedzone"], "resources": []},
|
||||
"route53:ListTrafficPolicies": {"action": "route53:ListTrafficPolicies", "types": [], "resources": []},
|
||||
"route53:ListTrafficPolicyInstances": {"action": "route53:ListTrafficPolicyInstances", "types": [], "resources": []},
|
||||
"route53:ListTrafficPolicyInstancesByHostedZone": {"action": "route53:ListTrafficPolicyInstancesByHostedZone", "types": ["hostedzone"], "resources": [{"type": "hostedzone", "fill": {"Id": "HostedZoneId"}}], "located": {"HostedZoneId": "?id"}},
|
||||
|
||||
@@ -51,6 +51,22 @@ class RequestResourcesTest {
|
||||
}
|
||||
};
|
||||
|
||||
@Test
|
||||
void detachFindsBothAttachmentEndpointsAndKeepsTypedMissingFallbacks() {
|
||||
String prefix = "arn:aws:ec2:us-east-1:000000000000:";
|
||||
StoredResourceArns stored = mock(StoredResourceArns.class);
|
||||
when(stored.findByMembers("instance", List.of("eni-attach-one"), "us-east-1"))
|
||||
.thenReturn(Optional.of(prefix + "instance/i-one"));
|
||||
when(stored.findByMembers("network-interface", List.of("eni-attach-one"), "us-east-1"))
|
||||
.thenReturn(Optional.of(prefix + "network-interface/eni-one"));
|
||||
assertEquals(List.of(prefix + "instance/i-one", prefix + "network-interface/eni-one"),
|
||||
of("ec2:DetachNetworkInterface", form("AttachmentId=eni-attach-one"), stored));
|
||||
List<String> missing = List.of(prefix + "instance/*", prefix + "network-interface/*");
|
||||
assertEquals(missing, of("ec2:DetachNetworkInterface", form("AttachmentId=eni-attach-missing"), stored));
|
||||
assertEquals(missing, of("ec2:DetachNetworkInterface", form("AttachmentId=eni-attach-one")));
|
||||
assertEquals(missing, of("ec2:DetachNetworkInterface", json("{\"AttachmentId\":\"eni-attach-missing\"}"), stored));
|
||||
}
|
||||
|
||||
@Test
|
||||
void ec2ListsUseSdkWireNamesAndIgnoreForgedQuerySpellings() {
|
||||
String prefix = "arn:aws:ec2:us-east-1:000000000000:";
|
||||
@@ -64,6 +80,39 @@ class RequestResourcesTest {
|
||||
""")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void vpcEndpointModificationChecksAddedAndRemovedResources() {
|
||||
String prefix = "arn:aws:ec2:us-east-1:000000000000:";
|
||||
List<String> expected = List.of(prefix + "route-table/rtb-add", prefix + "security-group/sg-add",
|
||||
prefix + "subnet/subnet-add", prefix + "vpc-endpoint/vpce-one",
|
||||
prefix + "route-table/rtb-remove", prefix + "security-group/sg-remove",
|
||||
prefix + "subnet/subnet-remove");
|
||||
assertEquals(expected, of("ec2:ModifyVpcEndpoint", form("VpcEndpointId=vpce-one"
|
||||
+ "&AddRouteTableId.1=rtb-add&RemoveRouteTableId.1=rtb-remove"
|
||||
+ "&AddSecurityGroupId.1=sg-add&RemoveSecurityGroupId.1=sg-remove"
|
||||
+ "&AddSubnetId.1=subnet-add&RemoveSubnetId.1=subnet-remove")));
|
||||
assertEquals(expected, of("ec2:ModifyVpcEndpoint", json("""
|
||||
{"VpcEndpointId":"vpce-one","AddRouteTableIds":["rtb-add"],
|
||||
"RemoveRouteTableIds":["rtb-remove"],"AddSecurityGroupIds":["sg-add"],
|
||||
"RemoveSecurityGroupIds":["sg-remove"],"AddSubnetIds":["subnet-add"],
|
||||
"RemoveSubnetIds":["subnet-remove"]}
|
||||
""")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void transitGatewayModificationChecksRemovedSubnetsWithItsDistinctWireSpelling() {
|
||||
String prefix = "arn:aws:ec2:us-east-1:000000000000:";
|
||||
List<String> expected = List.of(prefix + "subnet/subnet-add",
|
||||
prefix + "transit-gateway-attachment/tgw-attach-one", prefix + "subnet/subnet-remove");
|
||||
assertEquals(expected, of("ec2:ModifyTransitGatewayVpcAttachment", form(
|
||||
"TransitGatewayAttachmentId=tgw-attach-one&AddSubnetIds.1=subnet-add"
|
||||
+ "&RemoveSubnetIds.1=subnet-remove&RemoveSubnetId.1=subnet-forged")));
|
||||
assertEquals(expected, of("ec2:ModifyTransitGatewayVpcAttachment", json("""
|
||||
{"TransitGatewayAttachmentId":"tgw-attach-one","AddSubnetIds":["subnet-add"],
|
||||
"RemoveSubnetIds":["subnet-remove"]}
|
||||
""")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createVpcChecksItsNewArnAndOnlyThePoolsPresentInTheRequest() {
|
||||
String prefix = "arn:aws:ec2:us-east-1:000000000000:";
|
||||
@@ -162,6 +211,35 @@ class RequestResourcesTest {
|
||||
assertEquals(List.of(arn), of("signer:TagResource", request));
|
||||
}
|
||||
|
||||
@Test
|
||||
void endpointTagTargetsRetainTheCallerPartitionAndEachResource() throws Exception {
|
||||
for (String operation : List.of("ec2:CreateTags", "ec2:DeleteTags")) {
|
||||
List<String> expected = List.of(
|
||||
"arn:aws-us-gov:ec2:us-gov-west-1:111111111111:network-interface/eni-11111111",
|
||||
"*");
|
||||
assertEquals(expected, RequestResources.ofBody(operation,
|
||||
new ObjectMapper().readTree("{\"Resources\":[\"eni-11111111\",\"vpce-22222222\"]}"),
|
||||
"aws-us-gov", "us-gov-west-1", "111111111111", null));
|
||||
assertEquals(expected, RequestResources.of(operation,
|
||||
form("ResourceId.1=eni-11111111&ResourceId.2=vpce-22222222"),
|
||||
"aws-us-gov", "us-gov-west-1", "111111111111", null));
|
||||
assertEquals(List.of("*", "*"), of(operation,
|
||||
form("ResourceId.1=vpce-svc-22222222&ResourceId.2=eni-attach-11111111")));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void endpointDeletionReadsDistinctEndpointsUsingItsActualQueryListName() throws Exception {
|
||||
List<String> expected = List.of(
|
||||
"arn:aws:ec2:us-east-1:000000000000:vpc-endpoint/vpce-11111111",
|
||||
"arn:aws:ec2:us-east-1:000000000000:vpc-endpoint/vpce-22222222");
|
||||
assertEquals(expected, of("ec2:DeleteVpcEndpoints", form("VpcEndpointId.1=vpce-11111111"
|
||||
+ "&VpcEndpointId.2=vpce-22222222&VpcEndpointId.3=vpce-11111111&ResourceId.1=vpce-33333333")));
|
||||
assertEquals(expected, RequestResources.ofBody("ec2:DeleteVpcEndpoints", new ObjectMapper().readTree(
|
||||
"{\"VpcEndpointIds\":[\"vpce-11111111\",\"vpce-22222222\",\"vpce-11111111\"]}"),
|
||||
"aws", "us-east-1", "000000000000", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void generatedIdTargetsReadModelListsAndSerializedQueryNamesInOrder() throws Exception {
|
||||
String instance = "arn:aws:ec2:us-east-1:000000000000:instance/i-one";
|
||||
|
||||
+218
@@ -0,0 +1,218 @@
|
||||
package io.floci.aws.services.ec2;
|
||||
|
||||
import io.floci.aws.core.common.AwsArnUtils;
|
||||
import io.floci.aws.core.common.RequestScopes;
|
||||
import io.floci.aws.services.iam.IamService;
|
||||
import io.floci.aws.services.iam.model.AccessKey;
|
||||
import io.floci.aws.testing.AwsTestClients;
|
||||
import io.floci.aws.testing.SignedIamEnforcementProfile;
|
||||
import io.floci.aws.testing.SignedIamUsers;
|
||||
import io.quarkus.test.common.http.TestHTTPResource;
|
||||
import io.quarkus.test.junit.QuarkusTest;
|
||||
import io.quarkus.test.junit.TestProfile;
|
||||
import jakarta.inject.Inject;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
import software.amazon.awssdk.regions.Region;
|
||||
import software.amazon.awssdk.services.ec2.Ec2Client;
|
||||
import software.amazon.awssdk.services.ec2.model.Ec2Exception;
|
||||
import software.amazon.awssdk.services.ec2.model.Instance;
|
||||
import software.amazon.awssdk.services.ec2.model.InstanceType;
|
||||
|
||||
import java.net.URI;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
@QuarkusTest
|
||||
@TestProfile(SignedIamEnforcementProfile.class)
|
||||
class Ec2DetachNetworkInterfaceIamIntegrationTest {
|
||||
@TestHTTPResource("/")
|
||||
URI endpoint;
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"us-east-1", "us-gov-west-1", "cn-north-1"})
|
||||
void bothEndpointGrantsPermitDetach(String regionName) throws Exception {
|
||||
Region region = Region.of(regionName);
|
||||
try (Ec2Client admin = admin(region); Attachment fixture = attach(admin)) {
|
||||
String policy = policy("Allow", List.of(arn(region, "instance/" + fixture.instanceId()),
|
||||
arn(region, "network-interface/" + fixture.interfaceId())));
|
||||
try (SignedIamUsers.User user = SignedIamUsers.createUser(endpoint, "detach-", "detach", policy);
|
||||
Ec2Client caller = caller(user, region)) {
|
||||
assertTrue(caller.detachNetworkInterface(r -> r.attachmentId(fixture.attachmentId()))
|
||||
.sdkHttpResponse().isSuccessful());
|
||||
assertNull(admin.describeNetworkInterfaces(r -> r.networkInterfaceIds(fixture.interfaceId()))
|
||||
.networkInterfaces().getFirst().attachment());
|
||||
assertTrue(instance(admin, fixture.instanceId()).networkInterfaces().stream()
|
||||
.noneMatch(eni -> fixture.interfaceId().equals(eni.networkInterfaceId())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"instance", "network-interface", "explicit-deny"})
|
||||
void missingEndpointGrantOrExplicitDenyPreservesAttachment(String grant) throws Exception {
|
||||
Region region = Region.US_EAST_1;
|
||||
try (Ec2Client admin = admin(region); Attachment fixture = attach(admin)) {
|
||||
String instanceArn = arn(region, "instance/" + fixture.instanceId());
|
||||
String interfaceArn = arn(region, "network-interface/" + fixture.interfaceId());
|
||||
String policy = "explicit-deny".equals(grant)
|
||||
? "{\"Version\":\"2012-10-17\",\"Statement\":["
|
||||
+ statement("Allow", List.of("*")) + ","
|
||||
+ statement("Deny", List.of(interfaceArn)) + "]}"
|
||||
: policy("Allow", List.of("instance".equals(grant) ? instanceArn : interfaceArn));
|
||||
try (SignedIamUsers.User user = SignedIamUsers.createUser(endpoint, "detach-deny-", "detach", policy);
|
||||
Ec2Client caller = caller(user, region)) {
|
||||
error(caller, fixture.attachmentId(), "UnauthorizedOperation", 403);
|
||||
fixture.assertAttached();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void typedWildcardFallbackPreservesMissingAttachmentError() throws Exception {
|
||||
Region region = Region.US_EAST_1;
|
||||
String policy = policy("Allow", List.of(arn(region, "instance/*"), arn(region, "network-interface/*")));
|
||||
try (SignedIamUsers.User user = SignedIamUsers.createUser(endpoint, "detach-missing-", "detach", policy);
|
||||
Ec2Client caller = caller(user, region)) {
|
||||
error(caller, "eni-attach-0123456789abcdef0", "InvalidAttachmentID.NotFound", 400);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void foreignRegionAttachmentCannotSupplyLocalAuthorizationResources() throws Exception {
|
||||
try (Ec2Client remote = admin(Region.US_WEST_2); Attachment fixture = attach(remote)) {
|
||||
String remotePolicy = policy("Allow", List.of(arn(Region.US_WEST_2, "instance/" + fixture.instanceId()),
|
||||
arn(Region.US_WEST_2, "network-interface/" + fixture.interfaceId())));
|
||||
try (SignedIamUsers.User user = SignedIamUsers.createUser(endpoint, "detach-region-", "detach", remotePolicy);
|
||||
Ec2Client caller = caller(user, Region.US_EAST_1)) {
|
||||
error(caller, fixture.attachmentId(), "UnauthorizedOperation", 403);
|
||||
String local = policy("Allow", List.of(arn(Region.US_EAST_1, "instance/*"),
|
||||
arn(Region.US_EAST_1, "network-interface/*")));
|
||||
SignedIamUsers.iam(endpoint, "PutUserPolicy", Map.of("UserName", user.name(),
|
||||
"PolicyName", "detach", "PolicyDocument", local)).then().statusCode(200);
|
||||
error(caller, fixture.attachmentId(), "InvalidAttachmentID.NotFound", 400);
|
||||
fixture.assertAttached();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Inject
|
||||
IamService iam;
|
||||
|
||||
@Test
|
||||
void foreignAccountCannotResolveOrDetachTheOwnersAttachment() throws Exception {
|
||||
String foreign = "111122223333";
|
||||
String name = "detach-foreign-" + UUID.randomUUID();
|
||||
try (Ec2Client admin = admin(Region.US_EAST_1); Attachment fixture = attach(admin)) {
|
||||
RequestScopes.runAs(foreign, "us-east-1", () -> iam.createUser(name, "/"));
|
||||
try {
|
||||
String ownerPolicy = policy("Allow", List.of(arn(Region.US_EAST_1, "instance/" + fixture.instanceId()),
|
||||
arn(Region.US_EAST_1, "network-interface/" + fixture.interfaceId())));
|
||||
RequestScopes.runAs(foreign, "us-east-1", () -> iam.putUserPolicy(name, "detach", ownerPolicy));
|
||||
AccessKey key = RequestScopes.callAs(foreign, "us-east-1", () -> iam.createAccessKey(name));
|
||||
try (Ec2Client caller = AwsTestClients.create(Ec2Client.builder(), key.getAccessKeyId(),
|
||||
key.getSecretAccessKey(), Region.US_EAST_1, endpoint)) {
|
||||
error(caller, fixture.attachmentId(), "UnauthorizedOperation", 403);
|
||||
fixture.assertAttached();
|
||||
String localPolicy = policy("Allow", List.of(
|
||||
AwsArnUtils.Arn.of("ec2", "us-east-1", foreign, "instance/*").toString(),
|
||||
AwsArnUtils.Arn.of("ec2", "us-east-1", foreign, "network-interface/*").toString()));
|
||||
RequestScopes.runAs(foreign, "us-east-1", () -> iam.putUserPolicy(name, "detach", localPolicy));
|
||||
error(caller, fixture.attachmentId(), "InvalidAttachmentID.NotFound", 400);
|
||||
fixture.assertAttached();
|
||||
}
|
||||
} finally {
|
||||
RequestScopes.runAs(foreign, "us-east-1", () -> {
|
||||
for (AccessKey key : iam.listAccessKeys(name)) {
|
||||
iam.deleteAccessKey(name, key.getAccessKeyId());
|
||||
}
|
||||
for (String policyName : iam.listUserPolicies(name)) {
|
||||
iam.deleteUserPolicy(name, policyName);
|
||||
}
|
||||
iam.deleteUser(name);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Attachment attach(Ec2Client admin) {
|
||||
String instanceId = admin.runInstances(r -> r.imageId("ami-1234567890abcdef0")
|
||||
.instanceType(InstanceType.T3_MICRO).minCount(1).maxCount(1)).instances().getFirst().instanceId();
|
||||
String interfaceId = null;
|
||||
try {
|
||||
await().atMost(Duration.ofSeconds(10)).untilAsserted(() ->
|
||||
assertEquals("running", instance(admin, instanceId).state().nameAsString()));
|
||||
String subnet = instance(admin, instanceId).subnetId();
|
||||
interfaceId = admin.createNetworkInterface(r -> r.subnetId(subnet)).networkInterface().networkInterfaceId();
|
||||
String id = interfaceId;
|
||||
String attachmentId = admin.attachNetworkInterface(r -> r.networkInterfaceId(id)
|
||||
.instanceId(instanceId).deviceIndex(1)).attachmentId();
|
||||
return new Attachment(admin, instanceId, interfaceId, attachmentId);
|
||||
} catch (RuntimeException | AssertionError failure) {
|
||||
try {
|
||||
new Attachment(admin, instanceId, interfaceId, null).close();
|
||||
} catch (RuntimeException | AssertionError cleanup) {
|
||||
failure.addSuppressed(cleanup);
|
||||
}
|
||||
throw failure;
|
||||
}
|
||||
}
|
||||
|
||||
private record Attachment(Ec2Client admin, String instanceId, String interfaceId, String attachmentId)
|
||||
implements AutoCloseable {
|
||||
void assertAttached() {
|
||||
assertEquals(attachmentId, admin.describeNetworkInterfaces(r -> r.networkInterfaceIds(interfaceId))
|
||||
.networkInterfaces().getFirst().attachment().attachmentId());
|
||||
assertTrue(instance(admin, instanceId).networkInterfaces().stream()
|
||||
.anyMatch(eni -> interfaceId.equals(eni.networkInterfaceId())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
admin.terminateInstances(r -> r.instanceIds(instanceId));
|
||||
if (interfaceId != null) {
|
||||
admin.deleteNetworkInterface(r -> r.networkInterfaceId(interfaceId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Ec2Client admin(Region region) {
|
||||
return AwsTestClients.create(Ec2Client.builder(), "test", region, endpoint);
|
||||
}
|
||||
|
||||
private Ec2Client caller(SignedIamUsers.User user, Region region) {
|
||||
return AwsTestClients.create(Ec2Client.builder(), user.accessKeyId(), user.secretAccessKey(), region, endpoint);
|
||||
}
|
||||
|
||||
private static Instance instance(Ec2Client client, String id) {
|
||||
return client.describeInstances(r -> r.instanceIds(id)).reservations().getFirst().instances().getFirst();
|
||||
}
|
||||
|
||||
private static void error(Ec2Client caller, String id, String code, int status) {
|
||||
Ec2Exception error = assertThrows(Ec2Exception.class, () -> caller.detachNetworkInterface(r -> r.attachmentId(id)));
|
||||
assertEquals(status, error.statusCode());
|
||||
assertEquals(code, error.awsErrorDetails().errorCode());
|
||||
}
|
||||
|
||||
private static String arn(Region region, String resource) {
|
||||
return AwsArnUtils.Arn.of("ec2", region.id(), "000000000000", resource).toString();
|
||||
}
|
||||
|
||||
private static String policy(String effect, List<String> resources) {
|
||||
return "{\"Version\":\"2012-10-17\",\"Statement\":[" + statement(effect, resources) + "]}";
|
||||
}
|
||||
|
||||
private static String statement(String effect, List<String> resources) {
|
||||
return "{\"Effect\":\"" + effect + "\",\"Action\":\"ec2:DetachNetworkInterface\",\"Resource\":[\""
|
||||
+ String.join("\",\"", resources) + "\"]}";
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.github.dockerjava.api.DockerClient;
|
||||
import com.github.dockerjava.api.command.ListNetworksCmd;
|
||||
import io.floci.aws.config.EmulatorConfig;
|
||||
import io.floci.aws.core.common.AwsArnUtils;
|
||||
import io.floci.aws.core.common.AwsException;
|
||||
import io.floci.aws.core.common.AwsPartitions;
|
||||
import io.floci.aws.core.common.PaginatedResult;
|
||||
@@ -135,6 +136,7 @@ import static org.junit.jupiter.api.Assertions.assertInstanceOf;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertSame;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
@@ -665,6 +667,59 @@ class Ec2ServiceTest {
|
||||
List.of(data), false, null, null);
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"us-east-1", "us-gov-west-1", "cn-north-1"})
|
||||
void attachmentArnLookupStaysInTheCallerAccountAndRegion(String region) {
|
||||
String owner = "000000000000";
|
||||
String other = "111111111111";
|
||||
AccountAwareStorageBackend<NetworkInterface> interfaces = AccountAwareStorageBackend.inMemory(owner);
|
||||
Ec2Service service = spy(new Ec2Service(mockConfig(true), mock(Ec2ContainerManager.class),
|
||||
mock(Ec2PortForwardManager.class), mock(AmiImageResolver.class), mock(Ec2ImageCatalog.class),
|
||||
new Ec2InstanceTypeCatalog(),
|
||||
new InMemoryStorageFactory(Map.of("ec2-network-interfaces.json", interfaces))));
|
||||
NetworkInterface eni = new NetworkInterface();
|
||||
eni.setNetworkInterfaceId("eni-11111111");
|
||||
eni.setOwnerId(owner);
|
||||
NetworkInterfaceAttachment attachment = new NetworkInterfaceAttachment();
|
||||
attachment.setAttachmentId("eni-attach-11111111");
|
||||
attachment.setInstanceId("i-11111111");
|
||||
eni.setAttachment(attachment);
|
||||
interfaces.putForAccount(owner, region + "::" + eni.getNetworkInterfaceId(), eni);
|
||||
Ec2StoredResourceArns stored = new Ec2StoredResourceArns(service);
|
||||
|
||||
assertEquals(attachmentArns(region, owner, "i-11111111", "eni-11111111"),
|
||||
service.networkInterfaceAttachmentArns(region, attachment.getAttachmentId()));
|
||||
assertEquals(Optional.of(attachmentArns(region, owner, "i-11111111", "eni-11111111").getFirst()),
|
||||
stored.findByMembers("instance", List.of(attachment.getAttachmentId()), region));
|
||||
assertEquals(Optional.of(attachmentArns(region, owner, "i-11111111", "eni-11111111").getLast()),
|
||||
stored.findByMembers("network-interface", List.of(attachment.getAttachmentId()), region));
|
||||
assertTrue(stored.findByMembers("instance", List.of("eni-attach-missing"), region).isEmpty());
|
||||
assertTrue(stored.findByMembers("instance", List.of(), region).isEmpty());
|
||||
assertSame(attachment, eni.getAttachment(), "authorization lookup must not detach the interface");
|
||||
assertEquals(List.of(),
|
||||
service.networkInterfaceAttachmentArns("eu-west-1", attachment.getAttachmentId()));
|
||||
assertEquals(List.of(),
|
||||
service.networkInterfaceAttachmentArns(region, "eni-attach-missing"));
|
||||
doReturn(other).when(service).callerAccountId();
|
||||
assertEquals(List.of(),
|
||||
service.networkInterfaceAttachmentArns(region, attachment.getAttachmentId()));
|
||||
assertTrue(stored.findByMembers("instance", List.of(attachment.getAttachmentId()), region).isEmpty());
|
||||
assertTrue(stored.findByMembers("network-interface", List.of(attachment.getAttachmentId()), region).isEmpty());
|
||||
assertTrue(stored.through("UnrelatedId", attachment.getAttachmentId(), region).isEmpty());
|
||||
assertTrue(service.networkInterfaceAttachmentArns(region, null).isEmpty());
|
||||
assertTrue(service.networkInterfaceAttachmentArns(region, " ").isEmpty());
|
||||
doReturn(owner).when(service).callerAccountId();
|
||||
eni.setAttachment(null);
|
||||
interfaces.putForAccount(owner, region + "::" + eni.getNetworkInterfaceId(), eni);
|
||||
assertEquals(List.of(),
|
||||
service.networkInterfaceAttachmentArns(region, attachment.getAttachmentId()));
|
||||
}
|
||||
|
||||
private static List<String> attachmentArns(String region, String account, String instance, String eni) {
|
||||
return List.of(AwsArnUtils.Arn.of("ec2", region, account, "instance/" + instance).toString(),
|
||||
AwsArnUtils.Arn.of("ec2", region, account, "network-interface/" + eni).toString());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"grant-before-detach", "detach-before-grant", "grant-before-describe"})
|
||||
void interfacePermissionOperationsShareAttachmentSynchronization(String order) throws Exception {
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
package io.floci.aws.services.iam;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.ws.rs.container.ContainerRequestContext;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.MultivaluedHashMap;
|
||||
import jakarta.ws.rs.core.UriInfo;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* The resources network interface and VPC endpoint requests are checked on: the types AWS's Service
|
||||
* Authorization Reference gives each action, for the resources the request names. And what that
|
||||
* buys: Amazon OpenSearch Service's service-linked role policy, which scopes its EC2 grants to
|
||||
* resource ARNs, authorizes the calls the service makes in the customer's account with it, and still
|
||||
* refuses what lies outside its patterns.
|
||||
*/
|
||||
class Ec2NetworkInterfaceResourceArnTest {
|
||||
|
||||
private static final String CUSTOMER = "111111111111";
|
||||
private static final String PREFIX = "arn:aws:ec2:eu-west-1:" + CUSTOMER + ":";
|
||||
|
||||
private final IamPolicyEvaluator evaluator = new IamPolicyEvaluator(new ObjectMapper());
|
||||
|
||||
@Test
|
||||
void createNetworkInterfaceNamesTheInterfaceItsSubnetAndEachGroup() {
|
||||
assertResources(List.of(PREFIX + "network-interface/*", PREFIX + "subnet/subnet-11111111",
|
||||
PREFIX + "security-group/sg-11111111", PREFIX + "security-group/sg-22222222"),
|
||||
resources("CreateNetworkInterface", "SubnetId=subnet-11111111&SecurityGroupId.1=sg-11111111"
|
||||
+ "&SecurityGroupId.2=sg-22222222&Description=web"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void interfaceActionsNameTheInterface() {
|
||||
for (String operation : List.of("DeleteNetworkInterface", "CreateNetworkInterfacePermission")) {
|
||||
assertResources(List.of(PREFIX + "network-interface/eni-11111111"),
|
||||
resources(operation, "NetworkInterfaceId=eni-11111111&AwsAccountId=222222222222"
|
||||
+ "&Permission=INSTANCE-ATTACH"), operation);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void attachNamesTheInstanceAndTheInterface() {
|
||||
assertResources(List.of(PREFIX + "instance/i-11111111", PREFIX + "network-interface/eni-11111111"),
|
||||
resources("AttachNetworkInterface", "NetworkInterfaceId=eni-11111111&InstanceId=i-11111111"
|
||||
+ "&DeviceIndex=1"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anAttachmentNoServiceResolvesIsCheckedOnTheAccountsInstancesAndInterfaces() {
|
||||
assertResources(List.of(PREFIX + "instance/*", PREFIX + "network-interface/*"),
|
||||
resources("DetachNetworkInterface", "AttachmentId=eni-attach-11111111&Force=true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void vpcEndpointActionsNameTheEndpointAndWhatItIsPlacedIn() {
|
||||
assertResources(List.of(PREFIX + "vpc-endpoint/*", PREFIX + "vpc/vpc-11111111", PREFIX + "subnet/subnet-11111111",
|
||||
PREFIX + "security-group/sg-11111111", PREFIX + "route-table/rtb-11111111"),
|
||||
resources("CreateVpcEndpoint", "VpcId=vpc-11111111&ServiceName=com.amazonaws.vpce.x"
|
||||
+ "&SubnetId.1=subnet-11111111&SecurityGroupId.1=sg-11111111&RouteTableId.1=rtb-11111111"));
|
||||
assertResources(List.of(PREFIX + "vpc-endpoint/vpce-11111111", PREFIX + "subnet/subnet-22222222",
|
||||
PREFIX + "security-group/sg-33333333"),
|
||||
resources("ModifyVpcEndpoint", "VpcEndpointId=vpce-11111111&AddSubnetId.1=subnet-22222222"
|
||||
+ "&RemoveSecurityGroupId.1=sg-33333333"));
|
||||
assertResources(List.of(PREFIX + "vpc-endpoint/vpce-11111111", PREFIX + "vpc-endpoint/vpce-22222222"),
|
||||
resources("DeleteVpcEndpoints", "VpcEndpointId.1=vpce-11111111&VpcEndpointId.2=vpce-22222222"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void tagRequestsNameKnownInterfacesAndLeaveUncoveredEndpointIdsOnTheWildcard() {
|
||||
assertResources(List.of(PREFIX + "network-interface/eni-11111111", "*"),
|
||||
resources("CreateTags", "ResourceId.1=eni-11111111&ResourceId.2=vpce-11111111"
|
||||
+ "&Tag.1.Key=Name&Tag.1.Value=web"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void actionsAwsChecksOnNoResourceTypeStayOnTheWildcard() {
|
||||
for (String operation : List.of("DescribeNetworkInterfaces", "DescribeNetworkInterfacePermissions")) {
|
||||
assertResources(List.of("*"), resources(operation, "NetworkInterfaceId.1=eni-11111111"
|
||||
+ "&NetworkInterfaceId=eni-11111111"), operation);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void theOpenSearchServiceLinkedRolePolicyAuthorizesTheServicesInterfaceCalls() {
|
||||
List<String> policy = List.of(openSearchRolePolicy());
|
||||
List<String> create = resources("CreateNetworkInterface",
|
||||
"SubnetId=subnet-11111111&SecurityGroupId.1=sg-11111111");
|
||||
for (String resource : create) {
|
||||
assertEquals(IamPolicyEvaluator.Decision.ALLOW,
|
||||
evaluator.evaluate(policy, "ec2:CreateNetworkInterface", resource), resource);
|
||||
}
|
||||
for (String operation : List.of("DeleteNetworkInterface", "CreateTags")) {
|
||||
for (String resource : resources(operation, "NetworkInterfaceId=eni-11111111&ResourceId.1=eni-11111111")) {
|
||||
assertEquals(IamPolicyEvaluator.Decision.ALLOW,
|
||||
evaluator.evaluate(policy, "ec2:" + operation, resource), operation + " " + resource);
|
||||
}
|
||||
}
|
||||
// Checked on the wildcard, as before, the same grant matches none of its patterns.
|
||||
assertEquals(IamPolicyEvaluator.Decision.DENY, evaluator.evaluate(policy, "ec2:CreateNetworkInterface", "*"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theSamePolicyStillRefusesWhatLiesOutsideItsPatterns() {
|
||||
List<String> policy = List.of(openSearchRolePolicy());
|
||||
// CreateNetworkInterface is granted on interfaces, subnets and groups only.
|
||||
assertEquals(IamPolicyEvaluator.Decision.DENY,
|
||||
evaluator.evaluate(policy, "ec2:CreateNetworkInterface", PREFIX + "route-table/rtb-11111111"));
|
||||
// The policy grants no AttachNetworkInterface.
|
||||
for (String resource : resources("AttachNetworkInterface", "NetworkInterfaceId=eni-11111111&InstanceId=i-1")) {
|
||||
assertEquals(IamPolicyEvaluator.Decision.DENY,
|
||||
evaluator.evaluate(policy, "ec2:AttachNetworkInterface", resource), resource);
|
||||
}
|
||||
// Its CreateTags grant covers interfaces, and endpoints only while they are created.
|
||||
assertEquals(IamPolicyEvaluator.Decision.DENY,
|
||||
evaluator.evaluate(policy, "ec2:CreateTags", PREFIX + "instance/i-11111111"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void theEndpointItselfNeedsTheRequestTagThePolicyNames() {
|
||||
List<String> policy = List.of(openSearchRolePolicy());
|
||||
String endpoint = PREFIX + "vpc-endpoint/*";
|
||||
assertEquals(IamPolicyEvaluator.Decision.DENY,
|
||||
evaluator.simulateCustomPolicy(policy, "ec2:CreateVpcEndpoint", endpoint, Map.of()));
|
||||
assertEquals(IamPolicyEvaluator.Decision.ALLOW,
|
||||
evaluator.simulateCustomPolicy(policy, "ec2:CreateVpcEndpoint", endpoint,
|
||||
Map.of("aws:RequestTag/OpenSearchManaged", List.of("true"))));
|
||||
assertEquals(IamPolicyEvaluator.Decision.ALLOW,
|
||||
evaluator.evaluate(policy, "ec2:CreateVpcEndpoint", PREFIX + "subnet/subnet-11111111"));
|
||||
}
|
||||
|
||||
private static String openSearchRolePolicy() {
|
||||
return AwsManagedPolicies.POLICIES.stream()
|
||||
.filter(policy -> "AmazonOpenSearchServiceRolePolicy".equals(policy.name()))
|
||||
.findFirst()
|
||||
.orElseThrow()
|
||||
.document();
|
||||
}
|
||||
|
||||
private static void assertResources(List<String> expected, List<String> actual) {
|
||||
assertEquals(expected.stream().sorted().toList(), actual.stream().sorted().toList());
|
||||
}
|
||||
|
||||
private static void assertResources(List<String> expected, List<String> actual, String message) {
|
||||
assertEquals(expected.stream().sorted().toList(), actual.stream().sorted().toList(), message);
|
||||
}
|
||||
|
||||
private List<String> resources(String operation, String body) {
|
||||
ContainerRequestContext context = mock(ContainerRequestContext.class);
|
||||
UriInfo uri = mock(UriInfo.class);
|
||||
Map<String, Object> properties = new HashMap<>();
|
||||
when(context.getUriInfo()).thenReturn(uri);
|
||||
when(uri.getPath()).thenReturn("/");
|
||||
when(uri.getQueryParameters()).thenReturn(new MultivaluedHashMap<>());
|
||||
when(context.getMediaType()).thenReturn(MediaType.APPLICATION_FORM_URLENCODED_TYPE);
|
||||
when(context.getEntityStream()).thenReturn(
|
||||
new ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_8)));
|
||||
doAnswer(invocation -> {
|
||||
when(context.getEntityStream()).thenReturn(invocation.getArgument(0));
|
||||
return null;
|
||||
}).when(context).setEntityStream(any());
|
||||
when(context.getProperty(any())).thenAnswer(invocation -> properties.get(invocation.getArgument(0)));
|
||||
doAnswer(invocation -> {
|
||||
properties.put(invocation.getArgument(0), invocation.getArgument(1));
|
||||
return null;
|
||||
}).when(context).setProperty(any(), any());
|
||||
return new ResourceArnBuilder().buildResources("ec2", "ec2:" + operation, context,
|
||||
"eu-west-1", CUSTOMER, "aws");
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,8 @@ network resources): a resource ARN's variable names its list member, with the re
|
||||
it acts on (`Resources`) as a fallback. A list a type's variable names is the request's targets only when the
|
||||
request names nothing else the action acts on. Botocore supplies its serialized EC2 Query name (including queryName
|
||||
and capitalization), and the id prefix botocore gives each type, in its documentation ("the instance ID (for
|
||||
example, i-0123456789abcdef0)") or its examples (`"GroupId": "sg-903004f8"`), distinguishes them. Each generated
|
||||
example, i-0123456789abcdef0)") or its examples (`"GroupId": "sg-903004f8"`), distinguishes them. Cited EC2 API
|
||||
examples supply a missing VPC endpoint prefix. Each generated
|
||||
`targets` entry preserves the request's order and duplicates, including a wildcard for each unsupported id; only
|
||||
resolved ARNs use the corresponding target's condition context. Every other request of those namespaces is read by
|
||||
the ordinary rules, its EC2 Query wire names (`ec2Query`) from botocore. `resourceTagKeys` gives every type of the
|
||||
@@ -228,7 +229,10 @@ whose ARN is all an id its service mints is named by the members its service fin
|
||||
documents as its key ("Scalable targets are uniquely identified by the combination of resource ID, scalable
|
||||
dimension, and namespace"), or else a name of it where no request of the namespace gives the id (a Redshift
|
||||
Serverless namespace by its `namespaceName`), and the reader asks the service for the ARN they find, or else checks
|
||||
the ARN with its id open, as for a create. A member naming a resource the reference gives no type, whose botocore
|
||||
the ARN with its id open, as for a create. An id of a nested record also finds the containing resource and the
|
||||
resource ids held beside it: a NetworkInterface's Attachment holds AttachmentId beside InstanceId. Each selected
|
||||
reference type is found by that id, with the same typed caller fallback when no stored record exists. A member
|
||||
naming a resource the reference gives no type, whose botocore
|
||||
record holds it beside members named after types the action acts on, names those through it (`through`): a Data
|
||||
API session's `SessionData` holds its `SessionId` beside the `ClusterIdentifier` or `WorkgroupName` it runs on, and
|
||||
the reader asks the service for the ARN of the caller's resource at the other end, or else names none. A member
|
||||
@@ -485,9 +489,10 @@ KNOWN_VARIABLES = {"Partition", "Region", "Account"}
|
||||
# Floci's coverage of id-list namespaces: the types of each it reads by id, which ResourceArnBuilder and the condition
|
||||
# resolver resolve with their stored tags. It states no AWS fact: the model supplies each list member and its wire
|
||||
# name, the Service Reference the action's types and ARN formats, and botocore's documentation and examples the id
|
||||
# prefix of each type (`id_prefixes`). Other ids keep a wildcard entry until their coverage grows; every request
|
||||
# prefix of each type (`id_prefixes`), supplemented by cited API examples when botocore has none. Other ids keep
|
||||
# a wildcard entry until their coverage grows; every request
|
||||
# without those lists is read by the ordinary rules.
|
||||
ID_TARGETS = {"ec2": ("instance", "network-acl", "network-interface", "route-table", "security-group")}
|
||||
ID_TARGETS = {"ec2": ("instance", "network-acl", "network-interface", "route-table", "security-group", "vpc-endpoint")}
|
||||
# An ARN format's account given as `${AccountId}`, the account `${Account}` gives in every other format.
|
||||
ACCOUNT_ID_SLOT_RE = re.compile(r"^(arn:[^:]*:[^:]*:[^:]*:)\$\{AccountId}:")
|
||||
VARIABLE_RE = re.compile(r"\$\{(\w+)}")
|
||||
@@ -2050,7 +2055,8 @@ def also_filled(types: list[str], members: dict[str, str], filled: dict[str, dic
|
||||
<p>A re-encryption decrypts under the key its path names and encrypts under the key its body names, so both are
|
||||
acted on and both are checked. A member that names a resource of the type, with a word before it saying which of
|
||||
them it is, fills the type's variable as well, when botocore's shape for it takes an alias as well as the type's
|
||||
ARN, which the service resolves (Payment Cryptography's `KeyArnOrKeyAliasType`)."""
|
||||
ARN, which the service resolves (Payment Cryptography's `KeyArnOrKeyAliasType`). Paired Add/Remove ID lists
|
||||
of the same modeled shape also name separate resources, including the resources being removed."""
|
||||
found = []
|
||||
for kind in types:
|
||||
if kind not in kept or kind not in filled or not filled[kind]:
|
||||
@@ -2068,7 +2074,13 @@ def also_filled(types: list[str], members: dict[str, str], filled: dict[str, dic
|
||||
and stem(member).endswith(stem(variable)) and stem(selected).endswith(stem(variable))
|
||||
and (shapes or {}).get(member) == (shapes or {}).get(selected)
|
||||
and stem((shapes or {}).get(member, "")) == stem(variable))
|
||||
if not sibling_id and (member not in aliased or not names_type(member, kind_stem)):
|
||||
paired_lists = (len(filled[kind]) == 1 and members[member].endswith("[]")
|
||||
and members.get(selected, "").endswith("[]")
|
||||
and {member.removesuffix("s"), selected.removesuffix("s")}
|
||||
== {"Add" + variable, "Remove" + variable}
|
||||
and (shapes or {}).get(member) is not None
|
||||
and shapes[member] == shapes.get(selected))
|
||||
if not sibling_id and not paired_lists and (member not in aliased or not names_type(member, kind_stem)):
|
||||
continue
|
||||
if not compatible(member, variable):
|
||||
continue
|
||||
@@ -2162,7 +2174,9 @@ def id_prefixes(models: dict[str, dict], kinds: tuple[str, ...],
|
||||
def namespace_id_prefixes(namespace: str, models: dict[str, dict],
|
||||
examples: dict[str, dict] | None = None) -> dict[str, str] | None:
|
||||
"""`id_prefixes` of the types `ID_TARGETS` reads by id in the namespace; None for a namespace it reads none of."""
|
||||
return id_prefixes(models, ID_TARGETS[namespace], examples) if namespace in ID_TARGETS else None
|
||||
if namespace not in ID_TARGETS:
|
||||
return None
|
||||
return id_prefixes(models, ID_TARGETS[namespace], examples)
|
||||
|
||||
|
||||
def id_targets(operation: str, types: list[str], formats: dict[str, str], models: dict[str, dict],
|
||||
@@ -2174,7 +2188,7 @@ def id_targets(operation: str, types: list[str], formats: dict[str, str], models
|
||||
configured = ID_TARGETS.get(namespace_of(operation))
|
||||
if configured is None:
|
||||
return None
|
||||
known = known if known is not None else id_prefixes(models, configured)
|
||||
known = known if known is not None else namespace_id_prefixes(namespace_of(operation), models)
|
||||
found = None
|
||||
for model in models.values():
|
||||
spec = model["operations"].get(operation.split(":", 1)[1], {})
|
||||
@@ -2514,6 +2528,7 @@ def read_resources(operation: str, types: list[str], formats: dict[str, str], mo
|
||||
requested_members(models)),
|
||||
types, members, through_members(models, formats))
|
||||
resources = with_documented(operation, types, formats, models, resources)
|
||||
resources = with_nested_record_find(resources, types, formats, members, models)
|
||||
resources = with_find_scope(resources, models, name, formats)
|
||||
resources = with_typed_targets(resources, formats, typed_target_fields(models, name))
|
||||
resources = with_integer_members(resources, formats, models, name)
|
||||
@@ -3046,6 +3061,44 @@ def with_found(resources: list[dict], types: list[str], formats: dict[str, str],
|
||||
return found + [{"type": kind, "fill": {}, "find": list(by)} for kind, by in by_kind.items()]
|
||||
|
||||
|
||||
def with_nested_record_find(resources: list[dict], types: list[str], formats: dict[str, str],
|
||||
members: dict[str, str], models: dict[str, dict]) -> list[dict]:
|
||||
"""An id of a nested record linking two reference types selects both resource endpoints.
|
||||
|
||||
A NetworkInterface holds an Attachment whose AttachmentId and InstanceId identify its attachment and the
|
||||
instance at its other end. Only a record named exactly after a reference type, holding its own id, supplies
|
||||
this relationship; request wrappers and unrelated sibling fields do not. Existing explicit selectors win.
|
||||
"""
|
||||
candidates: dict[str, set[str]] = {}
|
||||
for model in models.values():
|
||||
shapes = model["shapes"]
|
||||
for shape_name, shape in shapes.items():
|
||||
parents = [kind for kind in types if stem(shape_name) == stem(kind)]
|
||||
fields = shape.get("members", {}) if shape.get("type") == "structure" else {}
|
||||
if not parents or not any(kind_of(field) == "id" and stem(field) == stem(shape_name)
|
||||
for field in fields):
|
||||
continue
|
||||
for child_name, spec in fields.items():
|
||||
child = shapes[spec["shape"]]
|
||||
nested = child.get("members", {}) if child.get("type") == "structure" else {}
|
||||
for key, key_spec in nested.items():
|
||||
if members.get(key) != key or kind_of(key) != "id" or stem(key) != stem(child_name) \
|
||||
or shapes[key_spec["shape"]]["type"] != "string" \
|
||||
or any(stem(key) == stem(kind) for kind in formats):
|
||||
continue
|
||||
reached = set(parents) | {kind for field, field_spec in nested.items()
|
||||
if field != key and kind_of(field) == "id"
|
||||
and shapes[field_spec["shape"]]["type"] == "string"
|
||||
for kind in types if stem(field) == stem(kind)}
|
||||
if len(reached) < 2:
|
||||
continue
|
||||
for kind in reached:
|
||||
candidates.setdefault(kind, set()).add(key)
|
||||
selected = {kind for resource in resources for kind in resource.get("types", [resource.get("type")])}
|
||||
return resources + [{"type": kind, "fill": {}, "find": sorted(keys)}
|
||||
for kind, keys in sorted(candidates.items()) if kind not in selected and len(keys) == 1]
|
||||
|
||||
|
||||
def with_find_scope(resources: list[dict], models: dict[str, dict], operation: str,
|
||||
formats: dict[str, str]) -> list[dict]:
|
||||
"""A found name is scoped by a request member its record says is associated with that resource."""
|
||||
|
||||
@@ -1616,6 +1616,16 @@ def test_id_prefixes_read_botocores_examples_by_the_shape_of_each_member():
|
||||
assert r.id_prefixes({"ec2": ec2}, ("security-group",)) == {}
|
||||
|
||||
|
||||
|
||||
def test_vpc_endpoint_prefix_remains_unknown_when_botocore_has_none():
|
||||
ec2 = model({"DescribeVpcEndpoints": {"VpcEndpointIds": "VpcEndpointIdList"}}, "ec2")
|
||||
ec2["shapes"]["VpcEndpointId"] = {"type": "string"}
|
||||
ec2["shapes"]["VpcEndpointIdList"] = {"type": "list", "member": {"shape": "VpcEndpointId"}}
|
||||
assert r.id_prefixes({"ec2": ec2}, ("vpc-endpoint",)) == {}
|
||||
assert r.namespace_id_prefixes("ec2", {"ec2": ec2}) == {}
|
||||
assert r.namespace_id_prefixes("other", {"ec2": ec2}) is None
|
||||
|
||||
|
||||
def test_id_targets_reject_unknown_types_ambiguous_prefixes_and_malformed_members():
|
||||
import copy
|
||||
|
||||
@@ -2709,3 +2719,46 @@ def test_a_name_for_a_new_resource_does_not_select_an_existing_id():
|
||||
models = cluster_model("CreateWidget", {"WidgetName": "<p>A name for the widget.</p>"})
|
||||
resource = {"type": "widget", "fill": {}}
|
||||
assert r.with_documented("svc:CreateWidget", ["widget"], formats, models, [resource]) == [resource]
|
||||
|
||||
|
||||
def test_paired_added_and_removed_id_lists_both_name_acted_on_resources():
|
||||
formats = {"security-group": "arn:${Partition}:ec2:${Region}:${Account}:security-group/${SecurityGroupId}"}
|
||||
named = members("AddSecurityGroupIds[]", "RemoveSecurityGroupIds[]")
|
||||
shapes = {name: "VpcEndpointSecurityGroupIdList" for name in named}
|
||||
resources = r.resources_for("ec2:ModifyVpcEndpoint", ["security-group"], formats, named, shapes=shapes)
|
||||
assert resources == [
|
||||
{"type": "security-group", "fill": {"SecurityGroupId": "AddSecurityGroupIds[]"}},
|
||||
{"type": "security-group", "fill": {"SecurityGroupId": "RemoveSecurityGroupIds[]"}}]
|
||||
shapes["RemoveSecurityGroupIds"] = "UnrelatedList"
|
||||
assert len(r.resources_for("ec2:ModifyVpcEndpoint", ["security-group"], formats, named, shapes=shapes)) == 1
|
||||
|
||||
|
||||
def test_nested_record_id_finds_only_containing_and_adjacent_resource_types():
|
||||
formats = {kind: "arn:${Partition}:svc:${Region}:${Account}:" + kind + "/${Id}"
|
||||
for kind in ("interface", "instance", "subnet")}
|
||||
shapes = {
|
||||
"String": {"type": "string"},
|
||||
"Interface": {"type": "structure", "members": {
|
||||
"InterfaceId": {"shape": "String"}, "SubnetId": {"shape": "String"},
|
||||
"Attachment": {"shape": "InterfaceAttachment"}}},
|
||||
"InterfaceAttachment": {"type": "structure", "members": {
|
||||
"AttachmentId": {"shape": "String"}, "InstanceId": {"shape": "String"}}}}
|
||||
shapes["Request"] = {"type": "structure", "members": {"AttachmentId": {"shape": "String"}}}
|
||||
models = {"svc": {"shapes": shapes, "metadata": {"protocol": "json"},
|
||||
"operations": {"DetachInterface": {"input": {"shape": "Request"}}}}}
|
||||
expected = [{"type": kind, "fill": {}, "find": ["AttachmentId"]} for kind in ("instance", "interface")]
|
||||
assert r.read_resources("svc:DetachInterface", list(formats), formats, models) == expected
|
||||
assert r.with_nested_record_find([], list(formats), formats, members("UnrelatedId"), models) == []
|
||||
existing = [{"type": "interface", "fill": {"Id": "InterfaceId"}}]
|
||||
assert r.with_nested_record_find(existing, list(formats), formats, members("AttachmentId"), models) == [
|
||||
*existing, expected[0]]
|
||||
instance = shapes["InterfaceAttachment"]["members"].pop("InstanceId")
|
||||
assert r.with_nested_record_find([], list(formats), formats, members("AttachmentId"), models) == []
|
||||
shapes["InterfaceAttachment"]["members"]["InstanceId"] = instance
|
||||
shapes["Interface"]["members"]["OtherAttachment"] = {"shape": "OtherAttachment"}
|
||||
shapes["OtherAttachment"] = {"type": "structure", "members": {
|
||||
"OtherAttachmentId": {"shape": "String"}, "InstanceId": {"shape": "String"}}}
|
||||
assert r.with_nested_record_find([], list(formats), formats,
|
||||
members("AttachmentId", "OtherAttachmentId"), models) == []
|
||||
shapes["DescribeInterfaceResponse"] = shapes.pop("Interface")
|
||||
assert r.with_nested_record_find([], list(formats), formats, members("AttachmentId"), models) == []
|
||||
Reference in new issue
Block a user