forked from ubaniabalogun/uscis-case-status-notifier
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.js
86 lines (80 loc) · 2.08 KB
/
config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
const prompt = require('cli-prompt')
const AWS = require('aws-sdk')
const package = require('./package.json')
// Collect environment variables for Lambda Function and Upload them to SSM
let prompt_questions = [
{
key: 'uscisReceiptNum',
label: 'USCIS Case Receipt Number'
},
{
key: 'twilioAccountSid',
label: 'Twilio Account SID'
},
{
key: 'twilioAuthToken',
type: 'password',
label: 'Twilio Auth Token'
},
{
key: 'twilioNumber',
label: 'Twilio Phone Number (include country code)',
},
{
key: 'recipientNumber',
label: 'Recipient Number (include country code)'
}
]
prompt.multi(prompt_questions, function(results) {
let envVariables = [
{
Name: '/twilio/account_sid',
Type: 'SecureString',
Value: results.twilioAccountSid,
Description: 'Twilio Account SID',
Overwrite: true
},
{
Name: '/twilio/auth_token',
Type: 'SecureString',
Value: results.twilioAuthToken,
'Description': "Twilio Auth Token",
Overwrite: true
},
{
Name: '/twilio/phonenumber',
Type: 'SecureString',
Value: results.twilioNumber,
Description: 'Twilio Phone Number',
Overwrite: true
},
{
Name: '/uscis/receipt_number',
Type: 'SecureString',
Value: results.uscisReceiptNum,
Description: 'USCIS Case Receipt Number',
Overwrite: true
},
{
Name: '/uscis/recipient_number',
Type: 'SecureString',
Value: results.recipientNumber,
Description: "Recipient's Number",
Overwrite: true
}
]
const awsCreds = new AWS.SharedIniFileCredentials({profile: package.config.awsProfile })
const ssm = new AWS.SSM({credentials: awsCreds , region: package.config.region })
envVariables.forEach( function(variable) {
ssm.putParameter(variable, (err, data) => {
if (err) {
console.log(err, err.stack)
}else {
console.log(`Uploaded ${variable.Description} to AWS SSM Parameter Store`)
}
})
})
console.log("uscis-case-status-notifier is ready to deploy.")
},
console.error
)