Some weeks ago someone proposed to rename cloudwat...
# sst
g
Some weeks ago someone proposed to rename cloudwatch log stream. I can’t find that topic, I remember @Frank opened a pull request. Is this issue in progress? Personally I found very difficult to find the properly log stream with these default names (in attachment). I would like to have an option which rename that default value, something like this:
new Api(this, "Api", {
routes: {
"GET /notes": {
function: {
srcPath: "src/",
handler: "list.main",
environment: { tableName: table.tableName },
permissions: [table],
logGroup: 'Notes-API-dev-readNote'
},
},
},
});
f
Hey @gio, yeah the default name is unreadable. Currently you can override the function names, and that should make the log group names more readable.
g
thanks Frank sorry for this duplicated issue but I didn’t found that pull request
f
Copy code
new sst.Function(this, "MyFunction", {
  handler: "src/lambda.main",
  functionName: app.logicalPrefixedName("my-function"),
});
It is highly requested… I’m going to put in a fix this week
g
do you have an example with Api Constructor?
f
Copy code
new Api(this, "Api", {
  routes: {
    "GET /notes": {
      function: {
        handler: "list.main",
        functionName: app.logicalPrefixedName("list-notes"),
      },
    },
  },
});
g
perfect
f
It’s pretty cumbersome to override the function name for each route currently as u can see
I’m planning to put in a fix for it later this week.
g
what do you think about some syntax sugar like this?
Copy code
routes: {
    'POST   /' : ['createReservation', 'src/reservations-api/reservations-api.createReservation']
just to preserve one line definition
f
Yeah, I like the 1 line definition.
I’m also thinking to have a way to assign names using the API route or the file name. Maybe? ie. ‘dev-POST-/’ or ‘dev-reservations-api-createReservation’ for this route
Copy code
'POST   /' : 'src/reservations-api/reservations-api.createReservation'
and maybe fall back to the 1 liner if they want to set it explicitly
g
It could be a nice way, I wouldn’t like to specify http method, I think it’s better to abstract function from the protocol (could be triggered in other way)
I would like to have some like that: /aws/lambda/dev/reservations-api/createReservation
so it is nice your second solution “dev-reservations-api-createReservation” I would just replace only that two “-” for “/” to be more coherent with log stream naming
f
/aws/lambda/dev/reservations-api/createReservation
Unfortunately this won’t work as the CloudWatch log group are automatically created by Lambda, and the log group name has to be
/aws/lambda/$FUNCTION_NAME
I see where you are coming from
g
what do you mean?
ok anyway it will be a nice solution what you propose “dev-reservations-api-createReservation”
f
Yeah,
/
isn’t allowed in function names