Skip to content

Conversation

peter-kasa
Copy link

@peter-kasa peter-kasa commented Feb 29, 2024

We ran into the issue of having a too large IAM role generated when using multiple snsSqs events in one serverless.yml. (An other PR also related to this issue: #715)

I noticed that the generated IAM role's size can be reduced by merging multiple policy statements into one. The scope of this PR is to do this resource merge. See the before/after example on what to expect.

Example

Before

{
    "Version": "2012-10-17",
    "Statement": [
        ...
        {
            "Action": [
                "sqs:DeleteMessage",
                "sqs:GetQueueAttributes",
                "sqs:ReceiveMessage"
            ],
            "Resource": [
                "arn:aws:sqs:us-west-2:123456789000:test-dev-testQueue",
                "arn:aws:sqs:us-west-2:123456789000:test-dev-testDeadLetterQueue"
            ],
            "Effect": "Allow"
        },
        {
            "Action": [
                "sqs:DeleteMessage",
                "sqs:GetQueueAttributes",
                "sqs:ReceiveMessage"
            ],
            "Resource": [
                "arn:aws:sqs:us-west-2:123456789000:test-dev-test2Queue",
                "arn:aws:sqs:us-west-2:123456789000:test-dev-test2DeadLetterQueue"
            ],
            "Effect": "Allow"
        }
        ...
    ]
}

After

{
    "Version": "2012-10-17",
    "Statement": [
        ...
        {
            "Action": [
                "sqs:DeleteMessage",
                "sqs:GetQueueAttributes",
                "sqs:ReceiveMessage"
            ],
            "Resource": [
                "arn:aws:sqs:us-west-2:123456789000:test-dev-testQueue",
                "arn:aws:sqs:us-west-2:123456789000:test-dev-testDeadLetterQueue",
                "arn:aws:sqs:us-west-2:123456789000:test-dev-test2Queue",
                "arn:aws:sqs:us-west-2:123456789000:test-dev-test2DeadLetterQueue"
            ],
            "Effect": "Allow"
        }
        ...
    ]
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant