-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupload_lambda.ps1
More file actions
43 lines (31 loc) · 1.21 KB
/
upload_lambda.ps1
File metadata and controls
43 lines (31 loc) · 1.21 KB
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
# Build and zip Lambda function for AWS deployment
param(
[Parameter(Mandatory=$true)]
[string]$FunctionName
)
Write-Host "Building Lambda function..." -ForegroundColor Green
# Build the project
dotnet publish .\src\AutoInvest\AutoInvest.csproj -c Release -r linux-x64 --self-contained false -o publish
if ($LASTEXITCODE -ne 0) {
Write-Host "Build failed!" -ForegroundColor Red
exit 1
}
Write-Host "Creating deployment package..." -ForegroundColor Green
# Remove old zip if it exists
if (Test-Path "lambda-deploy.zip") {
Remove-Item "lambda-deploy.zip"
}
# Create zip file
Compress-Archive -Path "publish\*" -DestinationPath "lambda-deploy.zip"
Write-Host "Deployment package created: lambda-deploy.zip" -ForegroundColor Green
# Clean up publish folder
Remove-Item -Recurse -Force "publish"
# Deploy to AWS Lambda
Write-Host "Deploying to AWS Lambda..." -ForegroundColor Green
# Deploy using AWS CLI
aws lambda update-function-code --no-cli-pager --function-name $FunctionName --zip-file fileb://lambda-deploy.zip
if ($LASTEXITCODE -ne 0) {
Write-Host "Deployment failed!" -ForegroundColor Red
exit 1
}
Write-Host "Successfully deployed to Lambda function: $FunctionName" -ForegroundColor Green