Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update serverless and code to fix dynamodb local connection issues #719

Open
wants to merge 2 commits into
base: v3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions aws-node-rest-api-with-dynamodb-and-offline/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ custom:
port: 8000
inMemory: true
migrate: true
# Comment if you don't have a DynamoDB running locally
noStart: true
# Comment if you don't have a DynamoDB running locally
#noStart: true
RichardWright marked this conversation as resolved.
Show resolved Hide resolved
migration:
dir: offline/migrations

provider:
name: aws
runtime: nodejs12.x
region: eu-west-1
stage: dev
RichardWright marked this conversation as resolved.
Show resolved Hide resolved
environment:
DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage}
DYNAMODB_TABLE: ${self:service}-${sls:stage}
iam:
role:
statements:
Expand All @@ -35,8 +37,8 @@ provider:
- dynamodb:PutItem
- dynamodb:UpdateItem
- dynamodb:DeleteItem
Resource: "arn:aws:dynamodb:${opt:region, self:provider.region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"

Resource: "arn:aws:dynamodb:${aws:region}:*:table/${self:provider.environment.DYNAMODB_TABLE}"
functions:
create:
handler: todos/create.create
Expand All @@ -61,7 +63,7 @@ functions:
path: todos/{id}
method: get
cors: true

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not introduce whitespace changes

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove

update:
handler: todos/update.update
events:
Expand Down
2 changes: 2 additions & 0 deletions aws-node-rest-api-with-dynamodb-and-offline/todos/dynamodb.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ if (process.env.IS_OFFLINE) {
options = {
region: 'localhost',
endpoint: 'http://localhost:8000',
accessKeyId: 'DEFAULT_ACCESS_KEY', // needed if you don't have aws credentials at all in env
secretAccessKey: 'DEFAULT_SECRET' // needed if you don't have aws credentials at all in env
medikoo marked this conversation as resolved.
Show resolved Hide resolved
};
}

Expand Down