Ask Your Question
1

What is the process for uploading a zip file to S3 using CDK?

asked 2023-07-02 18:35:49 +0000

qstack gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-07-02 18:57:02 +0000

scrum gravatar image

To upload a zip file to S3 using CDK, follow these steps:

  1. First, import the necessary modules:
import * as s3 from '@aws-cdk/aws-s3';
import * as s3deploy from '@aws-cdk/aws-s3-deployment';
  1. Create an S3 bucket:
const myBucket = new s3.Bucket(this, 'MyBucket');
  1. Define the local path of the zip file:
const localPath = path.join(__dirname, '../myapp.zip');
  1. Upload the zip file to the S3 bucket:
new s3deploy.BucketDeployment(this, 'DeployFiles', {
   sources: [s3deploy.Source.asset(localPath)], 
   destinationBucket: myBucket 
});
  1. Deploy the CDK stack:
cdk deploy

This will create an S3 bucket and upload the zip file to it.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-07-02 18:35:49 +0000

Seen: 16 times

Last updated: Jul 02 '23