Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the generated IAM role size by not creating separate policy statements for SQS and KMS resources #832

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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