Created
October 10, 2022 06:25
-
-
Save dhavaln/ea274ea5b314127c8a3d64f4b331ab80 to your computer and use it in GitHub Desktop.
Serverless framework AppSync service with custom split stacks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
custom: | |
splitStacks: | |
nestedStackCount: 50 | |
perFunction: false | |
perType: false | |
perGroupFunction: false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (resource, logicalId) => { | |
console.log(resource.Type, logicalId); | |
// Keep the deployment bucket with default setup | |
if( logicalId.startsWith('ServerlessDeploymentBucket') || resource.Type == 'AWS::Lambda::Permission'){ | |
return | |
} | |
if( (resource.Type == 'AWS::S3::Bucket' || resource.Type == 'AWS::S3::BucketPolicy') ){ | |
return { destination: 'S3GroupStack', allowSuffix: true, force: true }; | |
} | |
if ( resource.Type == "AWS::Logs::LogGroup" && !logicalId.endsWith('GraphQlApiLogGroup') ) { | |
return { destination: 'LogGroupsStack', allowSuffix: true, force: true }; | |
} | |
// Appsync specific resources | |
if( resource.Type == 'AWS::AppSync::GraphQLSchema' || | |
resource.Type == 'AWS::AppSync::FunctionConfiguration' || | |
resource.Type == 'AWS::AppSync::DataSource' || | |
resource.Type == 'AWS::AppSync::Resolver' ){ | |
return { destination: 'AppSync', allowSuffix: true, force: true }; | |
} | |
// Falls back to default | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Likely errors:
Circular dependencies
- This you can easily understand and resolve by going through your resources and keeping the related resources in the same stack.Resource already exists in another stack
- This will come if you are trying to deploy the changes on the existing stage that is not using split stack or has a different stack structure. For me, the closest solution was to deploy a new stage.