quaint-electrician-41503
10/10/2021, 2:12 AMimport * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";
import { ObjectIdentifier } from "aws-sdk/clients/s3";
import { exec } from "child_process";
// Create an AWS resource (S3 Bucket)
const dataBucket = new aws.s3.Bucket("xxxx-demo-bucket");
// Export the name of the bucket
export const bucketName = dataBucket.id;
// A handler function
const putObjects: aws.cloudwatch.EventRuleEventHandler = (
event: aws.cloudwatch.EventRuleEvent
) => {
exec("wget -r <https://some-path-to-copy> -l 1 -P /tmp", (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
exec(`aws s3 sync /tmp/result-path ${bucketName.get}`, (error, stdout, stderr) => {
if (error) {
console.log(`error: ${error.message}`);
return;
}
if (stderr) {
console.log(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});
}