Skip to content

Commit c1b29a2

Browse files
committed
Merge pull request #42 from jjmartin/master
updated build script
2 parents 0faf82d + cafc043 commit c1b29a2

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

build.ps1

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,30 @@ Write-Zip -Path index.js,common.js,constants.js, kmsCrypto.js, upgrades.js, *.t
1212

1313

1414
if($deploy.IsPresent) {
15-
$zipFile = Resolve-Path "dist\AWSLambdaRedshiftLoader-$version.zip"
15+
$zipFilePath = Resolve-Path "dist\AWSLambdaRedshiftLoader-$version.zip"
1616

17-
Remove-LMFunction -FunctionName $functionname -Force
17+
Try
18+
{
19+
$deployedFn = Get-LMFunction -FunctionName $functionname
20+
"Function Exists - trying to update"
21+
try{
22+
[system.io.stream]$zipStream = [system.io.File]::OpenRead($zipFilePath)
23+
$ms = new-Object IO.MemoryStream
24+
$zipStream.CopyTo($ms);
25+
Update-LMFunctionCode -FunctionName $functionname -ZipFile $ms
26+
}
27+
catch{
28+
$ErrorMessage = $_.Exception.Message
29+
Write-Host $ErrorMessage
30+
Write-Host $_.Exception
31+
break
32+
}
1833

19-
Publish-LMFunction -FunctionName $functionname -FunctionZip $zipFile -Handler "index.handler" `
20-
-Runtime nodejs -Role $role_arn `
34+
}
35+
Catch [InvalidOperationException]{
36+
"Function is New - trying to Publish"
37+
Publish-LMFunction -FunctionName $functionname -FunctionZip $zipFilePath -Handler "index.handler" `
38+
-Runtime nodejs -Role $role_arn -Description "loads the unzipped csv's from billingUnzip into redshift tables" `
2139
-MemorySize 128 -Timeout 60 -region us-west-2
40+
}
2241
}

0 commit comments

Comments
 (0)