问题
Let's say you have an AWS AppSync API named API-DEV
.
It hosts the GraphQL Schema, the Resolvers, the Data sources, DynamoDB tables (ex:Dev_Articles
), DynamoDB tables configuration, and DynamoDB data. The API is consumed by approx. 50 instances of the same React app.
How would you automate the migration of newest features from API-DEV
to API-STAGING
? Note that I want to update everything except data.
Ways to go I'm thinking about:
- Keep a list of things to update, move the staging apps to maintenance mode, and manually apply the changes to staging env. Seems like a lot of work to do at every "release" and error-prone.
- Use some kind of YAML template in conjunction with
aws-cli
to store the changes in a GIT repo and automatically deploy on push. Seems like a great way to do this but couldn't find a step-by-step guide, plus, all our config is already in AWS so my guess is that we would have to recreate all using the template. - Use some kind of tool that would automate compare and update from two given API and DynamoDB. Not found this yet.
- Build my own Nodejs app that would leverage
aws-cli
to compare and update. Then have this hosted on Lamda and triggered by pushes on thestaging
ormaster
branches of the React app repo (Code Commit > Code Build > Code Deploy). That's where I'm heading for now, but there may be an existing solution out there.
Have any other idea? Let me know!
回答1:
Use CloudFormation to model your API. You can then maintain your API configuration, resolvers, and data sources (without data) as code and run that template in the various stages.
To simplify creation of the CloudFormation, you can use the AWS Amplify CLI to define the GraphQL schema, which will autogenerate the resolvers for you.
回答2:
Check out this: https://github.com/sid88in/serverless-appsync-plugin
Serverless-appsync-plugin makes your life easier. It should have an easier configuration than setting up your own Cloudformation.
来源:https://stackoverflow.com/questions/52278353/how-to-keep-aws-appsync-apis-in-sync-from-dev-to-staging-to-production