Skip to content

How to add conditions to the IAM role statements for a specific function: #129

Description

@s1mrankaur

Here's a basic example of what I'd like to be able to do:

`service: my-service

provider:
name: aws
runtime: nodejs18.x

plugins:

  • serverless-iam-roles-per-function

functions:
myFunction:
handler: handler.myFunction
iamRoleStatements:
- Effect: Allow
Action:
- dynamodb:Query
- dynamodb:Scan
Resource: arn:aws:dynamodb:us-east-1:123456789012:table/my-table
Condition:
StringEquals:
"dynamodb:LeadingKeys": "userId"

secondFunction:
handler: handler.secondFunction
iamRoleStatements:
- Effect: Allow
Action:
- dynamoDB:UpdateItem
Resource: arn:aws:dynamodb:us-east-1:123456789012:table/my-table
Condition:
ForAllValues:StringNotLike:
"dynamodb:Attributes":[
"FreeGamesAvailable",
"BossLevelUnlocked"
]

anotherFunction:
handler: handler.anotherFunction
iamRoleStatements:
- Effect: Allow
Action:
- s3:GetObject
Resource: arn:aws:s3:::my-bucket/*
Condition:
IpAddress:
"aws:SourceIp": "203.0.113.0/24"`

If this isn't supported currently by the package, what are my options?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions