├── src ├── function1D0BF340 │ ├── package.json │ ├── README.md │ └── index.js ├── function48A53742 │ ├── package.json │ ├── index.js │ └── README.md ├── function5A53E646 │ ├── package.json │ ├── index.js │ └── README.md ├── function6871BEC5 │ ├── package.json │ ├── index.js │ └── README.md └── functionC2148022 │ ├── package.json │ ├── README.md │ └── index.js └── template.yaml /src/function1D0BF340/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "dependencies": { 4 | "aws-sdk": "~2" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/function48A53742/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "dependencies": { 4 | "aws-sdk": "~2" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/function5A53E646/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "dependencies": { 4 | "aws-sdk": "~2" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/function6871BEC5/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "dependencies": { 4 | "aws-sdk": "~2" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/functionC2148022/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "dependencies": { 4 | "aws-sdk": "~2" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /src/function48A53742/index.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | var dynamodb = new AWS.DynamoDB() 3 | 4 | exports.handler = async message => { 5 | console.log(message); 6 | 7 | let params = { 8 | TableName: process.env.TABLE_NAME, 9 | Select: 'ALL_ATTRIBUTES' 10 | }; 11 | 12 | console.log(`Getting all users from table ${process.env.TABLE_NAME}`); 13 | let results = await dynamodb.scan(params).promise() 14 | console.log(`Done: ${JSON.stringify(results)}`); 15 | 16 | return { 17 | statusCode: 200, 18 | headers: {}, 19 | body: JSON.stringify(results.Items) 20 | }; 21 | } 22 | -------------------------------------------------------------------------------- /src/function5A53E646/index.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | var dynamodb = new AWS.DynamoDB() 3 | 4 | exports.handler = async message => { 5 | console.log(message); 6 | let userId = message.pathParameters.id 7 | let params = { 8 | TableName: process.env.TABLE_NAME, 9 | Key: { 10 | id: { S: userId } 11 | } 12 | }; 13 | 14 | console.log(`Deleting user ${userId} from table ${process.env.TABLE_NAME}`); 15 | let results = await dynamodb.deleteItem(params).promise() 16 | console.log(`Done: ${JSON.stringify(results)}`); 17 | 18 | return { 19 | statusCode: 204, 20 | headers: {}, 21 | body: JSON.stringify({}) 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /src/function6871BEC5/index.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | var dynamodb = new AWS.DynamoDB() 3 | 4 | exports.handler = async message => { 5 | console.log(message); 6 | let userId = message.pathParameters.id 7 | let params = { 8 | TableName: process.env.TABLE_NAME, 9 | Key: { 10 | id: { S: userId } 11 | } 12 | }; 13 | 14 | console.log(`Getting user ${userId} from table ${process.env.TABLE_NAME}`); 15 | let results = await dynamodb.getItem(params).promise() 16 | console.log(`Done: ${JSON.stringify(results)}`); 17 | 18 | return { 19 | statusCode: 200, 20 | headers: {}, 21 | body: JSON.stringify(results.Item) 22 | }; 23 | } 24 | -------------------------------------------------------------------------------- /src/function1D0BF340/README.md: -------------------------------------------------------------------------------- 1 | 2 | This Stackery function node was generated by [Stackery.io](https://www.stackery.io). 3 | 4 | We recommend updating this readme with your own function specific documentation. 5 | 6 | # Dependencies 7 | You can add dependencies on other files and packages. 8 | Within this directory, local dependencies can be added as individual files and 9 | package dependencies can be added to [package.json](https://docs.npmjs.com/files/package.json). 10 | Package dependencies will be installed when the stack is deployed. 11 | 12 | # Stackery Documentation 13 | Documentation for Stackery function nodes can be found at [https://docs.stackery.io/nodes/Function/](https://docs.stackery.io/nodes/Function/). 14 | -------------------------------------------------------------------------------- /src/function48A53742/README.md: -------------------------------------------------------------------------------- 1 | 2 | This Stackery function node was generated by [Stackery.io](https://www.stackery.io). 3 | 4 | We recommend updating this readme with your own function specific documentation. 5 | 6 | # Dependencies 7 | You can add dependencies on other files and packages. 8 | Within this directory, local dependencies can be added as individual files and 9 | package dependencies can be added to [package.json](https://docs.npmjs.com/files/package.json). 10 | Package dependencies will be installed when the stack is deployed. 11 | 12 | # Stackery Documentation 13 | Documentation for Stackery function nodes can be found at [https://docs.stackery.io/nodes/Function/](https://docs.stackery.io/nodes/Function/). 14 | -------------------------------------------------------------------------------- /src/function5A53E646/README.md: -------------------------------------------------------------------------------- 1 | 2 | This Stackery function node was generated by [Stackery.io](https://www.stackery.io). 3 | 4 | We recommend updating this readme with your own function specific documentation. 5 | 6 | # Dependencies 7 | You can add dependencies on other files and packages. 8 | Within this directory, local dependencies can be added as individual files and 9 | package dependencies can be added to [package.json](https://docs.npmjs.com/files/package.json). 10 | Package dependencies will be installed when the stack is deployed. 11 | 12 | # Stackery Documentation 13 | Documentation for Stackery function nodes can be found at [https://docs.stackery.io/nodes/Function/](https://docs.stackery.io/nodes/Function/). 14 | -------------------------------------------------------------------------------- /src/function6871BEC5/README.md: -------------------------------------------------------------------------------- 1 | 2 | This Stackery function node was generated by [Stackery.io](https://www.stackery.io). 3 | 4 | We recommend updating this readme with your own function specific documentation. 5 | 6 | # Dependencies 7 | You can add dependencies on other files and packages. 8 | Within this directory, local dependencies can be added as individual files and 9 | package dependencies can be added to [package.json](https://docs.npmjs.com/files/package.json). 10 | Package dependencies will be installed when the stack is deployed. 11 | 12 | # Stackery Documentation 13 | Documentation for Stackery function nodes can be found at [https://docs.stackery.io/nodes/Function/](https://docs.stackery.io/nodes/Function/). 14 | -------------------------------------------------------------------------------- /src/functionC2148022/README.md: -------------------------------------------------------------------------------- 1 | 2 | This Stackery function node was generated by [Stackery.io](https://www.stackery.io). 3 | 4 | We recommend updating this readme with your own function specific documentation. 5 | 6 | # Dependencies 7 | You can add dependencies on other files and packages. 8 | Within this directory, local dependencies can be added as individual files and 9 | package dependencies can be added to [package.json](https://docs.npmjs.com/files/package.json). 10 | Package dependencies will be installed when the stack is deployed. 11 | 12 | # Stackery Documentation 13 | Documentation for Stackery function nodes can be found at [https://docs.stackery.io/nodes/Function/](https://docs.stackery.io/nodes/Function/). 14 | -------------------------------------------------------------------------------- /src/function1D0BF340/index.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | var dynamodb = new AWS.DynamoDB() 3 | 4 | exports.handler = async message => { 5 | console.log(message); 6 | 7 | if (message.body) { 8 | let user = JSON.parse(message.body); 9 | let params = { 10 | TableName: process.env.TABLE_NAME, 11 | Item: { 12 | id: { S: user.id }, 13 | FirstName: { S: user.firstName }, 14 | LastName: { S: user.lastName }, 15 | FavoriteColor: { S: user.color } 16 | } 17 | }; 18 | 19 | console.log(`Adding user to table ${process.env.TABLE_NAME}`); 20 | await dynamodb.putItem(params).promise() 21 | console.log(`User added to table, done`); 22 | } 23 | 24 | return {}; 25 | } 26 | -------------------------------------------------------------------------------- /src/functionC2148022/index.js: -------------------------------------------------------------------------------- 1 | const AWS = require('aws-sdk'); 2 | var dynamodb = new AWS.DynamoDB() 3 | 4 | exports.handler = async message => { 5 | console.log(message); 6 | 7 | if (message.body) { 8 | let userId = message.pathParameters.id 9 | let user = JSON.parse(message.body); 10 | let params = { 11 | TableName: process.env.TABLE_NAME, 12 | Item: { 13 | id: { S: userId }, 14 | FirstName: { S: user.firstName }, 15 | LastName: { S: user.lastName }, 16 | FavoriteColor: { S: user.color } 17 | } 18 | }; 19 | 20 | console.log(`Updating user ${userId} in table ${process.env.TABLE_NAME}`); 21 | await dynamodb.putItem(params).promise() 22 | console.log(`User added to table, done`); 23 | } 24 | 25 | return { 26 | statusCode: 204, 27 | headers: {}, 28 | body: JSON.stringify({}) 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /template.yaml: -------------------------------------------------------------------------------- 1 | AWSTemplateFormatVersion: 2010-09-09 2 | Transform: AWS::Serverless-2016-10-31 3 | Description: Stackery Serverless CRUD API Demo 4 | Resources: 5 | function48A53742: 6 | Type: AWS::Serverless::Function 7 | Properties: 8 | FunctionName: !Sub ${AWS::StackName}-function48A53742 9 | Description: !Sub 10 | - Stackery Stack ${StackeryStackTagName} Environment ${StackeryEnvironmentTagName} Function ${ResourceName} 11 | - ResourceName: listUsers 12 | CodeUri: src/function48A53742 13 | Handler: index.handler 14 | Runtime: nodejs8.10 15 | MemorySize: 3008 16 | Timeout: 30 17 | Tracing: Active 18 | Policies: 19 | - AWSXrayWriteOnlyAccess 20 | - DynamoDBCrudPolicy: 21 | TableName: !Ref table6E08C5D 22 | Environment: 23 | Variables: 24 | TABLE_NAME: !Ref table6E08C5D 25 | TABLE_ARN: !GetAtt table6E08C5D.Arn 26 | Events: 27 | api3FEE112A: 28 | Type: Api 29 | Properties: 30 | Path: /users 31 | Method: GET 32 | RestApiId: !Ref api3FEE112A 33 | Metadata: 34 | StackeryName: listUsers 35 | api3FEE112A: 36 | Type: AWS::Serverless::Api 37 | Properties: 38 | Name: !Sub 39 | - ${ResourceName} From Stackery Stack ${StackeryStackTagName} Environment ${StackeryEnvironmentTagName} 40 | - ResourceName: /users 41 | StageName: !Ref StackeryEnvironmentAPIGatewayStageName 42 | DefinitionBody: 43 | swagger: '2.0' 44 | info: {} 45 | paths: 46 | /users: 47 | get: 48 | x-amazon-apigateway-integration: 49 | httpMethod: POST 50 | type: aws_proxy 51 | uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${function48A53742.Arn}/invocations 52 | responses: {} 53 | post: 54 | x-amazon-apigateway-integration: 55 | httpMethod: POST 56 | type: aws_proxy 57 | uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${function1D0BF340.Arn}/invocations 58 | responses: {} 59 | /users/{id}: 60 | get: 61 | x-amazon-apigateway-integration: 62 | httpMethod: POST 63 | type: aws_proxy 64 | uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${function6871BEC5.Arn}/invocations 65 | responses: {} 66 | put: 67 | x-amazon-apigateway-integration: 68 | httpMethod: POST 69 | type: aws_proxy 70 | uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${functionC2148022.Arn}/invocations 71 | responses: {} 72 | delete: 73 | x-amazon-apigateway-integration: 74 | httpMethod: POST 75 | type: aws_proxy 76 | uri: !Sub arn:aws:apigateway:${AWS::Region}:lambda:path/2015-03-31/functions/${function5A53E646.Arn}/invocations 77 | responses: {} 78 | EndpointConfiguration: REGIONAL 79 | Metadata: 80 | StackeryName: /users 81 | function5A53E646: 82 | Type: AWS::Serverless::Function 83 | Properties: 84 | FunctionName: !Sub ${AWS::StackName}-function5A53E646 85 | Description: !Sub 86 | - Stackery Stack ${StackeryStackTagName} Environment ${StackeryEnvironmentTagName} Function ${ResourceName} 87 | - ResourceName: deleteUser 88 | CodeUri: src/function5A53E646 89 | Handler: index.handler 90 | Runtime: nodejs8.10 91 | MemorySize: 3008 92 | Timeout: 30 93 | Tracing: Active 94 | Policies: 95 | - AWSXrayWriteOnlyAccess 96 | - DynamoDBCrudPolicy: 97 | TableName: !Ref table6E08C5D 98 | Environment: 99 | Variables: 100 | TABLE_NAME: !Ref table6E08C5D 101 | TABLE_ARN: !GetAtt table6E08C5D.Arn 102 | Events: 103 | api3FEE112A: 104 | Type: Api 105 | Properties: 106 | Path: /users/{id} 107 | Method: DELETE 108 | RestApiId: !Ref api3FEE112A 109 | Metadata: 110 | StackeryName: deleteUser 111 | function1D0BF340: 112 | Type: AWS::Serverless::Function 113 | Properties: 114 | FunctionName: !Sub ${AWS::StackName}-function1D0BF340 115 | Description: !Sub 116 | - Stackery Stack ${StackeryStackTagName} Environment ${StackeryEnvironmentTagName} Function ${ResourceName} 117 | - ResourceName: createUser 118 | CodeUri: src/function1D0BF340 119 | Handler: index.handler 120 | Runtime: nodejs8.10 121 | MemorySize: 3008 122 | Timeout: 30 123 | Tracing: Active 124 | Policies: 125 | - AWSXrayWriteOnlyAccess 126 | - DynamoDBCrudPolicy: 127 | TableName: !Ref table6E08C5D 128 | Environment: 129 | Variables: 130 | TABLE_NAME: !Ref table6E08C5D 131 | TABLE_ARN: !GetAtt table6E08C5D.Arn 132 | Events: 133 | api3FEE112A: 134 | Type: Api 135 | Properties: 136 | Path: /users 137 | Method: POST 138 | RestApiId: !Ref api3FEE112A 139 | Metadata: 140 | StackeryName: createUser 141 | functionC2148022: 142 | Type: AWS::Serverless::Function 143 | Properties: 144 | FunctionName: !Sub ${AWS::StackName}-functionC2148022 145 | Description: !Sub 146 | - Stackery Stack ${StackeryStackTagName} Environment ${StackeryEnvironmentTagName} Function ${ResourceName} 147 | - ResourceName: updateUser 148 | CodeUri: src/functionC2148022 149 | Handler: index.handler 150 | Runtime: nodejs8.10 151 | MemorySize: 3008 152 | Timeout: 30 153 | Tracing: Active 154 | Policies: 155 | - AWSXrayWriteOnlyAccess 156 | - DynamoDBCrudPolicy: 157 | TableName: !Ref table6E08C5D 158 | Environment: 159 | Variables: 160 | TABLE_NAME: !Ref table6E08C5D 161 | TABLE_ARN: !GetAtt table6E08C5D.Arn 162 | Events: 163 | api3FEE112A: 164 | Type: Api 165 | Properties: 166 | Path: /users/{id} 167 | Method: PUT 168 | RestApiId: !Ref api3FEE112A 169 | Metadata: 170 | StackeryName: updateUser 171 | function6871BEC5: 172 | Type: AWS::Serverless::Function 173 | Properties: 174 | FunctionName: !Sub ${AWS::StackName}-function6871BEC5 175 | Description: !Sub 176 | - Stackery Stack ${StackeryStackTagName} Environment ${StackeryEnvironmentTagName} Function ${ResourceName} 177 | - ResourceName: getUser 178 | CodeUri: src/function6871BEC5 179 | Handler: index.handler 180 | Runtime: nodejs8.10 181 | MemorySize: 3008 182 | Timeout: 30 183 | Tracing: Active 184 | Policies: 185 | - AWSXrayWriteOnlyAccess 186 | - DynamoDBCrudPolicy: 187 | TableName: !Ref table6E08C5D 188 | Environment: 189 | Variables: 190 | TABLE_NAME: !Ref table6E08C5D 191 | TABLE_ARN: !GetAtt table6E08C5D.Arn 192 | Events: 193 | api3FEE112A: 194 | Type: Api 195 | Properties: 196 | Path: /users/{id} 197 | Method: GET 198 | RestApiId: !Ref api3FEE112A 199 | Metadata: 200 | StackeryName: getUser 201 | table6E08C5D: 202 | Type: AWS::DynamoDB::Table 203 | Properties: 204 | AttributeDefinitions: 205 | - AttributeName: id 206 | AttributeType: S 207 | KeySchema: 208 | - AttributeName: id 209 | KeyType: HASH 210 | ProvisionedThroughput: 211 | ReadCapacityUnits: 5 212 | WriteCapacityUnits: 5 213 | StreamSpecification: 214 | StreamViewType: NEW_AND_OLD_IMAGES 215 | TableName: !Sub ${AWS::StackName}-table6E08C5D 216 | Metadata: 217 | StackeryName: Users 218 | Parameters: 219 | StackeryStackTagName: 220 | Type: String 221 | Description: Stack Name (injected by Stackery at deployment time) 222 | StackeryEnvironmentTagName: 223 | Type: String 224 | Description: Environment Name (injected by Stackery at deployment time) 225 | StackeryEnvironmentAPIGatewayStageName: 226 | Type: String 227 | Description: Environment name used for API Gateway Stage names (injected by Stackery at deployment time) 228 | --------------------------------------------------------------------------------