Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Amplify and SAM together?

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

like image 805
Caleb Avatar asked Jul 18 '20 00:07

Caleb


People also ask

When would you use AWS amplify?

AWS Amplify can be used for auto-tracking to track user sessions and analytics webpage metrics. You can collect data streams and analyze data in real-time to build robust marketing strategies that increase the adoption, commitment and retention rate of customers.

Does amplify use CloudFormation?

The Amplify CLI provides the ability to add custom AWS resources with AWS CloudFormation. Running the amplify add custom command in your Amplify project provides CloudFormation starter templates along with mechanisms to reference other Amplify-generated resources.

Does AWS SAM support AppSync?

SAM does not provide any syntax for AppSync but the good thing about SAM is that you can still use it to build and deploy a template that contains CloudFormation. This means that while you don't get the shorthand that SAM provides for other services you can continue to use the same SAM setup and commands.

Is AWS amplify serverless?

What Is AWS Amplify? Amplify is a serverless framework for frontend developers; it offers frontend libraries for JavaScript, iOS, Android, and React Native and a CLI that helps to create serverless backend services for different use cases.


Video Answer


1 Answers

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
like image 68
petey Avatar answered Oct 12 '22 15:10

petey