I’m not sure how to interpret this top-level IAM r...
# help
c
I’m not sure how to interpret this top-level IAM role statement from Serverless Framework ↓ How might something like this be reproduced in SST or CDK for a service? Thanks in advance for any help.
Copy code
// serverless.yml

provider:
  name: aws
  iamRoleStatements:
    - Effect: Allow
      Action: cloudwatch:PutMetricData
      Resource: '*'
c
Thanks Frank, I’ll dig into that
One thing that threw me off was that the permission didn’t seem to be assigned to any resource - in Serverless Framework is a top-level statement like this implicitly applied to the function or all resources somehow?
o
SLS creates a role for that stack, and adds permissions to that role. Then all the functions in the stack run as that role. SLS also implicitly adds other permissions to that role for things like logging and tracing
c
Thanks @Omi Chowdhury
f
Yeah, if you want to assign a permission to all functions in the app you can do so inside app index:
Copy code
app.setDefaultFunctionProps({
  permissions: [
    new iam.PolicyStatement({
      actions: ["cloudwatch:PutMetricData"],
      effect: iam.Effect.ALLOW,
      resources: ["*"],
    }),
  ],
});