How to use the @aws-cdk/aws-s3-deployment.BucketDeployment function in @aws-cdk/aws-s3-deployment

To help you get started, we’ve selected a few @aws-cdk/aws-s3-deployment 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 josephluck / internote / ui / deploy / index.ts View on Github external
async function buildMyStack(scope: cdk.Construct, id: string, props: {}) {
  const stack = new cdk.Stack(scope, id, props);

  // TODO: inject environment variables
  // should be via SSM. See here:
  // https://docs.aws.amazon.com/cdk/latest/guide/get_ssm_value.html
  await execute("./node_modules/.bin/next", ["build"]);

  const manifest = await getBuildManifest();
  const staticPages = Object.values(manifest.pages.html);

  const bucket = new s3.Bucket(scope, `${id}-bucket`, {
    publicReadAccess: true
  });
  new s3Upload.BucketDeployment(stack, `${id}-s3-static-pages`, {
    // TODO: these files might already be prefixed with `pages/${page}`? This will need to be removed if so.
    sources: staticPages.map(page =>
      s3Upload.Source.asset(`./.next/serverless/${page}`)
    ),
    destinationBucket: bucket,
    destinationKeyPrefix: "static-pages"
  });
  new s3Upload.BucketDeployment(stack, `${id}-s3-next-static-files`, {
    sources: [s3Upload.Source.asset("./.next/static")],
    destinationBucket: bucket,
    destinationKeyPrefix: "_next/static"
  });
  new s3Upload.BucketDeployment(stack, `${id}-s3-public-files`, {
    sources: [s3Upload.Source.asset("./public")],
    destinationBucket: bucket,
    destinationKeyPrefix: "public"
github josephluck / internote / ui / deploy / index.ts View on Github external
const manifest = await getBuildManifest();
  const staticPages = Object.values(manifest.pages.html);

  const bucket = new s3.Bucket(scope, `${id}-bucket`, {
    publicReadAccess: true
  });
  new s3Upload.BucketDeployment(stack, `${id}-s3-static-pages`, {
    // TODO: these files might already be prefixed with `pages/${page}`? This will need to be removed if so.
    sources: staticPages.map(page =>
      s3Upload.Source.asset(`./.next/serverless/${page}`)
    ),
    destinationBucket: bucket,
    destinationKeyPrefix: "static-pages"
  });
  new s3Upload.BucketDeployment(stack, `${id}-s3-next-static-files`, {
    sources: [s3Upload.Source.asset("./.next/static")],
    destinationBucket: bucket,
    destinationKeyPrefix: "_next/static"
  });
  new s3Upload.BucketDeployment(stack, `${id}-s3-public-files`, {
    sources: [s3Upload.Source.asset("./public")],
    destinationBucket: bucket,
    destinationKeyPrefix: "public"
  });
  new s3Upload.BucketDeployment(stack, `${id}-s3-static-files`, {
    sources: [s3Upload.Source.asset("./static")],
    destinationBucket: bucket,
    destinationKeyPrefix: "static"
  });

  const ssrLambda = new lambda.Function(stack, `${id}-ssr-lambda`, {
github aws-samples / aws-cdk-changelogs-demo / changelogs-md.js View on Github external
constructor(parent, id, props) {
    super(parent, id, props);

    // Copy the static files into the static S3 bucket
    this.s3Deployment = new s3Deployment.BucketDeployment(this, 'deploy-web', {
      source: s3Deployment.Source.asset('./static'),
      destinationBucket: props.staticBucket,
    });

    // Create a lambda that regenerates the homepage
    const regenerateHomepage = new lambda.Function(this, 'regenerate-homepage', {
      runtime: lambda.Runtime.NODEJS_10_X,
      handler: 'regenerate-homepage.handle',
      code: lambda.Code.asset('./app/regenerate-homepage'),
      environment: {
        CHANGELOGS_TABLE_NAME: props.changelogsTable.tableName,
        FEEDS_TABLE_NAME: props.feedsTable.tableName,
        WEB_BUCKET_NAME: props.webBucket.bucketName
      }
    });
github cloudcomponents / cdk-components / packages / cdk-static-website / src / website-bucket.ts View on Github external
'OriginAccessIdentity',
            {
                cloudFrontOriginAccessIdentityConfig: {
                    comment: `CloudFront OriginAccessIdentity for ${bucket.bucketName}`,
                },
            },
        );

        bucket.grantRead(
            new CanonicalUserPrincipal(originId.attrS3CanonicalUserId),
        );

        if (!disableUpload) {
            const placeHolderSource = path.join(__dirname, '..', 'website');

            new BucketDeployment(this, 'WebsiteDeployment', {
                sources: [Source.asset(source || placeHolderSource)],
                destinationBucket: bucket,
                retainOnDelete: removalPolicy === RemovalPolicy.RETAIN,
            });
        }

        this.s3OriginConfig = {
            originAccessIdentityId: originId.ref,
            s3BucketSource: bucket,
        };
    }
}
github jeshan / scale-your-cloudformation / lib / cdk-stack.js View on Github external
},
            ],
            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);
    }
}

@aws-cdk/aws-s3-deployment

Constructs for deploying contents to S3 buckets

Apache-2.0
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis