When creating an S3 event handler for a Lambda ```...
# general
p
When creating an S3 event handler for a Lambda
Copy code
const input = new aws.s3.Bucket('inputbucket')
input.onObjectCreated('testing',(event,context)=> {
  console.log(event)
},{keyPrefix: ".csv"},)
Is there a way to alter the IAM execution role?
h
(not part of the pulumi team but i’ve been playing with lots of lambda/api gateway) it’s been easiest for me to create the lambda execution role and policy, associate them, and then associate the role with the lambda function
p
That's a helpful workflow - where would you suggest I associate the role with the lambda in that example?
h
are you using
aws.lambda.Function
?
p
No
Can you still in-line the execution code with that constructor? I need to be able to pass in an ECS task execution as part of the function
h
yeah, you can - what constructor are you using?
p
I was just using
bucket.onObjectCreated
and passing in the function code
h
ah I see - yeah, some of the other constructors wrap
aws.lambda.Function
but if you look to the source code you’ll see you can’t pass all the args you might need through those wrappers 😕
p
Yeah
h
hopefully you can find a way to modify 😛 I assume if you can grab the arn (I’d use outputs to dump the data structure of whatever gets created and then pull the arn from that, if it exists) then you can attach a policy to that role
p
If this is the constructor to use
Copy code
const testLambda = new aws.lambda.Function("test_lambda", {
    environment: {
        variables: {
            foo: "bar",
        },
    },
    code: new pulumi.asset.FileArchive("lambda_function_payload.zip"),
    name: "lambda_function_name",
    handler: "exports.test",
    role: iamForLambda.arn,
    runtime: "nodejs8.10",
});
any idea how to write the function in-line?
h
I imagine you can backtick it — so :
Copy code
const testLambda = new aws.lambda.Function("test_lambda", {
    environment: {
        variables: {
            foo: "bar",
        },
    },
    code: ` your code goes here \ 
some more code`,
    name: "lambda_function_name",
    handler: "exports.test",
    role: iamForLambda.arn,
    runtime: "nodejs8.10",
});
p
hmmm - I'll give that a try!!
Thanks