serverless-framework | Example project using the Serverless Framework | Serverless library
kandi X-RAY | Serverless Framework Summary
kandi X-RAY | Serverless Framework Summary
Example project using the Serverless Framework, JavaScript, AWS Lambda, AWS API Gateway and GitLab Pages.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of serverless-framework
Serverless Framework Key Features
Serverless Framework Examples and Code Snippets
Community Discussions
Trending Discussions on Serverless Framework
QUESTION
I am trying to create a simple Azure function app that receives image binary from HTTP request and write to blob storage using C# and Serverless Framework.
The C# function code looks is as follow:
...ANSWER
Answered 2021-Jun-12 at 12:33If I run your code locally, following exception is displayed:
Microsoft.Azure.WebJobs.Host: Error indexing method 'upload'. Microsoft.Azure.WebJobs.Host: Unable to resolve binding parameter 'name'. Binding expressions must map to either a value provided by the trigger or a property of the value the trigger is bound to, or must be a system binding expression (e.g. sys.randguid, sys.utcnow, etc.).
As mentioned in the error message, you have to specify the variable in the trigger. I guess, binding to the query-parameter is still not possible in Azure Functions.
So you have to specify it in the route:
QUESTION
I have been pouring way too many hours into getting this to work, and I see that similar questions are posted here on SO but I have yet to find a solution that'll solve my problem.
I have created a REST API using the Serverless Framework. I now want to create an endpoint to which a user can send a POST request with an image as in the body as a form-data.
The endpoint uses a middleware uploader.single('param')
and then passes the result to a function uploadImage
.
The middleware looks as following:
The image is stored by library "multer":
I read that you might need to add binaryMediaTypes to the apiGateway provider in serverless.ts, so I did as following:
Can anyone help me out with this?
...ANSWER
Answered 2021-Jun-03 at 14:25I suspect the bug is an edge case or encoding issue with your multipart handler, or perhaps a bug with the serverless-offline
plugin. But that's somewhat irrelevant.
The reason it's hard to find a solutions to this problem is that your chosen path is not compatible with the serverless development philosophy. Lambda doesn't have any filesystem space within its execution environment (well, a few MB. But once the lambda execution is finished, that space is freed). You'd need to store these images somewhere else, someplace durable like S3.
It's best practice instead to create an API endpoint which returns an presigned URL for an S3 bucket.
Then your users could upload the image to that URL.
Here's an excellent article which lays out this exact use case: https://serverlessfirst.com/serverless-photo-upload-api/
QUESTION
When I deploy a serverless framework codebase to AWS, I am curious about what method will be better. For now, there are 2 options.
- Use Nest.js or Express.js so I deploy one function to Lambda and this function will handle all API endpoints
- Deploy number of functions so each of them represents a single API endpoint
Regarding scalability, which option is a good approach?
...ANSWER
Answered 2021-May-21 at 21:38Second option is always better. Creating multiple lambda function for each functionality.
Lambda latency depend on how many calls get from API gateway. If you are using multiple endpoint and single lambda calls then it is going to bottleneck or high latency issue. Plus lambda charge based on per lambda calls. Each lambda 1 million request is free if you use one lambda for all use going to hit this limit early.
Recommendation is use different lambda function for each functionality and this is beauty of Micro Service. Keep simple and light weight.
QUESTION
According to this AWS documentation page covering authorizers for AWS API Gateway it is possible to define authorizer as lambda function returning a boolean value in isAuthorized
response field to allow/deny the API request.
However after numerous attempts I can't understand how to define it in serverless.yml
(or at least in AWS console)
I'm new to AWS and serverless framework. I've decided not to dive into IAM
access policies or Cognito
just yet, thus I'm trying to build a very simple lambda authorizer function that just yields a boolean value to allow/deny API access.
I have defined my functions
section in serverless.yml
as follows:
ANSWER
Answered 2021-May-03 at 21:35There are two possible problems.
- The response is incorrect for a custom authorizer for a REST API (which is what the
http
event
is in serverless). Output from an Amazon API Gateway Lambda authorizer shows what the output should look like, as well as what is required. - You intended to use an HTTP API. In that case you should change the
event
tohttpApi
: Announcing Support for AWS HTTP APIs
QUESTION
We are using serverless framework for our application with microservices (lambda functions). In the serverless.yml file we list down the resources which need to be created upon deployment.
The resources section of the serverles.yml file looks like the following:
...ANSWER
Answered 2021-Apr-29 at 05:31To add encryption to your queues you have to add KmsMasterKeyId to your queues in the template. If you want to use AWS managed CMK, the id will be alias/aws/sqs
(assuming both queues):
QUESTION
Using the serverless framework. I am doing some image processing in lambda with python and put the result in S3 bucket to be publicly accessible via a URL.
I spent hours and read every stack overflow answer, example code, etc that I could find to show how this is done. But no dice. I simply can't create minimum permissions that work. For this python code:
...ANSWER
Answered 2021-Apr-26 at 03:31these days iamRoleStatements:
are deprecated instead use I am docs for reference
example fine grained policies for writing to bucket which needs listing and put permission
QUESTION
Context :
I have just created a Node.JS application and deployed it with the Serverless Framework on AWS Lambda.
Problem :
I would like that application to be able to access my (free tier) MongoDB Atlas Cluster. For this I am using mongoose
.
Setup :
I have got a IAM User with AdministratorAccess rights. This user has been authorized on my MongoDB Cluster.
I am using the authMechanism=MONGODB-AWS
, therefore using the Token and Secret of that IAM user. The password has been correctly "url encoded".
This is the piece of code used to create a connection :
...ANSWER
Answered 2021-Apr-22 at 16:11if you are using an iam type mongodb user then you don't need the username + password in the connection string.
QUESTION
I am trying to deploy an API to the domain name in AWS using Serverless Framework. I want to be able to pass in the stage as an option and deploy to that custom domain name.
For example, stage dev
should make dev-api.firstcivdivcareers.com
.
I have the domain in Route53, created public certificates for the possible domains, but when I run the command I get the error below. It's either the way I am trying to use options and variables in serverless or something I am not setting up in AWS.
Still learning how to use serverless so any advice or commands I can use to debug is appreciated.
Error:
...ANSWER
Answered 2021-Apr-20 at 11:22First try to fix the indentation in the custom
section. The domainName
and basePath
should be under customDomain
:
QUESTION
I am trying to put a rule and a lambda target to the rule for EventBridge. The rule and the target are successfully added, however, the target Lambda is not triggered. And I cannot see the relevant Trigger when I navigate to the target Lambda function on AWS Console.
I'm using Serverless Framework to deploy the stack. The putRuleAndTarget
lambda is the one that creates the rule and adds notifyUser
as the target. Here's the relevant section of the serverless.ts
file:
ANSWER
Answered 2021-Apr-16 at 21:43It looks like you may be missing the permissions. The rule needs to have permission to invoke the lambda.
This tutorial shows the steps. In particular, check out the portion that covers
QUESTION
I have a policy attached to my CloudFormation stack:
...ANSWER
Answered 2021-Apr-16 at 15:25This can be done by using the environment variables of the serverless framework.
serverless.yml
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Serverless Framework
Create AWS credentials including the following inline IAM policy: { "Statement": [ { "Action": [ "apigateway:*", "cloudformation:CancelUpdateStack", "cloudformation:ContinueUpdateRollback", "cloudformation:CreateChangeSet", "cloudformation:CreateStack", "cloudformation:CreateUploadBucket", "cloudformation:DeleteStack", "cloudformation:Describe*", "cloudformation:EstimateTemplateCost", "cloudformation:ExecuteChangeSet", "cloudformation:Get*", "cloudformation:List*", "cloudformation:PreviewStackUpdate", "cloudformation:UpdateStack", "cloudformation:UpdateTerminationProtection", "cloudformation:ValidateTemplate", "dynamodb:CreateTable", "dynamodb:DeleteTable", "dynamodb:DescribeTable", "ec2:AttachInternetGateway", "ec2:AuthorizeSecurityGroupIngress", "ec2:CreateInternetGateway", "ec2:CreateNetworkAcl", "ec2:CreateNetworkAclEntry", "ec2:CreateRouteTable", "ec2:CreateSecurityGroup", "ec2:CreateSubnet", "ec2:CreateTags", "ec2:CreateVpc", "ec2:DeleteInternetGateway", "ec2:DeleteNetworkAcl", "ec2:DeleteNetworkAclEntry", "ec2:DeleteRouteTable", "ec2:DeleteSecurityGroup", "ec2:DeleteSubnet", "ec2:DeleteVpc", "ec2:Describe*", "ec2:DetachInternetGateway", "ec2:ModifyVpcAttribute", "events:DeleteRule", "events:DescribeRule", "events:ListRuleNamesByTarget", "events:ListRules", "events:ListTargetsByRule", "events:PutRule", "events:PutTargets", "events:RemoveTargets", "iam:CreateRole", "iam:DeleteRole", "iam:DeleteRolePolicy", "iam:GetRole", "iam:PassRole", "iam:PutRolePolicy", "iot:CreateTopicRule", "iot:DeleteTopicRule", "iot:DisableTopicRule", "iot:EnableTopicRule", "iot:ReplaceTopicRule", "kinesis:CreateStream", "kinesis:DeleteStream", "kinesis:DescribeStream", "lambda:*", "logs:CreateLogGroup", "logs:DeleteLogGroup", "logs:DescribeLogGroups", "logs:DescribeLogStreams", "logs:FilterLogEvents", "logs:GetLogEvents", "s3:CreateBucket", "s3:DeleteBucket", "s3:DeleteBucketPolicy", "s3:DeleteObject", "s3:DeleteObjectVersion", "s3:GetObject", "s3:GetObjectVersion", "s3:ListAllMyBuckets", "s3:ListBucket", "s3:PutBucketNotification", "s3:PutBucketPolicy", "s3:PutBucketTagging", "s3:PutBucketWebsite", "s3:PutEncryptionConfiguration", "s3:PutObject", "sns:CreateTopic", "sns:DeleteTopic", "sns:GetSubscriptionAttributes", "sns:GetTopicAttributes", "sns:ListSubscriptions", "sns:ListSubscriptionsByTopic", "sns:ListTopics", "sns:SetSubscriptionAttributes", "sns:SetTopicAttributes", "sns:Subscribe", "sns:Unsubscribe", "states:CreateStateMachine", "states:DeleteStateMachine" ], "Effect": "Allow", "Resource": "*" } ], "Version": "2012-10-17" }
Set the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables in the GitLab CI/CD settings. Settings > CI/CD > Variables.
This project sets up a static website from which the serverless function is called. Therefore the function needs to handle Cross-Origin Resource Sharing (CORS).
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page