1. 程式人生 > >Copy Objects Between S3 Buckets Using Lambda

Copy Objects Between S3 Buckets Using Lambda

// Load the AWS SDK
const aws = require('aws-sdk');

// Construct the AWS S3 Object - 
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#constructor-property
const s3 = new aws.S3({
            apiVersion: '2006-03-01'
 });
        
// Define 2 new variables for the source and destination buckets
var srcBucket = "YOUR-SOURCE-BUCKET";
var destBucket = "YOUR-DESTINATION-BUCKET";
var sourceObject = "YOUR-SOURCE-OBJECT";

//Main function
exports.handler = (event, context, callback) => {
        
//Copy the current object to the destination bucket
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#copyObject-property
s3.copyObject({ 
    CopySource: srcBucket + '/' + sourceObject,
    Bucket: destBucket,
    Key: sourceObject
    }, function(copyErr, copyData){
       if (copyErr) {
            console.log("Error: " + copyErr);
         } else {
            console.log('Copied OK');
         } 
    });
  callback(null, 'All done!');
};
        

相關推薦

Copy Objects Between S3 Buckets Using Lambda

// Load the AWS SDK const aws = require('aws-sdk'); // Construct the AWS S3 Object - http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3

Move Objects Between S3 Buckets

To copy objects from one S3 bucket to another, follow these steps: 1.    Create a new S3 bucket. 2.    Install and config

Account Access to Objects In S3 Buckets

ACL permissions vary based on which S3 resource, bucket, or object that an ACL is applied to. For more information, see Access Control List (AC

Mount S3 Buckets to a PC Using AWS Snowball Edge

After you mount one or more Amazon Simple Storage Service (Amazon S3) buckets in your AWS Snowball Edge to your PC, you can transfer files betw

Flag S3 Buckets That Allow Access From the Internet Using AWS Config

To check whether S3 buckets are publicly accessible, you can use the bucket permissions check in the Amazon S3 console, or you can use the AWS

learning system tackles speech and object recognition, all at once: Model learns to pick out objects within an image, using spok

Unlike current speech-recognition technologies, the model doesn't require manual transcriptions and annotations of the examples it's trained on. Instead,

Copy Data From S3 to HDFS in EMR

Troubleshooting To troubleshoot problems with S3DistCp, check the step and task logs. Step logs:

Securing Amazon EKS Using Lambda and Falco

Intrusion and abnormality detection are important tools for stronger run-time security in applications deployed in containers on Amazon EKS cluste

Start and Stop Instances at Scheduled Intervals Using Lambda and CloudWatch

CloudWatch Events allows you to create an event that is triggered at a specified time or interval in response to events that take place in your

AWS Config Update – New Managed Rules to Secure S3 Buckets

AWS Config captures the state of your AWS resources and the relationships between them. Among other features, it allows you to select a resource a

Delete S3 Objects and Buckets

Amazon Web Services is Hiring. Amazon Web Services (AWS) is a dynamic, growing business unit within Amazon.com. We are currently hiring So

Maven install [WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources

all div pro 警告 enc resource encoding sin 配置 一、背景   maven項目install過程中,出現:[WARNING] Using platform encoding (UTF-8 actually) to copy filter

MAVEN Error: Using platform encoding (GBK actually) to copy filtered resources.....

XML tracking pom.xml文件 pos bsp cli -a ati Coding 環境:Maven3.2.5+MyEclipse 2015CI 現象:在Maven編譯過程中出現錯誤信息:Using platform encoding (GBK act

[TypeScript] Shallow copy object by using spread opreator

cnblogs not all som htm div target oid html For example we have an object: const todo = { text: "Water the flowers", completed:

Macbook pro Version 14.0 cannot copy and paste between different applicatons after updated system

click one ebs book bubuko folder cbo AR ann Refer to : https://discussions.apple.com/thread/7679531 To fix a stuck clipboard (pasteboa

maven工程中警告[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!

文件 prop 源文件 使用 end 默認 .so utf-8 source [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platfor

How To Train an Object Detection Classifier for Multiple Objects Using TensorFlow (GPU) on Windows10

本文主要是記錄和簡義這個github專案的練習 裝置windows10 tensorflow1.10.0 原文github:點這裡 偶然發現的和我類似的文章還沒看 點這裡 首先我們知道,tensorflow官方是有一個物體檢測的API介面的。而我們今天要練習的專案就

Image resize on-the-fly with Lambda and S3

A crash course on Serverless with AWS — Image resize on-the-fly with Lambda and S3Handling large images has always been a pain in my side since I started w

Serverless Backend using AWS Lambda: Hands

Storing Data in DynamoDBBefore we can start storing data in our DynamoDB, we need to set some permissions for the Lambda function to have write access.Insi

Ask HN: Are you using AWS Lambda in production?

I use API Gateway to provide an API endpoint powered by Lambda (and deployed via Serverless). It took a few hours to understand the relationships between G