diff --git a/aws-node-rest-api-with-dynamodb-and-offline/serverless.yml b/aws-node-rest-api-with-dynamodb-and-offline/serverless.yml index 14995c42c..bbee446b6 100644 --- a/aws-node-rest-api-with-dynamodb-and-offline/serverless.yml +++ b/aws-node-rest-api-with-dynamodb-and-offline/serverless.yml @@ -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 migration: dir: offline/migrations provider: name: aws runtime: nodejs12.x + region: eu-west-1 + stage: dev environment: - DYNAMODB_TABLE: ${self:service}-${opt:stage, self:provider.stage} + DYNAMODB_TABLE: ${self:service}-${sls:stage} iam: role: statements: @@ -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 diff --git a/aws-node-rest-api-with-dynamodb-and-offline/todos/dynamodb.js b/aws-node-rest-api-with-dynamodb-and-offline/todos/dynamodb.js index 2a08ba9c4..bbf79ace9 100644 --- a/aws-node-rest-api-with-dynamodb-and-offline/todos/dynamodb.js +++ b/aws-node-rest-api-with-dynamodb-and-offline/todos/dynamodb.js @@ -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 }; }