Using Amplify and SAM together?
Asked Answered
S

1

20

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

Sola answered 18/7, 2020 at 0:55 Comment(0)
M
26

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

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
Marler answered 18/7, 2020 at 10:40 Comment(2)
Petey, thanks for ur detailed answer. another question on this: if I made lets say function using SAM and later added amplify (same app) how can i connect this function to the app so I could see it in admin ui under functions?Feather
@Feather the lambda function would be standalone from your webapp app (vue/react/etc) since it is a separate yaml resource. To connect, you would add amplify to the webapp then (dont forget to import your custom aws-exports.js). See the here and hereMarler

© 2022 - 2024 — McMap. All rights reserved.