@ts-cloud/core 0.5.3 → 0.5.5

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/index.js CHANGED
@@ -45833,7 +45833,7 @@ function composeServerlessAppTemplate(opts) {
45833
45833
  ...app.assetDomain ? {
45834
45834
  Aliases: [app.assetDomain],
45835
45835
  ViewerCertificate: {
45836
- AcmCertificateArn: app.assetCertificateArn,
45836
+ AcmCertificateArn: app.assetCertificateArn ?? Fn2.ref("AssetsCertificate"),
45837
45837
  SslSupportMethod: "sni-only",
45838
45838
  MinimumProtocolVersion: "TLSv1.2_2021"
45839
45839
  }
@@ -45842,8 +45842,20 @@ function composeServerlessAppTemplate(opts) {
45842
45842
  }
45843
45843
  };
45844
45844
  if (app.assetDomain) {
45845
- if (!app.assetCertificateArn)
45846
- throw new Error("serverless app: `assetDomain` requires `assetCertificateArn` (a us-east-1 ACM cert — CloudFront only accepts certs from us-east-1).");
45845
+ if (!app.assetCertificateArn) {
45846
+ if (!app.hostedZoneId)
45847
+ throw new Error("serverless app: `assetDomain` requires either `assetCertificateArn` (a us-east-1 ACM cert) or `hostedZoneId` (to auto-issue + validate one). CloudFront only accepts certs from us-east-1.");
45848
+ if (region !== "us-east-1")
45849
+ throw new Error(`serverless app: auto-issuing an asset-domain cert needs a us-east-1 app (CloudFront certs must be us-east-1); this app is in ${region}. Supply a pre-issued us-east-1 \`assetCertificateArn\` instead.`);
45850
+ resources.AssetsCertificate = {
45851
+ Type: "AWS::CertificateManager::Certificate",
45852
+ Properties: {
45853
+ DomainName: app.assetDomain,
45854
+ ValidationMethod: "DNS",
45855
+ DomainValidationOptions: [{ DomainName: app.assetDomain, HostedZoneId: app.hostedZoneId }]
45856
+ }
45857
+ };
45858
+ }
45847
45859
  if (app.hostedZoneId) {
45848
45860
  resources.AssetsDomainRecord = {
45849
45861
  Type: "AWS::Route53::RecordSet",
@@ -45930,9 +45942,12 @@ function composeServerlessAppTemplate(opts) {
45930
45942
  };
45931
45943
  }
45932
45944
  if (hasVpc && needsDataVpc) {
45945
+ if (!app.vpc?.id)
45946
+ throw new Error("serverless app: data services (elasticache / aurora-serverless / rdsProxy / efs) need app.vpc.id (the VPC id) so the managed security group is created in the right VPC.");
45933
45947
  resources.DataSecurityGroup = {
45934
45948
  Type: "AWS::EC2::SecurityGroup",
45935
45949
  Properties: {
45950
+ VpcId: app.vpc.id,
45936
45951
  GroupDescription: `${slug}-${environment} serverless data access`,
45937
45952
  SecurityGroupIngress: [{ IpProtocol: "-1", CidrIp: "10.0.0.0/8" }]
45938
45953
  }
@@ -46013,6 +46028,7 @@ function composeServerlessAppTemplate(opts) {
46013
46028
  Engine: "aurora-mysql",
46014
46029
  EngineMode: "provisioned",
46015
46030
  DBClusterIdentifier: `${slug}-${environment}-db`,
46031
+ DatabaseName: "app",
46016
46032
  MasterUsername: Fn2.sub("{{resolve:secretsmanager:${DbSecret}:SecretString:username}}"),
46017
46033
  MasterUserPassword: Fn2.sub("{{resolve:secretsmanager:${DbSecret}:SecretString:password}}"),
46018
46034
  ServerlessV2ScalingConfiguration: { MinCapacity: 0.5, MaxCapacity: 4 },
@@ -46059,6 +46075,15 @@ function composeServerlessAppTemplate(opts) {
46059
46075
  RequireTLS: false
46060
46076
  }
46061
46077
  };
46078
+ resources.DbProxyTargetGroup = {
46079
+ Type: "AWS::RDS::DBProxyTargetGroup",
46080
+ DependsOn: ["DbInstance"],
46081
+ Properties: {
46082
+ DBProxyName: Fn2.ref("DbProxy"),
46083
+ TargetGroupName: "default",
46084
+ DBClusterIdentifiers: [Fn2.ref("DbCluster")]
46085
+ }
46086
+ };
46062
46087
  outputs.DbProxyEndpoint = { Description: "RDS Proxy endpoint", Value: Fn2.getAtt("DbProxy", "Endpoint") };
46063
46088
  }
46064
46089
  outputs.HttpFunctionName = { Description: "HTTP function name", Value: Fn2.ref("HttpFunction") };
package/dist/types.d.ts CHANGED
@@ -1632,8 +1632,10 @@ export interface ServerlessAppConfig {
1632
1632
  * @default 'zip'
1633
1633
  */
1634
1634
  packaging?: 'zip' | 'image';
1635
- /** Attach the functions to a VPC (required for ElastiCache / private RDS). */
1635
+ /** Attach the functions to a VPC (required for ElastiCache / private RDS / EFS). */
1636
1636
  vpc?: {
1637
+ /** VPC id — required when ts-cloud provisions a managed security group for data services. */
1638
+ id?: string;
1637
1639
  subnets?: string[];
1638
1640
  securityGroups?: string[];
1639
1641
  };
@@ -1690,10 +1692,16 @@ export interface ServerlessAppConfig {
1690
1692
  assets?: string;
1691
1693
  /**
1692
1694
  * Serve assets from a custom CDN host instead of the default CloudFront domain
1693
- * (Vapor `asset-domain`). Requires a us-east-1 ACM cert via assetCertificateArn.
1695
+ * (Vapor `asset-domain`). CloudFront needs a us-east-1 ACM cert: supply one via
1696
+ * {@link assetCertificateArn}, or give {@link hostedZoneId} and (for a us-east-1
1697
+ * app) ts-cloud auto-issues + DNS-validates one.
1694
1698
  */
1695
1699
  assetDomain?: string;
1696
- /** us-east-1 ACM certificate ARN for {@link assetDomain} (CloudFront requirement). */
1700
+ /**
1701
+ * us-east-1 ACM certificate ARN for {@link assetDomain} (CloudFront requirement).
1702
+ * Optional when {@link hostedZoneId} is set and the app is in us-east-1 — the
1703
+ * cert is then auto-issued and DNS-validated.
1704
+ */
1697
1705
  assetCertificateArn?: string;
1698
1706
  /** Include dotfiles when uploading assets (Vapor `dot-files-as-assets`). @default false */
1699
1707
  dotFilesAsAssets?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ts-cloud/core",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "type": "module",
5
5
  "description": "Core CloudFormation generation library for ts-cloud",
6
6
  "author": "Chris Breuer <chris@stacksjs.com>",
@@ -31,7 +31,7 @@
31
31
  "typecheck": "tsc --noEmit"
32
32
  },
33
33
  "dependencies": {
34
- "@ts-cloud/aws-types": "0.5.3"
34
+ "@ts-cloud/aws-types": "0.5.5"
35
35
  },
36
36
  "devDependencies": {
37
37
  "typescript": "^5.9.3"