-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
136 additions
and
836 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
nodemon | ||
package-lock.json | ||
node_modules |
This file was deleted.
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,62 @@ | ||
const dotenv = require('dotenv'); | ||
var AWS = require('aws-sdk'); | ||
// const cloudformation = new AWS.CloudFormation({apiVersion: '2010-05-15'}); | ||
AWS.config.region = 'us-east-1' | ||
|
||
LOCAL_ENV_VARS = { | ||
AWS_DEFAULT_REGION:'', | ||
AWS_ACCESS_KEY_ID:'', | ||
AWS_SECRET_ACCESS_KEY:'', | ||
SAM_LOCAL_ABSOLUTE_PATH:'', | ||
SAM_CLI_TELEMETRY:'', | ||
LAMBDA_LAYER:'', | ||
APP_ADMIN_USER:'', | ||
PUBLIC_SHEETS_FOLDER:'', | ||
SHEET_DATA_S3_BUCKET:'', | ||
COGNITO_ID_JWK_BASE4:'', | ||
COGNITO_ACCESS_JWK_BASE4:'' | ||
} | ||
|
||
const createLocalEnv = () => { | ||
|
||
} | ||
|
||
const createEnv = (environment) => { | ||
if(environment === 'local') { | ||
var params = { | ||
}; | ||
dotenv.config({path: '../infrastructure.env'}); | ||
AWS.config.credentials = new AWS.Credentials(process.env.AWS_ACCESS_KEY_ID, process.env.AWS_SECRET_ACCESS_KEY); | ||
const cloudformation = new AWS.CloudFormation({ | ||
apiVersion: '2010-05-15' | ||
}); | ||
cloudformation.listExports(params, function(err, data) { | ||
if (err) console.log(err, err.stack); // an error occurred | ||
else console.log(data); // successful response | ||
}); | ||
} | ||
} | ||
|
||
module.exports = { | ||
createEnv | ||
}; | ||
|
||
|
||
// const readline = require('readline').createInterface({ | ||
// input: process.stdin, | ||
// output: process.stdout | ||
// }) | ||
// | ||
// readline.question(`What's your name?`, (name) => { | ||
// console.log(`Hi ${name}!`) | ||
// readline.close() | ||
// }) | ||
// console.log('HELLO'); | ||
// AWS_DEFAULT_REGION= | ||
// AWS_ACCESS_KEY_ID= | ||
// AWS_SECRET_ACCESS_KEY= | ||
// SAM_LOCAL_ABSOLUTE_PATH= | ||
// SAM_CLI_TELEMETRY=0 | ||
// PUBLIC_SHEETS_FOLDER= | ||
// SHEET_DATA_S3_BUCKET= | ||
// COGNITO_JWKS_BASE4= |
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,50 @@ | ||
const program = require('commander'); | ||
const { createEnv } = require('./create-env'); | ||
const { prompt } = require('inquirer'); | ||
const request = require('request'); | ||
|
||
program | ||
.description('Cheet Sheet Utility Functions'); | ||
|
||
program | ||
.command('create-env <environment>') | ||
.description('Add a contact') | ||
.action( (environment) => { | ||
createEnv(environment); | ||
}); | ||
|
||
program | ||
.command('generate COGNITO_JWKS_BASE64') | ||
.description('Add a contact') | ||
.action( (environment) => { | ||
|
||
prompt([ | ||
{ | ||
type : 'input', | ||
name : 'cognitoUserPoolId', | ||
message : 'Where is your Cognito User Pool ID' | ||
}, | ||
{ | ||
type : 'input', | ||
name : 'awsRegion', | ||
message : 'What is your AWS region' | ||
} | ||
]).then(answers => { | ||
const { cognitoUserPoolId, awsRegion } = answers | ||
request(`https://cognito-idp.${awsRegion}.amazonaws.com/${cognitoUserPoolId}/.well-known/jwks.json`, { json: false }, (err, res, body) => { | ||
|
||
if (err) { return console.log(err); } | ||
console.log('Retreived the following Json Web Key Set (JWKS) from AWS'); | ||
console.log(body); | ||
let buff = Buffer.from(body); | ||
console.log(); | ||
console.log('Here is the JWKS converted to Base64. Set this as the value of COGNITO_JWKS_BASE64 in local.env or remote.env.'); | ||
let base64body = buff.toString('base64'); | ||
console.log(base64body); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
|
||
program.parse(process.argv); |
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,18 @@ | ||
{ | ||
"name": "cheet-sheet-utils", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "main.js", | ||
"scripts": { | ||
"start": "node main.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"author": "", | ||
"dependencies": { | ||
"aws-sdk": "^2.592.0", | ||
"commander": "^4.0.1", | ||
"dotenv": "^8.2.0", | ||
"inquirer": "^7.0.1", | ||
"request": "^2.88.0" | ||
} | ||
} |
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
Oops, something went wrong.