Created
December 14, 2019 00:46
-
-
Save pjkelly/1f4dc3e1662717968abc821cf1e35d87 to your computer and use it in GitHub Desktop.
Serverless / LocalStack - DynamoDB Table
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
service: my-service | |
frameworkVersion: ">=1.45.0 <2.0.0" | |
plugins: | |
- serverless-localstack | |
- serverless-deployment-bucket | |
custom: | |
stage: ${opt:stage} | |
region: us-east-1 | |
# Set our DynamoDB throughput for prod and all other non-prod stages. | |
tableThroughputs: | |
prod: 5 | |
default: 1 | |
tableThroughput: ${self:custom.tableThroughputs.${self:custom.stage}, self:custom.tableThroughputs.default} | |
myTableName: "my-table" | |
localstack: | |
debug: true | |
stages: | |
- local | |
provider: | |
name: aws | |
runtime: nodejs10.x | |
stage: "${self:custom.stage}" | |
region: "${self:custom.region}" | |
environment: | |
SERVERLESS_ENV: "${self:custom.stage}" | |
functions: | |
resources: | |
Resources: | |
MyDynamoDbTable: | |
Type: 'AWS::DynamoDB::Table' | |
DeletionPolicy: Retain | |
Properties: | |
TableName: ${self:custom.myTableName} | |
AttributeDefinitions: | |
- AttributeName: my_id | |
AttributeType: N | |
KeySchema: | |
- AttributeName: my_id | |
KeyType: HASH | |
ProvisionedThroughput: | |
ReadCapacityUnits: ${self:custom.tableThroughput} | |
WriteCapacityUnits: ${self:custom.tableThroughput} | |
Outputs: | |
MyDynamoDbTableArn: | |
Value: | |
Fn::GetAtt: | |
- MyDynamoDbTable | |
- Arn | |
Export: | |
Name: ${self:custom.stage}-MyDynamoDbTableArn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment