serverless-framework

Destroy resources created via Serverless without destroying Lambda endpoints

匆匆过客 提交于 2019-12-23 09:28:01
问题 I have the following resource defined in my serverless.yml file. Its working great to create the resource for all my different stages of development. resources: Resources: uploadBucket: Type: AWS::S3::Bucket Properties: BucketName: ${self:service}-${self:custom.stage}-uploads visitsTable: Type: AWS::DynamoDB::Table Properties: TableName: ${self:custom.visitsTable} AttributeDefinitions: - AttributeName: userId AttributeType: S - AttributeName: visitId AttributeType: S KeySchema: -

Can't access to RDS from Amazon Lambda, same VPC and correct role permissions

孤人 提交于 2019-12-22 08:32:49
问题 i can't successfully connect to RDS from Amazon Lambda in production. For Amazon Lambda i'm using Serverless framework, executing sls offline i can connect with RDS from localhost, but in production Amazon Lambda doesn't. Both are in same VPC, in same security group, that has all traffic inbound access, and a rule that is pointing to Vpc's CIDR. I have these permissions attached: AmazonRDSFullAccess, AWSLambdaFullAccess, AmazonVPCFullAccess, AWSLambdaExecute and

Invoking the lambda gets timed out after adding VPC configurations

纵饮孤独 提交于 2019-12-22 07:09:11
问题 I am using serverless framework for creating lambdas. I created a simple Lambda function, which queries from an mongo instance and returns the response. Initially, I created the mongo instance with publicIp and made the Lambda access that instance with publicIP. It worked well. Now, in order to increase the security, I added the VPC configuration to the Lambda. Here is my serverless.yml: functions: graphql: handler: handler.graphql iamRoleStatements: - Effect: Allow Resource: "*" Action: -

How do I assign function level IamRoleStatements in Serverless Framework?

你。 提交于 2019-12-22 04:07:23
问题 I want to assign different permissions for different functions listed in my serverless.yml functions: hello: handler: handler.hello crawl-distributor: handler: CrawlDistributor.handler product-scanner: handler: ProductScanner.handler iamRoleStatements: - Effect: Allow Action: - dynamodb:* - lambda:* Resource: "*" This doesn't seem to work. When I add the iamRoleStatements at the provider level, it works, but ends up applying the permissions to all the functions. provider: name: aws runtime:

AWS Lambda Container destroy event

早过忘川 提交于 2019-12-22 01:39:28
问题 When to release connections and cleanup resources in lambda. In normal Node JS application we do use the hook process.on('exit', (code) => { console.log(`About to exit with code: ${code}`); }); However this doesn't work on AWS Lambda. Resulting the Mysql connection in sleep mode. We don't have enough resource for such active connections. None of the AWS documentation specify a way to achieve this. How to receive stop event of AWS Lambda container ? 回答1: EDIT: The short answer is that there is

Using sls deploy –package doesn’t work with serverless for google cloud functions

我的梦境 提交于 2019-12-22 00:09:09
问题 I was following the quick start guide for serverless https://serverless.com/framework/docs/providers/google/guide/quick-start/ and created a service as mentioned in the guide. I ran the following commands: serverless create --template google-nodejs --path my-service cd my-service npm install I edited the serverless.yml to contain a valid key path and tried the following command serverless package A .serverless folder was created with myservice.zip file in it. Later I tried to deploy this

AWS Lambda fails to return PDF file

穿精又带淫゛_ 提交于 2019-12-18 15:48:22
问题 I have created a lambda function using serverless. This function is fired via API Gateway on a GET request and should return a pdf file from a buffer. I'm using html-pdf to create the buffer and trying to return the pdf file with the following command let response = { statusCode: 200, headers: {'Content-type' : 'application/pdf'}, body: buffer.toString('base64'), isBase64Encoded : true, }; return callback(null, response); but the browser is just failing to load the pdf, so I don't know

Rename an Azure Function

不羁岁月 提交于 2019-12-18 11:38:15
问题 How to rename an Azure Function ? I want to replace a default 'HttpTriggerCSharp1' name to my own. At the moment unfortunately this name is included in the function url and there is no option to change it: https://functions-xxx.azurewebsites.net/api/HttpTriggerCSharp1 回答1: The UI does not directly support renaming a Function, but you can work around this using the following manual steps: Stop your Function App. To do this, go under Function app settings / Go To App Service Settings, and click

Serverless Framework with AWS cognito generates CORS error

霸气de小男生 提交于 2019-12-18 09:32:50
问题 I get this error message from the Angular frontend and I am not authorized to touch my lambda code: `Access to fetch at 'https://testapicd.***.***.com/localization/v1/role' from origin 'https://localization.test.***.***.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.` I have looked everywhere and there seems

How to import Python dependencies in Serverless v1.0

烈酒焚心 提交于 2019-12-18 06:09:10
问题 Language: Python Framework: Serverless v1.0 Typically I would run pip freeze > requirements.txt in the project root How can I get these dependencies packaged into every deploy? 回答1: create requirements.txt pip freeze > requirements.txt create a folder with all the dependencies: pip install -t vendored -r requirements.txt Note that in order to use these dependencies in the code you'll need to add the following: import os import sys here = os.path.dirname(os.path.realpath(__file__)) sys.path