Skip to content

Commit 47b683f

Browse files
author
joshuat
committed
Allowing the app to be packaged with custom env config
1 parent 275f204 commit 47b683f

File tree

2 files changed

+13
-32
lines changed

2 files changed

+13
-32
lines changed

index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
var AWS = require('aws-sdk');
23
var Dyno = require('dyno');
34
var queue = require('queue-async');
@@ -9,11 +10,6 @@ module.exports.streambotReplicate = streambot(replicate);
910
module.exports.backup = incrementalBackup;
1011
module.exports.streambotBackup = streambot(incrementalBackup);
1112

12-
//process.env.BackupBucket = 'pageup-dynamo-tokyo'
13-
//process.env.BackupPrefix = 'forms'
14-
//process.env.MultiTenancyColumn = 'RANGE'
15-
//process.env.PlainTextKeyAsFilename = true;
16-
1713
function replicate(event, context, callback) {
1814
var replicaConfig = {
1915
table: process.env.ReplicaTable,

package.ps1

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,23 @@ New-Item .\package -type directory -f
44
New-Item .\package\temp -type directory -f
55
Copy-Item .\backup.js .\package\temp\
66
Copy-Item .\diff.js .\package\temp\
7-
Copy-Item .\index.js .\package\temp\
87
Copy-Item .\s3-backfill.js .\package\temp\
98
Copy-Item .\s3-snapshot.js .\package\temp\
109
Copy-Item .\node_modules\ .\package\temp\ -recurse
1110

12-
$dc2 = New-Object System.Management.Automation.Host.ChoiceDescription "&2", "Deploys to dc2"
13-
$dc3 = New-Object System.Management.Automation.Host.ChoiceDescription "&3", "Deploys to dc3"
14-
$dc4 = New-Object System.Management.Automation.Host.ChoiceDescription "&4", "Deploys to dc4"
15-
$dc5 = New-Object System.Management.Automation.Host.ChoiceDescription "&5", "Deploys to dc5"
16-
$dc6 = New-Object System.Management.Automation.Host.ChoiceDescription "&6", "Deploys to dc6"
17-
$dc7 = New-Object System.Management.Automation.Host.ChoiceDescription "&7", "Deploys to dc7"
18-
$dc8 = New-Object System.Management.Automation.Host.ChoiceDescription "&8", "Deploys to dc8"
19-
20-
Write-Output "Which DC would you like to deploy to?"
21-
$options = [System.Management.Automation.Host.ChoiceDescription[]]($dc2, $dc3, $dc4, $dc5, $dc6, $dc7, $dc8)
22-
$result = $host.ui.PromptForChoice($title, $message, $options, 0)
23-
$dcDeploy = 0
24-
25-
switch ($result)
26-
{
27-
0 {$dcDeploy = 2}
28-
1 {$dcDeploy = 3}
29-
2 {$dcDeploy = 4}
30-
3 {$dcDeploy = 5}
31-
4 {$dcDeploy = 6}
32-
5 {$dcDeploy = 7}
33-
6 { $dcDeploy = 8}
34-
}
35-
Copy-Item .\config\dc$dcDeploy.env .\package\temp\deploy.env
11+
$environmentFile = Read-Host -Prompt 'Enter the name of the config file you would like to add to your deployment (e.g. dcx.env)'
12+
13+
$currentdir = $PSScriptRoot
14+
15+
New-Item .\package\temp\index.js -type file -f
16+
17+
get-content .\config\$environmentFile,".\index.js" | set-content ".\package\temp\index.js"
3618

3719
$version = Read-Host -Prompt 'What version of the application are you deploying?'
3820

39-
$currentdir = $PSScriptRoot
21+
$destination = $currentdir + "\package\" + $version + ".zip"
22+
4023
Add-Type -assembly "system.io.compression.filesystem"
41-
[io.compression.zipfile]::CreateFromDirectory($currentdir + "\package\temp", $currentdir + ".\package\" + $version + ".zip")
24+
[io.compression.zipfile]::CreateFromDirectory($currentdir + "\package\temp", $destination)
25+
26+
Write-Output "lambda app ready to be uploaded. Located at: " $destination

0 commit comments

Comments
 (0)