My AWS Amplify app requires some "seed" data that needs to start in the database. The mechanism by which this runs should not be accessible to users of the app. What is the most idiomatic way to load data into DynamoDB for this purpose?
I have looked into creating a lambda function for this purpose (ie amplify function add), which is well integrated into amplify. However there is no easy way to actually invoke this lambda. Amplify doesn't tell you the lambda ID for use with the aws command, and there is no amplify command that relates to invoking a lambda.
There are a lot of alternative ways to do that. One could be using CDK, CloudFormation, Terraform or other IaC tool to create initial DynamoDB tables and items.
Related
I am building a serverless application using AWS, with AWS API, AWS Lambda functions, and AWS RDS (database).
I have an existing MySQL schema (basically, a table dump), and I want to create the API automatically from this schema, ideally something that I can easily import into AWS API Gateway (like something from SwaggerHub or similar service).
Then, I want to have the operations for the database (CRUD operations that match the API) also automatically generated for NodeJs or Python, which I can then easily deploy to AWS Lambda, for example using SAM templates, or maybe just uploaded as a package somehow to AWS.
The lambda operations should be able to connect to my AWS RDS database, and perform the CRUD operations described by the API.
The idea is to determine some way to simplify this process. If the database schema changes significantly, for example, I do not want to manually edit a bunch of lambda functions to accommodate the new DB schema every time!
I'm wondering if anyone has any suggestions as to how I could make this work.
AWS Amplify and the "Applications" feature within AWS Lambda seem to have a few things in common:
Both seem to be a wrapper around several AWS resources
Both walk you through a guided setup to provision a working AWS stack
Both set up some CI/CD pipelines for you so that Git commits trigger a build and deploy
So what are the differences between these two services, and what are some scenarios where you might want to choose one over the other?
AWS Amplify is a toolchain for front-end developers to interact with AWS resources. It provides a cli program to manage resources and (JS/Android/iOS) libraries to integrate them into your front-end applications.
It doesn't 'wrap' resources, but is merely a convenience layer to manage them (it is somewhat similar to AWS SAM); Amplify generates CloudFormation templates, stores those locally, and uses aws-cli to provision them. Note that Amplify can also be used just as a front-end library to integrate resources that are already set up.
AWS Lambda Applications is an actual AWS service, or rather a feature of AWS Lambda. It groups related resources, so they can be managed and deployed as if it was a single resource.
... what are
some scenarios where you might want to choose one over the other?
Amplify is aimed at web- and mobile developers: it allows them to manage backend resources without much backend knowledge.
It is not a matter of 'using one over the other'; they can actually be used in conjunction with each other.
I'm having some confusion here and wanted to see if someone can set me straight.
I'm using Amplify for a Vue app. It calls API Gateway which calls Lambda and all of this is set up manually but I want to use the power of IaaS and do it with SAM.
Amplify CLI includes the ability to add APIs/Functions and in turn creates the CloudFormation Templates and Stack, which is nice. However this doesn't seem to create the Amplify app itself aside from creating an empty app connected to no repo and of course the CLI only stretches to so many services.
I see that it IS possible to configure an Amplify app in CloudFormation. And SAM comes with command line tools that'd be useful as well. What is the correct way to set all this up??
Can I create a SAM template for Amplify creation that works with the Stack created by Amplify to make API/Functions rather than manually building the SAM Template without auto generated assistance? Then if I add non-Amplify-supported Services later I can add them to the SAM as well.
I'm having a time trying to navigate SAM/CF/CDK/Amplify haha
I hope this helps. Lets start with your easier issues:
I'm having a time trying to navigate SAM/CF/CDK/Amplify haha
Yea.
AWS CF (Cloudformation) is aws's go at giving use a way to create(/rud) AWS resources using a templating engine. Its rather massive. And odd. Here's an example from the User Guide
Here is a JSON template to Create a simple DynamoDB table.
Here is that same template from the Designer Link next to it
Here is a pastebin version : 1QNXGTdZ
If the above brings up questions like, Why are both templates different? You are not alone. Overall, CF is massive but pretty neat as it lets you create/rud AWS resources
AWS SAM (Serverless Application Model) IMO is version of CF that is a lot simpler/easier. Here you can CRUD AWS Resources and organize them in a stack.
Note: SAM uses CF under the hood.
Amplify is a framework to make working with cognito (login) , aws js sdks, and more. It can take your vue/react app and add services such as, api, authentication, and document (dynamodb). For a node app, it stores config information in a file calls "aws-exports.js". Amplify can also help you deploy and store your codebase.
If you create any resources using the amplify cli, it uses CF under the hood. I believe all the files get stored in folder named ".amplify". IMO, its not fun as its hard to manage things later on using Amplify CLI or AWS console.
Can I create a SAM template for Amplify creation that works with the Stack created by Amplify to make API/Functions rather than manually building the SAM Template without auto generated assistance?
Yes. Just keep on using that Amplify CLI. Once that stops being fun use the AWS Console.
Then if I add non-Amplify-supported Services later I can add them to the SAM as well.
Also yes. You can create a new SAM stack any time with lambda's, userpools, etc and them connect to them with your Amplify applications new found AWS SDKs.
From my limited experience:
give AWS SAM a shot. Its simple and easier to get than CF
I never use the Amplify CLI anymore. It was neat in the start, but I've outgrown it as running the commands gives me a headache in comparsion to the SAM template defintions
I am currently looking into AWS Amplify as well as I am reading Serverless Stack. My goal is to create a simple ToDo list app. Both "Getting started" / Documentations seem to have the same goal. However, AWS Amplify guide seems to be way easier from the setup.
And that's where I am confused. As far as I understand AWS Amplify also uses DynamoDB and gets data via GraphQL. But where is the difference between these two documentations?
Serverless Stack is a resource providing guidance on how to create serverless applications with AWS. It was created by a company called Anomaly Innovations.
AWS Amplify is an open source framework maintained by AWS which helps developers integrate their applications with AWS resources.
AWS Amplify is a very confusing service and consists of many components. I would categorize as follow.
AWS Amplify Console
AWS Amplify CLI
AWS SDK&Libraries to integrate to your mobile or web
AWS Appsync Transformer
AWS Amplify Console gives you the ability to easily to setup Continous Deployment for your Amplify project. Amplify Console use together with AWS Amplify CLI for you to manage different environments.
Let's say you want to start the Todo App. You start on your local using Amplify CLI and create API Gateway/Lambda/DynamoDB stacks.
Amplify CLI lets you create the whole stack easily and push it to AWS to deploy the whole stack. Then you can create a different environment based on the same stacks, let's say you want your dev environment, and QA environment and production environment.
Amplify CLI gives you all the commands necessary for you to achieve this, then if you want to auto-deploy the change to AWS when someone push the code to your Git repository, you can use the Amplify Console to set up exactly that.
Amplify Console also integrate with AWS Domain so, you can easily point your own domain to any of the environment.
On top of these, Amplify also provides, GraphQL Transformer, which you can easily define the GraphQL schema in Amplify format and it will transform and deploy to AWS Appsync. And there is a Mobile SDK which you can sync data between AppSync and you're mobile and provides some UIs as well.
We used one of our web projects and we liked it for Continues Deployment aspect of the Amplify, but we didn't like the AppSync(GraphQL) aspect of Amplify just b/c it was not easy to implement layered resolver.
Also, keep in mind that Amplify CLI/SDK/Transformer is under one project and it's still very fragile. You can take a look at the version history from https://www.npmjs.com/package/#aws-amplify/cli and you will see few version bump just in a single month. There were many obvious bugs we encounter, even on the AWS Console.
I haven't use the Serverless yet, but as long as I know, Serverless provides No1 and No2 of Amplify with greater stability.
You can change the data source of appsync service in aws console, but I am not sure if it can work after I run command
amplify push api
And haven't found a way of changing data source with aws-amplify.
There isn't a direct way, no, as AppSync doesn't have native Postgres data sources. You could theoretically do anything with a Lambda data source, though, very much including Postgres.
An AppSync dev created a sample app that shows a way to do this, via what Amplify calls custom resolvers. You can find that repo here: https://github.com/mikeparisstuff/amplify-cli-nested-api-sample