Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-cdk/aws-s3-assets

Package Overview
Dependencies
Maintainers
5
Versions
249
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-cdk/aws-s3-assets

Deploy local files and directories to S3

  • 1.163.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
126K
decreased by-4.48%
Maintainers
5
Weekly downloads
 
Created

What is @aws-cdk/aws-s3-assets?

@aws-cdk/aws-s3-assets is an AWS CDK library that allows you to manage and deploy assets to Amazon S3. It simplifies the process of uploading files and directories to S3 and integrates seamlessly with other AWS CDK constructs.

What are @aws-cdk/aws-s3-assets's main functionalities?

Upload a File to S3

This feature allows you to upload a single file to an S3 bucket. The code sample demonstrates how to create a new asset from a file located at 'path/to/file.txt' and upload it to S3.

const s3assets = require('@aws-cdk/aws-s3-assets');
const cdk = require('@aws-cdk/core');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    new s3assets.Asset(this, 'MyAsset', {
      path: 'path/to/file.txt'
    });
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Upload a Directory to S3

This feature allows you to upload an entire directory to an S3 bucket. The code sample demonstrates how to create a new asset from a directory located at 'path/to/directory' and upload it to S3.

const s3assets = require('@aws-cdk/aws-s3-assets');
const cdk = require('@aws-cdk/core');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    new s3assets.Asset(this, 'MyAsset', {
      path: 'path/to/directory'
    });
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Grant Read Permissions

This feature allows you to grant read permissions to an IAM role for the uploaded asset. The code sample demonstrates how to create a new asset, an IAM role, and grant read permissions to the role for the asset.

const s3assets = require('@aws-cdk/aws-s3-assets');
const cdk = require('@aws-cdk/core');
const iam = require('@aws-cdk/aws-iam');

class MyStack extends cdk.Stack {
  constructor(scope, id, props) {
    super(scope, id, props);

    const asset = new s3assets.Asset(this, 'MyAsset', {
      path: 'path/to/file.txt'
    });

    const role = new iam.Role(this, 'MyRole', {
      assumedBy: new iam.ServicePrincipal('lambda.amazonaws.com')
    });

    asset.grantRead(role);
  }
}

const app = new cdk.App();
new MyStack(app, 'MyStack');

Other packages similar to @aws-cdk/aws-s3-assets

Keywords

FAQs

Package last updated on 06 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc