• Skip to primary navigation
  • Skip to main content

Josh Withee

  • Home
  • Blog
  • Contact
  • Show Search
Hide Search

How To Download All Lambda Functions From AWS Using PowerShell

Josh Withee · July 22, 2022 · Leave a Comment

Download all of your Lambda functions from AWS using this Windows PowerShell script

function MyLambdaDownloaderFunction{
param ([Parameter(Mandatory = $true)] [String] $FunctionName)
Write-Output "Downloading $FunctionName..."
$loc = aws lambda get-function --function-name $FunctionName --query 'Code.Location'
$loc = ($loc -replace '"', "")
Invoke-WebRequest -Uri $loc -OutFile .\lambda_functions\$FunctionName.zip
}

mkdir -p lambda_functions

$a = aws lambda list-functions
$b = $a -split "`r`n" | Select-String -Pattern '(?<="FunctionName": ")[-\w]+'
$c = $b.Matches | Select-Object -Property "Value"

foreach ($funcName in $c) {
	MyLambdaDownloaderFunction -FunctionName $funcName.Value
}

Write-Output "Completed Downloading all the Lamdba Functions!"

Related

Uncategorized AWS, Lambda, PowerShell

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023