same domain name for lambda function api endpoints(backend) and for frontend - amazon-s3

How to use same domain name for front end and for lambda function endpoints
for Serverless framework ?
I am using reactjs for frontend design and for frontend hosting I am using s3 and Aws Dynamodb for lambda functions.

We do the same in our systems, AWS solved it long time back.
It is the cloud service called CloudFront, which lets you connect multiple origins including external origins that are outside of AWS cloud.
Created a simple architecture diagram to help you view the same.
Hope it helps.

Related

Can AWS Lambda act as an API?

Trying to figure out the differences. Can AWS Lambda act as an API or vice versa? Would I still need to setup an API if I wanted to use Lambda functions or can I use Lambda functions right from the get go?
AWS Lambda can be used to serve an API. You could use API Gateway for setting up the API, and the serving can be done via a Lambda. It is a nice pattern.
Ref: https://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-with-lambda-integration.html
And to your main question, I don't think you can directly configure an API in AWS Lambda service.
Alternatively, you can do it by setting a Function URL to your lambda.
It will require changes in how you receive input and send the output for the lambda and also has some limitations related to authentication. Still, it would be a more self-contained approach than the API Gateway integration if you need to expose your API publicly.
Lambda functions can now be accessed directly with a Function Url. They have minimal functionality when compared to Amazon API Gateway.
However, since the integration event is effective the same. It is very easy to go from Function Urls to API Gateway or ALB in the future if you require greater functionality.

Invoke AWS Step Function from AWS Lambda Proxy (AWS API Gateway) .NET SAM Template

I have a AWS API Gateway, deployed using SAM template. The API request comes to the Proxy Lambda Function. From there I need to call a AWS Step Function which invokes multiple Lambda Functions. I have multiple Solutions. Following Microservices pattern. Need to call one microservice from another. Each Microservice is in a seperate solution and the startup project is a ClassLibrary(.NET Core 2.1). Using SAM template and deploying it via AWS Toolkit for Visual Studio. Not using Fargate Containers and WebApi projects. Need to coordinate between API Gateways.
In your question you say: "The API request comes to the Proxy Lambda Function. From there I need to call a AWS Step Function". It is simple, here an example of api gateway that use a lambda like authorizer and in the method execution I call a step function. In your step function later you manage your flow and your and the lambdas that you need execute

General vue.js. deployment with lambda

I have a question about deployment strategy with vue.js + express.js + lambda.
I can deploy express.js to lambda with serverless as backend. and then where can I deploy vue.js as frontend? I saw some kind of article. They deployed S3 and domain forward to S3 bucket. Is this common way?
I mean If I make html file in express.js and deploy to lambda. that's just one shot deployment. Can I deploy like this with vue.js?
thanks for answering in advance.
You can deploy your frontend (be it in Vue, React, Angular) via S3 by Hosting a Static Website using Amazon S3
Your frontend can then invoke API Gateway which will trigger your Lambda functions (which happens to be the backend of your application)

How to connect specific AWS API Gateway stage to specific AWS lambda alias

I have AWS Lambda function and I invoke it calling AWS API Gateway via REST API. For Lambda function I configured two aliases with versioning - QA and Prod.
API Gateway is configured with Lambda Proxy Integration Request. I know about AWS API Gateway stages feature and I create two stages (QA and Prod respectively), but I don't see any settings for Lambda aliases in stage configuration.
How can I specify QA Lambda alias for QA stage and Prod Lambda alias for Prod API stage?
On the integration request in API Gateway you can add the alias name to the end of the ARN to make sure your endpoint points to the correct alias. Something like this
arn:aws:lambda:region:account-id:function:function-name:alias-name
You can't tell an API Gateway stage to always use a specific Lambda alias and have multiple Gateway stages that all point towards different aliases.
Every time you need to deploy to a Gateway stage, you'll have to make sure your undeployed API Gateway endpoints are configured to point to the correct Lambda alias before deploying to the stage that matches that environment.
This get tricky to maintain, so I would recommend treating your two different stages as completely different resources using the serverless framework or another framework.
Useful resources:
https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-lambda
https://serverless.com/framework/docs/providers/aws/guide/intro/
On your integration request, you will see the Lambda Function - click on it to edit and add :QA or :Prod after it and hit the checkmark, I think that will do it.
example: myLambda:Prod

API/CLI to get all the services(ec2, s3, rds..etc) my account is using?

I tried to look around but couldn't find enough details on how to programatically get list of all services that my aws account is currently using.
Something like: EC2, S3, DynamoDB..etc
Is there a Java API or AWS CLI solution that I can use?
AFAIK there is no AWS service that exposes that information programatically. However if you're after this information for cost purposes there is the AWS Budgets service that allows you to setup budgets for your AWS resources - it has a public API which is accessible from Java and the CLI.