https://pulumi.com logo
Title
e

elegant-pager-5412

04/26/2021, 9:03 AM
Has anyone been successful in allowing lambdas (
CallbackFunction
) to send logs to CloudWatch? Can’t get it working 🤔
s

shy-house-53993

04/26/2021, 12:10 PM
@elegant-pager-5412, you need to make sure that your Lambda has the
AWSLambdaBasicExecutionRole
specified.
Or an equivalent custom policy of course.
e

elegant-pager-5412

04/26/2021, 12:12 PM
@shy-house-53993 Hey Simon! How do I ensure that? The way I got around it at the moment is by using the
aws.iam.ManagedPolicy.CloudWatchLogsFullAccess
policy, which isn’t ideal. I would love to be able to great a log group with specific retention days
Also would love to give each lambda specific queue access and not
AmaazonSQSFullAccess
s

shy-house-53993

04/26/2021, 12:12 PM
One moment. Grabbing the code I have.
e

elegant-pager-5412

04/26/2021, 12:12 PM
Thing is that I can’t pass
Output
objects to the
policies
property on the
CallbackFunction
s

shy-house-53993

04/26/2021, 12:13 PM
aws.cloudwatch.onSchedule(
  'rate(1 minute)',
  new aws.lambda.CallbackFunction('get-team-leads', {
    policies: [aws.iam.ManagedPolicy.AWSLambdaBasicExecutionRole, aws.iam.ManagedPolicy.AWSLambdaRole],
    callback: async (e) => {
      console.log('Running...');
Etc...
e

elegant-pager-5412

04/26/2021, 12:14 PM
I see
but this isn’t very specific, isn’t it?
s

shy-house-53993

04/26/2021, 12:14 PM
That's not what you asked for...
e

elegant-pager-5412

04/26/2021, 12:14 PM
I mean, how can you send all logs to a specific log group with retention days?
Yea you’re right, sorry
s

shy-house-53993

04/26/2021, 12:14 PM
Totally different question 🙂
e

elegant-pager-5412

04/26/2021, 12:15 PM
Yea you’re right 😕
got greedy haha
s

shy-house-53993

04/26/2021, 12:15 PM
Sorry, don't have any insight on your more specific problem. Only been playing with Pulumi a week myself.
e

elegant-pager-5412

04/26/2021, 12:15 PM
Yea
Playing for Pulumi for the past few days
It’s nice, but missing more concrete examples, in my opinion
r

red-match-15116

04/26/2021, 7:25 PM
@elegant-pager-5412 when you say “missing more concrete examples”, are you referring to things outside the ones available here: https://github.com/pulumi/examples?
e

elegant-pager-5412

04/27/2021, 4:33 AM
@red-match-15116 yea. While there are various examples for all supported languages, the examples are simple and do not reflect real life scenarios (in my opinion). I would love it if the examples would also nourish a style guide and best practices as-well. I don’t think anyone here would go ahead and create an
index.ts
file with 600 lines of code as a production code. They would split the code and will also split the logic from the infrastructure, so I don’t expect to see actual handler code along with the infrastructure definition
r

red-match-15116

04/27/2021, 4:38 AM
They would split the code and will also split the logic from the infrastructure, so I don’t expect to see actual handler code along with the infrastructure definition
It seems like you are looking for a very specific real world scenario that matches your exact use case. It is expected that users will decide what works best for them. The purpose of the examples is to demonstrate how Pulumi would fit into those scenarios, but we have built a purposefully generalized tool and providing examples for all possible use cases would be frankly impossible 😄
e

elegant-pager-5412

04/27/2021, 5:30 AM
@red-match-15116 I’m not really looking for a very specific real world scenario. I’m looking for “best practices”, but sure, we just eventually do whatever we feel comfortable with. Giving examples for every possible scenario is indeed impossible 🙂