https://serverless-stack.com/ logo
#random
Title
# random
a

Ashishkumar Pandey

10/04/2021, 12:51 AM
I was going through the design principles docs. It has this snippet of code which contains a couple of random
-
(hyphens), what are these? I’ve never seen these before, is this something new in javascript? Code snippet for reference :-
Copy code
cron.attachPermissions([
  new cdk.aws() -
    iam.PolicyStatement({
      actions: ["execute-api:Invoke"],
      effect: cdk.aws - iam.Effect.ALLOW,
      resources: [
        `arn:aws:execute-api:${region}:${account}:${api.httpApiId}/*`,
      ],
    }),
]);
a

Adrián Mouly

10/04/2021, 12:52 AM
Haahaha weird.
Might wrong formatting.
a

Ashishkumar Pandey

10/04/2021, 12:53 AM
oh lol! That’d be weird. 😂
f

Frank

10/04/2021, 3:24 AM
Oh no.. it’s definitely bad formatting, should be:
Copy code
import { PolicyStatement, Effect } from "@aws-cdk/aws-iam";

cron.attachPermissions([
  new PolicyStatement({
    actions: ["execute-api:Invoke"],
    effect: Effect.ALLOW,
    resources: [
      `arn:aws:execute-api:${region}:${account}:${api.httpApiId}/*`,
    ],
  }),
]);
Updated the doc
a

Ashishkumar Pandey

10/04/2021, 3:54 AM
okay, good to know and thank you. I thought how did I miss a new js operator. 😅