From 50c9ff00f4dd39eee0ef3fdea46979e05ffec27d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=B6tz=20Jensen?= Date: Wed, 26 Aug 2026 19:13:48 +0200 Subject: [PATCH 1/3] Feature: Add support for S3 connections / buckets --- .../internal/arms/API.Amazon.S3.json | 16 +++ .../internal/tasks/All/All.task.ps1 | 108 ++++++++++++++++++ ....ManagedApis.AmazonS3.AsArmObject.task.ps1 | 106 +++++++++++++++++ 3 files changed, 230 insertions(+) create mode 100644 PsLogicAppExtractor/internal/arms/API.Amazon.S3.json create mode 100644 PsLogicAppExtractor/internal/tasks/Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject.task.ps1 diff --git a/PsLogicAppExtractor/internal/arms/API.Amazon.S3.json b/PsLogicAppExtractor/internal/arms/API.Amazon.S3.json new file mode 100644 index 0000000..2b5466c --- /dev/null +++ b/PsLogicAppExtractor/internal/arms/API.Amazon.S3.json @@ -0,0 +1,16 @@ +{ + "type": "Microsoft.Web/connections", + "apiVersion": "2018-07-01-preview", + "name": "##NAME##", + "location": "[parameters('logicAppLocation')]", + "properties": { + "api": { + "id": "[subscriptionResourceId('Microsoft.Web/locations/managedApis', parameters('logicAppLocation'), 'amazons3')]" + }, + "displayName": "##NAME##", + "parameterValues": { + "accessKeyId": "[parameters('##ACCESSKEYID##')]", + "accessKeySecret": "[parameters('##ACCESSKEYSECRET##')]" + } + } +} diff --git a/PsLogicAppExtractor/internal/tasks/All/All.task.ps1 b/PsLogicAppExtractor/internal/tasks/All/All.task.ps1 index 6b73b6c..76c838a 100644 --- a/PsLogicAppExtractor/internal/tasks/All/All.task.ps1 +++ b/PsLogicAppExtractor/internal/tasks/All/All.task.ps1 @@ -118,6 +118,114 @@ Task -Name "Export-LogicApp" @parm -Action { Out-TaskFile -InputObject $resObj } +#Original file: Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject.task.ps1 +$parm = @{ + Description = @" +Loops all `$connections children +-Validates that is of the type AmazonS3 +--Creates a new resource in the ARM template, for the ApiConnection object +--With matching ARM Parameters, for the 'Access Key Secret' as a Secure String +--Makes sure the ARM Parameters logicAppLocation exists +--Displayname is extracted from the Api Connection Object +--The displayname will be configured to be the same as the name of the connection +Requires an authenticated session, either Az.Accounts or az cli +"@ + Alias = "Arm.Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject" +} + +Task -Name "Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject" @parm -Action { + Set-TaskWorkDirectory + + # We can either use the az cli or the Az modules + $tools = Get-PSFConfigValue -FullName PsLogicAppExtractor.Execution.Tools + + $found = $false + $conType = "amazons3" + + $armObj = Get-TaskWorkObject + + foreach ($connectionObj in $armObj.resources[0].properties.parameters.'$connections'.value.PsObject.Properties) { + if ($connectionObj.Value.id -like "*managedApis/amazons3*"` + -and (-not ($connectionObj.Value.id -like "*[*(*)*]*"))) { + + $found = $true + + # Fetch the details from the connection object + $uri = "{0}?api-version=2018-07-01-preview" -f $($connectionObj.Value.connectionId) + + if ($tools -eq "AzCli") { + $resObj = az rest --url $uri | ConvertFrom-Json + } + else { + $resObj = Invoke-AzRestMethod -Path $uri -Method Get | Select-Object -ExpandProperty content | ConvertFrom-Json + } + + # Use the display name as the name of the resource + $conName = $resObj.Properties.DisplayName + + # Fetch base template + $pathArms = "$(Get-PSFConfigValue -FullName PsLogicAppExtractor.ModulePath.Base)\internal\arms" + $apiObj = Get-Content -Path "$pathArms\API.Amazon.S3.json" -Raw | ConvertFrom-Json + + # Set the names of the parameters + $Prefix = Get-PSFConfigValue -FullName PsLogicAppExtractor.prefixsuffix.connection.prefix + $parmApicId = Format-Name -Type "Connection" -Prefix $Prefix -Value "$($connectionObj.Name)" + + $parmApicAccessKeyId = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_AccessKeyId" -Value "$($connectionObj.Name)" + $parmApicAccessKeySecret = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_AccessKeySecret" -Value "$($connectionObj.Name)" + + $armObj = Add-ArmParameter -InputObject $armObj -Name "$parmApicId" ` + -Type "string" ` + -Value $conName ` + -Description "The name / id of the ManagedApi connection object that is being utilized by the Logic App. Will be for the trigger and other actions that depend on connections." + + $armObj = Add-ArmParameter -InputObject $armObj -Name "$parmApicAccessKeyId" ` + -Type "string" ` + -Value "$($resObj.Properties.parameterValues.accessKeyId)" ` + -Description "The Access Key as provided from Amazon." + + $armObj = Add-ArmParameter -InputObject $armObj -Name "$parmApicAccessKeySecret" ` + -Type "SecureString" ` + -Value "" ` + -Description "The Secret Access Key as provided from Amazon." + + # Update the api object properties + $apiObj.Name = "[parameters('$parmApicId')]" + $apiObj.properties.displayName = "[parameters('$parmApicId')]" + + $apiObj.properties.parameterValues.accessKeyId = "[parameters('$parmApicAccessKeyId')]" + $apiObj.properties.parameterValues.accessKeySecret = "[parameters('$parmApicAccessKeySecret')]" + + # Append the new resource to the ARM template + $armObj.resources += $apiObj + + if ($null -eq $armObj.resources[0].dependsOn) { + # Create the dependsOn array if it does not exist + $armObj.resources[0] | Add-Member -MemberType NoteProperty -Name "dependsOn" -Value @() + } + + # Add the new resource to the dependsOn array, so that the deployment will work + $armObj.resources[0].dependsOn += "[resourceId('Microsoft.Web/connections', parameters('$parmApicId'))]" + + # Adjust the connection object to depend on the same name + $connectionObj.Value.connectionId = "[resourceId('Microsoft.Web/connections', parameters('$parmApicId'))]" + $connectionObj.Value.connectionName = "[parameters('$parmApicId')]" + $connectionObj.Value.id = "[format('/subscriptions/{0}/providers/Microsoft.Web/locations/{1}/managedApis/$conType', subscription().subscriptionId, parameters('logicAppLocation'))]" + } + } + + if ($found) { + if ($null -eq $armObj.parameters.logicAppLocation) { + $armObj = Add-ArmParameter -InputObject $armObj -Name "logicAppLocation" ` + -Type "string" ` + -Value "[resourceGroup().location]" ` + -Description "Location of the Logic App. Best practice recommendation is to make this depending on the Resource Group and its location." + } + } + + Out-TaskFileArm -InputObject $armObj +} + #Original file: Set-Arm.Connections.ManagedApis.AmazonSQS.AsArmObject.task.ps1 $parm = @{ Description = @" diff --git a/PsLogicAppExtractor/internal/tasks/Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject.task.ps1 b/PsLogicAppExtractor/internal/tasks/Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject.task.ps1 new file mode 100644 index 0000000..38b31e5 --- /dev/null +++ b/PsLogicAppExtractor/internal/tasks/Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject.task.ps1 @@ -0,0 +1,106 @@ +$parm = @{ + Description = @" +Loops all `$connections children +-Validates that is of the type AmazonS3 +--Creates a new resource in the ARM template, for the ApiConnection object +--With matching ARM Parameters, for the 'Access Key Secret' as a Secure String +--Makes sure the ARM Parameters logicAppLocation exists +--Displayname is extracted from the Api Connection Object +--The displayname will be configured to be the same as the name of the connection +Requires an authenticated session, either Az.Accounts or az cli +"@ + Alias = "Arm.Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject" +} + +Task -Name "Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject" @parm -Action { + Set-TaskWorkDirectory + + # We can either use the az cli or the Az modules + $tools = Get-PSFConfigValue -FullName PsLogicAppExtractor.Execution.Tools + + $found = $false + $conType = "amazons3" + + $armObj = Get-TaskWorkObject + + foreach ($connectionObj in $armObj.resources[0].properties.parameters.'$connections'.value.PsObject.Properties) { + if ($connectionObj.Value.id -like "*managedApis/amazons3*"` + -and (-not ($connectionObj.Value.id -like "*[*(*)*]*"))) { + + $found = $true + + # Fetch the details from the connection object + $uri = "{0}?api-version=2018-07-01-preview" -f $($connectionObj.Value.connectionId) + + if ($tools -eq "AzCli") { + $resObj = az rest --url $uri | ConvertFrom-Json + } + else { + $resObj = Invoke-AzRestMethod -Path $uri -Method Get | Select-Object -ExpandProperty content | ConvertFrom-Json + } + + # Use the display name as the name of the resource + $conName = $resObj.Properties.DisplayName + + # Fetch base template + $pathArms = "$(Get-PSFConfigValue -FullName PsLogicAppExtractor.ModulePath.Base)\internal\arms" + $apiObj = Get-Content -Path "$pathArms\API.Amazon.S3.json" -Raw | ConvertFrom-Json + + # Set the names of the parameters + $Prefix = Get-PSFConfigValue -FullName PsLogicAppExtractor.prefixsuffix.connection.prefix + $parmApicId = Format-Name -Type "Connection" -Prefix $Prefix -Value "$($connectionObj.Name)" + + $parmApicAccessKeyId = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_AccessKeyId" -Value "$($connectionObj.Name)" + $parmApicAccessKeySecret = Format-Name -Type "Connection" -Prefix $Prefix -Suffix "_AccessKeySecret" -Value "$($connectionObj.Name)" + + $armObj = Add-ArmParameter -InputObject $armObj -Name "$parmApicId" ` + -Type "string" ` + -Value $conName ` + -Description "The name / id of the ManagedApi connection object that is being utilized by the Logic App. Will be for the trigger and other actions that depend on connections." + + $armObj = Add-ArmParameter -InputObject $armObj -Name "$parmApicAccessKeyId" ` + -Type "string" ` + -Value "$($resObj.Properties.parameterValues.accessKeyId)" ` + -Description "The Access Key as provided from Amazon." + + $armObj = Add-ArmParameter -InputObject $armObj -Name "$parmApicAccessKeySecret" ` + -Type "SecureString" ` + -Value "" ` + -Description "The Secret Access Key as provided from Amazon." + + # Update the api object properties + $apiObj.Name = "[parameters('$parmApicId')]" + $apiObj.properties.displayName = "[parameters('$parmApicId')]" + + $apiObj.properties.parameterValues.accessKeyId = "[parameters('$parmApicAccessKeyId')]" + $apiObj.properties.parameterValues.accessKeySecret = "[parameters('$parmApicAccessKeySecret')]" + + # Append the new resource to the ARM template + $armObj.resources += $apiObj + + if ($null -eq $armObj.resources[0].dependsOn) { + # Create the dependsOn array if it does not exist + $armObj.resources[0] | Add-Member -MemberType NoteProperty -Name "dependsOn" -Value @() + } + + # Add the new resource to the dependsOn array, so that the deployment will work + $armObj.resources[0].dependsOn += "[resourceId('Microsoft.Web/connections', parameters('$parmApicId'))]" + + # Adjust the connection object to depend on the same name + $connectionObj.Value.connectionId = "[resourceId('Microsoft.Web/connections', parameters('$parmApicId'))]" + $connectionObj.Value.connectionName = "[parameters('$parmApicId')]" + $connectionObj.Value.id = "[format('/subscriptions/{0}/providers/Microsoft.Web/locations/{1}/managedApis/$conType', subscription().subscriptionId, parameters('logicAppLocation'))]" + } + } + + if ($found) { + if ($null -eq $armObj.parameters.logicAppLocation) { + $armObj = Add-ArmParameter -InputObject $armObj -Name "logicAppLocation" ` + -Type "string" ` + -Value "[resourceGroup().location]" ` + -Description "Location of the Logic App. Best practice recommendation is to make this depending on the Resource Group and its location." + } + } + + Out-TaskFileArm -InputObject $armObj +} From e63ae5c1549ab7903844d701d6c6d7fd7b35518f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=B6tz=20Jensen?= Date: Wed, 26 Aug 2026 19:18:58 +0200 Subject: [PATCH 2/3] Feature: Add support for S3 connections / buckets --- PsLogicAppExtractor/internal/arms/API.Amazon.S3.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PsLogicAppExtractor/internal/arms/API.Amazon.S3.json b/PsLogicAppExtractor/internal/arms/API.Amazon.S3.json index 2b5466c..53a0183 100644 --- a/PsLogicAppExtractor/internal/arms/API.Amazon.S3.json +++ b/PsLogicAppExtractor/internal/arms/API.Amazon.S3.json @@ -1,4 +1,4 @@ -{ +{ "type": "Microsoft.Web/connections", "apiVersion": "2018-07-01-preview", "name": "##NAME##", From 645240bc94ca542a7486711244aa2489cbff7165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=B6tz=20Jensen?= Date: Wed, 26 Aug 2026 19:23:41 +0200 Subject: [PATCH 3/3] Feature: Add support for S3 connections / buckets --- ...et-Arm.Connections.ManagedApis.AmazonS3.AsArmObject.task.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PsLogicAppExtractor/internal/tasks/Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject.task.ps1 b/PsLogicAppExtractor/internal/tasks/Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject.task.ps1 index 38b31e5..46ce3ec 100644 --- a/PsLogicAppExtractor/internal/tasks/Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject.task.ps1 +++ b/PsLogicAppExtractor/internal/tasks/Set-Arm.Connections.ManagedApis.AmazonS3.AsArmObject.task.ps1 @@ -1,4 +1,4 @@ -$parm = @{ +$parm = @{ Description = @" Loops all `$connections children -Validates that is of the type AmazonS3