import type { CloudConfig, ServerlessAppConfig } from '../types' import { describe, expect, it } from 'bun:test' import { validateResourceLimits, validateTemplate } from '../template-validator' import { composeServerlessAppTemplate, resolveQueueNames, resolveQueues } from './composer' const config = { project: { name: 'Demo', slug: 'demo', region: 'us-east-1' } } as Pick const handlers = { http: 'index.http', queue: 'index.queue', cli: 'index.cli' } function compose(app: ServerlessAppConfig) { return composeServerlessAppTemplate({ config, environment: 'production', app, handlers }) } describe('resolveQueueNames', () => { it('defaults to a single queue, supports arrays, and disables with false', () => { expect(resolveQueueNames({}, 'demo', 'production')).toEqual(['demo-production-default']) expect(resolveQueueNames({ queues: false }, 'demo', 'production')).toEqual([]) expect(resolveQueueNames({ queues: ['emails', { invoices: 5 }] }, 'demo', 'production')).toEqual([ 'demo-production-emails', 'demo-production-invoices', ]) }) }) describe('resolveQueues', () => { it('preserves per-queue concurrency from object entries', () => { expect(resolveQueues({ queues: ['emails', { invoices: 5 }] }, 'demo', 'production')).toEqual([ { name: 'demo-production-emails' }, { name: 'demo-production-invoices', concurrency: 5 }, ]) }) }) describe('composeServerlessAppTemplate', () => { it('wires three functions sharing one artifact via parameters', () => { const { template, functionNames } = compose({ kind: 'node', entry: 'src/server.ts' }) expect(functionNames).toEqual({ http: 'demo-production-http', queue: 'demo-production-queue', cli: 'demo-production-cli', }) for (const id of ['HttpFunction', 'QueueFunction', 'CliFunction']) { const fn = template.Resources[id] as any expect(fn.Type).toBe('AWS::Lambda::Function') expect(fn.Properties.Code).toEqual({ S3Bucket: { Ref: 'ArtifactBucket' }, S3Key: { Ref: 'ArtifactKey' } }) } expect(template.Parameters?.ArtifactBucket).toBeDefined() expect(template.Parameters?.ArtifactKey).toBeDefined() }) it('authors the HTTP API integration + $default route + invoke permission', () => { const { template } = compose({ kind: 'node', entry: 'a.ts' }) expect((template.Resources.HttpApi as any).Properties.ProtocolType).toBe('HTTP') expect((template.Resources.HttpIntegration as any).Properties.IntegrationType).toBe('AWS_PROXY') expect((template.Resources.HttpRoute as any).Properties.RouteKey).toBe('$default') expect((template.Resources.HttpPermission as any).Properties.Principal).toBe('apigateway.amazonaws.com') }) it('creates the queue, DLQ, and event source mapping with batch failure reporting', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', queues: ['jobs'], queueTries: 5 }) expect((template.Resources.AppQueue0 as any).Properties.QueueName).toBe('demo-production-jobs') expect((template.Resources.AppQueueDlq as any).Type).toBe('AWS::SQS::Queue') const mapping = template.Resources.AppQueue0Mapping as any expect(mapping.Type).toBe('AWS::Lambda::EventSourceMapping') expect(mapping.Properties.FunctionResponseTypes).toContain('ReportBatchItemFailures') expect((template.Resources.AppQueue0 as any).Properties.RedrivePolicy.maxReceiveCount).toBe(5) }) it('adds the EventBridge scheduler unless disabled', () => { const on = compose({ kind: 'node', entry: 'a.ts' }) expect((on.template.Resources.SchedulerRule as any).Properties.ScheduleExpression).toBe('rate(1 minute)') const off = compose({ kind: 'node', entry: 'a.ts', scheduler: 'off' }) expect(off.template.Resources.SchedulerRule).toBeUndefined() }) it('omits queue resources and function when queues are disabled', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', queues: false }) expect(template.Resources.QueueFunction).toBeUndefined() expect(template.Resources.AppQueue0).toBeUndefined() }) it('adds assets bucket + CloudFront when assets are configured', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', assets: 'public' }) expect((template.Resources.AssetsBucket as any).Properties.BucketName).toBe('demo-production-assets') expect((template.Resources.AssetsDistribution as any).Type).toBe('AWS::CloudFront::Distribution') }) it('attaches runtime layers and VPC config for PHP', () => { const { template } = compose({ kind: 'php', runtime: 'provided.al2023', architecture: 'arm64', vpc: { subnets: ['subnet-1', 'subnet-2'], securityGroups: ['sg-1'] }, } as ServerlessAppConfig) // PHP composer call without layers still works; pass layers explicitly: const withLayers = composeServerlessAppTemplate({ config, environment: 'production', app: { kind: 'php', runtime: 'provided.al2023', vpc: { subnets: ['subnet-1'] } }, handlers, runtimeLayers: ['arn:aws:lambda:us-east-1:123:layer:php-83:1'], }) const fn = withLayers.template.Resources.HttpFunction as any expect(fn.Properties.Layers).toEqual(['arn:aws:lambda:us-east-1:123:layer:php-83:1']) expect(fn.Properties.VpcConfig.SubnetIds).toEqual(['subnet-1']) expect((template.Resources.HttpFunction as any).Properties.Architectures).toEqual(['arm64']) }) it('creates a WAF WebACL when firewall is enabled, but NOT an association (WAFv2 cannot attach to HTTP API v2)', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', firewall: { enabled: true, rateLimit: 2000, rules: ['common', 'sqlInjection'] }, }) expect((template.Resources.WebAcl as any).Properties.Scope).toBe('REGIONAL') expect((template.Resources.WebAcl as any).Properties.Rules).toHaveLength(3) // No WebACLAssociation — AWS rejects associating a web ACL with an HTTP API // (v2) stage; the ARN is surfaced as an output to attach via CloudFront. expect(template.Resources.WebAclAssociation).toBeUndefined() expect((template.Outputs as any).WafAclArn.Value).toEqual({ 'Fn::GetAtt': ['WebAcl', 'Arn'] }) }) it('creates ElastiCache + security group when cache.driver is elasticache', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', cache: { driver: 'elasticache' }, vpc: { id: 'vpc-test', subnets: ['subnet-a', 'subnet-b'] }, }) expect((template.Resources.CacheCluster as any).Type).toBe('AWS::ElastiCache::ReplicationGroup') expect((template.Resources.DataSecurityGroup as any).Type).toBe('AWS::EC2::SecurityGroup') // No DynamoDB cache table when using elasticache. expect(template.Resources.CacheTable).toBeUndefined() // Functions join the VPC with the managed SG. const sg = (template.Resources.HttpFunction as any).Properties.VpcConfig.SecurityGroupIds expect(JSON.stringify(sg)).toContain('DataSecurityGroup') }) // Contract test: the dashboard resolver (ts-cloud/src/deploy/dashboard-data.ts) // reads these output keys + resource names by string. They are coupled only by // convention, so renaming one here silently breaks live dashboard data. This // locks the contract — it would have caught the EfsId/`-redis` drift bugs. it('emits the exact output keys + resource names the dashboard resolver depends on', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', vpc: { id: 'vpc-test', subnets: ['subnet-a', 'subnet-b'] }, database: { connection: 'aurora-serverless' }, rdsProxy: true, cache: { driver: 'elasticache' }, efs: true, assets: 'public', firewall: { enabled: true, rules: ['common'] }, queues: ['jobs'], } as ServerlessAppConfig) const outputs = template.Outputs as Record // Output keys read by resolveDashboardData / resolveServerlessFunctions. for (const key of [ 'DbEndpoint', 'DbProxyEndpoint', 'CacheEndpoint', 'EfsFileSystemId', 'AssetsCdnDomain', 'AssetsBucketName', 'HttpApiEndpoint', 'WafAclArn', ]) expect(outputs[key], `dashboard reads output '${key}'`).toBeDefined() // Resource-name conventions the resolver reconstructs from slug/env. expect((template.Resources.DbCluster as any).Properties.DBClusterIdentifier).toBe('demo-production-db') expect((template.Resources.CacheCluster as any).Properties.ReplicationGroupId).toBe('demo-production-cache') expect((template.Resources.WebAcl as any).Properties.Name).toBe('demo-production-waf') expect((template.Resources.AppQueueDlq as any).Properties.QueueName).toBe('demo-production-dlq') // Function names — resolveServerlessFunctions rebuilds `${slug}-${env}-{mode}`. expect((template.Resources.HttpFunction as any).Properties.FunctionName).toBe('demo-production-http') expect((template.Resources.QueueFunction as any).Properties.FunctionName).toBe('demo-production-queue') expect((template.Resources.CliFunction as any).Properties.FunctionName).toBe('demo-production-cli') // Template is structurally valid (incl. the WAF-without-association change). expect(validateTemplate(template as any).errors).toEqual([]) }) it('creates Aurora Serverless v2 + RDS Proxy', () => { const { template } = compose({ kind: 'php', database: { connection: 'aurora-serverless' }, rdsProxy: true, vpc: { id: 'vpc-test', subnets: ['subnet-a', 'subnet-b'] }, } as ServerlessAppConfig) expect((template.Resources.DbCluster as any).Properties.ServerlessV2ScalingConfiguration).toEqual({ MinCapacity: 0.5, MaxCapacity: 4, }) expect((template.Resources.DbInstance as any).Properties.DBInstanceClass).toBe('db.serverless') expect((template.Resources.DbProxy as any).Type).toBe('AWS::RDS::DBProxy') }) it('honors configurable Aurora min/max capacity', () => { const { template } = compose({ kind: 'php', database: { connection: 'aurora-serverless', minCapacity: 2, maxCapacity: 16 }, vpc: { id: 'vpc-test', subnets: ['subnet-a', 'subnet-b'] }, } as ServerlessAppConfig) expect((template.Resources.DbCluster as any).Properties.ServerlessV2ScalingConfiguration).toEqual({ MinCapacity: 2, MaxCapacity: 16, }) }) it('adds warmer rules sized to the warm count (5 targets/rule)', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', warm: 7 }) expect((template.Resources.WarmerHttpRule0 as any).Properties.Targets).toHaveLength(5) expect((template.Resources.WarmerHttpRule1 as any).Properties.Targets).toHaveLength(2) expect((template.Resources.WarmerHttpPermission as any).Properties.Principal).toBe('events.amazonaws.com') }) it('omits warmer rules when warm is unset', () => { const { template } = compose({ kind: 'node', entry: 'a.ts' }) expect(template.Resources.WarmerHttpRule0).toBeUndefined() }) it('attaches the Lambda Insights layer and execution policy to every zip function', () => { const layerArn = 'arn:aws:lambda:us-east-1:580247275435:layer:LambdaInsightsExtension:64' const { template } = compose({ kind: 'node', entry: 'a.ts', lambdaInsights: { layerArn } }) expect((template.Resources.AppRole as any).Properties.ManagedPolicyArns).toContain( 'arn:aws:iam::aws:policy/CloudWatchLambdaInsightsExecutionRolePolicy', ) expect((template.Resources.HttpFunction as any).Properties.Layers).toContain(layerArn) expect((template.Resources.CliFunction as any).Properties.Layers).toContain(layerArn) expect((template.Resources.QueueFunction as any).Properties.Layers).toContain(layerArn) }) it('preserves runtime layers when Lambda Insights is enabled', () => { const layerArn = 'arn:aws:lambda:us-east-1:580247275435:layer:LambdaInsightsExtension:64' const result = composeServerlessAppTemplate({ config, environment: 'production', handlers, app: { kind: 'bun', lambdaInsights: { layerArn } }, runtimeLayers: ['arn:aws:lambda:us-east-1:123456789012:layer:bun:1'], }) expect((result.template.Resources.HttpFunction as any).Properties.Layers).toEqual([ 'arn:aws:lambda:us-east-1:123456789012:layer:bun:1', layerArn, ]) }) it('requires image deployments to bake in the Lambda Insights extension', () => { expect(() => compose({ kind: 'node', entry: 'a.ts', packaging: 'image', lambdaInsights: { layerArn: 'arn:aws:lambda:us-east-1:580247275435:layer:LambdaInsightsExtension:64' }, }), ).toThrow(/install the Lambda Insights extension in the image/) }) it('sets TSCLOUD_OCTANE on functions when octane is enabled', () => { const { template } = compose({ kind: 'php', octane: true }) expect((template.Resources.HttpFunction as any).Properties.Environment.Variables.TSCLOUD_OCTANE).toBe('1') }) it('throws when data services are requested without VPC subnets', () => { expect(() => compose({ kind: 'node', entry: 'a.ts', cache: { driver: 'elasticache' } })).toThrow( /require app\.vpc\.subnets/, ) }) it('uses PackageType Image + ImageUri parameter in image mode', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', packaging: 'image' }) const fn = template.Resources.HttpFunction as any expect(fn.Properties.PackageType).toBe('Image') expect(fn.Properties.Code).toEqual({ ImageUri: { Ref: 'ImageUri' } }) expect(fn.Properties.ImageConfig.Command).toEqual(['index.http']) expect(template.Parameters?.ImageUri).toBeDefined() expect(template.Parameters?.ArtifactBucket).toBeUndefined() }) it('omits ImageConfig.Command for PHP images (mode comes from env)', () => { const { template } = compose({ kind: 'php', packaging: 'image' }) const fn = template.Resources.HttpFunction as any expect(fn.Properties.PackageType).toBe('Image') expect(fn.Properties.ImageConfig).toBeUndefined() }) it('derives a managed runtime for default Node (no layer needed)', () => { const { template } = compose({ kind: 'node', entry: 'a.ts' }) expect((template.Resources.HttpFunction as any).Properties.Runtime).toBe('nodejs22.x') }) it('derives provided.al2023 for newer Node and attaches the layer', () => { const { template } = composeServerlessAppTemplate({ config, environment: 'production', app: { kind: 'node', entry: 'a.ts', runtimeVersion: '24' }, handlers, runtimeLayers: ['arn:aws:lambda:us-east-1:1:layer:tscloud-node-24-x86_64:1'], }) const fn = template.Resources.HttpFunction as any expect(fn.Properties.Runtime).toBe('provided.al2023') expect(fn.Properties.Layers).toEqual(['arn:aws:lambda:us-east-1:1:layer:tscloud-node-24-x86_64:1']) }) it('derives provided.al2023 for Bun', () => { const { template } = compose({ kind: 'bun', entry: 'a.ts' }) expect((template.Resources.HttpFunction as any).Properties.Runtime).toBe('provided.al2023') }) it('provisions an APIGW custom domain + cert + alias when domain+hostedZoneId set', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', domain: 'app.acme.com', hostedZoneId: 'Z123' }) expect((template.Resources.HttpCertificate as any).Properties.ValidationMethod).toBe('DNS') expect((template.Resources.HttpDomain0 as any).Properties.DomainName).toBe('app.acme.com') expect((template.Resources.HttpApiMapping0 as any).Type).toBe('AWS::ApiGatewayV2::ApiMapping') expect((template.Resources.HttpDomainRecord0 as any).Properties.AliasTarget).toBeDefined() }) it('uses a pre-issued certificateArn without creating a cert', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', domain: ['a.acme.com', 'b.acme.com'], certificateArn: 'arn:aws:acm:us-east-1:1:certificate/x', }) expect(template.Resources.HttpCertificate).toBeUndefined() expect((template.Resources.HttpDomain0 as any).Properties.DomainNameConfigurations[0].CertificateArn).toBe( 'arn:aws:acm:us-east-1:1:certificate/x', ) expect((template.Resources.HttpDomain1 as any).Properties.DomainName).toBe('b.acme.com') }) it('throws when a custom domain has neither certificateArn nor hostedZoneId', () => { expect(() => compose({ kind: 'node', entry: 'a.ts', domain: 'app.acme.com' })).toThrow( /certificateArn.*hostedZoneId/s, ) }) it('applies per-function ephemeral storage (cli/queue tmp)', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', tmpStorage: 512, cliTmpStorage: 2048, queueTmpStorage: 1024, queues: ['jobs'], }) expect((template.Resources.HttpFunction as any).Properties.EphemeralStorage.Size).toBe(512) expect((template.Resources.CliFunction as any).Properties.EphemeralStorage.Size).toBe(2048) expect((template.Resources.QueueFunction as any).Properties.EphemeralStorage.Size).toBe(1024) }) it('sets TSCLOUD_SCHEDULER=sub-minute env when scheduler is sub-minute', () => { const { template } = compose({ kind: 'php', scheduler: 'sub-minute' }) expect((template.Resources.CliFunction as any).Properties.Environment.Variables.TSCLOUD_SCHEDULER).toBe( 'sub-minute', ) }) it('provisions + mounts EFS at /mnt/local when efs:true (with VPC)', () => { const { template } = compose({ kind: 'php', efs: true, vpc: { id: 'vpc-test', subnets: ['subnet-a', 'subnet-b'] } }) expect((template.Resources.EfsFileSystem as any).Type).toBe('AWS::EFS::FileSystem') expect((template.Resources.EfsMountTarget0 as any).Type).toBe('AWS::EFS::MountTarget') expect((template.Resources.EfsMountTarget1 as any).Type).toBe('AWS::EFS::MountTarget') expect((template.Resources.EfsAccessPoint as any).Type).toBe('AWS::EFS::AccessPoint') const fn = template.Resources.HttpFunction as any expect(fn.Properties.FileSystemConfigs[0].LocalMountPath).toBe('/mnt/local') expect(fn.DependsOn).toContain('EfsMountTarget0') }) it('attaches an existing EFS access point without provisioning', () => { const { template } = compose({ kind: 'php', vpc: { id: 'vpc-test', subnets: ['subnet-a'] }, efs: { accessPointArn: 'arn:aws:elasticfilesystem:us-east-1:1:access-point/fsap-x', mountPath: '/mnt/shared' }, }) expect(template.Resources.EfsFileSystem).toBeUndefined() expect((template.Resources.HttpFunction as any).Properties.FileSystemConfigs[0]).toEqual({ Arn: 'arn:aws:elasticfilesystem:us-east-1:1:access-point/fsap-x', LocalMountPath: '/mnt/shared', }) }) it('throws when efs is requested without VPC subnets', () => { expect(() => compose({ kind: 'php', efs: true })).toThrow(/efs require app\.vpc\.subnets/) }) it('adds a custom asset CDN host (Aliases + viewer cert) and errors without a cert', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', assets: 'public', assetDomain: 'cdn.acme.com', assetCertificateArn: 'arn:aws:acm:us-east-1:1:certificate/c', hostedZoneId: 'Z1', }) const cfg = (template.Resources.AssetsDistribution as any).Properties.DistributionConfig expect(cfg.Aliases).toEqual(['cdn.acme.com']) expect(cfg.ViewerCertificate.AcmCertificateArn).toBe('arn:aws:acm:us-east-1:1:certificate/c') expect((template.Resources.AssetsDomainRecord as any).Properties.AliasTarget.HostedZoneId).toBe('Z2FDTNDATAQYW2') expect(() => compose({ kind: 'node', entry: 'a.ts', assets: 'public', assetDomain: 'cdn.acme.com' })).toThrow( /assetCertificateArn/, ) }) it('auto-issues a DNS-validated asset cert when only a hostedZoneId is given (us-east-1)', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', assets: 'public', assetDomain: 'cdn.acme.com', hostedZoneId: 'Z1', }) const cert = template.Resources.AssetsCertificate as any expect(cert.Type).toBe('AWS::CertificateManager::Certificate') expect(cert.Properties.ValidationMethod).toBe('DNS') expect(cert.Properties.DomainValidationOptions[0]).toEqual({ DomainName: 'cdn.acme.com', HostedZoneId: 'Z1' }) const cfg = (template.Resources.AssetsDistribution as any).Properties.DistributionConfig expect(cfg.ViewerCertificate.AcmCertificateArn).toEqual({ Ref: 'AssetsCertificate' }) }) it('refuses to auto-issue an asset cert outside us-east-1 (CloudFront cert region)', () => { const euConfig = { project: { name: 'Demo', slug: 'demo', region: 'eu-west-1' } } as Pick expect(() => composeServerlessAppTemplate({ config: euConfig, environment: 'production', handlers, app: { kind: 'node', entry: 'a.ts', assets: 'public', assetDomain: 'cdn.acme.com', hostedZoneId: 'Z1' }, }), ).toThrow(/us-east-1/) }) it('sets SQS visibility timeout to 6x the function timeout (capped at 12h)', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', queues: ['jobs'], queueTimeout: 120 }) expect((template.Resources.AppQueue0 as any).Properties.VisibilityTimeout).toBe(720) const { template: big } = compose({ kind: 'node', entry: 'a.ts', queues: ['jobs'], queueTimeout: 900 }) expect((big.Resources.AppQueue0 as any).Properties.VisibilityTimeout).toBe(5400) }) it('applies per-queue concurrency, falling back to the global queueConcurrency', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', queues: ['emails', { invoices: 10 }], queueConcurrency: 3, }) expect((template.Resources.AppQueue0Mapping as any).Properties.ScalingConfig.MaximumConcurrency).toBe(3) // global expect((template.Resources.AppQueue1Mapping as any).Properties.ScalingConfig.MaximumConcurrency).toBe(10) // per-queue wins }) it('warms only HTTP by default', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', warm: 2 }) expect((template.Resources.WarmerHttpRule0 as any).Type).toBe('AWS::Events::Rule') expect(template.Resources.WarmerQueueRule0).toBeUndefined() expect(template.Resources.WarmerCliRule0).toBeUndefined() expect((template.Resources.WarmerHttpRule0 as any).Properties.Targets).toHaveLength(2) }) it('warms the configured set of functions', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', warm: 1, warmFunctions: ['http', 'cli'], queues: false, }) expect((template.Resources.WarmerHttpRule0 as any).Type).toBe('AWS::Events::Rule') expect((template.Resources.WarmerCliRule0 as any).Type).toBe('AWS::Events::Rule') expect((template.Resources.WarmerCliPermission as any).Properties.FunctionName).toEqual({ Ref: 'CliFunction' }) // queue not requested + queues disabled → no queue warmer expect(template.Resources.WarmerQueueRule0).toBeUndefined() }) it('routes traffic through a live alias when provisionedConcurrency is set', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', provisionedConcurrency: 2, queues: ['jobs'] }) // Version + alias per function, alias carries the PC config. expect((template.Resources.HttpFunctionVersion as any).Type).toBe('AWS::Lambda::Version') const alias = template.Resources.HttpFunctionAlias as any expect(alias.Type).toBe('AWS::Lambda::Alias') expect(alias.Properties.Name).toBe('live') expect(alias.Properties.ProvisionedConcurrencyConfig).toEqual({ ProvisionedConcurrentExecutions: 2 }) expect(template.Resources.CliFunctionAlias).toBeDefined() expect(template.Resources.QueueFunctionAlias).toBeDefined() // Integrations / event sources / scheduler target the alias. expect((template.Resources.HttpIntegration as any).Properties.IntegrationUri).toEqual({ Ref: 'HttpFunctionAlias' }) expect((template.Resources.HttpPermission as any).Properties.FunctionName).toEqual({ Ref: 'HttpFunctionAlias' }) expect((template.Resources.AppQueue0Mapping as any).Properties.FunctionName).toEqual({ Ref: 'QueueFunctionAlias' }) expect((template.Resources.SchedulerRule as any).Properties.Targets[0].Arn).toEqual({ Ref: 'CliFunctionAlias' }) }) it('keeps the $LATEST model (no aliases) when provisionedConcurrency is unset', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', queues: ['jobs'] }) expect(template.Resources.HttpFunctionAlias).toBeUndefined() expect(template.Resources.HttpFunctionVersion).toBeUndefined() expect((template.Resources.HttpIntegration as any).Properties.IntegrationUri).toEqual({ 'Fn::GetAtt': ['HttpFunction', 'Arn'], }) expect((template.Resources.AppQueue0Mapping as any).Properties.FunctionName).toEqual({ Ref: 'QueueFunction' }) }) it('honors a custom log retention', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', logRetention: 90 }) expect((template.Resources.HttpFunctionLogGroup as any).Properties.RetentionInDays).toBe(90) }) it('throws on the unsupported REST API (gatewayVersion: 1)', () => { expect(() => compose({ kind: 'node', entry: 'a.ts', gatewayVersion: 1 })).toThrow( /gatewayVersion: 1.*not supported/, ) }) it('passes structural + resource-limit validation', () => { const { template } = compose({ kind: 'node', entry: 'a.ts', queues: ['jobs'], assets: 'public' }) const structural = validateTemplate(template as any) expect(structural.errors).toEqual([]) const limits = validateResourceLimits(template as any) expect(limits.valid).toBe(true) }) })