cdk-local 0.163.6 → 0.164.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/README.md +1 -1
  2. package/dist/{assembly-path-R96uhMm1.js → assembly-path-4qK96UfP.js} +2 -2
  3. package/dist/{assembly-path-R96uhMm1.js.map → assembly-path-4qK96UfP.js.map} +1 -1
  4. package/dist/{cdkl-io-host-DFQf5KWv.js → cdkl-io-host-b34gsrHs.js} +2 -2
  5. package/dist/{cdkl-io-host-DFQf5KWv.js.map → cdkl-io-host-b34gsrHs.js.map} +1 -1
  6. package/dist/cli.js +2 -2
  7. package/dist/{docker-cmd-Cjg3jGYF.js → docker-cmd-C_Hfs3eo.js} +3 -3
  8. package/dist/{docker-cmd-Cjg3jGYF.js.map → docker-cmd-C_Hfs3eo.js.map} +1 -1
  9. package/dist/{docker-runner-B3OunVKV.js → docker-runner-C0Igd4LD.js} +15 -12
  10. package/dist/{docker-runner-B3OunVKV.js.map → docker-runner-C0Igd4LD.js.map} +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +2 -2
  14. package/dist/internal.d.ts +5 -3
  15. package/dist/internal.d.ts.map +1 -1
  16. package/dist/internal.js +5 -5
  17. package/dist/{local-studio-Cq73EZrD.d.ts → local-studio-B6fnvxp2.d.ts} +41 -20
  18. package/dist/local-studio-B6fnvxp2.d.ts.map +1 -0
  19. package/dist/{local-studio-BR8vPfCn.js → local-studio-Bo1NL6UK.js} +102 -55
  20. package/dist/local-studio-Bo1NL6UK.js.map +1 -0
  21. package/dist/{logger-Co5XVwco.js → logger-25be7ULc.js} +4 -2
  22. package/dist/logger-25be7ULc.js.map +1 -0
  23. package/dist/{workload-identity-BOEZuEDO.js → workload-identity-BQBoBgdT.js} +708 -137
  24. package/dist/workload-identity-BQBoBgdT.js.map +1 -0
  25. package/package.json +1 -1
  26. package/dist/local-studio-BR8vPfCn.js.map +0 -1
  27. package/dist/local-studio-Cq73EZrD.d.ts.map +0 -1
  28. package/dist/logger-Co5XVwco.js.map +0 -1
  29. package/dist/workload-identity-BOEZuEDO.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-w6R9maHv.js";
2
- import { c as getEmbedConfig, t as getLogger } from "./logger-Co5XVwco.js";
3
- import { r as displayUntrustedValue, u as describeCredentialLoadFailure } from "./assembly-path-R96uhMm1.js";
2
+ import { c as getEmbedConfig, t as getLogger } from "./logger-25be7ULc.js";
3
+ import { r as displayUntrustedValue, u as describeCredentialLoadFailure } from "./assembly-path-4qK96UfP.js";
4
4
  import { existsSync, lstatSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from "node:fs";
5
5
  import { createHash, generateKeyPairSync, randomBytes, sign } from "node:crypto";
6
6
  import { Agent, get, request } from "node:http";
@@ -568,21 +568,319 @@ const AWS_ENDPOINT_SERVICE_IDS = /* @__PURE__ */ new Set([
568
568
  "XRAY"
569
569
  ]);
570
570
 
571
+ //#endregion
572
+ //#region src/local/aws-real-endpoints.ts
573
+ const AWS_ENDPOINT_PREFIX_OVERRIDES = {
574
+ ACCESSANALYZER: "access-analyzer",
575
+ ACCOUNT_ACCESS: "account-access",
576
+ ACM_PCA: "acm-pca",
577
+ AGENT_REGISTRY: "agent-registry",
578
+ AGENT_REGISTRY_CONTROL: "agent-registry-control",
579
+ AMP: "aps",
580
+ APIGATEWAYMANAGEMENTAPI: "execute-api",
581
+ APIGATEWAYV2: "apigateway",
582
+ APPINTEGRATIONS: "app-integrations",
583
+ APPLICATIONCOSTPROFILER: "application-cost-profiler",
584
+ APPLICATION_AUTO_SCALING: "application-autoscaling",
585
+ APPLICATION_DISCOVERY_SERVICE: "discovery",
586
+ APPLICATION_SIGNALS: "application-signals",
587
+ APPSTREAM: "appstream2",
588
+ ARC_REGION_SWITCH: "arc-region-switch",
589
+ ARC_ZONAL_SHIFT: "arc-zonal-shift",
590
+ AUTO_SCALING_PLANS: "autoscaling-plans",
591
+ BACKUPSEARCH: "backup-search",
592
+ BACKUP_GATEWAY: "backup-gateway",
593
+ BCM_DASHBOARDS: "bcm-dashboards",
594
+ BCM_DATA_EXPORTS: "bcm-data-exports",
595
+ BCM_PRICING_CALCULATOR: "bcm-pricing-calculator",
596
+ BCM_RECOMMENDED_ACTIONS: "bcm-recommended-actions",
597
+ BEDROCK_AGENT: "bedrock-agent",
598
+ BEDROCK_AGENTCORE: "bedrock-agentcore",
599
+ BEDROCK_AGENTCORE_CONTROL: "bedrock-agentcore-control",
600
+ BEDROCK_AGENT_RUNTIME: "bedrock-agent-runtime",
601
+ BEDROCK_DATA_AUTOMATION: "bedrock-data-automation",
602
+ BEDROCK_DATA_AUTOMATION_RUNTIME: "bedrock-data-automation-runtime",
603
+ BEDROCK_RUNTIME: "bedrock-runtime",
604
+ CHIME_SDK_IDENTITY: "identity-chime",
605
+ CHIME_SDK_MEDIA_PIPELINES: "media-pipelines-chime",
606
+ CHIME_SDK_MEETINGS: "meetings-chime",
607
+ CHIME_SDK_MESSAGING: "messaging-chime",
608
+ CHIME_SDK_VOICE: "voice-chime",
609
+ CLEANROOMSML: "cleanrooms-ml",
610
+ CLOUDCONTROL: "cloudcontrolapi",
611
+ CLOUDFRONT_KEYVALUESTORE: "cloudfront-keyvaluestore",
612
+ CLOUDTRAIL_DATA: "cloudtrail-data",
613
+ CLOUDWATCH: "monitoring",
614
+ CLOUDWATCHOMNI: "cloudwatch-omni",
615
+ CLOUDWATCH_LOGS: "logs",
616
+ CODEGURUPROFILER: "codeguru-profiler",
617
+ CODEGURU_REVIEWER: "codeguru-reviewer",
618
+ CODEGURU_SECURITY: "codeguru-security",
619
+ CODESTAR_CONNECTIONS: "codestar-connections",
620
+ CODESTAR_NOTIFICATIONS: "codestar-notifications",
621
+ COGNITO_IDENTITY: "cognito-identity",
622
+ COGNITO_IDENTITY_PROVIDER: "cognito-idp",
623
+ COGNITO_SYNC: "cognito-sync",
624
+ COMPUTE_OPTIMIZER: "compute-optimizer",
625
+ COMPUTE_OPTIMIZER_AUTOMATION: "aco-automation",
626
+ CONFIG_SERVICE: "config",
627
+ CONNECTCAMPAIGNS: "connect-campaigns",
628
+ CONNECTCAMPAIGNSV2: "connect-campaigns",
629
+ CONNECTCASES: "cases",
630
+ CONNECTHEALTH: "health-agent",
631
+ CONNECTPARTICIPANT: "participant.connect",
632
+ CONNECT_CONTACT_LENS: "contact-lens",
633
+ COST_AND_USAGE_REPORT_SERVICE: "cur",
634
+ COST_EXPLORER: "ce",
635
+ COST_OPTIMIZATION_HUB: "cost-optimization-hub",
636
+ CUSTOMER_PROFILES: "profile",
637
+ DATABASE_MIGRATION_SERVICE: "dms",
638
+ DETECTIVE: "api.detective",
639
+ DEVOPS_AGENT: "aidevops",
640
+ DEVOPS_GURU: "devops-guru",
641
+ DIRECTORY_SERVICE: "ds",
642
+ DIRECTORY_SERVICE_DATA: "ds-data",
643
+ DOCDB: "rds",
644
+ DOCDB_ELASTIC: "docdb-elastic",
645
+ DYNAMODB_STREAMS: "streams.dynamodb",
646
+ EC2_INSTANCE_CONNECT: "ec2-instance-connect",
647
+ ECR: "api.ecr",
648
+ ECR_PUBLIC: "api.ecr-public",
649
+ EFS: "elasticfilesystem",
650
+ EKS_AUTH: "eks-auth",
651
+ ELASTICSEARCH_SERVICE: "es",
652
+ ELASTIC_LOAD_BALANCING_V2: "elasticloadbalancing",
653
+ ELEMENTALINFERENCE: "elemental-inference",
654
+ EMR: "elasticmapreduce",
655
+ EMR_CONTAINERS: "emr-containers",
656
+ EMR_SERVERLESS: "emr-serverless",
657
+ ENDUSERMESSAGING: "end-user-messaging",
658
+ EVENTBRIDGE: "events",
659
+ EVENTBRIDGEV2: "eventsv2",
660
+ GEO_MAPS: "geo-maps",
661
+ GEO_PLACES: "geo-places",
662
+ GEO_ROUTES: "geo-routes",
663
+ GREENGRASSV2: "greengrass",
664
+ IAM_TOOLBOX: "iam-toolbox",
665
+ INSPECTOR_SCAN: "inspector-scan",
666
+ IOTDEVICEADVISOR: "api.iotdeviceadvisor",
667
+ IOTSECURETUNNELING: "api.tunneling.iot",
668
+ IOT_DATA_PLANE: "data-ats.iot",
669
+ IOT_JOBS_DATA_PLANE: "data.jobs.iot",
670
+ IOT_MANAGED_INTEGRATIONS: "api.iotmanagedintegrations",
671
+ IOT_WIRELESS: "api.iotwireless",
672
+ KENDRA_RANKING: "kendra-ranking",
673
+ KEYSPACES: "cassandra",
674
+ KEYSPACESSTREAMS: "cassandra-streams",
675
+ KINESIS_ANALYTICS_V2: "kinesisanalytics",
676
+ KINESIS_VIDEO_ARCHIVED_MEDIA: "kinesisvideo",
677
+ KINESIS_VIDEO_MEDIA: "kinesisvideo",
678
+ KINESIS_VIDEO_SIGNALING: "kinesisvideo",
679
+ KINESIS_VIDEO_WEBRTC_STORAGE: "kinesisvideo",
680
+ LAMBDA_CORE: "lambda",
681
+ LAMBDA_MICROVMS: "lambda",
682
+ LAMBDA_WEB: "lambda",
683
+ LEX_MODELS_V2: "models-v2-lex",
684
+ LEX_MODEL_BUILDING_SERVICE: "models.lex",
685
+ LEX_RUNTIME_SERVICE: "runtime.lex",
686
+ LEX_RUNTIME_V2: "runtime-v2-lex",
687
+ LICENSE_MANAGER: "license-manager",
688
+ LICENSE_MANAGER_LINUX_SUBSCRIPTIONS: "license-manager-linux-subscriptions",
689
+ LICENSE_MANAGER_USER_SUBSCRIPTIONS: "license-manager-user-subscriptions",
690
+ LOCATION: "geo",
691
+ MAILMANAGER: "mail-manager",
692
+ MANAGEDBLOCKCHAIN_QUERY: "managedblockchain-query",
693
+ MARKETPLACE_AGREEMENT: "agreement-marketplace",
694
+ MARKETPLACE_CATALOG: "catalog.marketplace",
695
+ MARKETPLACE_DEPLOYMENT: "deployment-marketplace",
696
+ MARKETPLACE_DISCOVERY: "discovery-marketplace",
697
+ MARKETPLACE_ENTITLEMENT_SERVICE: "entitlement.marketplace",
698
+ MARKETPLACE_METERING: "metering.marketplace",
699
+ MARKETPLACE_REPORTING: "reporting-marketplace",
700
+ MEDIAPACKAGE_VOD: "mediapackage-vod",
701
+ MEDIASTORE_DATA: "data.mediastore",
702
+ MEDIATAILOR: "api.mediatailor",
703
+ MEDICAL_IMAGING: "medical-imaging",
704
+ MEMORYDB: "memory-db",
705
+ MIGRATIONHUBORCHESTRATOR: "migrationhub-orchestrator",
706
+ MIGRATIONHUBSTRATEGY: "migrationhub-strategy",
707
+ MIGRATIONHUB_CONFIG: "migrationhub-config",
708
+ MIGRATION_HUB: "mgh",
709
+ MIGRATION_HUB_REFACTOR_SPACES: "refactor-spaces",
710
+ MTURK: "mturk-requester",
711
+ MWAA: "airflow",
712
+ MWAA_SERVERLESS: "airflow-serverless",
713
+ NEPTUNE: "rds",
714
+ NEPTUNEDATA: "neptune-db",
715
+ NEPTUNE_GRAPH: "neptune-graph",
716
+ NETWORK_FIREWALL: "network-firewall",
717
+ NETWORK_SECURITY_MANAGER: "network-security-manager",
718
+ NOTIFICATIONSCONTACTS: "notifications-contacts",
719
+ NOVA_ACT: "nova-act",
720
+ OPENSEARCH: "es",
721
+ OPENSEARCHSERVERLESS: "aoss",
722
+ PARTNERCENTRAL_ACCOUNT: "partnercentral-account",
723
+ PARTNERCENTRAL_BENEFITS: "partnercentral-benefits",
724
+ PARTNERCENTRAL_CHANNEL: "partnercentral-channel",
725
+ PARTNERCENTRAL_REVENUE_MEASUREMENT: "partnercentral-prm",
726
+ PARTNERCENTRAL_SELLING: "partnercentral-selling",
727
+ PAYMENT_CRYPTOGRAPHY: "controlplane.payment-cryptography",
728
+ PAYMENT_CRYPTOGRAPHY_DATA: "dataplane.payment-cryptography",
729
+ PCA_CONNECTOR_AD: "pca-connector-ad",
730
+ PCA_CONNECTOR_SCEP: "pca-connector-scep",
731
+ PERSONALIZE_EVENTS: "personalize-events",
732
+ PERSONALIZE_RUNTIME: "personalize-runtime",
733
+ PINPOINT_EMAIL: "email",
734
+ PINPOINT_SMS_VOICE: "sms-voice.pinpoint",
735
+ PINPOINT_SMS_VOICE_V2: "sms-voice",
736
+ PRICING: "api.pricing",
737
+ QAPPS: "data.qapps",
738
+ QCONNECT: "wisdom",
739
+ RDS_DATA: "rds-data",
740
+ REDSHIFT_DATA: "redshift-data",
741
+ REDSHIFT_SERVERLESS: "redshift-serverless",
742
+ RESILIENCEHUBV2: "resiliencehub",
743
+ RESOURCE_EXPLORER_2: "resource-explorer-2",
744
+ RESOURCE_GROUPS: "resource-groups",
745
+ RESOURCE_GROUPS_TAGGING_API: "tagging",
746
+ ROUTE53_RECOVERY_CLUSTER: "route53-recovery-cluster",
747
+ ROUTE53_RECOVERY_CONTROL_CONFIG: "route53-recovery-control-config",
748
+ ROUTE53_RECOVERY_READINESS: "route53-recovery-readiness",
749
+ S3OUTPOSTS: "s3-outposts",
750
+ S3_CONTROL: "s3-control",
751
+ SAGEMAKER: "api.sagemaker",
752
+ SAGEMAKERJOBRUNTIME: "job-runtime.sagemaker",
753
+ SAGEMAKERTRAININGSESSIONRUNTIME: "training-session-runtime.sagemaker",
754
+ SAGEMAKER_A2I_RUNTIME: "a2i-runtime.sagemaker",
755
+ SAGEMAKER_EDGE: "edge.sagemaker",
756
+ SAGEMAKER_FEATURESTORE_RUNTIME: "featurestore-runtime.sagemaker",
757
+ SAGEMAKER_GEOSPATIAL: "sagemaker-geospatial",
758
+ SAGEMAKER_METRICS: "metrics.sagemaker",
759
+ SAGEMAKER_RUNTIME: "runtime.sagemaker",
760
+ SECURITY_IR: "security-ir",
761
+ SERVERLESSAPPLICATIONREPOSITORY: "serverlessrepo",
762
+ SERVICE_CATALOG_APPREGISTRY: "servicecatalog-appregistry",
763
+ SES: "email",
764
+ SESV2: "email",
765
+ SFN: "states",
766
+ SIGNER_DATA: "data-signer",
767
+ SIMPLEDB: "sdb",
768
+ SIMPLEDBV2: "sdb",
769
+ SNOW_DEVICE_MANAGEMENT: "snow-device-management",
770
+ SOCIALMESSAGING: "social-messaging",
771
+ SSM_CONTACTS: "ssm-contacts",
772
+ SSM_GUICONNECT: "ssm-guiconnect",
773
+ SSM_INCIDENTS: "ssm-incidents",
774
+ SSM_QUICKSETUP: "ssm-quicksetup",
775
+ SSM_SAP: "ssm-sap",
776
+ SSO: "portal.sso",
777
+ SSO_ADMIN: "sso",
778
+ SSO_OIDC: "oidc",
779
+ SUPPLYCHAIN: "scn",
780
+ TAXSETTINGS: "tax",
781
+ TIMESTREAM_INFLUXDB: "timestream-influxdb",
782
+ TIMESTREAM_QUERY: "query.timestream",
783
+ TIMESTREAM_WRITE: "ingest.timestream",
784
+ VPC_LATTICE: "vpc-lattice",
785
+ WAF_REGIONAL: "waf-regional",
786
+ WICKR: "admin.wickr",
787
+ WORKSPACES_INSTANCES: "workspaces-instances",
788
+ WORKSPACES_THIN_CLIENT: "thinclient",
789
+ WORKSPACES_WEB: "workspaces-web"
790
+ };
791
+ const AWS_GLOBAL_ENDPOINTS = {
792
+ account: {
793
+ hostname: "account.us-east-1.amazonaws.com",
794
+ signingRegion: "us-east-1"
795
+ },
796
+ billingconductor: {
797
+ hostname: "billingconductor.us-east-1.amazonaws.com",
798
+ signingRegion: "us-east-1"
799
+ },
800
+ budgets: {
801
+ hostname: "budgets.amazonaws.com",
802
+ signingRegion: "us-east-1"
803
+ },
804
+ ce: {
805
+ hostname: "ce.us-east-1.amazonaws.com",
806
+ signingRegion: "us-east-1"
807
+ },
808
+ chime: {
809
+ hostname: "chime.us-east-1.amazonaws.com",
810
+ signingRegion: "us-east-1"
811
+ },
812
+ cloudfront: {
813
+ hostname: "cloudfront.amazonaws.com",
814
+ signingRegion: "us-east-1"
815
+ },
816
+ health: {
817
+ hostname: "global.health.amazonaws.com",
818
+ signingRegion: "us-east-1"
819
+ },
820
+ iam: {
821
+ hostname: "iam.amazonaws.com",
822
+ signingRegion: "us-east-1"
823
+ },
824
+ importexport: {
825
+ hostname: "importexport.amazonaws.com",
826
+ signingRegion: "us-east-1"
827
+ },
828
+ networkmanager: {
829
+ hostname: "networkmanager.us-west-2.amazonaws.com",
830
+ signingRegion: "us-west-2"
831
+ },
832
+ "notifications-contacts": {
833
+ hostname: "notifications-contacts.us-east-1.api.aws",
834
+ signingRegion: "us-east-1"
835
+ },
836
+ organizations: {
837
+ hostname: "organizations.us-east-1.amazonaws.com",
838
+ signingRegion: "us-east-1"
839
+ },
840
+ route53: {
841
+ hostname: "route53.amazonaws.com",
842
+ signingRegion: "us-east-1"
843
+ },
844
+ savingsplans: {
845
+ hostname: "savingsplans.amazonaws.com",
846
+ signingRegion: "us-east-1"
847
+ },
848
+ shield: {
849
+ hostname: "shield.us-east-1.amazonaws.com",
850
+ signingRegion: "us-east-1"
851
+ },
852
+ tax: {
853
+ hostname: "tax.us-east-1.amazonaws.com",
854
+ signingRegion: "us-east-1"
855
+ },
856
+ waf: {
857
+ hostname: "waf.amazonaws.com",
858
+ signingRegion: "us-east-1"
859
+ }
860
+ };
861
+
571
862
  //#endregion
572
863
  //#region src/local/aws-emulator-mixed-mode.ts
573
- const AWS_EMULATOR_SENTINEL = "aws-emulator";
864
+ const REAL_AWS_SENTINEL = "real-aws";
865
+ const LEGACY_AWS_EMULATOR_SENTINEL = "aws-emulator";
574
866
  const MIXED_MODE_RESIGN_PORT = 47297;
575
867
  const ENDPOINT_KEY = /^AWS_ENDPOINT_URL(?:_([A-Z0-9_]+))?$/;
576
- function isAwsEmulatorSentinel(key, value) {
577
- return typeof value === "string" && value.trim() === "aws-emulator" && ENDPOINT_KEY.test(key);
868
+ function isSentinel(key, value, sentinel) {
869
+ return typeof value === "string" && value.trim() === sentinel && ENDPOINT_KEY.test(key);
578
870
  }
579
- function findAwsEmulatorSentinels(overrides) {
871
+ function isRealAwsSentinel(key, value) {
872
+ return isSentinel(key, value, REAL_AWS_SENTINEL);
873
+ }
874
+ function isLegacyAwsEmulatorSentinel(key, value) {
875
+ return isSentinel(key, value, LEGACY_AWS_EMULATOR_SENTINEL);
876
+ }
877
+ function findSentinels(overrides, match) {
580
878
  const found = [];
581
879
  if (!overrides || typeof overrides !== "object") return found;
582
880
  for (const [section, map] of Object.entries(overrides)) {
583
881
  if (!map || typeof map !== "object" || Array.isArray(map)) continue;
584
882
  for (const [key, value] of Object.entries(map)) {
585
- if (!isAwsEmulatorSentinel(key, value)) continue;
883
+ if (!match(key, value)) continue;
586
884
  found.push({
587
885
  section,
588
886
  key,
@@ -592,33 +890,33 @@ function findAwsEmulatorSentinels(overrides) {
592
890
  }
593
891
  return found;
594
892
  }
893
+ function findRealAwsExceptions(overrides) {
894
+ return findSentinels(overrides, isRealAwsSentinel);
895
+ }
896
+ function findLegacyAwsEmulatorSentinels(overrides) {
897
+ return findSentinels(overrides, isLegacyAwsEmulatorSentinel);
898
+ }
595
899
  function readAwsEmulatorEnvVarsFile(filePath) {
596
- if (!filePath) return {
900
+ const none = {
597
901
  overrides: void 0,
598
- sentinels: []
902
+ exceptions: [],
903
+ legacySentinels: []
599
904
  };
905
+ if (!filePath) return none;
600
906
  let parsed;
601
907
  try {
602
908
  parsed = JSON.parse(readEnvVarsFileText(filePath));
603
909
  } catch {
604
- return {
605
- overrides: void 0,
606
- sentinels: []
607
- };
910
+ return none;
608
911
  }
609
- if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {
610
- overrides: void 0,
611
- sentinels: []
612
- };
912
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return none;
613
913
  const overrides = parsed;
614
914
  return {
615
915
  overrides,
616
- sentinels: findAwsEmulatorSentinels(overrides)
916
+ exceptions: findRealAwsExceptions(overrides),
917
+ legacySentinels: findLegacyAwsEmulatorSentinels(overrides)
617
918
  };
618
919
  }
619
- function readAwsEmulatorSentinelsFromFile(filePath) {
620
- return readAwsEmulatorEnvVarsFile(filePath).sentinels;
621
- }
622
920
  function sectionAppliesTo(section, workload) {
623
921
  if (section === "Parameters") return false;
624
922
  if (workload.logicalId !== void 0 && section === workload.logicalId) return true;
@@ -626,14 +924,14 @@ function sectionAppliesTo(section, workload) {
626
924
  const path = workload.cdkPath;
627
925
  return path !== void 0 && (path === section || path.startsWith(`${section}/`));
628
926
  }
629
- function emulatedServicesForWorkload(overrides, workload) {
927
+ function realAwsServicesForWorkload(overrides, workload) {
630
928
  const out = /* @__PURE__ */ new Set();
631
929
  const apply = (map) => {
632
930
  if (!map || typeof map !== "object" || Array.isArray(map)) return;
633
931
  for (const [key, value] of Object.entries(map)) {
634
932
  const service = ENDPOINT_KEY.exec(key)?.[1];
635
933
  if (service === void 0) continue;
636
- if (isAwsEmulatorSentinel(key, value)) out.add(service);
934
+ if (isRealAwsSentinel(key, value)) out.add(service);
637
935
  else if (value === null || [
638
936
  "string",
639
937
  "number",
@@ -650,21 +948,39 @@ function correctServiceIdSpelling(service) {
650
948
  const bare = service.replace(/_/g, "");
651
949
  for (const id of AWS_ENDPOINT_SERVICE_IDS) if (id.replace(/_/g, "") === bare) return id;
652
950
  }
653
- function validateAwsEmulatorSentinels(sentinels, awsEmulatorOn, envVarName = "CDK_LOCAL_AWS_EMULATOR") {
654
- const first = sentinels[0];
655
- if (!first) return;
656
- const where = (s) => `${s.key} under ${displayUntrustedValue(s.section)}`;
657
- const bare = sentinels.find((s) => s.service === "");
658
- if (bare) throw new Error(`--env-vars sets ${where(bare)} to "${AWS_EMULATOR_SENTINEL}", but the sentinel routes ONE service (AWS_ENDPOINT_URL_<SERVICE>). To send every service to AWS Emulator, use --aws-emulator without a sentinel.`);
659
- const unknown = sentinels.find((s) => !AWS_ENDPOINT_SERVICE_IDS.has(s.service));
951
+ function legacyAwsEmulatorSentinelMessage(s) {
952
+ return `--env-vars sets ${s.key} under ${displayUntrustedValue(s.section)} to "${LEGACY_AWS_EMULATOR_SENTINEL}", which is no longer supported: --aws-emulator now sends EVERY service to AWS Emulator, and the --env-vars file marks only the exceptions that must reach real AWS, with "${REAL_AWS_SENTINEL}". Remove the "${LEGACY_AWS_EMULATOR_SENTINEL}" entries, and mark each service that must stay on real AWS instead, e.g. "AWS_ENDPOINT_URL_SECRETS_MANAGER": "${REAL_AWS_SENTINEL}".`;
953
+ }
954
+ function validateAwsEmulatorEnvVars(scan, awsEmulatorOn) {
955
+ const legacy = scan.legacySentinels[0];
956
+ if (legacy) throw new Error(legacyAwsEmulatorSentinelMessage(legacy));
957
+ if (!awsEmulatorOn) return;
958
+ if (scan.exceptions.some((s) => s.service === "")) throw new Error(`--env-vars: "AWS_ENDPOINT_URL": "${REAL_AWS_SENTINEL}" would send every AWS call to real AWS, which is what running without --aws-emulator does. Remove --aws-emulator to run against real AWS, or keep it and mark only the services that must reach real AWS, e.g. "AWS_ENDPOINT_URL_SECRETS_MANAGER": "${REAL_AWS_SENTINEL}".`);
959
+ const unknown = scan.exceptions.find((s) => !AWS_ENDPOINT_SERVICE_IDS.has(s.service));
660
960
  if (unknown) {
661
961
  const fix = correctServiceIdSpelling(unknown.service);
662
- throw new Error(`--env-vars sets ${where(unknown)} to "${AWS_EMULATOR_SENTINEL}", but the AWS SDKs do not read ${unknown.key}, so the workload's calls would still go to real AWS. ` + (fix ? `Use AWS_ENDPOINT_URL_${fix}.` : "The suffix must be the service's SDK endpoint id (its serviceId, uppercased, spaces as underscores)."));
962
+ throw new Error(`--env-vars sets ${unknown.key} under ${displayUntrustedValue(unknown.section)} to "${REAL_AWS_SENTINEL}", but the AWS SDKs do not read ${unknown.key}, so the workload's calls would still go to AWS Emulator. ` + (fix ? `Use AWS_ENDPOINT_URL_${fix}.` : "The suffix must be the service's SDK endpoint id (its serviceId, uppercased, spaces as underscores)."));
663
963
  }
664
- if (!awsEmulatorOn) throw new Error(`--env-vars sets ${where(first)} to "${AWS_EMULATOR_SENTINEL}", which needs --aws-emulator [url] (or ${envVarName}) to name the AWS Emulator to route it to.`);
665
964
  }
666
- function emulatedServicesOf(sentinels) {
667
- return [...new Set(sentinels.map((s) => s.service).filter((s) => s !== ""))].sort();
965
+ function realAwsServicesOf(exceptions) {
966
+ return [...new Set(exceptions.map((s) => s.service).filter((s) => s !== ""))].sort();
967
+ }
968
+ const NO_REGIONAL_ENDPOINT = /* @__PURE__ */ new Set(["APIGATEWAYMANAGEMENTAPI", "CLOUDFRONT_KEYVALUESTORE"]);
969
+ const REGION_SHAPE = /^[a-z]{2}(-[a-z]+)+-\d+$/;
970
+ function realAwsEndpointFor(service, region) {
971
+ if (!REGION_SHAPE.test(region)) throw new Error(`--env-vars marks AWS_ENDPOINT_URL_${service} "${REAL_AWS_SENTINEL}", but the workload's region ${displayUntrustedValue(region)} is not an AWS region name.`);
972
+ if (NO_REGIONAL_ENDPOINT.has(service)) throw new Error(`--env-vars marks AWS_ENDPOINT_URL_${service} "${REAL_AWS_SENTINEL}", but ${service} has no regional endpoint to name. Set AWS_ENDPOINT_URL_${service} to the real endpoint URL instead (a literal URL is passed through as-is).`);
973
+ const prefix = AWS_ENDPOINT_PREFIX_OVERRIDES[service] ?? service.toLowerCase().replace(/_/g, "");
974
+ const isolated = /^(us|eu)-iso[a-z]*-/.test(region);
975
+ const china = region.startsWith("cn-");
976
+ const gov = region.startsWith("us-gov-");
977
+ const global = AWS_GLOBAL_ENDPOINTS[prefix];
978
+ if (isolated || global && (china || gov)) throw new Error(`--env-vars marks AWS_ENDPOINT_URL_${service} "${REAL_AWS_SENTINEL}", but ${displayUntrustedValue(region)} has no known real ${service} endpoint. Set AWS_ENDPOINT_URL_${service} to the real endpoint URL instead (a literal URL is passed through as-is).`);
979
+ if (global) {
980
+ if (global.signingRegion !== region) throw new Error(`--env-vars marks AWS_ENDPOINT_URL_${service} "${REAL_AWS_SENTINEL}", but ${service} is served by one global endpoint (https://${global.hostname}) that accepts only requests signed for ${global.signingRegion}, and an SDK signs a request to an explicit endpoint for the workload's region (${displayUntrustedValue(region)}), which that endpoint refuses. Leave ${service} on AWS Emulator, or run the workload in ${global.signingRegion}.`);
981
+ return `https://${global.hostname}`;
982
+ }
983
+ return `https://${prefix}.${region}.${china ? "amazonaws.com.cn" : "amazonaws.com"}`;
668
984
  }
669
985
  const SERVICE_NAMESPACE_ALIASES = {
670
986
  EVENTBRIDGE: ["EVENTS"],
@@ -676,7 +992,7 @@ const SERVICE_NAMESPACE_ALIASES = {
676
992
  OPENSEARCH: ["OPENSEARCHSERVICE"],
677
993
  ELASTICSEARCHSERVICE: ["ELASTICSEARCH"]
678
994
  };
679
- function resourceTypeMatchesEmulatedService(resourceType, services) {
995
+ function resourceTypeMatchesService(resourceType, services) {
680
996
  const ns = /^AWS::([A-Za-z0-9]+)::/.exec(resourceType)?.[1]?.toUpperCase();
681
997
  if (!ns) return false;
682
998
  return services.some((s) => {
@@ -686,71 +1002,71 @@ function resourceTypeMatchesEmulatedService(resourceType, services) {
686
1002
  }
687
1003
  const MISSING_LIST_LIMIT = 10;
688
1004
  function createMixedModeStateProvider(opts) {
689
- const { real, emulator, emulatedServices } = opts;
1005
+ const { real, emulator, realServices } = opts;
690
1006
  const swaps = /* @__PURE__ */ new Map();
1007
+ const toReal = /* @__PURE__ */ new Map();
691
1008
  const warned = /* @__PURE__ */ new Set();
692
- const warnedReal = /* @__PURE__ */ new Set();
1009
+ const warnedEmulator = /* @__PURE__ */ new Set();
693
1010
  const swap = (v) => swaps.get(v) ?? v;
1011
+ const excepted = (res) => resourceTypeMatchesService(res.resourceType, realServices);
694
1012
  const provider = {
695
- label: real.label,
1013
+ label: emulator.label,
696
1014
  async load(stackName, synthRegion) {
697
- const [r, e] = await Promise.all([real.load(stackName, synthRegion), emulator.load(stackName, synthRegion)]);
698
- if (!e) {
699
- if (r && !warned.has(stackName)) {
700
- if (Object.values(r.resources).some((res) => resourceTypeMatchesEmulatedService(res.resourceType, emulatedServices))) {
701
- warned.add(stackName);
702
- const why = emulator.getLastLoadError?.();
703
- getLogger().warn(`${real.label}: stack ${displayUntrustedValue(stackName)} could not be read from AWS Emulator${why ? ` (${why})` : ""}; resources of the emulated services (${emulatedServices.join(", ")}) keep their real AWS names. Override them with --env-vars, or deploy the stack into the emulator.`);
704
- }
1015
+ const [e, r] = await Promise.all([emulator.load(stackName, synthRegion), real.load(stackName, synthRegion)]);
1016
+ if (!r) {
1017
+ if (e && !warned.has(stackName) && Object.values(e.resources).some(excepted)) {
1018
+ warned.add(stackName);
1019
+ const why = real.getLastLoadError?.();
1020
+ getLogger().warn(`${emulator.label}: stack ${displayUntrustedValue(stackName)} could not be read from real AWS${why ? ` (${why})` : ""}; resources of the services marked "${REAL_AWS_SENTINEL}" (${realServices.join(", ")}) keep their AWS Emulator names. Override them with --env-vars, or deploy the stack to real AWS too.`);
705
1021
  }
706
- return r;
1022
+ return e;
707
1023
  }
708
- const emulated = (res) => resourceTypeMatchesEmulatedService(res.resourceType, emulatedServices);
709
- if (!r) {
1024
+ if (!e) {
710
1025
  const resources = {};
711
1026
  const dropped = [];
712
- for (const [id, res] of Object.entries(e.resources)) if (emulated(res)) resources[id] = res;
1027
+ for (const [id, res] of Object.entries(r.resources)) if (excepted(res)) resources[id] = res;
713
1028
  else dropped.push(`${displayUntrustedValue(id)} (${displayUntrustedValue(res.resourceType)})`);
714
- if (dropped.length > 0 && !warnedReal.has(stackName)) {
715
- warnedReal.add(stackName);
716
- const why = real.getLastLoadError?.();
1029
+ if (dropped.length > 0 && !warnedEmulator.has(stackName)) {
1030
+ warnedEmulator.add(stackName);
1031
+ const why = emulator.getLastLoadError?.();
717
1032
  const shown = dropped.slice(0, MISSING_LIST_LIMIT).join(", ");
718
1033
  const more = dropped.length > MISSING_LIST_LIMIT ? ` and ${dropped.length - MISSING_LIST_LIMIT} more` : "";
719
- getLogger().warn(`${real.label}: stack ${displayUntrustedValue(stackName)} could not be read from real AWS${why ? ` (${why})` : ""}, only from AWS Emulator; resources outside the emulated services (${emulatedServices.join(", ")}) stay unresolved: ${shown}${more}. Deploy the stack to real AWS too, under the same stack name (the same CDK context, e.g. -c stage=dev), or override them with --env-vars.`);
1034
+ getLogger().warn(`${emulator.label}: stack ${displayUntrustedValue(stackName)} could not be read from AWS Emulator${why ? ` (${why})` : ""}, only from real AWS; resources outside the services marked "${REAL_AWS_SENTINEL}" (${realServices.join(", ")}) stay unresolved: ${shown}${more}. Deploy the stack into AWS Emulator under the same stack name (the same CDK context, e.g. -c stage=dev), or override them with --env-vars.`);
720
1035
  }
721
1036
  return {
722
1037
  resources,
723
- outputs: { ...e.outputs },
724
- region: e.region
1038
+ outputs: {},
1039
+ region: r.region
725
1040
  };
726
1041
  }
727
- const resources = { ...r.resources };
728
- for (const [id, res] of Object.entries(e.resources)) {
729
- if (!emulated(res)) continue;
730
- const realRes = r.resources[id];
731
- if (realRes?.physicalId && res.physicalId && realRes.physicalId !== res.physicalId) swaps.set(realRes.physicalId, res.physicalId);
1042
+ const resources = { ...e.resources };
1043
+ for (const [id, res] of Object.entries(r.resources)) {
1044
+ const emuId = e.resources[id]?.physicalId;
1045
+ if (emuId && res.physicalId) toReal.set(emuId, res.physicalId);
1046
+ if (!excepted(res)) continue;
1047
+ const emuRes = e.resources[id];
1048
+ if (emuRes?.physicalId && res.physicalId && emuRes.physicalId !== res.physicalId) swaps.set(emuRes.physicalId, res.physicalId);
732
1049
  resources[id] = res;
733
1050
  }
734
1051
  const outputs = {};
735
- for (const [k, v] of Object.entries(e.outputs)) outputs[k] = v;
736
- for (const [k, v] of Object.entries(r.outputs)) outputs[k] = swap(v);
1052
+ for (const [k, v] of Object.entries(e.outputs)) outputs[k] = swap(v);
737
1053
  return {
738
1054
  resources,
739
1055
  outputs,
740
- region: r.region
1056
+ region: e.region
741
1057
  };
742
1058
  },
743
- buildCrossStackResolver: (region) => real.buildCrossStackResolver(region),
1059
+ buildCrossStackResolver: (region) => emulator.buildCrossStackResolver(region),
744
1060
  dispose() {
745
1061
  try {
746
- real.dispose();
747
- } finally {
748
1062
  emulator.dispose();
1063
+ } finally {
1064
+ real.dispose();
749
1065
  }
750
1066
  }
751
1067
  };
752
- if (real.resolveDeployedFunctionEnv) {
753
- const fn = real.resolveDeployedFunctionEnv.bind(real);
1068
+ if (emulator.resolveDeployedFunctionEnv) {
1069
+ const fn = emulator.resolveDeployedFunctionEnv.bind(emulator);
754
1070
  provider.resolveDeployedFunctionEnv = async (id) => {
755
1071
  const env = await fn(id);
756
1072
  if (!env) return env;
@@ -759,10 +1075,16 @@ function createMixedModeStateProvider(opts) {
759
1075
  return out;
760
1076
  };
761
1077
  }
762
- if (real.resolveLambdaExecutionRoleArn) provider.resolveLambdaExecutionRoleArn = real.resolveLambdaExecutionRoleArn.bind(real);
763
- if (real.resolveAgentCoreRuntimeRoleArn) provider.resolveAgentCoreRuntimeRoleArn = real.resolveAgentCoreRuntimeRoleArn.bind(real);
1078
+ if (real.resolveLambdaExecutionRoleArn) {
1079
+ const fn = real.resolveLambdaExecutionRoleArn.bind(real);
1080
+ provider.resolveLambdaExecutionRoleArn = (id) => fn(toReal.get(id) ?? id);
1081
+ }
1082
+ if (real.resolveAgentCoreRuntimeRoleArn) {
1083
+ const fn = real.resolveAgentCoreRuntimeRoleArn.bind(real);
1084
+ provider.resolveAgentCoreRuntimeRoleArn = (id) => fn(toReal.get(id) ?? id);
1085
+ }
764
1086
  if (real.resolveTemplateSsmParameters) provider.resolveTemplateSsmParameters = real.resolveTemplateSsmParameters.bind(real);
765
- if (real.getLastLoadError) provider.getLastLoadError = real.getLastLoadError.bind(real);
1087
+ if (emulator.getLastLoadError) provider.getLastLoadError = emulator.getLastLoadError.bind(emulator);
766
1088
  return provider;
767
1089
  }
768
1090
 
@@ -858,25 +1180,26 @@ function normalizeAwsEndpointServiceId(serviceId) {
858
1180
  }
859
1181
  function setAwsEmulatorServiceRouting(r) {
860
1182
  serviceRouting = r ? {
861
- services: new Set(r.services.map(normalizeAwsEndpointServiceId)),
1183
+ realServices: new Set(r.realServices.map(normalizeAwsEndpointServiceId)),
862
1184
  override: r.override,
863
1185
  envOverrides: r.envOverrides
864
1186
  } : void 0;
865
1187
  }
866
1188
  function getAwsEmulatorServiceRouting() {
867
1189
  return serviceRouting ? {
868
- services: [...serviceRouting.services].sort(),
1190
+ realServices: [...serviceRouting.realServices].sort(),
869
1191
  override: serviceRouting.override,
870
1192
  ...serviceRouting.envOverrides && { envOverrides: serviceRouting.envOverrides }
871
1193
  } : void 0;
872
1194
  }
873
- function awsEmulatorRoutedServices(workload) {
1195
+ function awsEmulatorRealServices(workload) {
874
1196
  if (!serviceRouting) return void 0;
875
- if (workload === void 0 || serviceRouting.envOverrides === void 0) return [...serviceRouting.services].sort();
876
- return emulatedServicesForWorkload(serviceRouting.envOverrides, workload);
1197
+ if (serviceRouting.envOverrides === void 0) return [...serviceRouting.realServices].sort();
1198
+ return realAwsServicesForWorkload(serviceRouting.envOverrides, workload ?? {});
877
1199
  }
878
1200
  function mixedModeRoutes(serviceId, workload) {
879
- return awsEmulatorRoutedServices(workload)?.includes(normalizeAwsEndpointServiceId(serviceId)) ?? false;
1201
+ const real = awsEmulatorRealServices(workload);
1202
+ return real !== void 0 && !real.includes(normalizeAwsEndpointServiceId(serviceId));
880
1203
  }
881
1204
  function isAwsServiceRoutedToEmulator(serviceId, workload) {
882
1205
  if (endpointOverride) return true;
@@ -891,6 +1214,13 @@ function awsClientConfigForService(serviceId, opts = {}) {
891
1214
  function awsEndpointOverrideClientConfig(o) {
892
1215
  return endpointOverrideClientConfig(o);
893
1216
  }
1217
+ function deployArtifactsReadEmulator() {
1218
+ return endpointOverride !== void 0 || serviceRouting !== void 0;
1219
+ }
1220
+ function deployArtifactClientConfig(opts = {}) {
1221
+ if (!endpointOverride && serviceRouting) return endpointOverrideClientConfig(serviceRouting.override);
1222
+ return buildProxyClientConfig(opts);
1223
+ }
894
1224
  function endpointOverrideClientConfig(o) {
895
1225
  const httpsAgent = new Agent$1({
896
1226
  keepAlive: true,
@@ -1253,6 +1583,25 @@ function createMixedModeTlsMaterials(now = /* @__PURE__ */ new Date(), leafDnsNa
1253
1583
  }).toString()
1254
1584
  };
1255
1585
  }
1586
+ const OID_PKCS7_DATA = "1.2.840.113549.1.7.1";
1587
+ const OID_CERT_BAG = "1.2.840.113549.1.12.10.1.3";
1588
+ const OID_X509_CERTIFICATE = "1.2.840.113549.1.9.22.1";
1589
+ const OID_FRIENDLY_NAME = "1.2.840.113549.1.9.20";
1590
+ const OID_JDK_TRUSTED_KEY_USAGE = "2.16.840.1.113894.746875.1.1";
1591
+ const OID_ANY_EXTENDED_KEY_USAGE = "2.5.29.37.0";
1592
+ function buildJavaTrustStore(pems, aliasPrefix = "cdk-local") {
1593
+ const bags = [];
1594
+ for (const pem of pems) for (const block of pem.match(/-----BEGIN CERTIFICATE-----[\s\S]*?-----END CERTIFICATE-----/g) ?? []) {
1595
+ const body = block.replace(/-----(BEGIN|END) CERTIFICATE-----/g, "").replace(/\s+/g, "");
1596
+ const certDer = Buffer.from(body, "base64");
1597
+ const alias = `${aliasPrefix}-${bags.length}`;
1598
+ const bmp = Buffer.from(alias, "utf16le").swap16();
1599
+ bags.push(seq(oid(OID_CERT_BAG), explicit(0, seq(oid(OID_X509_CERTIFICATE), explicit(0, octets(certDer)))), set(seq(oid(OID_JDK_TRUSTED_KEY_USAGE), set(oid(OID_ANY_EXTENDED_KEY_USAGE))), seq(oid(OID_FRIENDLY_NAME), set(der(30, bmp))))));
1600
+ }
1601
+ const safeContents = seq(...bags);
1602
+ const authSafe = seq(seq(oid(OID_PKCS7_DATA), explicit(0, octets(safeContents))));
1603
+ return seq(integer(Buffer.from([3])), seq(oid(OID_PKCS7_DATA), explicit(0, octets(authSafe))));
1604
+ }
1256
1605
 
1257
1606
  //#endregion
1258
1607
  //#region src/local/emulator-resign-sidecar.ts
@@ -1411,17 +1760,100 @@ function errorBody(err,service){
1411
1760
  if(service==='s3'||service===undefined)return {type:'application/xml',text:'<?xml version="1.0" encoding="UTF-8"?><Error><Code>'+err.code+'</Code><Message>'+err.message.replace(/&/g,'&amp;').replace(/</g,'&lt;')+'</Message></Error>'};
1412
1761
  return {type:'application/x-amz-json-1.0',text:JSON.stringify({__type:err.code,message:err.message})};
1413
1762
  }
1763
+ var PASS_DROP_HEADERS=new Set(['connection','keep-alive','proxy-authorization','proxy-connection','te','trailer','transfer-encoding','upgrade','expect']);
1764
+ function passthroughHeaders(incoming){
1765
+ var out=Object.create(null);
1766
+ Object.keys(incoming).forEach(function(k){var lk=k.toLowerCase();if(PASS_DROP_HEADERS.has(lk))return;var v=incoming[k];if(v===undefined)return;out[lk]=v;});
1767
+ return out;
1768
+ }
1769
+ // Only a real SQS queue URL is rewritten: an AWS SQS host (either form, any
1770
+ // partition suffix), no port, user info, query or fragment, and a path of a
1771
+ // 12-digit account and a queue name.
1772
+ var SQS_QUEUE_URL=/^https?:\/\/(?:sqs\.[a-z0-9-]+|[a-z0-9-]+\.queue)\.amazonaws\.com(?:\.cn)?\/([0-9]{12}\/[A-Za-z0-9_-]{1,80}(?:\.fifo)?)$/;
1773
+ function localQueueUrl(u,origin){var m=SQS_QUEUE_URL.exec(String(u));return m?origin+'/'+m[1]:u;}
1774
+ var SQS_QUEUE_URL_OPERATIONS=new Set(['CreateQueue','GetQueueUrl','ListQueues','ListDeadLetterSourceQueues']);
1775
+ // An unsigned request (an emulator run with --auth off and an SDK that signs
1776
+ // nothing) has no scope: only the JSON protocol's target names SQS then.
1777
+ function isSqsRequest(headers,service){return service==='sqs'||String(headers['x-amz-target']||'').indexOf('AmazonSQS.')===0;}
1778
+ // JSON protocol: the target names the operation. Query protocol: unknown here,
1779
+ // so every response is a candidate.
1780
+ function sqsResponseMayCarryQueueUrl(headers){
1781
+ var t=String(headers['x-amz-target']||'');
1782
+ if(t==='')return true;
1783
+ return t.indexOf('AmazonSQS.')===0&&SQS_QUEUE_URL_OPERATIONS.has(t.slice('AmazonSQS.'.length));
1784
+ }
1785
+ function rewriteSqsQueueUrls(text,contentType,origin){
1786
+ var ct=String(contentType||'').toLowerCase(),changed=false;
1787
+ function one(u){if(typeof u!=='string')return u;var n=localQueueUrl(u,origin);if(n!==u)changed=true;return n;}
1788
+ if(ct.indexOf('json')>=0){
1789
+ var o;
1790
+ try{o=JSON.parse(text);}catch(e){return undefined;}
1791
+ if(!o||typeof o!=='object'||Array.isArray(o))return undefined;
1792
+ if(typeof o.QueueUrl==='string')o.QueueUrl=one(o.QueueUrl);
1793
+ ['QueueUrls','queueUrls'].forEach(function(k){if(Array.isArray(o[k]))o[k]=o[k].map(one);});
1794
+ return changed?JSON.stringify(o):undefined;
1795
+ }
1796
+ if(ct.indexOf('xml')>=0){
1797
+ // A message body inside XML is escaped, so a literal element is never user data.
1798
+ var out=String(text).replace(/<QueueUrl>([^<]*)<\/QueueUrl>/g,function(all,u){var n=one(u.trim());return n===u.trim()?all:'<QueueUrl>'+n+'</QueueUrl>';});
1799
+ return changed?out:undefined;
1800
+ }
1801
+ return undefined;
1802
+ }
1414
1803
  `;
1415
1804
  const RESIGN_SIDECAR_SERVER = String.raw`
1416
1805
  function startResigner(cfgPath){return new Promise(function(done){
1417
- var fs=require('fs'),https=require('https'),http=require('http'),tls=require('tls');
1806
+ var fs=require('fs'),https=require('https'),http=require('http'),tls=require('tls'),net=require('net'),zlib=require('zlib');
1418
1807
  var cfg;
1419
1808
  try{cfg=JSON.parse(fs.readFileSync(cfgPath,'utf8'));}catch(e){done({error:'CONFIG_'+(e.code||'ERROR')});return;}
1809
+ var passthrough=cfg.passthrough===true;
1810
+ if(!passthrough&&!cfg.credentials){done({error:'CONFIG_ERROR'});return;}
1811
+ var label=passthrough?'cdk-local --aws-emulator':'cdk-local mixed mode';
1420
1812
  var up=new URL(cfg.upstream),secure=up.protocol==='https:',mod=secure?https:http;
1813
+ var upHost=up.hostname.replace(/^\[|\]$/g,'');
1421
1814
  cfg.upstreamHost=up.host;
1422
1815
  var agentOpts={keepAlive:true};
1423
1816
  if(secure&&cfg.upstreamCaPem)agentOpts.ca=tls.rootCertificates.concat([cfg.upstreamCaPem]);
1424
1817
  var agent=new mod.Agent(agentOpts);
1818
+ // What a rewritten queue URL points at: this sidecar, the endpoint the workload already uses.
1819
+ var origin='https://127.0.0.1:'+cfg.port;
1820
+ var REWRITE_CAP=16*1048576;
1821
+ // Response bytes held at once across concurrent requests; past it a
1822
+ // response streams through unrewritten.
1823
+ var heldResp=0,HELD_RESP_CAP=4*REWRITE_CAP;
1824
+ var DECODERS={identity:null,gzip:zlib.gunzipSync,'x-gzip':zlib.gunzipSync,deflate:zlib.inflateSync,br:zlib.brotliDecompressSync};
1825
+ // Relay an emulator response. An SQS response that may carry a queue URL is
1826
+ // held (up to a cap) and its queue URLs point back here; anything else, and
1827
+ // a response that needs no change, goes through byte for byte.
1828
+ function relay(ur,resp,rewrite){
1829
+ var h={};
1830
+ Object.keys(ur.headers).forEach(function(k){if(k==='connection'||k==='keep-alive'||k==='transfer-encoding')return;h[k]=ur.headers[k];});
1831
+ var status=ur.statusCode||502,enc=String(ur.headers['content-encoding']||'identity').trim().toLowerCase();
1832
+ ur.on('error',function(){resp.destroy();});
1833
+ if(!rewrite||status<200||status>=300||!Object.prototype.hasOwnProperty.call(DECODERS,enc)||Number(ur.headers['content-length'])>REWRITE_CAP){resp.writeHead(status,h);ur.pipe(resp);return;}
1834
+ var chunks=[],n=0,released=false;
1835
+ function release(){if(!released){released=true;heldResp-=n;}}
1836
+ function onData(c){
1837
+ n+=c.length;heldResp+=c.length;chunks.push(c);
1838
+ if(n<=REWRITE_CAP&&heldResp<=HELD_RESP_CAP)return;
1839
+ ur.removeListener('data',onData);ur.removeListener('end',onEnd);release();
1840
+ resp.writeHead(status,h);chunks.forEach(function(x){resp.write(x);});chunks=[];
1841
+ ur.pipe(resp);
1842
+ }
1843
+ function onEnd(){
1844
+ release();
1845
+ var raw=Buffer.concat(chunks),text,out;chunks=[];
1846
+ try{var dec=DECODERS[enc];text=(dec?dec(raw,{maxOutputLength:4*REWRITE_CAP}):raw).toString('utf8');}catch(e){text=undefined;}
1847
+ if(text!==undefined)out=rewriteSqsQueueUrls(text,ur.headers['content-type'],origin);
1848
+ if(out===undefined){h['content-length']=String(raw.length);resp.writeHead(status,h);resp.end(raw);return;}
1849
+ var b=Buffer.from(out,'utf8');
1850
+ delete h['content-encoding'];delete h['content-md5'];delete h['x-amz-crc32'];
1851
+ h['content-length']=String(b.length);
1852
+ resp.writeHead(status,h);resp.end(b);
1853
+ }
1854
+ ur.on('data',onData);ur.on('end',onEnd);ur.on('close',release);
1855
+ }
1856
+ function rewritesResponse(req,service){return isSqsRequest(req.headers,service)&&sqsResponseMayCarryQueueUrl(req.headers);}
1425
1857
  function send(resp,status,err,service){
1426
1858
  if(resp.headersSent){resp.destroy();return;}
1427
1859
  var b=errorBody(err,service);
@@ -1448,37 +1880,58 @@ function startResigner(cfgPath){return new Promise(function(done){
1448
1880
  req.on('error',function(){drop();resp.destroy();});
1449
1881
  resp.on('close',drop);
1450
1882
  req.on('end',function(){
1451
- if(busy){send(resp,503,{code:'SlowDown',message:'cdk-local mixed mode: the AWS Emulator re-signing sidecar is holding too many request bodies at once; retry.'},serviceOf(req));return;}
1883
+ if(busy){send(resp,503,{code:'SlowDown',message:label+': the AWS Emulator re-signing sidecar is holding too many request bodies at once; retry.'},serviceOf(req));return;}
1452
1884
  if(over){process.stdout.write('CDKL-RESIGN rejected a streamed request body over the cap without holding it\n');send(resp,413,tooLargeError(seen,cfg.capBytes,serviceOf(req)),serviceOf(req));return;}
1453
1885
  var p;
1454
1886
  var joined=Buffer.concat(chunks);chunks=[];
1455
- try{p=prepareResign(req,joined,cfg,new Date());}catch(e){p={error:{status:400,code:'InvalidRequest',message:'cdk-local mixed mode: the request could not be re-signed.'}};}
1887
+ try{p=prepareResign(req,joined,cfg,new Date());}catch(e){p={error:{status:400,code:'InvalidRequest',message:label+': the request could not be re-signed.'}};}
1456
1888
  joined=null;
1457
1889
  if(p.error){if(p.error.status===413)process.stdout.write('CDKL-RESIGN rejected a request body over the cap\n');send(resp,p.error.status,p.error,serviceOf(req));return;}
1458
- var r;
1459
- try{r=mod.request({host:up.hostname.replace(/^\[|\]$/g,''),port:up.port||(secure?443:80),method:req.method,path:p.path,headers:p.headers,agent:agent},function(ur){
1460
- var h={};
1461
- Object.keys(ur.headers).forEach(function(k){if(k==='connection'||k==='keep-alive'||k==='transfer-encoding')return;h[k]=ur.headers[k];});
1462
- resp.writeHead(ur.statusCode||502,h);
1463
- ur.pipe(resp);
1464
- ur.on('error',function(){resp.destroy();});
1465
- });}catch(e){send(resp,400,{code:'InvalidRequest',message:'cdk-local mixed mode: the request has a header the AWS Emulator re-signing sidecar cannot forward.'},p.service);return;}
1466
- // A client that hangs up (an aborted GetObject) frees the upstream socket too.
1467
- resp.on('close',function(){if(!resp.writableFinished)r.destroy();});
1468
- r.setTimeout(300000,function(){r.destroy(Object.assign(new Error('upstream timeout'),{code:'ETIMEDOUT'}));});
1469
- r.on('error',function(e){process.stdout.write('CDKL-RESIGN upstream error '+(e.code||'ERROR')+'\n');send(resp,502,{code:'BadGateway',message:'cdk-local mixed mode: the AWS Emulator at '+cfg.upstream+' did not answer ('+(e.code||'ERROR')+').'},p.service);});
1470
- r.end(p.body);
1890
+ // Re-signed anyway (accept-encoding is not a signed header): ask for an
1891
+ // identity body, so an encoding the sidecar cannot decode never carries
1892
+ // a real queue URL past it.
1893
+ if(rewritesResponse(req,p.service))delete p.headers['accept-encoding'];
1894
+ var r=upstreamRequest(req,resp,p.path,p.headers,p.service,{});
1895
+ if(r)r.end(p.body);
1471
1896
  });
1472
1897
  }
1473
- var srv=https.createServer({key:cfg.keyPem,cert:cfg.certPem},handle);
1898
+ // One upstream request; the response is relayed back. Undefined when the
1899
+ // headers cannot be sent (the client got a 400).
1900
+ function upstreamRequest(req,resp,path,headers,service,extra){
1901
+ var r,opts={host:upHost,port:up.port||(secure?443:80),method:req.method,path:path,headers:headers,agent:agent};
1902
+ Object.keys(extra).forEach(function(k){opts[k]=extra[k];});
1903
+ try{r=mod.request(opts,function(ur){relay(ur,resp,rewritesResponse(req,service));});}
1904
+ catch(e){send(resp,400,{code:'InvalidRequest',message:label+': the request has a header the AWS Emulator sidecar cannot forward.'},service);return undefined;}
1905
+ // A client that hangs up (an aborted GetObject) frees the upstream socket too.
1906
+ resp.on('close',function(){if(!resp.writableFinished)r.destroy();});
1907
+ r.setTimeout(300000,function(){r.destroy(Object.assign(new Error('upstream timeout'),{code:'ETIMEDOUT'}));});
1908
+ r.on('error',function(e){process.stdout.write('CDKL-RESIGN upstream error '+(e.code||'ERROR')+'\n');send(resp,502,{code:'BadGateway',message:label+': the AWS Emulator at '+cfg.upstream+' did not answer ('+(e.code||'ERROR')+').'},service);});
1909
+ return r;
1910
+ }
1911
+ // Full emulator mode: the workload already signs with the emulator's keys,
1912
+ // so the request goes upstream unchanged (its Host header too, which the
1913
+ // signature covers) and streams; only hop-by-hop headers are dropped. TLS
1914
+ // to the emulator is verified against the emulator's host name.
1915
+ function handlePassthrough(req,resp){
1916
+ var service=serviceOf(req);
1917
+ // The incoming Host names the sidecar, not the emulator: SNI (and with it
1918
+ // the certificate check) uses the emulator's own host name instead.
1919
+ var extra=secure?{servername:net.isIP(upHost)?'':upHost}:{};
1920
+ var r=upstreamRequest(req,resp,String(req.url||'/'),passthroughHeaders(req.headers),service,extra);
1921
+ if(!r){req.resume();return;}
1922
+ req.on('error',function(){r.destroy();resp.destroy();});
1923
+ req.pipe(r);
1924
+ }
1925
+ var srv=https.createServer({key:cfg.keyPem,cert:cfg.certPem},passthrough?handlePassthrough:handle);
1474
1926
  srv.on('checkContinue',function(req,resp){
1927
+ if(passthrough){resp.writeContinue();handlePassthrough(req,resp);return;}
1475
1928
  var n=tooLargeByHeaders(req.headers,cfg.capBytes);
1476
1929
  if(n>0){process.stdout.write('CDKL-RESIGN rejected a request body over the cap\n');send(resp,413,tooLargeError(n,cfg.capBytes,serviceOf(req)),serviceOf(req));req.resume();return;}
1477
1930
  resp.writeContinue();
1478
1931
  handle(req,resp);
1479
1932
  });
1480
1933
  srv.once('error',function(e){done({error:e.code||'ERROR',port:cfg.port});});
1481
- // Loopback only: it signs with the emulator's keys for whoever connects.
1934
+ // Loopback only: in mixed mode it signs with the emulator's keys for whoever connects.
1482
1935
  srv.listen(cfg.port,'127.0.0.1',function(){done({port:cfg.port,address:srv.address().address});});
1483
1936
  });}
1484
1937
  `;
@@ -1500,6 +1953,7 @@ var workload_aws_wiring_exports = /* @__PURE__ */ __exportAll({
1500
1953
  collectHostEndpointOverrides: () => collectHostEndpointOverrides,
1501
1954
  displayEndpointValue: () => displayEndpointValue,
1502
1955
  effectiveLoopbackPorts: () => effectiveLoopbackPorts,
1956
+ envKeepsRealAwsException: () => envKeepsRealAwsException,
1503
1957
  getActiveWorkloadAwsWiring: () => getActiveWorkloadAwsWiring,
1504
1958
  getContainerCaBundlePath: () => getContainerCaBundlePath,
1505
1959
  getContainerJavaTruststorePath: () => getContainerJavaTruststorePath,
@@ -1516,6 +1970,8 @@ var workload_aws_wiring_exports = /* @__PURE__ */ __exportAll({
1516
1970
  resolveWorkloadAwsWiring: () => resolveWorkloadAwsWiring,
1517
1971
  setActiveWorkloadAwsWiring: () => setActiveWorkloadAwsWiring,
1518
1972
  sweepStaleResignDirs: () => sweepStaleResignDirs,
1973
+ takeAwsEmulatorStateSourceHint: () => takeAwsEmulatorStateSourceHint,
1974
+ workloadGetsEmulatorKeysOnly: () => workloadGetsEmulatorKeysOnly,
1519
1975
  writeCaBundleFile: () => writeCaBundleFile
1520
1976
  });
1521
1977
  const CA_TRUST_ENV_KEYS = [
@@ -1793,18 +2249,7 @@ function processAlive(pid) {
1793
2249
  return err.code === "EPERM";
1794
2250
  }
1795
2251
  }
1796
- function resolveMixedModeWiring(args) {
1797
- const { ep, services, credentials, caSources, disposers } = args;
1798
- const caPems = [];
1799
- for (const source of caSources) try {
1800
- caPems.push(...pemCertificates(readFileSync(source, "utf8")));
1801
- } catch (err) {
1802
- throw new Error(`--aws-emulator: the CA bundle ${displayUntrustedValue(source)} cannot be read (${err.code ?? "error"}).`);
1803
- }
1804
- const upstreamCaPem = caPems.length > 0 ? caPems.join("\n") : void 0;
1805
- const tls = createMixedModeTlsMaterials();
1806
- const bundle = writeCaBundleFile(void 0, [...caPems, tls.caCertPem]);
1807
- disposers.push(bundle.dispose);
2252
+ function writeSidecarConfig(config, disposers) {
1808
2253
  sweepStaleResignDirs();
1809
2254
  const dir = mkdtempSync(path$1.join(tmpdir(), `${getEmbedConfig().productName}-resign-`));
1810
2255
  disposers.push(() => rmSync(dir, {
@@ -1812,7 +2257,39 @@ function resolveMixedModeWiring(args) {
1812
2257
  force: true
1813
2258
  }));
1814
2259
  writeFileSync(path$1.join(dir, "owner.pid"), String(process.pid), { mode: 384 });
1815
- const resignConfigHostPath = path$1.join(dir, "resign.json");
2260
+ const configPath = path$1.join(dir, "resign.json");
2261
+ writeFileSync(configPath, JSON.stringify(config), { mode: 384 });
2262
+ return configPath;
2263
+ }
2264
+ function readPemCertificates(sources) {
2265
+ const out = [];
2266
+ for (const source of new Set(sources)) try {
2267
+ out.push(...pemCertificates(readFileSync(source, "utf8")));
2268
+ } catch (err) {
2269
+ throw new Error(`--aws-emulator: the CA bundle ${displayUntrustedValue(source)} cannot be read (${err.code ?? "error"}).`);
2270
+ }
2271
+ return out;
2272
+ }
2273
+ function writeJavaTrustStoreFile(pems) {
2274
+ const dir = mkdtempSync(path$1.join(tmpdir(), `${getEmbedConfig().productName}-truststore-`));
2275
+ const hostPath = path$1.join(dir, "truststore.p12");
2276
+ writeFileSync(hostPath, buildJavaTrustStore(pems), { mode: 420 });
2277
+ return {
2278
+ hostPath,
2279
+ dispose: () => rmSync(dir, {
2280
+ recursive: true,
2281
+ force: true
2282
+ })
2283
+ };
2284
+ }
2285
+ function resolveMixedModeWiring(args) {
2286
+ const { ep, services, credentials, caSources, disposers } = args;
2287
+ const resignEndpoint = `https://127.0.0.1:${MIXED_MODE_RESIGN_PORT}`;
2288
+ const caPems = readPemCertificates(caSources);
2289
+ const upstreamCaPem = caPems.length > 0 ? caPems.join("\n") : void 0;
2290
+ const tls = createMixedModeTlsMaterials();
2291
+ const bundle = writeCaBundleFile(void 0, [...caPems, tls.caCertPem]);
2292
+ disposers.push(bundle.dispose);
1816
2293
  const config = {
1817
2294
  port: MIXED_MODE_RESIGN_PORT,
1818
2295
  upstream: ep.url,
@@ -1827,17 +2304,26 @@ function resolveMixedModeWiring(args) {
1827
2304
  capBytes: MIXED_MODE_RESIGN_BODY_CAP_BYTES,
1828
2305
  ...args.region ? { region: args.region } : {}
1829
2306
  };
1830
- writeFileSync(resignConfigHostPath, JSON.stringify(config), { mode: 384 });
2307
+ const resignConfigHostPath = writeSidecarConfig(config, disposers);
1831
2308
  const containerPath = getContainerCaBundlePath();
1832
2309
  const trust = {};
1833
2310
  for (const k of CA_TRUST_ENV_KEYS) trust[k] = containerPath;
1834
2311
  return {
1835
2312
  mode: "forward",
2313
+ sidecar: {
2314
+ port: MIXED_MODE_RESIGN_PORT,
2315
+ endpoint: resignEndpoint,
2316
+ upstream: ep,
2317
+ configHostPath: resignConfigHostPath,
2318
+ passthrough: false
2319
+ },
1836
2320
  mixed: {
1837
- services,
2321
+ realServices: services,
1838
2322
  emulatorEndpoint: ep,
1839
2323
  resignPort: MIXED_MODE_RESIGN_PORT,
1840
- resignEndpoint: `https://127.0.0.1:${MIXED_MODE_RESIGN_PORT}`,
2324
+ resignEndpoint,
2325
+ emulatorCredentials: config.credentials,
2326
+ ...args.region ? { region: args.region } : {},
1841
2327
  resignConfigHostPath,
1842
2328
  emulatorClientOverride: {
1843
2329
  endpoint: ep.url,
@@ -1845,7 +2331,12 @@ function resolveMixedModeWiring(args) {
1845
2331
  credentials: config.credentials
1846
2332
  }
1847
2333
  },
1848
- env: trust,
2334
+ env: {
2335
+ AWS_ENDPOINT_URL: resignEndpoint,
2336
+ AWS_EC2_METADATA_DISABLED: "true",
2337
+ AWS_DISABLE_HOST_PREFIX_INJECTION: "true",
2338
+ ...trust
2339
+ },
1849
2340
  scrubEnvKeys: [],
1850
2341
  mounts: [{
1851
2342
  hostPath: bundle.hostPath,
@@ -1867,8 +2358,8 @@ async function resolveWorkloadAwsWiring(opts) {
1867
2358
  d();
1868
2359
  } catch {}
1869
2360
  };
1870
- const caMount = (source, keys = CA_TRUST_ENV_KEYS) => {
1871
- const file = writeCaBundleFile(expandHome(source, homeDir));
2361
+ const caMount = (source, keys = CA_TRUST_ENV_KEYS, extraCertsPem = []) => {
2362
+ const file = writeCaBundleFile(expandHome(source, homeDir), extraCertsPem);
1872
2363
  disposers.push(file.dispose);
1873
2364
  const containerPath = getContainerCaBundlePath();
1874
2365
  const caEnv = {};
@@ -1891,7 +2382,7 @@ async function resolveWorkloadAwsWiring(opts) {
1891
2382
  }
1892
2383
  const run = readEmulatorRunFiles(ep.port, homeDir);
1893
2384
  const caSource = opts.caBundle || run.caPath || env["AWS_CA_BUNDLE"];
1894
- const mixedServices = emulatedServicesOf(opts.awsEmulatorSentinels ?? []);
2385
+ const mixedServices = realAwsServicesOf(opts.realAwsExceptions ?? []);
1895
2386
  const probeCa = mixedServices.length > 0 ? run.caPath || caSource : caSource;
1896
2387
  const failure = await (opts.probeHealth ?? probeAwsEmulatorHealth)(ep.url, probeCa ? expandHome(probeCa, homeDir) : void 0);
1897
2388
  if (failure) throw new Error(describeEmulatorUnreachable(ep, failure));
@@ -1915,14 +2406,36 @@ async function resolveWorkloadAwsWiring(opts) {
1915
2406
  skipPull: opts.skipPull,
1916
2407
  region: env["AWS_REGION"] || env["AWS_DEFAULT_REGION"] || void 0
1917
2408
  });
1918
- const ca = caSource && ep.url.startsWith("https:") ? caMount(caSource) : void 0;
2409
+ const https = ep.url.startsWith("https:");
2410
+ const sidecarTls = https && run.caPath && getEmbedConfig().awsEmulatorSqsSidecar ? createMixedModeTlsMaterials() : void 0;
2411
+ const ca = caSource && https ? caMount(caSource, CA_TRUST_ENV_KEYS, sidecarTls ? [sidecarTls.caCertPem] : []) : void 0;
2412
+ let sidecar;
2413
+ if (sidecarTls && run.caPath) {
2414
+ const upstreamPems = readPemCertificates([run.caPath, ...caSource ? [caSource] : []].map((c) => expandHome(c, homeDir)));
2415
+ sidecar = {
2416
+ port: MIXED_MODE_RESIGN_PORT,
2417
+ endpoint: `https://127.0.0.1:${MIXED_MODE_RESIGN_PORT}`,
2418
+ upstream: ep,
2419
+ passthrough: true,
2420
+ configHostPath: writeSidecarConfig({
2421
+ port: MIXED_MODE_RESIGN_PORT,
2422
+ upstream: ep.url,
2423
+ ...upstreamPems.length > 0 ? { upstreamCaPem: upstreamPems.join("\n") } : {},
2424
+ certPem: sidecarTls.certPem,
2425
+ keyPem: sidecarTls.keyPem,
2426
+ capBytes: MIXED_MODE_RESIGN_BODY_CAP_BYTES,
2427
+ passthrough: true
2428
+ }, disposers)
2429
+ };
2430
+ }
1919
2431
  let java;
1920
- if (run.truststorePath && ep.url.startsWith("https:")) {
2432
+ if (run.truststorePath && https) {
1921
2433
  let file;
2434
+ const source = sidecarTls && run.caPath ? run.caPath : run.truststorePath;
1922
2435
  try {
1923
- file = copyTruststoreFile(run.truststorePath);
2436
+ file = sidecarTls && run.caPath ? writeJavaTrustStoreFile([readFileSync(run.caPath, "utf8"), sidecarTls.caCertPem]) : copyTruststoreFile(run.truststorePath);
1924
2437
  } catch (err) {
1925
- getLogger().warn(`--aws-emulator: ${run.truststorePath} cannot be read (${err.code ?? "error"}); Java workloads get no JAVA_TOOL_OPTIONS trust store.`);
2438
+ getLogger().warn(`--aws-emulator: ${source} cannot be read (${err.code ?? "error"}); Java workloads get no JAVA_TOOL_OPTIONS trust store.`);
1926
2439
  }
1927
2440
  if (file) {
1928
2441
  disposers.push(file.dispose);
@@ -1939,16 +2452,19 @@ async function resolveWorkloadAwsWiring(opts) {
1939
2452
  return {
1940
2453
  mode: "emulator",
1941
2454
  emulatorEndpoint: ep,
2455
+ ...sidecar ? { sidecar } : {},
1942
2456
  env: {
1943
2457
  AWS_ENDPOINT_URL: ep.url,
2458
+ ...sidecar ? { AWS_ENDPOINT_URL_SQS: sidecar.endpoint } : {},
1944
2459
  AWS_EC2_METADATA_DISABLED: "true",
1945
2460
  AWS_DISABLE_HOST_PREFIX_INJECTION: "true",
2461
+ AWS_IGNORE_CONFIGURED_ENDPOINT_URLS: "false",
1946
2462
  ...ca?.env ?? {},
1947
2463
  ...java?.env ?? {}
1948
2464
  },
1949
2465
  scrubEnvKeys: EMULATOR_SCRUBBED_ENV_KEYS,
1950
2466
  mounts: [...ca?.mounts ?? [], ...java ? [java.mount] : []],
1951
- loopbackPorts: ep.loopback ? [ep.port] : [],
2467
+ loopbackPorts: [...ep.loopback ? [ep.port] : [], ...sidecar ? [sidecar.port] : []],
1952
2468
  probeHealth: ca !== void 0,
1953
2469
  ...ca ? { caHostPath: ca.hostPath } : {},
1954
2470
  emulatorCredentials: credentials,
@@ -1994,6 +2510,18 @@ async function resolveWorkloadAwsWiring(opts) {
1994
2510
  throw err;
1995
2511
  }
1996
2512
  }
2513
+ function sidecarOf(wiring) {
2514
+ if (wiring.sidecar) return wiring.sidecar;
2515
+ const mixed = wiring.mixed;
2516
+ if (!mixed) return void 0;
2517
+ return {
2518
+ port: mixed.resignPort,
2519
+ endpoint: mixed.resignEndpoint,
2520
+ upstream: mixed.emulatorEndpoint,
2521
+ configHostPath: mixed.resignConfigHostPath,
2522
+ passthrough: false
2523
+ };
2524
+ }
1997
2525
  function effectiveLoopbackPorts(env, wiring) {
1998
2526
  const used = /* @__PURE__ */ new Set();
1999
2527
  for (const [k, v] of Object.entries(env)) {
@@ -2003,16 +2531,16 @@ function effectiveLoopbackPorts(env, wiring) {
2003
2531
  if (ep.loopback) used.add(ep.port);
2004
2532
  } catch {}
2005
2533
  }
2006
- const mixed = wiring.mixed;
2007
- if (mixed && used.has(mixed.resignPort) && mixed.emulatorEndpoint.loopback) used.add(mixed.emulatorEndpoint.port);
2534
+ const sidecar = sidecarOf(wiring);
2535
+ if (sidecar && used.has(sidecar.port) && sidecar.upstream.loopback) used.add(sidecar.upstream.port);
2008
2536
  return wiring.loopbackPorts.filter((p) => used.has(p));
2009
2537
  }
2010
2538
  function loopbackForwarderPlan(wiring, ports) {
2011
- const mixed = wiring.mixed;
2012
- if (!mixed || !ports.includes(mixed.resignPort)) return { ports: [...ports] };
2539
+ const sidecar = sidecarOf(wiring);
2540
+ if (!sidecar || !ports.includes(sidecar.port)) return { ports: [...ports] };
2013
2541
  return {
2014
- ports: ports.filter((p) => p !== mixed.resignPort),
2015
- resignConfigHostPath: mixed.resignConfigHostPath
2542
+ ports: ports.filter((p) => p !== sidecar.port),
2543
+ resignConfigHostPath: sidecar.configHostPath
2016
2544
  };
2017
2545
  }
2018
2546
  function applyWorkloadAwsWiringToEnv(env, wiring, defaultCredentials) {
@@ -2023,10 +2551,24 @@ function applyWorkloadAwsWiringToEnv(env, wiring, defaultCredentials) {
2023
2551
  configurable: true,
2024
2552
  writable: true
2025
2553
  });
2554
+ let keepsException = false;
2026
2555
  for (const [k, v] of Object.entries(out)) {
2027
- if (!isAwsEmulatorSentinel(k, v)) continue;
2028
- if (!wiring.mixed || k === "AWS_ENDPOINT_URL") throw new Error(`${k}="${AWS_EMULATOR_SENTINEL}" reached a workload container outside mixed mode. The sentinel is read from the --env-vars file, on an AWS_ENDPOINT_URL_<SERVICE> variable, and needs --aws-emulator [url].`);
2029
- out[k] = wiring.mixed.resignEndpoint;
2556
+ if (isLegacyAwsEmulatorSentinel(k, v)) throw new Error(legacyAwsEmulatorSentinelMessage({
2557
+ section: "the container env",
2558
+ key: k,
2559
+ service: ""
2560
+ }));
2561
+ if (!isRealAwsSentinel(k, v)) continue;
2562
+ if (wiring.mode === "forward" && !wiring.mixed) {
2563
+ getLogger().debug(`${k}="${REAL_AWS_SENTINEL}" without --aws-emulator: dropped (a no-op).`);
2564
+ delete out[k];
2565
+ continue;
2566
+ }
2567
+ if (!wiring.mixed || k === "AWS_ENDPOINT_URL") throw new Error(`${k}="${REAL_AWS_SENTINEL}" reached a workload container under --aws-emulator without mixed-mode wiring. Mark exceptions in the --env-vars file, on an AWS_ENDPOINT_URL_<SERVICE> variable.`);
2568
+ const region = out["AWS_REGION"] || out["AWS_DEFAULT_REGION"] || wiring.mixed.region;
2569
+ if (!region) throw new Error(`${k}="${REAL_AWS_SENTINEL}" needs the workload's region to name the real endpoint, and none is set. Pass --region, or set AWS_REGION.`);
2570
+ out[k] = realAwsEndpointFor(k.slice(17), region);
2571
+ keepsException = true;
2030
2572
  }
2031
2573
  const setCreds = (c) => {
2032
2574
  for (const k of CREDENTIAL_KEYS) delete out[k];
@@ -2037,18 +2579,34 @@ function applyWorkloadAwsWiringToEnv(env, wiring, defaultCredentials) {
2037
2579
  };
2038
2580
  if (wiring.mode === "emulator") {
2039
2581
  const ownJavaToolOptions = out["JAVA_TOOL_OPTIONS"];
2582
+ const ownSqsEndpoint = out["AWS_ENDPOINT_URL_SQS"];
2040
2583
  for (const k of wiring.scrubEnvKeys) delete out[k];
2041
2584
  Object.assign(out, wiring.env);
2585
+ if (ownSqsEndpoint !== void 0) out["AWS_ENDPOINT_URL_SQS"] = ownSqsEndpoint;
2042
2586
  const javaToolOptions = wiring.env["JAVA_TOOL_OPTIONS"];
2043
2587
  if (javaToolOptions !== void 0) out["JAVA_TOOL_OPTIONS"] = mergeJavaToolOptions(ownJavaToolOptions, javaToolOptions);
2044
2588
  setCreds(wiring.emulatorCredentials);
2589
+ } else if (wiring.mixed && !keepsException) {
2590
+ for (const k of EMULATOR_SCRUBBED_ENV_KEYS) delete out[k];
2591
+ delete out["AWS_CONTAINER_CREDENTIALS_RELATIVE_URI"];
2592
+ out["AWS_IGNORE_CONFIGURED_ENDPOINT_URLS"] = "false";
2593
+ for (const [k, v] of Object.entries(wiring.env)) if (out[k] === void 0) out[k] = v;
2594
+ setCreds(wiring.mixed.emulatorCredentials);
2045
2595
  } else {
2596
+ if (wiring.mixed) out["AWS_IGNORE_CONFIGURED_ENDPOINT_URLS"] = "false";
2046
2597
  for (const [k, v] of Object.entries(wiring.env)) if (out[k] === void 0) out[k] = v;
2047
2598
  if (defaultCredentials && !out["AWS_ACCESS_KEY_ID"]) setCreds(defaultCredentials);
2048
2599
  }
2049
2600
  if (out["AWS_REGION"] && !out["AWS_DEFAULT_REGION"]) out["AWS_DEFAULT_REGION"] = out["AWS_REGION"];
2050
2601
  return out;
2051
2602
  }
2603
+ function envKeepsRealAwsException(env) {
2604
+ return Object.entries(env).some(([k, v]) => k !== "AWS_ENDPOINT_URL" && isRealAwsSentinel(k, v));
2605
+ }
2606
+ function workloadGetsEmulatorKeysOnly(env, wiring) {
2607
+ if (!wiring) return false;
2608
+ return wiring.mode === "emulator" || wiring.mixed !== void 0 && !envKeepsRealAwsException(env);
2609
+ }
2052
2610
  async function resolveHostDefaultCredentials(opts = {}) {
2053
2611
  const name = assumedRoleRecorded() ? profileName(process.env, opts.profile) : opts.profile;
2054
2612
  const key = `${assumedRoleRecorded() ? "noenv" : "chain"}:${name ?? ""}`;
@@ -2107,24 +2665,25 @@ function resolveAwsEmulatorOption(flag, env = process.env) {
2107
2665
  }
2108
2666
  async function activateWorkloadAwsWiring(options) {
2109
2667
  const awsEmulator = resolveAwsEmulatorOption(options.awsEmulator);
2110
- const { overrides, sentinels } = readAwsEmulatorEnvVarsFile(options.envVars);
2111
- validateAwsEmulatorSentinels(sentinels, awsEmulator !== void 0, awsEmulatorEnvName());
2668
+ const scan = readAwsEmulatorEnvVarsFile(options.envVars);
2669
+ validateAwsEmulatorEnvVars(scan, awsEmulator !== void 0);
2670
+ const { overrides } = scan;
2112
2671
  const wiring = await resolveWorkloadAwsWiring({
2113
2672
  awsEmulator,
2114
2673
  caBundle: options.caBundle,
2115
2674
  profile: options.profile,
2116
2675
  skipPull: options.pull === false,
2117
- awsEmulatorSentinels: sentinels
2676
+ ...awsEmulator !== void 0 && { realAwsExceptions: scan.exceptions }
2118
2677
  });
2119
2678
  setActiveWorkloadAwsWiring(wiring);
2120
2679
  if (wiring.mixed) {
2121
2680
  setAwsEndpointOverride(void 0);
2122
2681
  setAwsEmulatorServiceRouting({
2123
- services: wiring.mixed.services,
2682
+ realServices: wiring.mixed.realServices,
2124
2683
  override: wiring.mixed.emulatorClientOverride,
2125
2684
  envOverrides: overrides
2126
2685
  });
2127
- getLogger().info(`Mixed mode: ${wiring.mixed.services.join(", ")} go to AWS Emulator at ${wiring.mixed.emulatorEndpoint.url} (signed with its keys), for the workload and for ${getEmbedConfig().productName}'s own calls; every other AWS call uses your real credentials.`);
2686
+ getLogger().info(`Mixed mode: every AWS call goes to AWS Emulator at ${wiring.mixed.emulatorEndpoint.url} (signed with its keys) except ${wiring.mixed.realServices.join(", ")}, which go to real AWS with your real credentials, for the workload and for ${getEmbedConfig().productName}'s own calls.`);
2128
2687
  } else if (wiring.mode === "emulator" && wiring.emulatorEndpoint) {
2129
2688
  setAwsEmulatorServiceRouting(void 0);
2130
2689
  setAwsEndpointOverride({
@@ -2139,6 +2698,14 @@ async function activateWorkloadAwsWiring(options) {
2139
2698
  }
2140
2699
  return wiring;
2141
2700
  }
2701
+ let stateSourceHintShown = false;
2702
+ function takeAwsEmulatorStateSourceHint() {
2703
+ const wiring = active;
2704
+ if (stateSourceHintShown || !wiring || wiring.mode !== "emulator" && !wiring.mixed) return;
2705
+ stateSourceHintShown = true;
2706
+ const { cliName } = getEmbedConfig();
2707
+ return `Under --aws-emulator, the environment variables above that reference a resource need deployed names: pass ${cliName === "cdkl" ? "a host CLI's --from-state (the stack deployed into AWS Emulator with that host's own deploy)" : `--from-state (the stack deployed into AWS Emulator with \`${cliName} deploy --aws-emulator\`)`}, or --from-cfn-stack (the stack deployed into AWS Emulator with \`cdk deploy\`), or set the values with --env-vars.`;
2708
+ }
2142
2709
 
2143
2710
  //#endregion
2144
2711
  //#region src/utils/workload-identity.ts
@@ -2264,6 +2831,10 @@ function deployAccountStsClientConfig(args) {
2264
2831
  };
2265
2832
  }
2266
2833
  function accountLookupStsClientConfig(args) {
2834
+ if (getAwsEmulatorServiceRouting() && isAwsServiceRoutedToEmulator("STS")) return {
2835
+ ...buildProxyClientConfig({ service: "STS" }),
2836
+ ...args.region && { region: args.region }
2837
+ };
2267
2838
  return args.readFromCfnStack ? workloadStsClientConfig({
2268
2839
  region: args.region,
2269
2840
  profile: args.profile
@@ -2296,5 +2867,5 @@ function warnWorkloadCredentialsStripped() {
2296
2867
  }
2297
2868
 
2298
2869
  //#endregion
2299
- export { setAwsEmulatorServiceRouting as $, parseAwsEndpoint as A, MIXED_MODE_RESIGN_BODY_CAP_BYTES as B, effectiveLoopbackPorts as C, javaTruststoreToolOptions as D, getContainerJavaTruststorePath as E, resolveHostDefaultCredentials as F, awsEndpointOverrideClientConfig as G, createMixedModeTlsMaterials as H, resolveWorkloadAwsWiring as I, getAwsEndpointOverride as J, buildProxyClientConfig as K, setActiveWorkloadAwsWiring as L, readEmulatorRunFiles as M, readProfileEndpointSettings as N, loopbackForwarderPlan as O, resolveAwsEmulatorOption as P, proxyAwareFetch as Q, workload_aws_wiring_exports as R, displayEndpointValue as S, getContainerCaBundlePath as T, awsClientConfigForService as U, RESIGN_SIDECAR_SCRIPT as V, awsEmulatorRoutedServices as W, isProxyEnvConfigured as X, isAwsServiceRoutedToEmulator as Y, normalizeAwsEndpointServiceId as Z, HOST_DEFAULT_CREDENTIALS_MISS_TTL_MS as _, isLoopbackHostname as _t, deployAccountStsClientConfig as a, emulatedServicesOf as at, awsEmulatorEnvName as b, formatHostForAuthority as bt, resetWorkloadIdentity as c, readAwsEmulatorEnvVarsFile as ct, workloadStsClientConfig as d, validateAwsEmulatorSentinels as dt, setAwsEndpointOverride as et, AUTH_OFF_PLACEHOLDER_CREDENTIALS as f, AWS_ENDPOINT_SERVICE_IDS as ft, HOST_CA_TRUST_ENV_KEYS as g, defineOwnKey as gt, EMULATOR_SCRUBBED_ENV_KEYS as h, resolveEnvVars as ht, assumedRoleRecorded as i, emulatedServicesForWorkload as it, probeAwsEmulatorHealth as j, mergeJavaToolOptions as k, warnWorkloadCredentialsStripped as l, readAwsEmulatorSentinelsFromFile as lt, DEFAULT_AWS_EMULATOR_URL as m, readEnvVarsFileText as mt, accountLookupStsClientConfig as n, MIXED_MODE_RESIGN_PORT as nt, readEnvCallerCredentials as o, findAwsEmulatorSentinels as ot, CA_TRUST_ENV_KEYS as p, applyEnvOverrideMap as pt, getAwsEmulatorServiceRouting as q, applyWorkloadEnvCredentials as r, createMixedModeStateProvider as rt, recordAssumedRole as s, isAwsEmulatorSentinel as st, SECOND_ASSUME_MESSAGE as t, AWS_EMULATOR_SENTINEL as tt, workloadClientConfig as u, resourceTypeMatchesEmulatedService as ut, activateWorkloadAwsWiring as v, isWildcardHostname as vt, getActiveWorkloadAwsWiring as w, collectHostEndpointOverrides as x, hostFromAuthority as xt, applyWorkloadAwsWiringToEnv as y, formatAuthority as yt, writeCaBundleFile as z };
2300
- //# sourceMappingURL=workload-identity-BOEZuEDO.js.map
2870
+ export { getAwsEndpointOverride as $, parseAwsEndpoint as A, hostFromAuthority as At, workload_aws_wiring_exports as B, effectiveLoopbackPorts as C, readEnvVarsFileText as Ct, javaTruststoreToolOptions as D, isWildcardHostname as Dt, getContainerJavaTruststorePath as E, isLoopbackHostname as Et, resolveHostDefaultCredentials as F, createMixedModeTlsMaterials as G, MIXED_MODE_RESIGN_BODY_CAP_BYTES as H, resolveWorkloadAwsWiring as I, awsEndpointOverrideClientConfig as J, awsClientConfigForService as K, setActiveWorkloadAwsWiring as L, readEmulatorRunFiles as M, readProfileEndpointSettings as N, loopbackForwarderPlan as O, formatAuthority as Ot, resolveAwsEmulatorOption as P, getAwsEmulatorServiceRouting as Q, takeAwsEmulatorStateSourceHint as R, displayEndpointValue as S, applyEnvOverrideMap as St, getContainerCaBundlePath as T, defineOwnKey as Tt, RESIGN_SIDECAR_SCRIPT as U, writeCaBundleFile as V, buildJavaTrustStore as W, deployArtifactClientConfig as X, buildProxyClientConfig as Y, deployArtifactsReadEmulator as Z, HOST_DEFAULT_CREDENTIALS_MISS_TTL_MS as _, realAwsServicesForWorkload as _t, deployAccountStsClientConfig as a, setAwsEndpointOverride as at, awsEmulatorEnvName as b, validateAwsEmulatorEnvVars as bt, resetWorkloadIdentity as c, REAL_AWS_SENTINEL as ct, workloadStsClientConfig as d, findRealAwsExceptions as dt, isAwsServiceRoutedToEmulator as et, AUTH_OFF_PLACEHOLDER_CREDENTIALS as f, isLegacyAwsEmulatorSentinel as ft, HOST_CA_TRUST_ENV_KEYS as g, realAwsEndpointFor as gt, EMULATOR_SCRUBBED_ENV_KEYS as h, readAwsEmulatorEnvVarsFile as ht, assumedRoleRecorded as i, setAwsEmulatorServiceRouting as it, probeAwsEmulatorHealth as j, mergeJavaToolOptions as k, formatHostForAuthority as kt, warnWorkloadCredentialsStripped as l, createMixedModeStateProvider as lt, DEFAULT_AWS_EMULATOR_URL as m, legacyAwsEmulatorSentinelMessage as mt, accountLookupStsClientConfig as n, normalizeAwsEndpointServiceId as nt, readEnvCallerCredentials as o, LEGACY_AWS_EMULATOR_SENTINEL as ot, CA_TRUST_ENV_KEYS as p, isRealAwsSentinel as pt, awsEmulatorRealServices as q, applyWorkloadEnvCredentials as r, proxyAwareFetch as rt, recordAssumedRole as s, MIXED_MODE_RESIGN_PORT as st, SECOND_ASSUME_MESSAGE as t, isProxyEnvConfigured as tt, workloadClientConfig as u, findLegacyAwsEmulatorSentinels as ut, activateWorkloadAwsWiring as v, realAwsServicesOf as vt, getActiveWorkloadAwsWiring as w, resolveEnvVars as wt, collectHostEndpointOverrides as x, AWS_ENDPOINT_SERVICE_IDS as xt, applyWorkloadAwsWiringToEnv as y, resourceTypeMatchesService as yt, workloadGetsEmulatorKeysOnly as z };
2871
+ //# sourceMappingURL=workload-identity-BQBoBgdT.js.map