How to use @aws-cdk/aws-cloudfront - 10 common examples

To help you get started, we’ve selected a few @aws-cdk/aws-cloudfront examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github seagull-js / seagull / packages / deploy / src / lib / cdk / stack.ts View on Github external
private addCloudfront() {
    const name = `${this.name}CFD`
    const originPath = this.apiGatewayOriginPath
    const allowedMethods = CF.CloudFrontAllowedMethods.ALL
    const behaviors = [{ allowedMethods, isDefaultBehavior: true }]
    const customOriginSource = { domainName: this.apiGatewayDomain }
    const originConfigs = [{ behaviors, customOriginSource, originPath }]
    const conf = { defaultRootObject: '', originConfigs }
    // tslint:disable-next-line:no-unused-expression
    new CF.CloudFrontWebDistribution(this, name, conf)
  }
}
github aws-samples / aws-cdk-changelogs-demo / changelogs-md.js View on Github external
constructor(parent, id, props) {
    super(parent, id, props);

    this.dist = new cloudfront.CloudFrontWebDistribution(this, 'ChangelogsDistribution', {
      aliasConfiguration: domain,
      originConfigs: [
        // All the static files, like CSS, JS, images, etc
        {
          customOriginSource: {
            domainName: props.staticBucket.bucketName + '.s3-website.' + this.region + '.amazonaws.com',
            originProtocolPolicy: 'http-only'
          },
          behaviors: [
            {
              isDefaultBehavior: true,
              compress: true
            }
          ]
        },
        // The automatically generated HTML files
github seagull-js / seagull / packages / deploy / src / cdk_stack.ts View on Github external
private addCloudfront() {
    const name = `${this.name}CFD`
    const originPath = this.apiGatewayOriginPath
    const behaviors = [{ isDefaultBehavior: true }]
    const customOriginSource = { domainName: this.apiGatewayDomain }
    const originConfigs = [{ behaviors, customOriginSource, originPath }]
    const conf = { defaultRootObject: '', originConfigs }
    // tslint:disable-next-line:no-unused-expression
    new cloudFront.CloudFrontWebDistribution(this, name, conf)
  }
}
github seagull-js / seagull / packages / deploy / src / lib / cdk / stack.ts View on Github external
private addCloudfront() {
    const name = `${this.name}CFD`
    const originPath = this.apiGatewayOriginPath
    const allowedMethods = CF.CloudFrontAllowedMethods.ALL
    const behaviors = [{ allowedMethods, isDefaultBehavior: true }]
    const customOriginSource = { domainName: this.apiGatewayDomain }
    const originConfigs = [{ behaviors, customOriginSource, originPath }]
    const conf = { defaultRootObject: '', originConfigs }
    // tslint:disable-next-line:no-unused-expression
    new CF.CloudFrontWebDistribution(this, name, conf)
  }
}
github seagull-js / seagull / examples / helloworld / src / cdk / index.ts View on Github external
'lambda:InvokeAsync'
        )
    )
    const cfConfig = {
      defaultRootObject: '',
      originConfigs: [
        {
          behaviors: [{ isDefaultBehavior: true }],
          customOriginSource: {
            domainName: getApiGatewayDomain(apiGateway.url.toString()),
          },
          originPath: getApiGatewayPath(apiGateway.url.toString()),
        },
      ],
    }
    new cf.CloudFrontWebDistribution(this, `${pkg.name}CFD`, cfConfig)
  }
}
github cloudcomponents / cdk-components / packages / cdk-static-website / src / static-website.ts View on Github external
});

        const distibutionConfig: CloudFrontWebDistributionProps = {
            webACLId,
            originConfigs: [
                {
                    s3OriginSource: {
                        ...websiteBucket.s3OriginConfig,
                    },
                    behaviors: [{ isDefaultBehavior: true }],
                },
            ],
            aliasConfiguration,
        };

        this.distribution = new CloudFrontWebDistribution(
            this,
            'WebSiteDistribution',
            distibutionConfig,
        );

        if (aliasConfiguration) {
            new WebsiteAliasRecord(this, 'WebsiteAliasRecord', {
                domainName: aliasConfiguration.domainName,
                recordNames: aliasConfiguration.names,
                target: new CloudFrontTarget(this.distribution),
            });
        }
    }
github jeshan / scale-your-cloudformation / lib / cdk-stack.js View on Github external
const distributionConfig = {
            originConfigs: [
                {
                    s3OriginSource: {
                        ...s3OriginConfig,
                    },
                    behaviors: [{ isDefaultBehavior: true }],
                },
            ],
            aliasConfiguration: {
                acmCertRef: cert.certificateArn,
                names: [domainName],
            },
        };
        let distribution = new CloudFrontWebDistribution(
            this,
            'WebSiteDistribution',
            distributionConfig,
        );

        const placeHolderSource = path.join(__dirname, '..', 'docs');

        new BucketDeployment(this, 'WebsiteDeployment', {
            sources: [Source.asset(placeHolderSource)],
            destinationBucket: websiteBucket,
            distribution,
            retainOnDelete: false,
        });

        new PipelineConstruct(this);
    }
github seagull-js / seagull / packages / deploy-aws / src / seagull_stack.ts View on Github external
const originConfigurations = compact([
      { behaviors, customOriginSource, originPath },
      errorPageConfig,
    ])

    const errorConfig = this.getErrorConfig(500, 500, '/error.html', 60)

    const conf: CloudFrontWebDistributionProps = {
      aliasConfiguration: props.aliasConfig,
      comment: this.id,
      defaultRootObject: '',
      errorConfigurations: [errorConfig],
      loggingConfig: props.logBucket ? { bucket: props.logBucket } : {},
      originConfigs: originConfigurations,
    }
    return new CF.CloudFrontWebDistribution(this, name, conf)
  }
github seagull-js / seagull / packages / deploy-aws / src / seagull_stack.ts View on Github external
getDefaultBehavior() {
    return {
      allowedMethods: CF.CloudFrontAllowedMethods.ALL,
      compress: true,
      forwardedValues: { headers: ['authorization'], queryString: true },
      isDefaultBehavior: true,
    }
  }