title: Serverless framework, yaml and AWS lambda/DynamoDB concepts
body: <p>I recently explored serverless and I would like to create a &quot;kind of simple&quot; backend for my app. It should like <a href="https://github.com/hidjou/classsed-lambda-dynamodb-api" rel="nofollow noreferrer">CRUD</a> connected to <a href="https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/dynamodb-example-document-client.html" rel="nofollow noreferrer">DynamoDB</a> like it is nicely shown <a href="https://amazonaws-china.com/blogs/security/how-to-create-an-aws-iam-policy-to-grant-aws-lambda-access-to-an-amazon-dynamodb-table/" rel="nofollow noreferrer">here</a>. And then later converted into logging users with Cognito. <a href="https://serverless-stack.com/chapters/handle-cors-in-serverless-apis.html" rel="nofollow noreferrer">Link1</a> and <a href="https://www.youtube.com/watch?v=kjXtid259hU" rel="nofollow noreferrer">link2</a> (</p>
  <p>During my implementation I have got into a few issue and would like to ask you for help because I don't like using something I only copied and don't exactly know how it is working:</p>
  <ol>
  <li><p><strong>Using callbacks vs returns in lambda functions</strong>
  Please can you describe the difference between these two?
  I have found some resources on this, however, they won't clear it for me. On <a href="https://docs.aws.amazon.com/lambda/latest/dg/nodejs-handler.html" rel="nofollow noreferrer">Amazon Docs</a> and <a href="https://stackoverflow.com/questions/54626183/whats-the-right-way-to-return-from-an-aws-lambda-function-in-node-js">here Stack overflow</a>.</p>
  </li>
  <li><p>Why I don't need to set <strong>CORS (headers)</strong> when initializing lambdas with serverless as opposed to lambda functions created in the amazon console (like <a href="https://codeburst.io/react-js-api-calls-to-aws-lambda-api-gateway-and-dealing-with-cors-89fb897eb04d" rel="nofollow noreferrer">here</a>)?</p>
  </li>
  <li><p>In serverless frameworks what is the difference between <code>functions.events.http</code> and <code>functions.events.httpapi</code>?</p>
  </li>
  <li><p><strong>Serverless.yml</strong>
  Is there any guide to YAML? I understand that Amazon writing user guides and templates like <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-iam-role.html#cfn-iam-role-managepolicyarns" rel="nofollow noreferrer">AWS::IAM::Role</a> or for <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-dynamodb-table.html" rel="nofollow noreferrer">Dynamo Tables</a> and all others. And also that resources make a cloudformation but what is the purpose for example for Lambda functions listing there when I create/code them? To reference them? Add them privileges?</p>
  </li>
  </ol>
  <p>Also how the referencing works there? Do I only specify resources that should be created or can I also reference already existing ones via ARN? If so how?</p>
  <p>Do the policies are only set globally like <a href="https://www.serverless.com/framework/docs/providers/aws/guide/iam/" rel="nofollow noreferrer">documentation showing</a> or the only other option is to use plugin <code>serverless-iam-roles-per-function</code>? The same question could be applied to roles and policies in resources.</p>
  <p>I am just overwhelmed with the documentation and all the different guides and sometimes can't find the right answers. I appreciate any answers to any of my questions! I like serverless functions and see huge potential in it and therefore want to get more knowledge about it and start using it more :)</p>
  <p>Cheers and thanks in advance
  Lukas!</p>