Closed hisham closed 5 years ago
I think the answer is yes, but "refactoring" of nested stacks is more than just moving text from one file to another, or renaming a file, it needs to be a multi-step process of deleting a nested stack and its resource then adding the resources back under a new nested stack name.
I have multiple files in the stacks/
folder, everything is working, but I've never tried to rename a template. @hisham is right about refactoring nested stacks.
It took me a while to figure out, because I was trying to "nest stacks" inside of CustomResources.json. But it turns out the CLI will package up any valid JSON stacks in your /stacks folder. It helped me to look under my /amplify/#current-cloud-backend/api/{appname}/build/stacks
folder and the ../cloudformation-template.json
file to observe how the CLI is packaging things up before it pushes to AWS.
@hisham You're right and it's a multi-step process (first to delete the existing resolver and then to create the same one in another stack). We're looking into this from the service side and seeing if we can optimize for this situation.
Multiple stacks are supported, which is nice, but to solve issues with CloudFormation templates, typically nesting is required. For example, I generated a GraphQL stack with amplify api add-graphql-datasource
and the file generated has 247 resources and is more than 480600 bytes.
In the past, I would have separated this by concerns. The existing file would still create the data source and pass it by parameters to child stacks that each manage a table or group of related tables/objects in the database.
When I implemented this, the passed parameters were completely ignored and the stack failed to build correctly.
+1 on this, the whole point of having multiple stacks is to refactor resources in a way that they depend on each other. In my case, I have a need to create numerous additional appsync data sources and pipeline resolvers. My aim is to break it down into multiple nested stacks that have dependencies instead of putting everything in CustomResources.json
This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.
Looking for a help forum? We recommend joining the Amplify Community Discord server *-help
channels for those types of questions.
In the documentation, it's implied that only one file called 'CustomResources.json' should be in
stacks/
. See https://aws-amplify.github.io/docs/cli/graphql?sdk=js.I tried splitting CustomResources.json into multiple files for better separation of concerns but it seems to cause various 'resolver not found' errors when pushing (see https://github.com/aws-amplify/amplify-cli/issues/1189 for an example).
Are multiple files within stacks/ supported or should we stick to one file?
Which Category is your question related to? graphql api
Provide additional details e.g. code snippets
Example errors I ran into: