sst 2.8.6 → 2.8.8

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.
@@ -2,7 +2,7 @@ import { Construct } from "constructs";
2
2
  import { SSTConstruct } from "./Construct.js";
3
3
  import { Function as Fn, FunctionProps, FunctionDefinition } from "./Function.js";
4
4
  import { Permissions } from "./util/permission.js";
5
- import { CfnIdentityPool, CfnIdentityPoolProps, IUserPool, IUserPoolClient, UserPoolClientOptions, UserPoolProps } from "aws-cdk-lib/aws-cognito";
5
+ import { CfnIdentityPool, CfnIdentityPoolProps, CfnIdentityPoolRoleAttachment, IUserPool, IUserPoolClient, UserPoolClientOptions, UserPoolProps } from "aws-cdk-lib/aws-cognito";
6
6
  import { Role } from "aws-cdk-lib/aws-iam";
7
7
  export interface CognitoUserPoolTriggers {
8
8
  createAuthChallenge?: FunctionDefinition;
@@ -136,6 +136,7 @@ export declare class Cognito extends Construct implements SSTConstruct {
136
136
  userPool: IUserPool;
137
137
  userPoolClient: IUserPoolClient;
138
138
  cfnIdentityPool?: CfnIdentityPool;
139
+ cfnIdentityPoolRoleAttachment?: CfnIdentityPoolRoleAttachment;
139
140
  authRole: Role;
140
141
  unauthRole: Role;
141
142
  };
@@ -275,7 +275,7 @@ export class Cognito extends Construct {
275
275
  this.cdk.authRole = this.createAuthRole(this.cdk.cfnIdentityPool);
276
276
  this.cdk.unauthRole = this.createUnauthRole(this.cdk.cfnIdentityPool);
277
277
  // Attach roles to Identity Pool
278
- new CfnIdentityPoolRoleAttachment(this, "IdentityPoolRoleAttachment", {
278
+ this.cdk.cfnIdentityPoolRoleAttachment = new CfnIdentityPoolRoleAttachment(this, "IdentityPoolRoleAttachment", {
279
279
  identityPoolId: this.cdk.cfnIdentityPool.ref,
280
280
  roles: {
281
281
  authenticated: this.cdk.authRole.roleArn,
@@ -8,7 +8,7 @@ import { execSync } from "child_process";
8
8
  import { Construct } from "constructs";
9
9
  import { Fn, Token, Duration as CdkDuration, RemovalPolicy, CustomResource, } from "aws-cdk-lib";
10
10
  import { BlockPublicAccess, Bucket, } from "aws-cdk-lib/aws-s3";
11
- import { Role, Effect, Policy, PolicyStatement, AnyPrincipal, } from "aws-cdk-lib/aws-iam";
11
+ import { Role, Effect, Policy, PolicyStatement, AccountPrincipal, ServicePrincipal, CompositePrincipal, } from "aws-cdk-lib/aws-iam";
12
12
  import { Function as CdkFunction, Code, Runtime, FunctionUrlAuthType, } from "aws-cdk-lib/aws-lambda";
13
13
  import { HostedZone, ARecord, AaaaRecord, RecordTarget, } from "aws-cdk-lib/aws-route53";
14
14
  import { Asset } from "aws-cdk-lib/aws-s3-assets";
@@ -430,8 +430,9 @@ export class SsrSite extends Construct {
430
430
  }
431
431
  createFunctionForDev() {
432
432
  const { runtime, timeout, memorySize, permissions, environment, bind } = this.props;
433
+ const app = this.node.root;
433
434
  const role = new Role(this, "ServerFunctionRole", {
434
- assumedBy: new AnyPrincipal(),
435
+ assumedBy: new CompositePrincipal(new AccountPrincipal(app.account), new ServicePrincipal("lambda.amazonaws.com")),
435
436
  maxSessionDuration: CdkDuration.hours(12),
436
437
  });
437
438
  const ssrFn = new SsrFunction(this, `ServerFunction`, {
@@ -2,7 +2,7 @@ import { Construct } from "constructs";
2
2
  import { Bucket, BucketProps, IBucket } from "aws-cdk-lib/aws-s3";
3
3
  import { ICertificate } from "aws-cdk-lib/aws-certificatemanager";
4
4
  import { IHostedZone } from "aws-cdk-lib/aws-route53";
5
- import { Distribution } from "aws-cdk-lib/aws-cloudfront";
5
+ import { Distribution, IDistribution } from "aws-cdk-lib/aws-cloudfront";
6
6
  import { BaseSiteDomainProps, BaseSiteReplaceProps, BaseSiteCdkDistributionProps } from "./BaseSite.js";
7
7
  import { SSTConstruct } from "./Construct.js";
8
8
  import { FunctionBindingProps } from "./util/functionBinding.js";
@@ -242,7 +242,7 @@ export interface StaticSiteProps {
242
242
  */
243
243
  bucket?: BucketProps | IBucket;
244
244
  /**
245
- * Configure the internally created CDK `Distribution` instance.
245
+ * Configure the internally created CDK `Distribution` instance or provide an existing distribution
246
246
  *
247
247
  * @example
248
248
  * ```js
@@ -256,7 +256,7 @@ export interface StaticSiteProps {
256
256
  * });
257
257
  * ```
258
258
  */
259
- distribution?: StaticSiteCdkDistributionProps;
259
+ distribution?: IDistribution | StaticSiteCdkDistributionProps;
260
260
  };
261
261
  }
262
262
  export interface StaticSiteDomainProps extends BaseSiteDomainProps {
@@ -322,7 +322,6 @@ export declare class StaticSite extends Construct implements SSTConstruct {
322
322
  private bundleFilenamesAsset;
323
323
  private createS3Bucket;
324
324
  private createS3Deployment;
325
- private validateCloudFrontDistributionSettings;
326
325
  private createCfDistribution;
327
326
  private createCloudFrontInvalidation;
328
327
  protected buildDistributionDomainNames(): string[];
@@ -86,7 +86,6 @@ export class StaticSite extends Construct {
86
86
  // Create S3 Deployment
87
87
  const s3deployCR = this.createS3Deployment(cliLayer, assets, filenamesAsset);
88
88
  // Create CloudFront
89
- this.validateCloudFrontDistributionSettings();
90
89
  this.distribution = this.createCfDistribution();
91
90
  this.distribution.node.addDependency(s3deployCR);
92
91
  // Invalidate CloudFront
@@ -372,8 +371,16 @@ interface ImportMeta {
372
371
  /////////////////////
373
372
  // CloudFront Distribution
374
373
  /////////////////////
375
- validateCloudFrontDistributionSettings() {
374
+ createCfDistribution() {
376
375
  const { cdk, errorPage } = this.props;
376
+ const isImportedCloudFrontDistribution = (distribution) => {
377
+ return distribution !== undefined && isCDKConstruct(distribution);
378
+ };
379
+ // cdk.distribution is an imported construct
380
+ if (isImportedCloudFrontDistribution(cdk?.distribution)) {
381
+ return cdk?.distribution;
382
+ }
383
+ // Validate input
377
384
  if (cdk?.distribution?.certificate) {
378
385
  throw new Error(`Do not configure the "cfDistribution.certificate". Use the "customDomain" to configure the domain certificate.`);
379
386
  }
@@ -383,11 +390,8 @@ interface ImportMeta {
383
390
  if (errorPage && cdk?.distribution?.errorResponses) {
384
391
  throw new Error(`Cannot configure the "cfDistribution.errorResponses" when "errorPage" is passed in. Use one or the other to configure the behavior for error pages.`);
385
392
  }
386
- }
387
- createCfDistribution() {
388
- const { cdk, errorPage } = this.props;
389
- const indexPage = this.props.indexPage || "index.html";
390
393
  // Create CloudFront distribution
394
+ const indexPage = this.props.indexPage || "index.html";
391
395
  return new Distribution(this, "Distribution", {
392
396
  // these values can be overwritten by cfDistributionProps
393
397
  defaultRootObject: indexPage,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.8.6",
4
+ "version": "2.8.8",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },