https://pulumi.com logo
#general
Title
# general
q

quaint-electrician-41503

10/10/2021, 2:12 AM
been at that place for at least 5 minutes for what should be a simple program
Maybe I have written a bad program?
Copy code
import * 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}`);
     });
 }
I will admit I'm fooling around with things I'm not entirely familiar with. I am trying to write a lambda function that executes some system / shell commands. I could be using IE s3api, etc but just trying this out to get started quickly. The commands work from a bash script on my local environment.
Thinking about it further perhaps exec is trying to execute as part of the pulumi preview and not being "packaged" as part of a lambda function?
I was using https://www.pulumi.com/blog/scheduling-serverless/ as an example to get started
ignorance exposed ¯\_(ツ)_/¯