sid88in / serverless-appsync-plugin

serverless plugin for appsync
MIT License
951 stars 188 forks source link

Issue with split stack plugin for Lambda functions. #266

Open hmshoaib opened 5 years ago

hmshoaib commented 5 years ago

Hi, I have gone through the closed and open issues regarding the limit issues which is 60 per stack. I have modified my stacks-map.js The problem is I am using all the data sources as lambda and the resources count for GraphQLDsLambda gets to 182. I am assuming its because of IAM roles and etc is there any fix for this? this is the stack summary

Serverless: [serverless-plugin-split-stacks]:    Resources per stack:
Serverless: [serverless-plugin-split-stacks]:    - (root): 193
Serverless: [serverless-plugin-split-stacks]:    - GraphQlFunctionConfigurationNestedStack: 39
Serverless: [serverless-plugin-split-stacks]:    - GraphQlResolverMutationNestedStack: 58
Serverless: [serverless-plugin-split-stacks]:    - GraphQlResolverQueryNestedStack: 28

Here is mystifying stacks-map.js


ServerlessPluginSplitStacks.resolveMigration = function(
    resource,
    logicalId,
    serverless
) {
    if (logicalId.startsWith('GraphQlResolverMutation'))
        return { destination: 'GraphQlResolverMutation', allowSuffix: true  };
    if (logicalId.startsWith('GraphQlResolverQuery'))
        return { destination: 'GraphQlResolverQuery', allowSuffix: true  };
    if (logicalId.startsWith('GraphQlFunctionConfiguration'))
        return { destination: 'GraphQlFunctionConfiguration', allowSuffix: true  };

    // Fallback to default:
    return this.stacksMap[resource.Type];
};

if i add below code it gives me error

// if (logicalId.startsWith('GraphQlDsLambda'))
    //     return { destination: 'GraphQlDsLambda', allowSuffix: true  };
    // if (logicalId.startsWith('GraphQlDsLambdaD'))
    //     return { destination: 'GraphQlDsLambdaD', allowSuffix: true  };
    // if (logicalId.startsWith('GraphQlDsLambdaU'))
    //     return { destination: 'GraphQlDsLambdaU', allowSuffix: true  };
    // if (logicalId.startsWith('GraphQlDsLambdaG'))
    //     return { destination: 'GraphQlDsLambdaG', allowSuffix: true  };

Here is the error that i get

 Serverless Error ---------------------------------------

  An error occurred: GraphQlDsLambdaUNestedStack - Embedded stack arn:aws:cloudformation:ap-southeast-1:651110316028:stack/sc-manager-appsync-beta-dev-GraphQlDsLambdaUNestedStack-5YBYY3ZEAHS8/3581d490-b1ec-11e9-913d-0a9b79aa12c6 was not successfully created: The following resource(s) failed to create: [GraphQlDsLambdaUpdateFBLSRole, GraphQlDsLambdaUpdateDefaultFieldRole, GraphQlDsLambdaUpdateLeadRole, GraphQlDsLambdaUpdateWonDataRole, GraphQlDsLambdaUpdateFollowUpRole, GraphQlDsLambdaUpdateUserRole, GraphQlDsLambdaUpdateLeadAndActionTemplateRole, GraphQlDsLambdaUpdateTagRole, GraphQlDsLambdaUpdateWonScreenTemplateRole, GraphQlDsLambdaUpdateCandyPixelRole, GraphQlDsLambdaUpdateGroupRole, GraphQlDsLambdaUnArchiveFBListRole, GraphQlDsLambdaUpdateProjectRole, GraphQlDsLambdaUpdateProjectGroupRole, GraphQlDsLambdaUpdateSmartAlertRole]. .

I have to add more mutations, queries and subscriptions so it will break. Please if any one have solved this already.

hmshoaib commented 5 years ago

I have figured it out it only breaks when we try to split GraphQlDsLambda is there a bug or any limitation?

morficus commented 4 years ago

This is an issue has nothing to do with the appsync plugin. It has to do with https://github.com/dougmoscrop/serverless-plugin-split-stacks and how it tries to create nested stacks only based on resource count (not looking at parameters nor outputs).