@intentius/chant-lexicon-aws 0.124.30 → 0.124.32
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.
- package/dist/actions/dynamodb.js +41 -0
- package/dist/actions/ecr.js +9 -0
- package/dist/actions/ecs.js +5 -0
- package/dist/actions/iam.js +3 -0
- package/dist/actions/index.js +9 -0
- package/dist/actions/lambda.js +11 -0
- package/dist/actions/logs.js +4 -0
- package/dist/actions/s3.js +40 -0
- package/dist/actions/sns.js +5 -0
- package/dist/actions/sqs.js +15 -0
- package/dist/agentcore/trace-fetch.d.ts.map +1 -1
- package/dist/agentcore/trace-fetch.js +472 -0
- package/dist/agentcore/trace-render.js +359 -0
- package/dist/ambient.js +148 -0
- package/dist/api/credential-chain.d.ts +30 -3
- package/dist/api/credential-chain.d.ts.map +1 -1
- package/dist/api/credential-chain.js +509 -0
- package/dist/api/read-client.d.ts +16 -43
- package/dist/api/read-client.d.ts.map +1 -1
- package/dist/api/read-client.js +458 -0
- package/dist/api/sigv4.d.ts +4 -4
- package/dist/api/sigv4.js +185 -0
- package/dist/behaviour-kinds.js +114 -0
- package/dist/caller-identity.d.ts +3 -5
- package/dist/caller-identity.d.ts.map +1 -1
- package/dist/caller-identity.js +146 -0
- package/dist/codegen/docs-cli.js +2 -0
- package/dist/codegen/docs.js +120 -0
- package/dist/codegen/enum-overlay.js +162 -0
- package/dist/codegen/extensions.js +139 -0
- package/dist/codegen/fallback.js +32 -0
- package/dist/codegen/generate-cli.js +15 -0
- package/dist/codegen/generate-lexicon.js +70 -0
- package/dist/codegen/generate-typescript.js +226 -0
- package/dist/codegen/generate.d.ts.map +1 -1
- package/dist/codegen/generate.js +234 -0
- package/dist/codegen/naming.js +135 -0
- package/dist/codegen/package.js +67 -0
- package/dist/codegen/patches.d.ts +26 -1
- package/dist/codegen/patches.d.ts.map +1 -1
- package/dist/codegen/patches.js +90 -0
- package/dist/codegen/property-overlay.js +85 -0
- package/dist/codegen/property-overlay.json +1 -16
- package/dist/codegen/sam.js +402 -0
- package/dist/codegen/typecheck.js +4 -0
- package/dist/codegen/versions.js +31 -0
- package/dist/components/__tests__/mock-cloud-executor.js +326 -0
- package/dist/components/apply.d.ts +44 -1
- package/dist/components/apply.d.ts.map +1 -1
- package/dist/components/apply.js +752 -0
- package/dist/components/builders.js +37 -0
- package/dist/components/capability-plugin.js +66 -0
- package/dist/components/cloud-executor.d.ts +35 -0
- package/dist/components/cloud-executor.d.ts.map +1 -1
- package/dist/components/cloud-executor.js +576 -0
- package/dist/components/config-bom.js +207 -0
- package/dist/components/host-delivery.js +117 -0
- package/dist/components/index.js +18 -0
- package/dist/components/job-submission.js +77 -0
- package/dist/components/publish.js +234 -0
- package/dist/components/safety.js +62 -0
- package/dist/components/wait-aws.js +68 -0
- package/dist/composites/agentcore-agent.js +187 -0
- package/dist/composites/agentcore-trust-policy.js +13 -0
- package/dist/composites/alb-shared.js +84 -0
- package/dist/composites/bucket-deployment.js +93 -0
- package/dist/composites/catalog.js +2714 -0
- package/dist/composites/dynamodb-table.js +66 -0
- package/dist/composites/ec2-instance-bundle.js +75 -0
- package/dist/composites/ec2-instance-role.js +26 -0
- package/dist/composites/ecr-repository.js +64 -0
- package/dist/composites/ecs-trust-policy.js +10 -0
- package/dist/composites/efs-with-access-point.js +44 -0
- package/dist/composites/eks-cluster.js +118 -0
- package/dist/composites/fargate-alb.js +216 -0
- package/dist/composites/fargate-service.js +222 -0
- package/dist/composites/index.js +28 -0
- package/dist/composites/lambda-api.js +15 -0
- package/dist/composites/lambda-dynamodb.js +77 -0
- package/dist/composites/lambda-eventbridge.js +27 -0
- package/dist/composites/lambda-function.js +54 -0
- package/dist/composites/lambda-s3.js +93 -0
- package/dist/composites/lambda-sns.js +23 -0
- package/dist/composites/lambda-sqs.js +34 -0
- package/dist/composites/landing-zone.js +82 -0
- package/dist/composites/microvm-app.js +293 -0
- package/dist/composites/minimal-vpc.js +40 -0
- package/dist/composites/monitoring-stack.js +105 -0
- package/dist/composites/nlb-service.js +61 -0
- package/dist/composites/rds-instance.js +98 -0
- package/dist/composites/scheduled-lambda.js +28 -0
- package/dist/composites/solr-fargate-service.js +33 -0
- package/dist/composites/step-functions-workflow.js +78 -0
- package/dist/composites/vpc-default.js +132 -0
- package/dist/condition.js +43 -0
- package/dist/coverage.js +4 -0
- package/dist/deep-observe.d.ts.map +1 -1
- package/dist/deep-observe.js +709 -0
- package/dist/deep-topology.js +226 -0
- package/dist/default-tags.js +50 -0
- package/dist/defaults.js +85 -0
- package/dist/dependencies.js +269 -0
- package/dist/detect.js +21 -0
- package/dist/disruption.d.ts.map +1 -1
- package/dist/disruption.js +129 -0
- package/dist/effect-receipt-row.js +107 -0
- package/dist/generated/index.d.ts +1297 -82
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +12382 -0
- package/dist/generated/runtime.js +4 -0
- package/dist/governance.js +131 -0
- package/dist/identity-observe.d.ts.map +1 -1
- package/dist/identity-observe.js +127 -0
- package/dist/import/generator.js +757 -0
- package/dist/import/live-export.js +34 -0
- package/dist/import/parser.js +394 -0
- package/dist/index.js +69 -0
- package/dist/integrity.json +6 -6
- package/dist/intrinsics.js +393 -0
- package/dist/lint/audit-catalog.js +87 -0
- package/dist/lint/audit-lineage.js +150 -0
- package/dist/lint/post-synth/cf-refs.js +247 -0
- package/dist/lint/post-synth/cor020.js +60 -0
- package/dist/lint/post-synth/ext001.d.ts.map +1 -1
- package/dist/lint/post-synth/ext001.js +197 -0
- package/dist/lint/post-synth/index.js +124 -0
- package/dist/lint/post-synth/waw010.js +41 -0
- package/dist/lint/post-synth/waw011.js +41 -0
- package/dist/lint/post-synth/waw013.js +38 -0
- package/dist/lint/post-synth/waw014.js +42 -0
- package/dist/lint/post-synth/waw015.js +88 -0
- package/dist/lint/post-synth/waw016.d.ts.map +1 -1
- package/dist/lint/post-synth/waw016.js +116 -0
- package/dist/lint/post-synth/waw017.js +43 -0
- package/dist/lint/post-synth/waw018.js +61 -0
- package/dist/lint/post-synth/waw019.js +64 -0
- package/dist/lint/post-synth/waw020.js +56 -0
- package/dist/lint/post-synth/waw021.js +44 -0
- package/dist/lint/post-synth/waw022.js +36 -0
- package/dist/lint/post-synth/waw023.js +40 -0
- package/dist/lint/post-synth/waw024.js +46 -0
- package/dist/lint/post-synth/waw025.js +36 -0
- package/dist/lint/post-synth/waw026.js +38 -0
- package/dist/lint/post-synth/waw027.js +41 -0
- package/dist/lint/post-synth/waw028.js +39 -0
- package/dist/lint/post-synth/waw029.js +54 -0
- package/dist/lint/post-synth/waw030.js +282 -0
- package/dist/lint/post-synth/waw031.js +58 -0
- package/dist/lint/post-synth/waw032.js +45 -0
- package/dist/lint/post-synth/waw033.js +75 -0
- package/dist/lint/post-synth/waw034.js +52 -0
- package/dist/lint/post-synth/waw035.js +56 -0
- package/dist/lint/post-synth/waw036.js +79 -0
- package/dist/lint/post-synth/waw037.js +67 -0
- package/dist/lint/post-synth/waw038.js +42 -0
- package/dist/lint/post-synth/waw039.js +42 -0
- package/dist/lint/post-synth/waw040.js +45 -0
- package/dist/lint/post-synth/waw041.js +40 -0
- package/dist/lint/post-synth/waw042.js +99 -0
- package/dist/lint/post-synth/waw043.js +51 -0
- package/dist/lint/post-synth/waw044.js +64 -0
- package/dist/lint/post-synth/waw045.js +49 -0
- package/dist/lint/post-synth/waw046.js +52 -0
- package/dist/lint/post-synth/waw047.js +43 -0
- package/dist/lint/post-synth/waw048.js +40 -0
- package/dist/lint/post-synth/waw049.js +78 -0
- package/dist/lint/post-synth/waw050.js +44 -0
- package/dist/lint/post-synth/waw051.js +41 -0
- package/dist/lint/post-synth/waw052.js +43 -0
- package/dist/lint/post-synth/waw053.js +43 -0
- package/dist/lint/post-synth/waw054.js +41 -0
- package/dist/lint/post-synth/waw055.js +41 -0
- package/dist/lint/post-synth/waw056.js +65 -0
- package/dist/lint/post-synth/waw057.js +43 -0
- package/dist/lint/post-synth/waw058.js +61 -0
- package/dist/lint/post-synth/waw059.js +338 -0
- package/dist/lint/post-synth/waw060.js +83 -0
- package/dist/lint/post-synth/waw061.js +60 -0
- package/dist/lint/post-synth/waw062.js +0 -0
- package/dist/lint/post-synth/waw063.js +0 -0
- package/dist/lint/post-synth/waw064.js +45 -0
- package/dist/lint/post-synth/waw065.js +104 -0
- package/dist/lint/post-synth/waw066.js +145 -0
- package/dist/lint/post-synth/waw067.js +115 -0
- package/dist/lint/post-synth/waw068.js +69 -0
- package/dist/lint/post-synth/waw069.js +0 -0
- package/dist/lint/rules/hardcoded-region.js +38 -0
- package/dist/lint/rules/iam-wildcard.js +60 -0
- package/dist/lint/rules/index.js +6 -0
- package/dist/lint/rules/s3-encryption.js +60 -0
- package/dist/live-attrs.js +42 -0
- package/dist/lsp/completions.d.ts.map +1 -1
- package/dist/lsp/completions.js +18 -0
- package/dist/lsp/hover.d.ts.map +1 -1
- package/dist/lsp/hover.js +66 -0
- package/dist/manifest.json +1 -1
- package/dist/mapping.js +33 -0
- package/dist/meta.json +17359 -784
- package/dist/nested-stack.js +95 -0
- package/dist/okf/index.md +203 -0
- package/dist/okf/rules/EXT001.md +1 -0
- package/dist/okf/rules/WAW016.md +2 -0
- package/dist/okf/rules/WAW019.md +1 -0
- package/dist/okf/rules/WAW028.md +1 -0
- package/dist/okf/rules/WAW030.md +2 -0
- package/dist/okf/rules/WAW039.md +1 -0
- package/dist/okf/rules/WAW049.md +1 -0
- package/dist/okf/rules/WAW056.md +1 -0
- package/dist/okf/rules/WAW058.md +1 -0
- package/dist/okf/rules/WAW062.md +1 -0
- package/dist/okf/rules/WAW064.md +1 -0
- package/dist/okf/rules/WAW065.md +1 -0
- package/dist/okf/rules/WAW066.md +1 -0
- package/dist/okf/rules/WAW067.md +1 -0
- package/dist/okf/rules/WAW068.md +1 -0
- package/dist/okf/rules/WAW069.md +4 -0
- package/dist/okf/types/AIWorkloadConfig.md +23 -0
- package/dist/okf/types/ARCRegionSwitchPlan.md +1 -0
- package/dist/okf/types/AccountAccessApplication.md +28 -0
- package/dist/okf/types/AccountAccessEntitlement.md +22 -0
- package/dist/okf/types/ActionTarget.md +20 -0
- package/dist/okf/types/AdConfiguration.md +21 -0
- package/dist/okf/types/Adapter.md +26 -0
- package/dist/okf/types/AgentContext.md +35 -0
- package/dist/okf/types/AgentGoal.md +31 -0
- package/dist/okf/types/AgentProfile.md +34 -0
- package/dist/okf/types/Alarm.md +3 -1
- package/dist/okf/types/AlarmModel.md +14 -9
- package/dist/okf/types/AmplifyWebhook.md +25 -0
- package/dist/okf/types/ApiCache.md +8 -8
- package/dist/okf/types/ApiGatewayManagedOverrides.md +5 -5
- package/dist/okf/types/AppAuthorization.md +35 -0
- package/dist/okf/types/AppBlockBuilder.md +1 -0
- package/dist/okf/types/AppInstance.md +2 -2
- package/dist/okf/types/AppInstanceBot.md +2 -2
- package/dist/okf/types/AppStreamFleet.md +3 -2
- package/dist/okf/types/AppSyncApiKey.md +6 -6
- package/dist/okf/types/AppSyncType.md +22 -0
- package/dist/okf/types/ApplicationStatusCheck.md +36 -0
- package/dist/okf/types/ApplicationVersion.md +4 -1
- package/dist/okf/types/ApplicationsList.md +26 -0
- package/dist/okf/types/ApprovalPolicy.md +28 -0
- package/dist/okf/types/ArchiveRule.md +24 -0
- package/dist/okf/types/Asset.md +30 -0
- package/dist/okf/types/Backup.md +31 -0
- package/dist/okf/types/BedrockAgentCoreDataset.md +1 -1
- package/dist/okf/types/BedrockAgentCoreGateway.md +3 -0
- package/dist/okf/types/BedrockSession.md +28 -0
- package/dist/okf/types/BillEstimate.md +35 -0
- package/dist/okf/types/Brand.md +32 -0
- package/dist/okf/types/CallAnalyticsCategory.md +25 -0
- package/dist/okf/types/Campaign.md +28 -0
- package/dist/okf/types/CapacityProvider.md +30 -0
- package/dist/okf/types/Case.md +24 -0
- package/dist/okf/types/CertificateAssociation.md +13 -0
- package/dist/okf/types/ChangeSet.md +36 -0
- package/dist/okf/types/ChannelFlow.md +29 -0
- package/dist/okf/types/ChimeChannel.md +39 -0
- package/dist/okf/types/Classifier.md +6 -6
- package/dist/okf/types/ClientVpnAuthorizationRule.md +6 -6
- package/dist/okf/types/ClientVpnEndpoint.md +2 -0
- package/dist/okf/types/ClientVpnRoute.md +5 -5
- package/dist/okf/types/CloudConnector.md +29 -0
- package/dist/okf/types/Cluster.md +39 -0
- package/dist/okf/types/ClusterSchedulerConfig.md +30 -0
- package/dist/okf/types/CodeCommitRepository.md +12 -12
- package/dist/okf/types/CodeConnectionsHost.md +26 -0
- package/dist/okf/types/CodeRepository.md +5 -5
- package/dist/okf/types/CompositeAlarm.md +1 -0
- package/dist/okf/types/ComputeEnvironment.md +2 -0
- package/dist/okf/types/ComputeNodeGroup.md +1 -1
- package/dist/okf/types/ComputeQuota.md +34 -0
- package/dist/okf/types/ConfigRule.md +1 -1
- package/dist/okf/types/ConfigurationRecorder.md +7 -6
- package/dist/okf/types/ConnectAttachment.md +2 -0
- package/dist/okf/types/ConnectQueue.md +5 -1
- package/dist/okf/types/ConnectVocabulary.md +28 -0
- package/dist/okf/types/ConnectionType.md +24 -0
- package/dist/okf/types/ConsentPortal.md +33 -0
- package/dist/okf/types/ContactMethod.md +29 -0
- package/dist/okf/types/ContainerAssociation.md +26 -0
- package/dist/okf/types/ContainerFleet.md +1 -1
- package/dist/okf/types/ContainerGroupDefinition.md +1 -1
- package/dist/okf/types/Content.md +40 -0
- package/dist/okf/types/ContentAssociation.md +28 -0
- package/dist/okf/types/CustomDetectionRuleAssociation.md +28 -0
- package/dist/okf/types/CustomEntityType.md +4 -9
- package/dist/okf/types/Customization.md +22 -0
- package/dist/okf/types/CwIntegration.md +31 -0
- package/dist/okf/types/DAXParameterGroup.md +3 -8
- package/dist/okf/types/DAXSubnetGroup.md +0 -5
- package/dist/okf/types/DBClusterEndpoint.md +31 -0
- package/dist/okf/types/DBProxyTargetGroup.md +1 -0
- package/dist/okf/types/DBSnapshot.md +62 -0
- package/dist/okf/types/DLMLifecyclePolicy.md +12 -12
- package/dist/okf/types/DLPSetting.md +31 -0
- package/dist/okf/types/DMSInstanceProfile.md +1 -1
- package/dist/okf/types/DRSLaunchConfigurationTemplate.md +28 -0
- package/dist/okf/types/Daemon.md +1 -0
- package/dist/okf/types/DataExchangeDataSet.md +29 -0
- package/dist/okf/types/DataIntegrationFlow.md +27 -0
- package/dist/okf/types/DataMigration.md +1 -1
- package/dist/okf/types/DataProvider.md +2 -1
- package/dist/okf/types/DataQualityRuleset.md +6 -11
- package/dist/okf/types/DataSource.md +23 -0
- package/dist/okf/types/Dataset.md +20 -0
- package/dist/okf/types/DatasetIntegration.md +23 -0
- package/dist/okf/types/DbCluster.md +1 -1
- package/dist/okf/types/DbInstance.md +8 -2
- package/dist/okf/types/DeadlineBudget.md +29 -0
- package/dist/okf/types/DelegationSet.md +23 -0
- package/dist/okf/types/DeliveryChannel.md +6 -11
- package/dist/okf/types/DevOpsAgentAgentSpace.md +4 -0
- package/dist/okf/types/DevOpsAgentService.md +1 -0
- package/dist/okf/types/DevOpsAgentTrigger.md +28 -0
- package/dist/okf/types/DirectConnectGatewayAttachment.md +2 -0
- package/dist/okf/types/Directory.md +60 -0
- package/dist/okf/types/DocDBDBClusterParameterGroup.md +5 -10
- package/dist/okf/types/DocDBDBSubnetGroup.md +4 -9
- package/dist/okf/types/DocDBElasticClusterSnapshot.md +36 -0
- package/dist/okf/types/DocumentClassifierEndpoint.md +27 -0
- package/dist/okf/types/Domain.md +27 -0
- package/dist/okf/types/EKSCertificateAuthority.md +42 -0
- package/dist/okf/types/EKSCluster.md +8 -0
- package/dist/okf/types/EcSnapshot.md +66 -0
- package/dist/okf/types/EmailIdentityCertificate.md +15 -0
- package/dist/okf/types/EndpointConfig.md +14 -13
- package/dist/okf/types/EntityRecognizer.md +27 -0
- package/dist/okf/types/EntityRecognizerEndpoint.md +31 -0
- package/dist/okf/types/EnvironmentEC2.md +13 -13
- package/dist/okf/types/EvaluationForm.md +1 -0
- package/dist/okf/types/Evaluator.md +6 -2
- package/dist/okf/types/EventAction.md +26 -0
- package/dist/okf/types/EventRule.md +2 -0
- package/dist/okf/types/EventSource.md +30 -0
- package/dist/okf/types/EventTracker.md +22 -0
- package/dist/okf/types/EventsV2EventBus.md +28 -0
- package/dist/okf/types/EventsV2ResourcePolicy.md +19 -0
- package/dist/okf/types/EventsV2Subscriber.md +39 -0
- package/dist/okf/types/ExperimentDefinition.md +39 -0
- package/dist/okf/types/ExperimentRun.md +33 -0
- package/dist/okf/types/ExperimentTrialComponent.md +13 -11
- package/dist/okf/types/FHIRDatastore.md +3 -0
- package/dist/okf/types/FSxSnapshot.md +5 -5
- package/dist/okf/types/FSxVolume.md +9 -9
- package/dist/okf/types/FeaturedResultsSet.md +26 -0
- package/dist/okf/types/Feed.md +1 -0
- package/dist/okf/types/FieldLevelEncryptionConfig.md +25 -0
- package/dist/okf/types/FieldLevelEncryptionProfile.md +22 -0
- package/dist/okf/types/FileCache.md +45 -0
- package/dist/okf/types/Filter.md +27 -0
- package/dist/okf/types/Firewall.md +6 -0
- package/dist/okf/types/FlowMediaStream.md +28 -0
- package/dist/okf/types/FlowOutput.md +1 -0
- package/dist/okf/types/FpgaImage.md +38 -0
- package/dist/okf/types/Function.md +2 -2
- package/dist/okf/types/Gateway.md +41 -0
- package/dist/okf/types/GatewayClusterAssociations.md +23 -0
- package/dist/okf/types/GatewayRateLimit.md +26 -0
- package/dist/okf/types/GatewayRule.md +32 -0
- package/dist/okf/types/GlobalReplicationGroup.md +3 -0
- package/dist/okf/types/GlobalResolver.md +1 -1
- package/dist/okf/types/GlobalTable.md +1 -0
- package/dist/okf/types/GlueConnection.md +5 -4
- package/dist/okf/types/GlueSecurityConfiguration.md +1 -6
- package/dist/okf/types/GlueSession.md +38 -0
- package/dist/okf/types/GlueTable.md +5 -10
- package/dist/okf/types/GlueWorkflow.md +5 -10
- package/dist/okf/types/Group.md +27 -0
- package/dist/okf/types/Harness.md +1 -0
- package/dist/okf/types/HostKey.md +33 -0
- package/dist/okf/types/HostedZone.md +1 -0
- package/dist/okf/types/HttpApi.md +2 -0
- package/dist/okf/types/HttpNamespace.md +5 -5
- package/dist/okf/types/HubV2.md +1 -0
- package/dist/okf/types/HumanTaskUi.md +22 -0
- package/dist/okf/types/IPv4Pool.md +28 -0
- package/dist/okf/types/ImageBuilder.md +1 -0
- package/dist/okf/types/ImageBuilderImage.md +1 -1
- package/dist/okf/types/ImagePipeline.md +1 -1
- package/dist/okf/types/InferenceComponent.md +5 -1
- package/dist/okf/types/InfluxDBBackup.md +65 -0
- package/dist/okf/types/InfluxDBCluster.md +3 -0
- package/dist/okf/types/InfrastructureConfiguration.md +2 -0
- package/dist/okf/types/IngestionDestination.md +28 -0
- package/dist/okf/types/InputSecurityGroup.md +6 -4
- package/dist/okf/types/InspectorV2Connector.md +38 -0
- package/dist/okf/types/InstanceEventWindow.md +25 -0
- package/dist/okf/types/InstanceFleetConfig.md +10 -10
- package/dist/okf/types/InstanceGroupConfig.md +3 -3
- package/dist/okf/types/InstrumentationConfig.md +31 -0
- package/dist/okf/types/IntegrationAssociation.md +3 -0
- package/dist/okf/types/IoTSiteWiseApplication.md +34 -0
- package/dist/okf/types/IoTSiteWiseDataset.md +5 -2
- package/dist/okf/types/IoTSiteWiseTask.md +24 -0
- package/dist/okf/types/IpamExternalResourceVerificationToken.md +35 -0
- package/dist/okf/types/IpamInternetRegistryAssociation.md +32 -0
- package/dist/okf/types/Job.md +35 -0
- package/dist/okf/types/JobTemplate.md +26 -0
- package/dist/okf/types/KinesisChannel.md +31 -0
- package/dist/okf/types/KinesisStream.md +1 -0
- package/dist/okf/types/LambdaResourcePolicy.md +14 -0
- package/dist/okf/types/Lexicon.md +34 -0
- package/dist/okf/types/LicenseAssetGroup.md +23 -0
- package/dist/okf/types/LicenseConfiguration.md +33 -0
- package/dist/okf/types/LicenseServerEndpoint.md +32 -0
- package/dist/okf/types/LightsailKeyPair.md +29 -0
- package/dist/okf/types/LimitsProfile.md +27 -0
- package/dist/okf/types/LocationAzureBlob.md +2 -1
- package/dist/okf/types/LocationObjectStorage.md +1 -0
- package/dist/okf/types/LogAlarm.md +2 -0
- package/dist/okf/types/MGNConnector.md +23 -0
- package/dist/okf/types/MGNLaunchConfigurationTemplate.md +37 -0
- package/dist/okf/types/MLTransform.md +15 -15
- package/dist/okf/types/MWAAServerlessWorkflow.md +3 -0
- package/dist/okf/types/ManagedNotificationAccountContactAssociation.md +1 -0
- package/dist/okf/types/ManagedNotificationAdditionalChannelAssociation.md +1 -0
- package/dist/okf/types/MediaConvertJobTemplate.md +11 -13
- package/dist/okf/types/MediaConvertQueue.md +8 -10
- package/dist/okf/types/MediaInsightsPipelineConfiguration.md +28 -0
- package/dist/okf/types/MediaLiveInput.md +41 -18
- package/dist/okf/types/MediaPackageV2Channel.md +3 -0
- package/dist/okf/types/MediaPackageV2OriginEndpoint.md +1 -0
- package/dist/okf/types/MediaPipelineKinesisVideoStreamPool.md +28 -0
- package/dist/okf/types/MediaTailorFunction.md +27 -0
- package/dist/okf/types/MedicalVocabulary.md +21 -0
- package/dist/okf/types/Member.md +26 -0
- package/dist/okf/types/Memory.md +6 -0
- package/dist/okf/types/MemoryDBSnapshot.md +29 -0
- package/dist/okf/types/Metric.md +59 -0
- package/dist/okf/types/MetricAttribution.md +23 -0
- package/dist/okf/types/MicrosoftAD.md +11 -11
- package/dist/okf/types/MigrationProject.md +8 -1
- package/dist/okf/types/Monitor.md +26 -0
- package/dist/okf/types/NFSFileShare.md +44 -0
- package/dist/okf/types/NeptuneGraphGraph.md +1 -0
- package/dist/okf/types/NetworkConnector.md +4 -0
- package/dist/okf/types/NetworkFlowMonitorScope.md +23 -0
- package/dist/okf/types/NetworkMigrationDefinition.md +31 -0
- package/dist/okf/types/NetworkSecurityManagerDeployment.md +31 -0
- package/dist/okf/types/NetworkSecurityManagerPolicy.md +32 -0
- package/dist/okf/types/NetworkSecurityManagerScope.md +29 -0
- package/dist/okf/types/NotebookInstance.md +18 -18
- package/dist/okf/types/NotebookInstanceLifecycleConfig.md +6 -5
- package/dist/okf/types/NotifyConfiguration.md +35 -0
- package/dist/okf/types/OTelEnrichment.md +2 -0
- package/dist/okf/types/OnlineEvaluationConfig.md +0 -1
- package/dist/okf/types/OrganizationConfigRule.md +7 -7
- package/dist/okf/types/Outpost.md +32 -0
- package/dist/okf/types/ParallelData.md +40 -0
- package/dist/okf/types/Partition.md +5 -5
- package/dist/okf/types/PaymentConnector.md +4 -1
- package/dist/okf/types/Pentest.md +1 -0
- package/dist/okf/types/PerfReports.md +28 -0
- package/dist/okf/types/PermissionAssociation.md +30 -0
- package/dist/okf/types/PersonalizeDataset.md +1 -0
- package/dist/okf/types/PersonalizeDatasetGroup.md +1 -0
- package/dist/okf/types/PersonalizeSchema.md +1 -0
- package/dist/okf/types/Pipeline.md +25 -0
- package/dist/okf/types/PlaybackConfiguration.md +1 -0
- package/dist/okf/types/PolicyAssociation.md +1 -1
- package/dist/okf/types/PolicyGrant.md +2 -2
- package/dist/okf/types/PolicyPrincipalAttachment.md +2 -7
- package/dist/okf/types/PortalProduct.md +24 -0
- package/dist/okf/types/PrefetchSchedule.md +25 -0
- package/dist/okf/types/PricingPlanManagerSubscription.md +31 -0
- package/dist/okf/types/PrincipalAssociation.md +27 -0
- package/dist/okf/types/PrivateDnsNamespace.md +8 -8
- package/dist/okf/types/PrivateVirtualInterface.md +1 -0
- package/dist/okf/types/ProcurementPortalPreference.md +45 -0
- package/dist/okf/types/Program.md +33 -0
- package/dist/okf/types/ProjectMembership.md +1 -1
- package/dist/okf/types/ProtocolsList.md +26 -0
- package/dist/okf/types/PublicDnsNamespace.md +7 -7
- package/dist/okf/types/PublicVirtualInterface.md +1 -0
- package/dist/okf/types/QEV2IdcApplication.md +25 -0
- package/dist/okf/types/QueryLoggingConfig.md +21 -0
- package/dist/okf/types/QuerySuggestionsBlockList.md +25 -0
- package/dist/okf/types/QuickSightAssignment.md +24 -0
- package/dist/okf/types/RAMResourceAssociation.md +27 -0
- package/dist/okf/types/RDSClusterSnapshot.md +54 -0
- package/dist/okf/types/RDSDBParameterGroup.md +5 -0
- package/dist/okf/types/RDSDeployment.md +41 -0
- package/dist/okf/types/RcsAgent.md +38 -0
- package/dist/okf/types/ReceiptRule.md +5 -5
- package/dist/okf/types/ReceiptRuleSet.md +1 -6
- package/dist/okf/types/RecommenderFilter.md +27 -0
- package/dist/okf/types/RecommenderSchema.md +25 -0
- package/dist/okf/types/RecordSet.md +16 -22
- package/dist/okf/types/RecoveryPlan.md +28 -0
- package/dist/okf/types/RedshiftIdcApplication.md +31 -0
- package/dist/okf/types/RedshiftSnapshot.md +59 -0
- package/dist/okf/types/RegistrationAttachment.md +28 -0
- package/dist/okf/types/Registry.md +41 -0
- package/dist/okf/types/RegistryRecord.md +38 -0
- package/dist/okf/types/RelatedItem.md +24 -0
- package/dist/okf/types/ReplicationConfigurationTemplate.md +35 -0
- package/dist/okf/types/ReplicationSubnetGroup.md +4 -9
- package/dist/okf/types/ReplicationTask.md +14 -14
- package/dist/okf/types/ReportGenerator.md +29 -0
- package/dist/okf/types/ReportGroup.md +1 -3
- package/dist/okf/types/ResilienceHubV2Policy.md +1 -0
- package/dist/okf/types/ResilienceHubV2Service.md +1 -0
- package/dist/okf/types/ResourceConfiguration.md +1 -1
- package/dist/okf/types/ResourceMetricsConfiguration.md +21 -0
- package/dist/okf/types/RestApi.md +1 -0
- package/dist/okf/types/RetrievalInstruction.md +32 -0
- package/dist/okf/types/RouterOutput.md +1 -0
- package/dist/okf/types/Rule.md +31 -0
- package/dist/okf/types/RunCache.md +29 -0
- package/dist/okf/types/Runtime.md +2 -1
- package/dist/okf/types/SCNInstance.md +33 -0
- package/dist/okf/types/SDBDomain.md +2 -2
- package/dist/okf/types/SMBFileShare.md +49 -0
- package/dist/okf/types/SageMakerArtifact.md +27 -0
- package/dist/okf/types/SageMakerEndpoint.md +0 -1
- package/dist/okf/types/ScalableTarget.md +1 -0
- package/dist/okf/types/ScalingPlan.md +6 -6
- package/dist/okf/types/ScheduledReport.md +31 -0
- package/dist/okf/types/SecondaryNetwork.md +26 -0
- package/dist/okf/types/SecurityAgentArtifact.md +25 -0
- package/dist/okf/types/SecurityAgentIntegration.md +31 -0
- package/dist/okf/types/Server.md +1 -0
- package/dist/okf/types/ServerlessCache.md +2 -0
- package/dist/okf/types/ServerlessCacheSnapshot.md +31 -0
- package/dist/okf/types/ServerlessRepoApplication.md +32 -0
- package/dist/okf/types/ServiceDiscoveryInstance.md +3 -7
- package/dist/okf/types/SipMediaApplication.md +27 -0
- package/dist/okf/types/SiteToSiteVpnAttachment.md +2 -0
- package/dist/okf/types/SnapshotCopyGrant.md +20 -0
- package/dist/okf/types/Solution.md +1 -0
- package/dist/okf/types/SourceAssociation.md +25 -0
- package/dist/okf/types/SourceCredential.md +6 -6
- package/dist/okf/types/SourceNetwork.md +23 -0
- package/dist/okf/types/StackFleetAssociation.md +2 -7
- package/dist/okf/types/StorageTierPolicy.md +20 -0
- package/dist/okf/types/StorageVirtualMachine.md +9 -9
- package/dist/okf/types/Stream.md +28 -0
- package/dist/okf/types/SubnetCidrReservation.md +26 -0
- package/dist/okf/types/SubscriptionProvider.md +26 -0
- package/dist/okf/types/SupportPermit.md +29 -0
- package/dist/okf/types/Table.md +2 -1
- package/dist/okf/types/TableOptimizer.md +5 -10
- package/dist/okf/types/Tape.md +31 -0
- package/dist/okf/types/Template.md +36 -0
- package/dist/okf/types/Tenant.md +2 -0
- package/dist/okf/types/Terminology.md +39 -0
- package/dist/okf/types/Thesaurus.md +25 -0
- package/dist/okf/types/ThingPrincipalAttachment.md +3 -8
- package/dist/okf/types/Topic.md +1 -0
- package/dist/okf/types/TopicRuleDestination.md +1 -0
- package/dist/okf/types/TrafficPolicy.md +26 -0
- package/dist/okf/types/TrafficPolicyInstance.md +28 -0
- package/dist/okf/types/TranscribeVocabulary.md +27 -0
- package/dist/okf/types/TransitGatewayRouteTableAttachment.md +2 -0
- package/dist/okf/types/TransitVirtualInterface.md +1 -0
- package/dist/okf/types/Tunnel.md +25 -0
- package/dist/okf/types/UsageLimit.md +26 -0
- package/dist/okf/types/UseCase.md +23 -0
- package/dist/okf/types/User.md +47 -0
- package/dist/okf/types/VPCEndpoint.md +1 -1
- package/dist/okf/types/VPCEndpointService.md +6 -0
- package/dist/okf/types/VPCPeeringConnection.md +2 -2
- package/dist/okf/types/VPNConcentrator.md +1 -1
- package/dist/okf/types/VPNConnection.md +1 -1
- package/dist/okf/types/VerifiedDestinationNumber.md +25 -0
- package/dist/okf/types/View.md +27 -0
- package/dist/okf/types/VoiceConnector.md +30 -0
- package/dist/okf/types/Volume.md +44 -0
- package/dist/okf/types/Vpc.md +1 -1
- package/dist/okf/types/VpcAttachment.md +2 -0
- package/dist/okf/types/WebFunction.md +27 -0
- package/dist/okf/types/WebFunctionEndpoint.md +44 -0
- package/dist/okf/types/WebFunctionRevision.md +32 -0
- package/dist/okf/types/WickrNetwork.md +27 -0
- package/dist/okf/types/Worker.md +29 -0
- package/dist/okf/types/Workforce.md +26 -0
- package/dist/okf/types/Workload.md +35 -0
- package/dist/okf/types/WorkloadEstimate.md +35 -0
- package/dist/okf/types/Workspace.md +28 -0
- package/dist/okf/types/Workteam.md +8 -8
- package/dist/op/activities/aws-apply.js +214 -0
- package/dist/op/activities/floci.js +97 -0
- package/dist/op/activities/index.js +32 -0
- package/dist/op/builders.js +50 -0
- package/dist/ownership.js +52 -0
- package/dist/package-cli.js +25 -0
- package/dist/parameter.js +19 -0
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +1006 -0
- package/dist/properties.js +166 -0
- package/dist/pseudo.js +25 -0
- package/dist/receipt-store.d.ts.map +1 -1
- package/dist/receipt-store.js +233 -0
- package/dist/reference-catalog.js +106 -0
- package/dist/rules/ext001.ts +3 -3
- package/dist/rules/waw016.ts +2 -2
- package/dist/serializer.js +529 -0
- package/dist/spec/fetch.js +193 -0
- package/dist/spec/parse.js +259 -0
- package/dist/spec/pin.js +185 -0
- package/dist/spec/pinned-types.json +203 -0
- package/dist/stack-errors.js +14 -0
- package/dist/taggable.d.ts.map +1 -1
- package/dist/taggable.js +33 -0
- package/dist/teardown.js +199 -0
- package/dist/template-sections.js +53 -0
- package/dist/template-transform.js +50 -0
- package/dist/types/index.d.ts +18847 -1124
- package/dist/validate-cli.js +16 -0
- package/dist/validate.js +33 -0
- package/package.json +9 -9
- package/src/agentcore/trace-fetch.ts +2 -1
- package/src/api/credential-chain.ts +119 -9
- package/src/api/credential-isolation.test.ts +72 -0
- package/src/api/read-client-chain.test.ts +159 -0
- package/src/api/read-client.ts +42 -6
- package/src/api/sigv4.ts +4 -4
- package/src/caller-identity.ts +3 -5
- package/src/codegen/any-budget.test.ts +12 -2
- package/src/codegen/generate.ts +9 -0
- package/src/codegen/package.ts +2 -2
- package/src/codegen/patches.test.ts +95 -0
- package/src/codegen/patches.ts +53 -9
- package/src/codegen/property-overlay.json +1 -16
- package/src/components/apply.ts +218 -6
- package/src/components/cfn-plan-floci.e2e.test.ts +76 -0
- package/src/components/cfn-plan.test.ts +225 -16
- package/src/components/cloud-executor.ts +73 -25
- package/src/deep-observe.ts +2 -1
- package/src/disruption.ts +2 -1
- package/src/generated/index.d.ts +18847 -1124
- package/src/generated/index.ts +1376 -161
- package/src/generated/lexicon-aws.json +17359 -784
- package/src/identity-observe.ts +2 -1
- package/src/lint/post-synth/ext001.ts +3 -3
- package/src/lint/post-synth/waw016.ts +2 -2
- package/src/lsp/completions.ts +2 -1
- package/src/lsp/hover.ts +2 -1
- package/src/plugin.ts +2 -1
- package/src/receipt-store.ts +2 -1
- package/src/spec/pin.ts +3 -3
- package/src/spec/pinned-types.json +203 -0
- package/src/taggable.ts +2 -2
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
import { loadLexiconRegistry } from "@intentius/chant/codegen/registry";
|
|
2
|
+
import { createRequire } from "module";
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
import { topoSort } from "@intentius/chant/codegen/topo-sort";
|
|
5
|
+
import { hasIntrinsicInValue, irUsesIntrinsic, collectDependencies } from "@intentius/chant/import/ir-utils";
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
/**
|
|
8
|
+
* TypeScript code generator for CloudFormation templates
|
|
9
|
+
*/
|
|
10
|
+
export class CFGenerator {
|
|
11
|
+
constructor() {
|
|
12
|
+
/** One `main.ts` holds the whole template. Split files would each need the
|
|
13
|
+
* parameters, conditions and resources the others declare. */
|
|
14
|
+
this.ownsLayout = true;
|
|
15
|
+
/** Resource classes imported under another name, because a logical id in
|
|
16
|
+
* the template is the class's own name (`InternetGateway`). */
|
|
17
|
+
this.classAliases = new Map();
|
|
18
|
+
/** Variable names for mappings ("m:<name>"), conditions ("c:<name>") and
|
|
19
|
+
* outputs ("o:<name>") whose template name is already a parameter's or
|
|
20
|
+
* resource's (#3604). */
|
|
21
|
+
this.renames = new Map();
|
|
22
|
+
// Reverse lookup from the generated registry: resourceType → className.
|
|
23
|
+
// Loaded through core so a missing registry says what to run rather than
|
|
24
|
+
// "Cannot find module .../dist/meta.json" (#1367).
|
|
25
|
+
const meta = loadLexiconRegistry(join(import.meta.dirname, "../.."), "aws");
|
|
26
|
+
this.typeToClass = new Map();
|
|
27
|
+
this.allClassNames = new Set();
|
|
28
|
+
this.attrsByType = new Map();
|
|
29
|
+
for (const [className, entry] of Object.entries(meta)) {
|
|
30
|
+
if (entry.kind === "resource" && !className.includes("_")) {
|
|
31
|
+
this.typeToClass.set(entry.resourceType, className);
|
|
32
|
+
this.allClassNames.add(className);
|
|
33
|
+
// The aws registry also carries each class's attribute map.
|
|
34
|
+
this.attrsByType.set(entry.resourceType, entry.attrs ?? {});
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generate TypeScript files from intermediate representation
|
|
40
|
+
*/
|
|
41
|
+
generate(ir) {
|
|
42
|
+
const lines = [];
|
|
43
|
+
this.classAliases = this.computeClassAliases(ir);
|
|
44
|
+
// Collect the set of imported class names so we can detect variable name conflicts
|
|
45
|
+
const importedSymbols = this.collectImportedSymbols(ir);
|
|
46
|
+
this.renames = this.collisionRenames(ir, importedSymbols);
|
|
47
|
+
// Generate imports
|
|
48
|
+
lines.push(this.generateImports(ir));
|
|
49
|
+
lines.push("");
|
|
50
|
+
// Template-level Description and Metadata
|
|
51
|
+
const sections = this.generateTemplateSections(ir, importedSymbols);
|
|
52
|
+
if (sections.length > 0) {
|
|
53
|
+
lines.push(...sections, "");
|
|
54
|
+
}
|
|
55
|
+
// Generate parameters
|
|
56
|
+
for (const param of ir.parameters) {
|
|
57
|
+
lines.push(this.generateParameter(param, importedSymbols));
|
|
58
|
+
}
|
|
59
|
+
if (ir.parameters.length > 0) {
|
|
60
|
+
lines.push("");
|
|
61
|
+
}
|
|
62
|
+
// Generate mappings
|
|
63
|
+
const mappings = this.mappings(ir);
|
|
64
|
+
for (const [name, map] of Object.entries(mappings)) {
|
|
65
|
+
lines.push(this.generateMapping(name, map, importedSymbols));
|
|
66
|
+
}
|
|
67
|
+
if (Object.keys(mappings).length > 0) {
|
|
68
|
+
lines.push("");
|
|
69
|
+
}
|
|
70
|
+
// Generate conditions in dependency order ({ Condition: ... } references
|
|
71
|
+
// point at earlier declarations) — #2069
|
|
72
|
+
const conditions = ir.conditions ?? [];
|
|
73
|
+
const sortedConditions = this.sortConditions(conditions);
|
|
74
|
+
for (const condition of sortedConditions) {
|
|
75
|
+
lines.push(this.generateCondition(condition, ir, importedSymbols));
|
|
76
|
+
}
|
|
77
|
+
if (conditions.length > 0) {
|
|
78
|
+
lines.push("");
|
|
79
|
+
}
|
|
80
|
+
// Generate resources in dependency order
|
|
81
|
+
const sortedResources = this.sortByDependencies(ir.resources);
|
|
82
|
+
for (const resource of sortedResources) {
|
|
83
|
+
lines.push(this.generateResource(resource, ir, importedSymbols));
|
|
84
|
+
}
|
|
85
|
+
// Generate outputs (#2069)
|
|
86
|
+
const outputs = ir.outputs ?? [];
|
|
87
|
+
if (outputs.length > 0) {
|
|
88
|
+
lines.push("");
|
|
89
|
+
for (const output of outputs) {
|
|
90
|
+
lines.push(this.generateOutput(output, ir, importedSymbols));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return [
|
|
94
|
+
{
|
|
95
|
+
path: "main.ts",
|
|
96
|
+
content: lines.join("\n") + "\n",
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Collect the set of symbols that will be imported (class names, intrinsics, etc.)
|
|
102
|
+
*/
|
|
103
|
+
collectImportedSymbols(ir) {
|
|
104
|
+
const symbols = new Set();
|
|
105
|
+
if (ir.parameters.length > 0)
|
|
106
|
+
symbols.add("Parameter");
|
|
107
|
+
if (Object.keys(this.mappings(ir)).length > 0)
|
|
108
|
+
symbols.add("Mapping");
|
|
109
|
+
if ((ir.conditions ?? []).length > 0)
|
|
110
|
+
symbols.add("Condition");
|
|
111
|
+
if ((ir.outputs ?? []).length > 0)
|
|
112
|
+
symbols.add("stackOutput");
|
|
113
|
+
const intrinsics = ["Sub", "Ref", "If", "Join", "Select", "Split", "Base64", "GetAZs", "Equals", "And", "Or", "Not", "FindInMap", "ImportValue", "Cidr"];
|
|
114
|
+
for (const name of intrinsics) {
|
|
115
|
+
if (irUsesIntrinsic(ir, name))
|
|
116
|
+
symbols.add(name);
|
|
117
|
+
}
|
|
118
|
+
// Outputs whose value is a Ref envelope render as Ref(<var>) (#2069)
|
|
119
|
+
if ((ir.outputs ?? []).some((o) => hasIntrinsicInValue(o.value, "Ref")))
|
|
120
|
+
symbols.add("Ref");
|
|
121
|
+
// A Sub that names a parameter or resource renders it as Ref(<var>), and an
|
|
122
|
+
// attribute the class does not expose renders as GetAtt("<id>", "<attr>").
|
|
123
|
+
const uses = this.scanGeneratedIntrinsics(ir);
|
|
124
|
+
if (uses.ref)
|
|
125
|
+
symbols.add("Ref");
|
|
126
|
+
if (uses.getAtt)
|
|
127
|
+
symbols.add("GetAtt");
|
|
128
|
+
if (this.needsAWSPseudo(ir))
|
|
129
|
+
symbols.add("AWS");
|
|
130
|
+
for (const resource of ir.resources) {
|
|
131
|
+
const parsed = this.parseResourceType(resource.type);
|
|
132
|
+
if (parsed)
|
|
133
|
+
symbols.add(this.classAliases.get(parsed.resourceClass) ?? parsed.resourceClass);
|
|
134
|
+
}
|
|
135
|
+
if (typeof ir.metadata?.description === "string")
|
|
136
|
+
symbols.add("templateDescription");
|
|
137
|
+
if (ir.metadata?.templateMetadata !== undefined)
|
|
138
|
+
symbols.add("templateMetadata");
|
|
139
|
+
return symbols;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Resolve a logical ID to a safe variable name, suffixing with _ if it conflicts with an imported symbol
|
|
143
|
+
*/
|
|
144
|
+
safeVarName(name, importedSymbols) {
|
|
145
|
+
return importedSymbols.has(name) ? name + "_" : name;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The property on the generated class that reads `attribute` of the
|
|
149
|
+
* resource `logicalId`, or undefined when the class has none. A dotted
|
|
150
|
+
* CloudFormation attribute (`Endpoint.Address`) maps to its underscored
|
|
151
|
+
* property (`Endpoint_Address`).
|
|
152
|
+
*/
|
|
153
|
+
attrProperty(logicalId, attribute, ir) {
|
|
154
|
+
const resource = ir.resources.find((r) => r.logicalId === logicalId);
|
|
155
|
+
if (!resource || !this.parseResourceType(resource.type))
|
|
156
|
+
return undefined;
|
|
157
|
+
const attrs = this.attrsByType.get(resource.type) ?? {};
|
|
158
|
+
const key = Object.keys(attrs).find((k) => attrs[k] === attribute);
|
|
159
|
+
return key !== undefined && /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key) ? key : undefined;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* An attribute read: `<var>.<property>` when the class exposes the
|
|
163
|
+
* attribute, else `GetAtt("<id>", "<attr>")`. CloudFormation accepts
|
|
164
|
+
* GetAtt on some writable properties (`AWS::SQS::Queue` `QueueName`) that
|
|
165
|
+
* the class does not list, and reading those as a property gives
|
|
166
|
+
* undefined.
|
|
167
|
+
*/
|
|
168
|
+
attrExpr(logicalId, attribute, ir, importedSymbols) {
|
|
169
|
+
const prop = this.attrProperty(logicalId, attribute, ir);
|
|
170
|
+
if (prop !== undefined)
|
|
171
|
+
return `${this.safeVarName(logicalId, importedSymbols)}.${prop}`;
|
|
172
|
+
return `GetAtt(${JSON.stringify(logicalId)}, ${JSON.stringify(attribute)})`;
|
|
173
|
+
}
|
|
174
|
+
/** Whether `name` is a parameter or resource the template declares. */
|
|
175
|
+
isDeclaredName(name, ir) {
|
|
176
|
+
return ir.parameters.some((p) => p.name === name) || ir.resources.some((r) => r.logicalId === name);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Which of Ref and GetAtt the generated source calls beyond the IR's own
|
|
180
|
+
* Ref and GetAtt envelopes: Sub interpolations of a declared name, and
|
|
181
|
+
* attribute reads the class does not expose.
|
|
182
|
+
*/
|
|
183
|
+
scanGeneratedIntrinsics(ir) {
|
|
184
|
+
const uses = { ref: false, getAtt: false };
|
|
185
|
+
const visit = (value) => {
|
|
186
|
+
if (value === null || typeof value !== "object")
|
|
187
|
+
return;
|
|
188
|
+
if (Array.isArray(value)) {
|
|
189
|
+
for (const item of value)
|
|
190
|
+
visit(item);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
const obj = value;
|
|
194
|
+
if (obj.__intrinsic === "GetAtt") {
|
|
195
|
+
if (this.attrProperty(obj.logicalId, obj.attribute, ir) === undefined)
|
|
196
|
+
uses.getAtt = true;
|
|
197
|
+
}
|
|
198
|
+
else if (obj.__intrinsic === "Sub") {
|
|
199
|
+
const variables = (obj.variables ?? {});
|
|
200
|
+
for (const m of obj.template.matchAll(/\$\{([^}]+)\}/g)) {
|
|
201
|
+
const expr = m[1];
|
|
202
|
+
if (expr.startsWith("AWS::") || expr.startsWith("!") || expr in variables)
|
|
203
|
+
continue;
|
|
204
|
+
const dot = expr.indexOf(".");
|
|
205
|
+
if (dot < 0)
|
|
206
|
+
uses.ref = true;
|
|
207
|
+
else if (this.attrProperty(expr.slice(0, dot), expr.slice(dot + 1), ir) === undefined)
|
|
208
|
+
uses.getAtt = true;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (const v of Object.values(obj))
|
|
212
|
+
visit(v);
|
|
213
|
+
};
|
|
214
|
+
for (const v of this.generatedValues(ir))
|
|
215
|
+
visit(v);
|
|
216
|
+
return uses;
|
|
217
|
+
}
|
|
218
|
+
/** Every name the template declares: parameters, resources, conditions, outputs. */
|
|
219
|
+
declaredNames(ir) {
|
|
220
|
+
return new Set([
|
|
221
|
+
...ir.parameters.map((p) => p.name),
|
|
222
|
+
...ir.resources.map((r) => r.logicalId),
|
|
223
|
+
...(ir.conditions ?? []).map((c) => c.name),
|
|
224
|
+
...(ir.outputs ?? []).map((o) => o.name),
|
|
225
|
+
...Object.keys(this.mappings(ir)),
|
|
226
|
+
]);
|
|
227
|
+
}
|
|
228
|
+
/** The template's Mappings section, as the parser carried it. */
|
|
229
|
+
mappings(ir) {
|
|
230
|
+
return (ir.metadata?.mappings ?? {});
|
|
231
|
+
}
|
|
232
|
+
/** The variable a declared mapping is exported as. */
|
|
233
|
+
mappingVar(name, importedSymbols) {
|
|
234
|
+
return this.renames.get(`m:${name}`) ?? this.safeVarName(name, importedSymbols);
|
|
235
|
+
}
|
|
236
|
+
/** A mapping declaration. */
|
|
237
|
+
generateMapping(name, map, importedSymbols) {
|
|
238
|
+
const varName = this.mappingVar(name, importedSymbols);
|
|
239
|
+
const nameOpt = this.renames.has(`m:${name}`) ? `, { name: ${JSON.stringify(name)} }` : "";
|
|
240
|
+
return `export const ${varName} = new Mapping(${JSON.stringify(map, null, 2)}${nameOpt});`;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* A resource class whose name the template also uses for something it
|
|
244
|
+
* declares is imported under an alias (`InternetGateway as
|
|
245
|
+
* InternetGatewayResource`), so the declaration keeps its name. Suffixing
|
|
246
|
+
* the declaration instead would change its logical id.
|
|
247
|
+
*/
|
|
248
|
+
computeClassAliases(ir) {
|
|
249
|
+
const declared = this.declaredNames(ir);
|
|
250
|
+
const aliases = new Map();
|
|
251
|
+
for (const resource of ir.resources) {
|
|
252
|
+
const cls = this.parseResourceType(resource.type)?.resourceClass;
|
|
253
|
+
if (!cls || !declared.has(cls) || aliases.has(cls))
|
|
254
|
+
continue;
|
|
255
|
+
let alias = `${cls}Resource`;
|
|
256
|
+
for (let i = 2; declared.has(alias) || this.allClassNames.has(alias); i++)
|
|
257
|
+
alias = `${cls}Resource${i}`;
|
|
258
|
+
aliases.set(cls, alias);
|
|
259
|
+
}
|
|
260
|
+
return aliases;
|
|
261
|
+
}
|
|
262
|
+
/** `templateDescription(...)` and `templateMetadata(...)` for the template's own sections. */
|
|
263
|
+
generateTemplateSections(ir, importedSymbols) {
|
|
264
|
+
const declared = this.declaredNames(ir);
|
|
265
|
+
const freeName = (base) => {
|
|
266
|
+
let v = base;
|
|
267
|
+
for (let i = 2; declared.has(v) || importedSymbols.has(v); i++)
|
|
268
|
+
v = `${base}${i}`;
|
|
269
|
+
declared.add(v);
|
|
270
|
+
return v;
|
|
271
|
+
};
|
|
272
|
+
const lines = [];
|
|
273
|
+
if (typeof ir.metadata?.description === "string") {
|
|
274
|
+
lines.push(`export const ${freeName("description")} = templateDescription(${JSON.stringify(ir.metadata.description)});`);
|
|
275
|
+
}
|
|
276
|
+
if (ir.metadata?.templateMetadata !== undefined) {
|
|
277
|
+
const value = this.generateValue(ir.metadata.templateMetadata, ir, importedSymbols);
|
|
278
|
+
lines.push(`export const ${freeName("metadata")} = templateMetadata(${value});`);
|
|
279
|
+
}
|
|
280
|
+
return lines;
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* A condition or output whose template name is a parameter's or resource's
|
|
284
|
+
* cannot be exported under that name too. It gets a suffixed variable
|
|
285
|
+
* (`EnableReadReplicaCondition`, `QueueNameOutput`), and the generated code
|
|
286
|
+
* passes the template name as its `name` option.
|
|
287
|
+
*/
|
|
288
|
+
collisionRenames(ir, importedSymbols) {
|
|
289
|
+
const renames = new Map();
|
|
290
|
+
const taken = new Set();
|
|
291
|
+
const varOf = (name) => this.safeVarName(name, importedSymbols);
|
|
292
|
+
for (const p of ir.parameters)
|
|
293
|
+
taken.add(varOf(p.name));
|
|
294
|
+
for (const r of ir.resources)
|
|
295
|
+
taken.add(varOf(r.logicalId));
|
|
296
|
+
const claim = (key, name, suffix) => {
|
|
297
|
+
let v = varOf(name);
|
|
298
|
+
if (taken.has(v)) {
|
|
299
|
+
v = `${name}${suffix}`;
|
|
300
|
+
for (let i = 2; taken.has(v); i++)
|
|
301
|
+
v = `${name}${suffix}${i}`;
|
|
302
|
+
renames.set(key, v);
|
|
303
|
+
}
|
|
304
|
+
taken.add(v);
|
|
305
|
+
};
|
|
306
|
+
for (const m of Object.keys(this.mappings(ir)))
|
|
307
|
+
claim(`m:${m}`, m, "Mapping");
|
|
308
|
+
for (const c of ir.conditions ?? [])
|
|
309
|
+
claim(`c:${c.name}`, c.name, "Condition");
|
|
310
|
+
for (const o of ir.outputs ?? [])
|
|
311
|
+
claim(`o:${o.name}`, o.name, "Output");
|
|
312
|
+
return renames;
|
|
313
|
+
}
|
|
314
|
+
/** The variable a declared condition is exported as. */
|
|
315
|
+
conditionVar(name, importedSymbols) {
|
|
316
|
+
return this.renames.get(`c:${name}`) ?? this.safeVarName(name, importedSymbols);
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Generate import statements
|
|
320
|
+
*/
|
|
321
|
+
generateImports(ir) {
|
|
322
|
+
// Everything comes from the flat @intentius/chant-lexicon-aws package,
|
|
323
|
+
// and the needed symbol set is exactly what collectImportedSymbols
|
|
324
|
+
// computes for variable-name conflict detection.
|
|
325
|
+
const aliasOf = new Map([...this.classAliases].map(([cls, alias]) => [alias, cls]));
|
|
326
|
+
const allImports = [...this.collectImportedSymbols(ir)].map((s) => (aliasOf.has(s) ? `${aliasOf.get(s)} as ${s}` : s));
|
|
327
|
+
if (allImports.length === 0) {
|
|
328
|
+
return "";
|
|
329
|
+
}
|
|
330
|
+
return `import { ${allImports.join(", ")} } from "@intentius/chant-lexicon-aws";`;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Parse AWS resource type into service and class names.
|
|
334
|
+
* Returns null for unknown/unsupported types (Custom::*, third-party, etc.)
|
|
335
|
+
*/
|
|
336
|
+
parseResourceType(type) {
|
|
337
|
+
const className = this.typeToClass.get(type);
|
|
338
|
+
if (!className)
|
|
339
|
+
return null;
|
|
340
|
+
const parts = type.split("::");
|
|
341
|
+
return {
|
|
342
|
+
service: parts[1]?.toLowerCase() ?? "unknown",
|
|
343
|
+
resourceClass: className,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Check if AWS pseudo-parameters are used
|
|
348
|
+
*/
|
|
349
|
+
needsAWSPseudo(ir) {
|
|
350
|
+
return this.generatedValues(ir).some((v) => this.hasAWSPseudo(v));
|
|
351
|
+
}
|
|
352
|
+
/** Every IR value the generator writes as source. */
|
|
353
|
+
generatedValues(ir) {
|
|
354
|
+
return [
|
|
355
|
+
...ir.resources.flatMap((r) => [r.properties, r.metadata, r.attributes]),
|
|
356
|
+
...(ir.conditions ?? []).map((c) => c.expression),
|
|
357
|
+
...(ir.outputs ?? []).flatMap((o) => [o.value, o.exportName]),
|
|
358
|
+
ir.metadata?.templateMetadata,
|
|
359
|
+
];
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Recursively check for AWS pseudo-parameter references
|
|
363
|
+
*/
|
|
364
|
+
hasAWSPseudo(value) {
|
|
365
|
+
if (value === null || value === undefined) {
|
|
366
|
+
return false;
|
|
367
|
+
}
|
|
368
|
+
if (Array.isArray(value)) {
|
|
369
|
+
return value.some((item) => this.hasAWSPseudo(item));
|
|
370
|
+
}
|
|
371
|
+
if (typeof value === "object") {
|
|
372
|
+
const obj = value;
|
|
373
|
+
if (obj.__intrinsic === "Ref") {
|
|
374
|
+
const name = obj.name;
|
|
375
|
+
return name.startsWith("AWS::");
|
|
376
|
+
}
|
|
377
|
+
if (obj.__intrinsic === "Sub") {
|
|
378
|
+
const template = obj.template;
|
|
379
|
+
return template.includes("${AWS::");
|
|
380
|
+
}
|
|
381
|
+
return Object.values(obj).some((v) => this.hasAWSPseudo(v));
|
|
382
|
+
}
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Sort resources by dependencies
|
|
387
|
+
*/
|
|
388
|
+
sortByDependencies(resources) {
|
|
389
|
+
const resourceIds = new Set(resources.map((r) => r.logicalId));
|
|
390
|
+
return topoSort(resources, (r) => r.logicalId, (r) => {
|
|
391
|
+
const extraDeps = new Set();
|
|
392
|
+
// DependsOn names a resource that is generated as a variable reference.
|
|
393
|
+
const dependsOn = r.attributes?.DependsOn;
|
|
394
|
+
for (const d of Array.isArray(dependsOn) ? dependsOn : dependsOn !== undefined ? [dependsOn] : []) {
|
|
395
|
+
if (typeof d === "string" && resourceIds.has(d))
|
|
396
|
+
extraDeps.add(d);
|
|
397
|
+
}
|
|
398
|
+
const deps = collectDependencies({ properties: r.properties, metadata: r.metadata, attributes: r.attributes }, (obj) => {
|
|
399
|
+
if (obj.__intrinsic === "Ref") {
|
|
400
|
+
const name = obj.name;
|
|
401
|
+
return name.startsWith("AWS::") ? null : name;
|
|
402
|
+
}
|
|
403
|
+
if (obj.__intrinsic === "GetAtt") {
|
|
404
|
+
return obj.logicalId;
|
|
405
|
+
}
|
|
406
|
+
if (obj.__intrinsic === "Sub") {
|
|
407
|
+
const tpl = obj.template;
|
|
408
|
+
const re = /\$\{([^}]+)\}/g;
|
|
409
|
+
let m;
|
|
410
|
+
while ((m = re.exec(tpl)) !== null) {
|
|
411
|
+
const expr = m[1];
|
|
412
|
+
if (!expr.startsWith("AWS::")) {
|
|
413
|
+
const id = expr.split(".")[0];
|
|
414
|
+
if (resourceIds.has(id))
|
|
415
|
+
extraDeps.add(id);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return null;
|
|
419
|
+
}
|
|
420
|
+
return null;
|
|
421
|
+
});
|
|
422
|
+
for (const d of extraDeps)
|
|
423
|
+
deps.add(d);
|
|
424
|
+
return [...deps];
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Sort conditions so `{ Condition: ... }` references point at earlier
|
|
429
|
+
* declarations (#2069).
|
|
430
|
+
*/
|
|
431
|
+
sortConditions(conditions) {
|
|
432
|
+
return topoSort(conditions, (c) => c.name, (c) => [
|
|
433
|
+
...collectDependencies(c.expression, (obj) => obj.__intrinsic === "ConditionRef" ? obj.name : null),
|
|
434
|
+
]);
|
|
435
|
+
}
|
|
436
|
+
/**
|
|
437
|
+
* Render a condition reference as the condition's variable when the
|
|
438
|
+
* template declares it, or as a literal name string when it doesn't (an
|
|
439
|
+
* undeclared reference stays visible rather than breaking generation).
|
|
440
|
+
*/
|
|
441
|
+
conditionVarRef(name, ir, importedSymbols) {
|
|
442
|
+
const declared = (ir.conditions ?? []).some((c) => c.name === name);
|
|
443
|
+
return declared ? this.conditionVar(name, importedSymbols) : JSON.stringify(name);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Generate a condition declaration (#2069)
|
|
447
|
+
*/
|
|
448
|
+
generateCondition(condition, ir, importedSymbols) {
|
|
449
|
+
const varName = this.conditionVar(condition.name, importedSymbols);
|
|
450
|
+
const exprStr = this.generateValue(condition.expression, ir, importedSymbols);
|
|
451
|
+
if (this.renames.has(`c:${condition.name}`)) {
|
|
452
|
+
return `export const ${varName} = new Condition(${exprStr}, { name: ${JSON.stringify(condition.name)} });`;
|
|
453
|
+
}
|
|
454
|
+
return `export const ${varName} = new Condition(${exprStr});`;
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Generate an output declaration as stackOutput(...) (#2069)
|
|
458
|
+
*/
|
|
459
|
+
generateOutput(output, ir, importedSymbols) {
|
|
460
|
+
const varName = this.renames.get(`o:${output.name}`) ?? this.safeVarName(output.name, importedSymbols);
|
|
461
|
+
// A bare Ref envelope becomes Ref(<var>) — stackOutput takes an intrinsic
|
|
462
|
+
// or attribute reference, not the resource/parameter object itself.
|
|
463
|
+
let valueStr;
|
|
464
|
+
const value = output.value;
|
|
465
|
+
if (value !== null && typeof value === "object" && !Array.isArray(value) && value.__intrinsic === "Ref" && !value.name.startsWith("AWS::")) {
|
|
466
|
+
valueStr = `Ref(${this.safeVarName(value.name, importedSymbols)})`;
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
valueStr = this.generateValue(output.value, ir, importedSymbols);
|
|
470
|
+
}
|
|
471
|
+
const opts = [];
|
|
472
|
+
if (output.description)
|
|
473
|
+
opts.push(`description: ${JSON.stringify(output.description)}`);
|
|
474
|
+
if (output.exportName !== undefined) {
|
|
475
|
+
opts.push(`exportName: ${this.generateValue(output.exportName, ir, importedSymbols)}`);
|
|
476
|
+
}
|
|
477
|
+
if (output.condition) {
|
|
478
|
+
opts.push(`condition: ${this.conditionVarRef(output.condition, ir, importedSymbols)}`);
|
|
479
|
+
}
|
|
480
|
+
// Every output names its lexicon. A literal, or a GetAtt written by name,
|
|
481
|
+
// has no entity to derive it from, and an output without one is dropped
|
|
482
|
+
// at serialization.
|
|
483
|
+
opts.push(`lexicon: "aws"`);
|
|
484
|
+
if (this.renames.has(`o:${output.name}`))
|
|
485
|
+
opts.push(`name: ${JSON.stringify(output.name)}`);
|
|
486
|
+
return `export const ${varName} = stackOutput(${valueStr}, { ${opts.join(", ")} });`;
|
|
487
|
+
}
|
|
488
|
+
/**
|
|
489
|
+
* Generate a parameter declaration
|
|
490
|
+
*/
|
|
491
|
+
generateParameter(param, importedSymbols) {
|
|
492
|
+
const varName = this.safeVarName(param.name, importedSymbols);
|
|
493
|
+
const opts = [];
|
|
494
|
+
if (param.description)
|
|
495
|
+
opts.push(`description: ${JSON.stringify(param.description)}`);
|
|
496
|
+
if (param.defaultValue !== undefined)
|
|
497
|
+
opts.push(`defaultValue: ${JSON.stringify(param.defaultValue)}`);
|
|
498
|
+
for (const [key, value] of Object.entries(param.constraints ?? {})) {
|
|
499
|
+
opts.push(`${key.charAt(0).toLowerCase()}${key.slice(1)}: ${JSON.stringify(value)}`);
|
|
500
|
+
}
|
|
501
|
+
if (opts.length > 0) {
|
|
502
|
+
return `export const ${varName} = new Parameter("${param.type}", { ${opts.join(", ")} });`;
|
|
503
|
+
}
|
|
504
|
+
return `export const ${varName} = new Parameter("${param.type}");`;
|
|
505
|
+
}
|
|
506
|
+
/**
|
|
507
|
+
* Generate a resource declaration, or a comment if the type is unknown
|
|
508
|
+
*/
|
|
509
|
+
generateResource(resource, ir, importedSymbols) {
|
|
510
|
+
const parsed = this.parseResourceType(resource.type);
|
|
511
|
+
if (!parsed) {
|
|
512
|
+
const varName = this.safeVarName(resource.logicalId, importedSymbols);
|
|
513
|
+
return `// Unsupported type: ${resource.type}\nexport const ${varName} = "${resource.logicalId}";`;
|
|
514
|
+
}
|
|
515
|
+
const varName = this.safeVarName(resource.logicalId, importedSymbols);
|
|
516
|
+
const resourceClass = this.classAliases.get(parsed.resourceClass) ?? parsed.resourceClass;
|
|
517
|
+
const propsStr = this.generateProps(resource.properties, ir, importedSymbols);
|
|
518
|
+
// Resource attributes -> the attributes argument: Condition (#2069),
|
|
519
|
+
// DependsOn, the policies, and Metadata.
|
|
520
|
+
const attrs = [];
|
|
521
|
+
if (resource.condition) {
|
|
522
|
+
attrs.push(`Condition: ${this.conditionVarRef(resource.condition, ir, importedSymbols)}`);
|
|
523
|
+
}
|
|
524
|
+
for (const [key, value] of Object.entries(resource.attributes ?? {})) {
|
|
525
|
+
const valueStr = key === "DependsOn"
|
|
526
|
+
? this.generateDependsOn(value, ir, importedSymbols)
|
|
527
|
+
: this.generateValue(value, ir, importedSymbols);
|
|
528
|
+
attrs.push(`${key}: ${valueStr}`);
|
|
529
|
+
}
|
|
530
|
+
if (resource.metadata !== undefined) {
|
|
531
|
+
attrs.push(`Metadata: ${this.generateValue(resource.metadata, ir, importedSymbols)}`);
|
|
532
|
+
}
|
|
533
|
+
if (attrs.length > 0) {
|
|
534
|
+
return `export const ${varName} = new ${resourceClass}(${propsStr}, { ${attrs.join(", ")} });`;
|
|
535
|
+
}
|
|
536
|
+
if (propsStr === "{}") {
|
|
537
|
+
return `export const ${varName} = new ${resourceClass}();`;
|
|
538
|
+
}
|
|
539
|
+
return `export const ${varName} = new ${resourceClass}(${propsStr});`;
|
|
540
|
+
}
|
|
541
|
+
/**
|
|
542
|
+
* DependsOn as the variables of the resources it names, so the generated
|
|
543
|
+
* source references them. A name the template does not declare as a
|
|
544
|
+
* supported resource stays a string.
|
|
545
|
+
*/
|
|
546
|
+
generateDependsOn(value, ir, importedSymbols) {
|
|
547
|
+
const one = (d) => typeof d === "string" && ir.resources.some((r) => r.logicalId === d && this.parseResourceType(r.type))
|
|
548
|
+
? this.safeVarName(d, importedSymbols)
|
|
549
|
+
: this.generateValue(d, ir, importedSymbols);
|
|
550
|
+
return Array.isArray(value) ? `[${value.map(one).join(", ")}]` : one(value);
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Generate property object as TypeScript
|
|
554
|
+
*/
|
|
555
|
+
generateProps(props, ir, importedSymbols) {
|
|
556
|
+
if (Object.keys(props).length === 0) {
|
|
557
|
+
return "{}";
|
|
558
|
+
}
|
|
559
|
+
const entries = Object.entries(props).map(([key, value]) => {
|
|
560
|
+
const propName = this.toPropName(key);
|
|
561
|
+
const valueStr = this.generateValue(value, ir, importedSymbols);
|
|
562
|
+
return ` ${propName}: ${valueStr}`;
|
|
563
|
+
});
|
|
564
|
+
return `{\n${entries.join(",\n")},\n}`;
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Generate a value as TypeScript
|
|
568
|
+
*/
|
|
569
|
+
generateValue(value, ir, importedSymbols = new Set()) {
|
|
570
|
+
if (value === null || value === undefined) {
|
|
571
|
+
return "undefined";
|
|
572
|
+
}
|
|
573
|
+
if (typeof value === "string") {
|
|
574
|
+
return JSON.stringify(value);
|
|
575
|
+
}
|
|
576
|
+
if (typeof value === "number" || typeof value === "boolean") {
|
|
577
|
+
return String(value);
|
|
578
|
+
}
|
|
579
|
+
if (Array.isArray(value)) {
|
|
580
|
+
const items = value.map((item) => this.generateValue(item, ir, importedSymbols));
|
|
581
|
+
return `[${items.join(", ")}]`;
|
|
582
|
+
}
|
|
583
|
+
if (typeof value === "object") {
|
|
584
|
+
const obj = value;
|
|
585
|
+
// Handle intrinsic functions
|
|
586
|
+
if (obj.__intrinsic === "Ref") {
|
|
587
|
+
const name = obj.name;
|
|
588
|
+
if (name.startsWith("AWS::")) {
|
|
589
|
+
return `AWS.${this.pseudoParamName(name)}`;
|
|
590
|
+
}
|
|
591
|
+
const varName = this.safeVarName(name, importedSymbols);
|
|
592
|
+
// Parameters need Ref() — bare variable would pass the Parameter object, not its value
|
|
593
|
+
const isParam = ir.parameters.some((p) => p.name === name);
|
|
594
|
+
if (isParam) {
|
|
595
|
+
return `Ref(${varName})`;
|
|
596
|
+
}
|
|
597
|
+
return varName;
|
|
598
|
+
}
|
|
599
|
+
if (obj.__intrinsic === "GetAtt") {
|
|
600
|
+
return this.attrExpr(obj.logicalId, obj.attribute, ir, importedSymbols);
|
|
601
|
+
}
|
|
602
|
+
if (obj.__intrinsic === "Sub") {
|
|
603
|
+
return this.generateSubIntrinsic(obj.template, obj.variables, ir, importedSymbols);
|
|
604
|
+
}
|
|
605
|
+
if (obj.__intrinsic === "If") {
|
|
606
|
+
const condition = obj.condition;
|
|
607
|
+
const condRef = this.conditionVarRef(condition, ir, importedSymbols);
|
|
608
|
+
const trueVal = this.generateValue(obj.valueIfTrue, ir, importedSymbols);
|
|
609
|
+
const falseVal = this.generateValue(obj.valueIfFalse, ir, importedSymbols);
|
|
610
|
+
return `If(${condRef}, ${trueVal}, ${falseVal})`;
|
|
611
|
+
}
|
|
612
|
+
if (obj.__intrinsic === "Equals") {
|
|
613
|
+
const left = this.generateValue(obj.left, ir, importedSymbols);
|
|
614
|
+
const right = this.generateValue(obj.right, ir, importedSymbols);
|
|
615
|
+
return `Equals(${left}, ${right})`;
|
|
616
|
+
}
|
|
617
|
+
if (obj.__intrinsic === "And" || obj.__intrinsic === "Or") {
|
|
618
|
+
const operands = obj.conditions.map((c) => this.generateValue(c, ir, importedSymbols));
|
|
619
|
+
return `${obj.__intrinsic}(${operands.join(", ")})`;
|
|
620
|
+
}
|
|
621
|
+
if (obj.__intrinsic === "Not") {
|
|
622
|
+
return `Not(${this.generateValue(obj.condition, ir, importedSymbols)})`;
|
|
623
|
+
}
|
|
624
|
+
if (obj.__intrinsic === "ConditionRef") {
|
|
625
|
+
return this.conditionVarRef(obj.name, ir, importedSymbols);
|
|
626
|
+
}
|
|
627
|
+
if (obj.__intrinsic === "Join") {
|
|
628
|
+
const delimiter = JSON.stringify(obj.delimiter);
|
|
629
|
+
const values = obj.values.map((v) => this.generateValue(v, ir, importedSymbols));
|
|
630
|
+
return `Join(${delimiter}, [${values.join(", ")}])`;
|
|
631
|
+
}
|
|
632
|
+
if (obj.__intrinsic === "Select") {
|
|
633
|
+
const index = JSON.stringify(obj.index);
|
|
634
|
+
if (Array.isArray(obj.values)) {
|
|
635
|
+
const values = obj.values.map((v) => this.generateValue(v, ir, importedSymbols));
|
|
636
|
+
return `Select(${index}, [${values.join(", ")}])`;
|
|
637
|
+
}
|
|
638
|
+
return `Select(${index}, ${this.generateValue(obj.source, ir, importedSymbols)})`;
|
|
639
|
+
}
|
|
640
|
+
if (obj.__intrinsic === "Split") {
|
|
641
|
+
const delimiter = JSON.stringify(obj.delimiter);
|
|
642
|
+
const source = this.generateValue(obj.source, ir, importedSymbols);
|
|
643
|
+
return `Split(${delimiter}, ${source})`;
|
|
644
|
+
}
|
|
645
|
+
if (obj.__intrinsic === "Base64") {
|
|
646
|
+
const value = this.generateValue(obj.value, ir, importedSymbols);
|
|
647
|
+
return `Base64(${value})`;
|
|
648
|
+
}
|
|
649
|
+
if (obj.__intrinsic === "GetAZs") {
|
|
650
|
+
const region = obj.region;
|
|
651
|
+
if (region === undefined || region === "" || region === null) {
|
|
652
|
+
return "GetAZs()";
|
|
653
|
+
}
|
|
654
|
+
return `GetAZs(${this.generateValue(region, ir, importedSymbols)})`;
|
|
655
|
+
}
|
|
656
|
+
if (obj.__intrinsic === "FindInMap") {
|
|
657
|
+
const mapName = obj.mapName;
|
|
658
|
+
const map = typeof mapName === "string" && mapName in this.mappings(ir)
|
|
659
|
+
? this.mappingVar(mapName, importedSymbols)
|
|
660
|
+
: this.generateValue(mapName, ir, importedSymbols);
|
|
661
|
+
const first = this.generateValue(obj.firstKey, ir, importedSymbols);
|
|
662
|
+
const second = this.generateValue(obj.secondKey, ir, importedSymbols);
|
|
663
|
+
return `FindInMap(${map}, ${first}, ${second})`;
|
|
664
|
+
}
|
|
665
|
+
if (obj.__intrinsic === "ImportValue") {
|
|
666
|
+
return `ImportValue(${this.generateValue(obj.value, ir, importedSymbols)})`;
|
|
667
|
+
}
|
|
668
|
+
if (obj.__intrinsic === "Cidr") {
|
|
669
|
+
const args = [obj.ipBlock, obj.count, obj.cidrBits].map((v) => this.generateValue(v, ir, importedSymbols));
|
|
670
|
+
return `Cidr(${args.join(", ")})`;
|
|
671
|
+
}
|
|
672
|
+
// An intrinsic the parser read but the generator has no form for
|
|
673
|
+
// (Fn::Transform) is refused. Written as an object literal, it would
|
|
674
|
+
// build into a template CloudFormation cannot read.
|
|
675
|
+
if (typeof obj.__intrinsic === "string") {
|
|
676
|
+
throw new Error(`chant import cannot generate Fn::${obj.__intrinsic} yet; the template uses it, so it is not imported`);
|
|
677
|
+
}
|
|
678
|
+
// Regular object — quote keys that aren't valid JS identifiers
|
|
679
|
+
const entries = Object.entries(obj).map(([key, val]) => {
|
|
680
|
+
const safeKey = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key) ? key : JSON.stringify(key);
|
|
681
|
+
return `${safeKey}: ${this.generateValue(val, ir, importedSymbols)}`;
|
|
682
|
+
});
|
|
683
|
+
return `{ ${entries.join(", ")} }`;
|
|
684
|
+
}
|
|
685
|
+
return String(value);
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Generate Sub intrinsic as tagged template literal
|
|
689
|
+
*/
|
|
690
|
+
generateSubIntrinsic(template, variables, ir, importedSymbols) {
|
|
691
|
+
const escapePart = (s) => s.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
|
|
692
|
+
// Parse ${...} interpolations from the Sub template
|
|
693
|
+
const parts = [];
|
|
694
|
+
const expressions = [];
|
|
695
|
+
let currentPos = 0;
|
|
696
|
+
const regex = /\$\{([^}]+)\}/g;
|
|
697
|
+
let match;
|
|
698
|
+
let literal = "";
|
|
699
|
+
while ((match = regex.exec(template)) !== null) {
|
|
700
|
+
const expr = match[1];
|
|
701
|
+
// `${!Literal}` is CloudFormation's escape for a literal `${Literal}`;
|
|
702
|
+
// it stays in the template text.
|
|
703
|
+
if (expr.startsWith("!")) {
|
|
704
|
+
literal += template.slice(currentPos, match.index + match[0].length);
|
|
705
|
+
currentPos = match.index + match[0].length;
|
|
706
|
+
continue;
|
|
707
|
+
}
|
|
708
|
+
parts.push(literal + template.slice(currentPos, match.index));
|
|
709
|
+
literal = "";
|
|
710
|
+
if (expr.startsWith("AWS::")) {
|
|
711
|
+
expressions.push(`AWS.${this.pseudoParamName(expr)}`);
|
|
712
|
+
}
|
|
713
|
+
else if (variables && expr in variables) {
|
|
714
|
+
expressions.push(this.generateValue(variables[expr], ir, importedSymbols));
|
|
715
|
+
}
|
|
716
|
+
else if (expr.includes(".")) {
|
|
717
|
+
const dotIdx = expr.indexOf(".");
|
|
718
|
+
expressions.push(this.attrExpr(expr.slice(0, dotIdx), expr.slice(dotIdx + 1), ir, importedSymbols));
|
|
719
|
+
}
|
|
720
|
+
else if (this.isDeclaredName(expr, ir)) {
|
|
721
|
+
// A Declarable cannot be interpolated into Sub; Ref(<var>) serializes
|
|
722
|
+
// as `${Name}`.
|
|
723
|
+
expressions.push(`Ref(${this.safeVarName(expr, importedSymbols)})`);
|
|
724
|
+
}
|
|
725
|
+
else {
|
|
726
|
+
expressions.push(`Ref(${JSON.stringify(expr)})`);
|
|
727
|
+
}
|
|
728
|
+
currentPos = match.index + match[0].length;
|
|
729
|
+
}
|
|
730
|
+
parts.push(literal + template.slice(currentPos));
|
|
731
|
+
if (expressions.length === 0) {
|
|
732
|
+
return `Sub\`${escapePart(template)}\``;
|
|
733
|
+
}
|
|
734
|
+
let result = "Sub`";
|
|
735
|
+
for (let i = 0; i < parts.length; i++) {
|
|
736
|
+
result += escapePart(parts[i]);
|
|
737
|
+
if (i < expressions.length) {
|
|
738
|
+
result += `\${${expressions[i]}}`;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
result += "`";
|
|
742
|
+
return result;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Convert AWS pseudo-parameter name to TypeScript
|
|
746
|
+
*/
|
|
747
|
+
pseudoParamName(awsName) {
|
|
748
|
+
// AWS::StackName -> StackName
|
|
749
|
+
return awsName.replace("AWS::", "");
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Property names use spec-native casing (PascalCase for CloudFormation).
|
|
753
|
+
*/
|
|
754
|
+
toPropName(name) {
|
|
755
|
+
return name;
|
|
756
|
+
}
|
|
757
|
+
}
|