diff --git a/lib/plugins/aws/custom-resources/resources/api-gateway-cloud-watch-role/handler.js b/lib/plugins/aws/custom-resources/resources/api-gateway-cloud-watch-role/handler.js index 58a59def90..9724717667 100644 --- a/lib/plugins/aws/custom-resources/resources/api-gateway-cloud-watch-role/handler.js +++ b/lib/plugins/aws/custom-resources/resources/api-gateway-cloud-watch-role/handler.js @@ -1,5 +1,11 @@ 'use strict'; +/** + * IMPORTANT: This file is cached, so when you test changes made to this file, + * make sure you delete the .serverless directory, and un-memoize the packaging code. + * For more info search for the "utils/ensure-artifact.js" file in the codebase. + */ + const { wait, MAX_AWS_REQUEST_TRY } = require('../utils'); const { getEnvironment, handlerWrapper } = require('../utils'); const { @@ -52,7 +58,10 @@ async function create(event, context) { return (await iam.send(new ListAttachedRolePoliciesCommand({ RoleName: roleName }))) .AttachedPolicies; } catch (error) { - if (error.code === 'NoSuchEntity') { + if ( + error.code === 'NoSuchEntity' || + error.message.includes('cannot be found') + ) { // Role doesn't exist yet, create; await iam.send( new CreateRoleCommand({