#✅ - Custom Lambda Auth Gen2 - Revoking Access to All Update Mutations

4 messages · Page 1 of 1 (latest)

sour jasper
#

Hello,

Wondering how I can set custom rules in my lambda auth where I deny access to all update mutations unless some condition is met. Or alternatively how could I remove all update mutations from my schema from typscirpt API.

wide swan
#

If you don't want to allow update mutations, or add custom logic to allow update, you can do it like this:

// amplify/data/resource.ts
...
  ExampleModelName: a
    .model({
      content: a.string().required(),
    })
    .authorization([
      a.allow.public("iam").to(["read", "create", "delete"]) // allows everything except update
      a.allow.custom().to(["update"]) // invokes custom lambda logic to determine whether update is allowed
     ]),
sour jasper
#

@wide swan This is awesome! Exactly what I wanted. Thank you. I didn't realize you could do two types of authorization! 🎉

sterile vesselBOT
#

✅ - Custom Lambda Auth Gen2 - Revoking Access to All Update Mutations