-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1207 from blackflux/dev
[Gally]: master <- dev
- Loading branch information
Showing
52 changed files
with
5,815 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
2,073 changes: 2,073 additions & 0 deletions
2,073
src/plugin/docs/assorted/@sls-closedsource-dynamodb.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"description": "Test for creating script for DynamoDB table(s) init.", | ||
"details": [], | ||
"formats": ["other"], | ||
"requires": ["serverless"], | ||
"website": null | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"tasks": [ | ||
"struct/#serverless", | ||
"badges/#serverless", | ||
"circleci/#serverless", | ||
"docker/#serverless-dynamodb", | ||
"gally/#serverless", | ||
"editor/#default", | ||
"gitignore/#serverless", | ||
"jetbrains/#default", | ||
"license/#closedsource", | ||
"package/#serverless-dynamodb", | ||
"serverless/#two-stack-dynamodb" | ||
], | ||
"description": "Manage various configuration files for serverless project with the option of running DynamoDB locally." | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"tasks": [ | ||
"sls-dynamodb-docker", | ||
"sls-dynamodb-manage" | ||
], | ||
"description": "Manage DynamoDB docker test configuration for a DynamoDB-based serverless project." | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"target": "docker/Dockerfile", | ||
"strategy": "overwrite", | ||
"snippets": [ | ||
"sls-dynamodb/Dockerfile" | ||
], | ||
"requires": [ | ||
"docker", | ||
"serverless" | ||
], | ||
"purpose": [ | ||
"Docker environment definition for allowing to run tests using DynamoDB local and automate table(s) creation." | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"target": "manage.sh", | ||
"strategy": "overwrite", | ||
"snippets": [ | ||
"sls-dynamodb/manage.sh" | ||
], | ||
"requires": [ | ||
"docker", | ||
"serverless" | ||
], | ||
"purpose": [ | ||
"Enable spawning a docker serverless container as default or with a local DynamoDB instance." | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
FROM lambci/lambda:build-nodejs12.x | ||
|
||
WORKDIR /user | ||
|
||
RUN yum install git vi -y | ||
|
||
# set home folder | ||
ENV HOME /user | ||
|
||
RUN touch ~/.bashrc && \ | ||
curl -o- -L https://yarnpkg.com/install.sh | bash && \ | ||
source ~/.bashrc && \ | ||
yarn global add serverless@2.1.0 | ||
|
||
RUN touch ~/.bashrc && \ | ||
echo "alias u='yarn run u'" >> ~/.bashrc && \ | ||
echo "alias i='yarn run i'" >> ~/.bashrc && \ | ||
echo "alias it='yarn run it'" >> ~/.bashrc && \ | ||
echo "alias t='yarn run t'" >> ~/.bashrc && \ | ||
echo "alias ts='yarn run ts'" >> ~/.bashrc && \ | ||
echo "alias tsv='yarn run tsv'" >> ~/.bashrc && \ | ||
source ~/.bashrc | ||
|
||
RUN chmod -R 757 /user | ||
|
||
# set correct execution env | ||
ENV LAMBDA_TASK_ROOT /user/project | ||
# disable babel trying to access root file location | ||
ENV BABEL_DISABLE_CACHE 1 | ||
|
||
ENTRYPOINT (cd project && \ | ||
if [[ "$\{DYNAMODB_LOCAL_ENABLE}" = true ]]; \ | ||
then sh ./docker/dynamodb.sh &> /dev/null; \ | ||
fi && \ | ||
bash) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
|
||
if [ "$\{1}" = 'dynamodb' ]; | ||
then | ||
docker run \ | ||
--name dynamodb-local \ | ||
-p 0.0.0.0:8000:8000 \ | ||
-d amazon/dynamodb-local | ||
LINK='--link dynamodb-local -e DYNAMODB_LOCAL_ENABLE=true' | ||
else | ||
NET_HOST = '--net host' | ||
fi | ||
|
||
docker build -t lambda-environment-node ./docker && | ||
docker run \ | ||
$NET_HOST \ | ||
$LINK \ | ||
-u`id -u`:`id -g` \ | ||
-v $(pwd):/user/project \ | ||
-v ~/.aws:/user/.aws \ | ||
-v ~/.npmrc:/user/.npmrc \ | ||
-it lambda-environment-node | ||
|
||
if [ -n "$\{LINK}" ]; then | ||
docker stop dynamodb-local -t 0 | ||
docker rm -f dynamodb-local | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"tasks": [ | ||
"serverless-dynamodb_default-shallow", | ||
"serverless-dynamodb_default-deep", | ||
"serverless-dynamodb_merge-shallow", | ||
"serverless_merge-deep" | ||
], | ||
"description": "Manage package.json for serverless project with DynamoDB local." | ||
} |
15 changes: 15 additions & 0 deletions
15
src/plugin/tasks/package/serverless-dynamodb_default-deep.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"target": "package.json", | ||
"pretty": false, | ||
"strategy": "default-deep", | ||
"snippets": [ | ||
"default/default-deep", | ||
"serverless-dynamodb/default-deep" | ||
], | ||
"requires": [ | ||
"javascript" | ||
], | ||
"purpose": [ | ||
"Set defaults for various entries." | ||
] | ||
} |
15 changes: 15 additions & 0 deletions
15
src/plugin/tasks/package/serverless-dynamodb_default-shallow.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"target": "package.json", | ||
"pretty": false, | ||
"strategy": "default-shallow", | ||
"snippets": [ | ||
"default/default-shallow", | ||
"serverless-dynamodb/default-shallow" | ||
], | ||
"requires": [ | ||
"javascript" | ||
], | ||
"purpose": [ | ||
"Set defaults for various entries." | ||
] | ||
} |
22 changes: 22 additions & 0 deletions
22
src/plugin/tasks/package/serverless-dynamodb_merge-shallow.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"target": "package.json", | ||
"pretty": false, | ||
"strategy": "merge-shallow", | ||
"snippets": [ | ||
"serverless/merge-shallow", | ||
{ | ||
"name": "serverless-dynamodb/merge-shallow", | ||
"variables": { | ||
"awsRegion": "${awsRegion}", | ||
"awsAccessKeyId": "XXXXXXXXXXXXXXXXXXXX", | ||
"awsSecretAccessKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | ||
} | ||
} | ||
], | ||
"requires": [ | ||
"javascript" | ||
], | ||
"purpose": [ | ||
"Set various entries." | ||
] | ||
} |
5 changes: 5 additions & 0 deletions
5
src/plugin/tasks/package/snippets/serverless-dynamodb/default-deep.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"devDependencies": { | ||
"dynamodb-admin": "4.0.0" | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/plugin/tasks/package/snippets/serverless-dynamodb/default-shallow.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
5 changes: 5 additions & 0 deletions
5
src/plugin/tasks/package/snippets/serverless-dynamodb/merge-shallow.json
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"scripts": { | ||
"ddba": "AWS_REGION=${awsRegion|LOWER} AWS_ACCESS_KEY_ID=${awsAccessKeyId} AWS_SECRET_ACCESS_KEY=${awsSecretAccessKey} DYNAMO_ENDPOINT=http://0.0.0.0:8000 dynamodb-admin" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"tasks": [ | ||
"serverless", | ||
"serverless-wrapper", | ||
"test-sls-cf-stack", | ||
"test-sls-cf-stack-routes", | ||
"test-sls-cfg", | ||
"test-sls-dynamodb-local", | ||
"serverless-base-resolver", | ||
"serverless-base-api", | ||
"serverless-base-data", | ||
"serverless-base-data-stack-hash", | ||
"serverless-api", | ||
"serverless-data" | ||
], | ||
"description": "Manage serverless configuration for deployment to AWS." | ||
} |
56 changes: 56 additions & 0 deletions
56
src/plugin/tasks/serverless/snippets/serverless-dynamodb/test/1-sls-dynamodb-local.spec.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const path = require('path'); | ||
const yaml = require('yaml-boost'); | ||
const objectScan = require('object-scan'); | ||
const { describe } = require('node-tdd'); | ||
const fs = require('smart-fs'); | ||
const expect = require('chai').expect; | ||
|
||
describe('Testing dynamodb-local', { envVarsFile: 'env.yml' }, () => { | ||
let dataStack; | ||
let tables = []; | ||
before(() => { | ||
dataStack = yaml.load( | ||
path.join(__dirname, '..', 'serverless.wrapper.yml'), | ||
{ | ||
stack: 'data', | ||
region: process.env.AWS_REGION, | ||
env: 'local' | ||
} | ||
); | ||
tables = objectScan(['resources.Resources.*'], { | ||
filterFn: ({ value, context }) => { | ||
if (value.Type === 'AWS::DynamoDB::Table') { | ||
context.push(value.Properties); | ||
} | ||
} | ||
})(dataStack, []); | ||
}); | ||
|
||
it('Testing tables set-up', async () => { | ||
const result = ['#!/bin/sh']; | ||
tables.forEach((table) => { | ||
const t = Object.fromEntries(Object.entries(table) | ||
.filter(([k]) => k !== 'PointInTimeRecoverySpecification') | ||
.map(([k, v]) => { | ||
if (k === 'TableName') { | ||
// eslint-disable-next-line no-template-curly-in-string | ||
return [k, v.replace('${self:provider.stage}', 'dynamodb')]; | ||
} | ||
return [k, v]; | ||
})); | ||
result.push( | ||
`AWS_ACCESS_KEY_ID=${process.env.AWS_ACCESS_KEY_ID} \\`, | ||
`AWS_SECRET_ACCESS_KEY=${process.env.AWS_SECRET_ACCESS_KEY} \\`, | ||
`AWS_REGION=${process.env.AWS_REGION} \\`, | ||
'aws dynamodb create-table \\', | ||
` --cli-input-json '${JSON.stringify(t)}' \\`, | ||
' --endpoint-url http://dynamodb-local:8000 \\', | ||
` --region ${process.env.AWS_REGION}` | ||
); | ||
}); | ||
expect( | ||
fs.smartWrite(path.join(__dirname, '..', 'docker', 'dynamodb.sh'), result), | ||
'DynamoDb tables updated. Please re-run.' | ||
).to.equal(false); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"target": "test/1-sls-dynamodb-local.spec.js", | ||
"format": "txt", | ||
"strategy": "overwrite", | ||
"snippets": [ | ||
"serverless-dynamodb/test/1-sls-dynamodb-local.spec.js" | ||
], | ||
"requires": [ | ||
"serverless", | ||
"aws" | ||
], | ||
"purpose": [ | ||
"Test for generating script for DynamoDB table(s) creation.." | ||
] | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
AWS_REGION: "${awsRegion}" | ||
AWS_ACCESS_KEY_ID: "XXXXXXXXXXXXXXXXXXXX" | ||
AWS_SECRET_ACCESS_KEY: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | ||
AWS_SESSION_TOKEN: "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" | ||
AWS_ACCESS_KEY_ID: "${awsAccessKeyId}" | ||
AWS_SECRET_ACCESS_KEY: "${awsSecretAccessKey}" | ||
AWS_SESSION_TOKEN: "${awsSessionToken}" |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"presets": [["latest-node", {"target": "nodeVersion"}]], | ||
"plugins": [], | ||
"sourceMaps": false | ||
} |
Oops, something went wrong.