https://pulumi.com logo
#aws
Title
# aws
c

creamy-traffic-12121

11/03/2020, 2:46 PM
Copying this question from the typescript room, in case this has a more general answer: How do I get a lambda using an S3 source to update its source code when a new zip file is uploaded to the bucket? Even if I push a new zip to the S3 bucket, the lambda function won't update on 
$ pulumi up
 . The bucket in question does have versioning enabled.
w

witty-candle-66007

11/03/2020, 3:35 PM
To clarify, are you updating the code in the S3 bucket via Pulumi? Or outside of Pulumi?
c

creamy-traffic-12121

11/03/2020, 3:42 PM
In this case, it would be outside of Pulumi.
w

witty-candle-66007

11/03/2020, 5:05 PM
Is the S3 bucket under Pulumi management at all?
c

creamy-traffic-12121

11/03/2020, 6:16 PM
No, the S3 bucket is outside of the stack in this case @witty-candle-66007
w

witty-candle-66007

11/03/2020, 6:33 PM
So, that’s the root issue. Since Pulumi doesn’t know the S3 bucket changed, it doesn’t know to try and update the Lambda resource. But you should be able to use the S3 Object version as an indicator of a change to Pulumi. I think if you add a call to https://www.pulumi.com/docs/reference/pkg/aws/s3/getbucketobject/ you can obtain the S3 Object’s version ID. And then add the
s3ObjectVersion
property to your Lambda Function creation and set it to the version retrieved from the getbucketobject() call. I haven’t tested this, but I’m thinking this should cause Pulumi to update the Lambda function on pulumi up.
👍 1
👀 1
c

creamy-traffic-12121

11/03/2020, 6:44 PM
Thanks. That sounds like it would work, I'll give it try. It would be nice if Pulumi automatically checked the version ID of the object on
pulumi up
, but I'm not sure if that would produce undesirable behavior in some cases.
Didn't work in this case. The object version of the Lambda will update, but the lambda won't pull the most recent version of the code.
@witty-candle-66007 Nevermind, it did go through. Thanks again. 👍