sam

Fix CORS “Response to preflight…” header not present with AWS API gateway and amplify

∥☆過路亽.° 提交于 2020-08-27 08:24:29
问题 I've been struggling so long with the error below. I've tried so many tutorials and stackoverflow answers and none of the solutions fixes my problem. Access to XMLHttpRequest at 'https://xxx' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. I'm using SAM serverless to create my api. template.yaml: Globals: Function: Timeout: 10 Api:

How to deploy SAM stack with localstack?

点点圈 提交于 2020-06-01 01:45:15
问题 I've written a SAM stack and I can build, package and deploy it on AWS. I can also use start-local or invoke to test. Now I need to test to other AWS resources. I've added those resources to my SAM template. It works well on AWS but I'm searching for a way to deploy my SAM stack in localstack (local dynamodb e.g.). Now I have to create the resources with the CLI and after that I can deploy my SAM stack (only lambda, API GW in this case). How can I do this? 回答1: I've just gone through this. I

How to deploy SAM stack with localstack?

徘徊边缘 提交于 2020-06-01 01:40:49
问题 I've written a SAM stack and I can build, package and deploy it on AWS. I can also use start-local or invoke to test. Now I need to test to other AWS resources. I've added those resources to my SAM template. It works well on AWS but I'm searching for a way to deploy my SAM stack in localstack (local dynamodb e.g.). Now I have to create the resources with the CLI and after that I can deploy my SAM stack (only lambda, API GW in this case). How can I do this? 回答1: I've just gone through this. I

How to deploy SAM stack with localstack?

不打扰是莪最后的温柔 提交于 2020-06-01 01:38:41
问题 I've written a SAM stack and I can build, package and deploy it on AWS. I can also use start-local or invoke to test. Now I need to test to other AWS resources. I've added those resources to my SAM template. It works well on AWS but I'm searching for a way to deploy my SAM stack in localstack (local dynamodb e.g.). Now I have to create the resources with the CLI and after that I can deploy my SAM stack (only lambda, API GW in this case). How can I do this? 回答1: I've just gone through this. I

Preflight response 403 forbidden. How can I allow options method without x-api-key?

偶尔善良 提交于 2020-04-30 08:47:22
问题 I'm using SAM to create my API in cloudformation. I'm getting a 403 FORBIDDEN on my options method (thus also my preflight for my get method). How can I allow my options method to reply with 200 OK without my x-api-key? I've tried so many stackoverflow answers but none fit my SAM template format. I've tried all the different combinations of my AllowHeaders. I've ommited the x-api-key - still the same 403 FORBIDDEN. If I send my x-api-key in postman with my request I get a 200 OK, but in my

Recommended Project Structure for multi-function SAM Template

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-22 08:47:47
问题 I have a new project that requires a relatively small amount of services, maybe 10 or less (and therefore it is not economical to place each in a separate project repository). Each service will be defined as an AWS::Serverless::Function via SAM Template. My question is: what is the recommended way to organize or structure such a project? Currently the structure is: |- src |- lambdas |- service-one |- stuff |- package.json |- service-two |- stuff |- package.json |- other-stuff |- test |-

How to add a custom folder and file via YAML in Serverless app

被刻印的时光 ゝ 提交于 2019-12-11 12:45:59
问题 I am writing a serverless app by using SAM. I created a config folder to keep some table information and some other info. then I load it in my app.js. when I deploy the app.js locally by using SAM deploy, I observe that the config folder will not include. would you mind advise me how to add config folder in final build folder in .aws-sam\build folder? my Yaml file AWSTemplateFormatVersion: '2010-09-09' Transform: AWS::Serverless-2016-10-31 Description: Sample SAM Template for test Globals:

Kotlin recommended way of unregistering a listener with a SAM

久未见 提交于 2019-12-11 00:28:16
问题 So i have an interactor which performs an insert operation with Realm and then notifies that the insertion is completed with a RealChangeListener. It is something like this: fun insertCar(item: Car) { realm.doInTransaction { val car = Car(...) val copy = copyToRealm(car) copy.addChangeListener(...) } } I can do it this way: fun insertCar(item: Car, listener: RealmChangeListener<Car>) { realm.doInTransaction { val car = Car(...) val copy = copyToRealm(car) copy.addChangeListener(listener) } }

Recommended Project Structure for multi-function SAM Template

风格不统一 提交于 2019-12-05 18:12:11
I have a new project that requires a relatively small amount of services, maybe 10 or less (and therefore it is not economical to place each in a separate project repository). Each service will be defined as an AWS::Serverless::Function via SAM Template. My question is: what is the recommended way to organize or structure such a project? Currently the structure is: |- src |- lambdas |- service-one |- stuff |- package.json |- service-two |- stuff |- package.json |- other-stuff |- test |- package.json Is there a way to avoid having each lambda act as its own sub-project with unique package.json

Cloudformation Cognito - how to setup App Client Settings, Domain, and Federated Identities via SAM template

天大地大妈咪最大 提交于 2019-12-03 04:15:48
问题 I already have my cognito user pool cloudformation template working, and have it integrated to my api gateway. But somehow i still have to manually configure the app client settings, domain, and federated identities to have a working login portal for the users. I have been looking here and there for possible solutions in automating these, but i cannot seem to find anything close to it. I would like to automate the configuration of the app client settings, domain, and federated identities via