fix(dev): ensures that dev mode supports the serverless-iam-role-per-function plugin (#12633)

This commit is contained in:
Eslam λ Hefnawy 2024-06-24 12:00:30 -07:00 committed by GitHub
parent 6ab69067bf
commit 4f2dc57eb8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -589,6 +589,22 @@ class AwsDev {
functionConfig.environment.SLS_SERVICE = serviceName
functionConfig.environment.SLS_STAGE = stageName
functionConfig.environment.SLS_FUNCTION = functionName
// Make sure dev mode also supports the "serverless-iam-roles-per-function" plugin:
// https://github.com/functionalone/serverless-iam-roles-per-function
// Issue Ref: https://github.com/serverless/serverless/issues/12619
if (
functionConfig.iamRoleStatements &&
Array.isArray(functionConfig.iamRoleStatements)
) {
const functionIamRoleStatements = functionConfig.iamRoleStatements
functionIamRoleStatements.push({
Effect: 'Allow',
Action: ['iot:*'],
Resource: '*',
})
}
})
// Disable observability if it's enabled