aws / aws-tools-for-powershell

The AWS Tools for PowerShell lets developers and administrators manage their AWS services from the PowerShell scripting environment.
Apache License 2.0
235 stars 77 forks source link

Install-AWSToolsModule -Cleanup uninstalls 4.1.31 #248

Closed mhunsber closed 2 years ago

mhunsber commented 2 years ago

Description

The most recent release doesn't have all 4 version parts, so if you run Install-AWSToolsModule -Name 'somename' -Cleanup, the installer will uninstall 4.1.31 because the uninstall command converts 4.1.31 to a "CleanVersion" of 4.1.31.0, but the module version is "4.1.31.(-1)".

Reproduction Steps

Logs

Install-AWSToolsModule -Name AWS.Tools.Route53 -CleanUp -Verbose -Confirm:$false                    VERBOSE: [Install-AWSToolsModule] ConfirmPreference=None WhatIfPreference=False VerbosePreference=Continue Force=False  Name=(AWS.Tools.Route53) RequiredVersion= SkipUpdate=False CleanUp=True                                                 VERBOSE: [Find-AWSToolsModule] ConfirmPreference=None WhatIfPreference=False VerbosePreference=Continue                 Name=(AWS.Tools.Route53)                                                                                                VERBOSE: [Find-AWSToolsModule] End                                                                                      VERBOSE: [Install-AWSToolsModule] Installing AWS Tools version 4.1.31                                                   VERBOSE: [Install-AWSToolsModule] Searching installed modules
VERBOSE: [Install-AWSToolsModule] Removing already installed modules from the. Final list of modules to install:
(AWS.Tools.Route53)
VERBOSE: Performing the operation "Install-AWSToolsModule" on target "AWS Tools version 4.1.31".
VERBOSE: [Install-AWSToolsModule] Create folder for temporary repository
C:\Users\bamboo\AppData\Local\Temp\ikjk4um3.igg
VERBOSE: [Install-AWSToolsModule] Registering temporary repository AWSToolsTemp
Package source with Name: AWSToolsTemp added successfully.
VERBOSE: [Install-AWSToolsModule] Downloading modules to temporary repository
VERBOSE: [Install-AWSToolsModule] Downloading modules (AWS.Tools.Route53)
VERBOSE: [Install-AWSToolsModule] Downloading module AWS.Tools.Route53 to
C:\Users\bamboo\AppData\Local\Temp\ikjk4um3.igg
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] ConfirmPreference=None WhatIfPreference=False
VerbosePreference=Continue Name=AWS.Tools.Route53
Path=C:\Users\bamboo\AppData\Local\Temp\ikjk4um3.igg\AWS.Tools.Route53.4.1.31.nupkg
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] Manifest signature correctly validated
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] Found dependency AWS.Tools.Common
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] End
VERBOSE: [Install-AWSToolsModule] Downloading module AWS.Tools.Common to
C:\Users\bamboo\AppData\Local\Temp\ikjk4um3.igg
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] ConfirmPreference=None WhatIfPreference=False
VerbosePreference=Continue Name=AWS.Tools.Common
Path=C:\Users\bamboo\AppData\Local\Temp\ikjk4um3.igg\AWS.Tools.Common.4.1.31.nupkg
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] Manifest signature correctly validated
VERBOSE: [Get-AWSToolsModuleDependenciesAndValidate] End
VERBOSE: [Install-AWSToolsModule] Installing modules (AWS.Tools.Route53)
Installing module AWS.Tools.Route53 version 4.1.31
VERBOSE: [Install-AWSToolsModule] Modules install complete
VERBOSE: [Install-AWSToolsModule] Unregistering temporary repository AWSToolsTemp
Package source with Name: AWSToolsTemp removed successfully.
VERBOSE: [Install-AWSToolsModule] Delete repository folder C:\Users\bamboo\AppData\Local\Temp\ikjk4um3.igg
VERBOSE: [Uninstall-AWSToolsModule] ConfirmPreference=None WhatIfPreference=False VerbosePreference=Continue
Force=False
VERBOSE: [Uninstall-AWSToolsModule] Searching installed modules
Uninstalling AWS.Tools version 4.1.31
Uninstalling module AWS.Tools.Route53
Uninstalling module AWS.Tools.Common
VERBOSE: [Uninstall-AWSToolsModule] End
VERBOSE: [Install-AWSToolsModule] End

Environment

Resolution


This is a :bug: bug-report

boblodgett commented 2 years ago

Reason for dropping trailing .0 from 4 part versions: https://github.com/PowerShell/PowerShellGallery/issues/217

Looking into Install-AWSToolsModule for this issue.

chris-peterson commented 2 years ago

I don't think the title and description express the magnitude of the issue -- I'd advocate for pulling 4.1.31 from PSGallery until the issue can be resolved.

I have this bit of code that makes sure the AWS tools I rely on are installed. This code runs both at the start of sessions on my local dev machine, also as part of a docker container build.

#!/usr/bin/env pwsh
$ErrorActionPreference='Stop'

$AWSToolModules = @{
    'AutoScaling'            = 'Get-ASAutoScalingGroup'
    'CertificateManager'     = 'Get-ACMCertificate'
    'CloudWatch'             = 'Get-CWMetricStatistic'
    'Common'                 = 'Get-DefaultAWSRegion'
    'DynamoDBv2'             = 'Get-DDBTable'
    'EC2'                    = 'Get-EC2Instance'
    'ECS'                    = 'Get-ECSCluster'
    'ElasticLoadBalancingV2' = 'Get-ELBV2LoadBalancer'
    'Elasticsearch'          = 'Get-ESDomain'
    'IdentityManagement'     = 'Get-IAMRole'
    'Route53'                = 'Get-R53ResourceRecordSet'
    'RDS'                    = 'Get-RDSDBInstance'
    'SecurityToken'          = 'Use-STSRoleWithSAML'
    'StorageGateway'         = 'Get-SGGateway'
}

function Install-AWSTools {
    foreach($Key in $AWSToolModules.Keys) {
        $Command = Get-Command -Name $AWSToolModules[$Key] -ErrorAction SilentlyContinue
        if(-not $Command) {
            Install-AWSToolsModule -Force -Cleanup "AWS.Tools.$($Key)"
        }
    }
}

Install-Package -Force 'AWS.Tools.Installer' | Out-Null
Install-AWSTools

To my surprise, after this code is executed, there are no tools modules installed. i.e. the only module left behind is AWS.Tools.Installer!

chris-peterson commented 2 years ago

As a workaround, I've added -MaximumVersion '4.1.30'

normj commented 2 years ago

We are treating this as a highly important issue and are working on the fix now. Rolling back the 300+ modules of 4.1.31 would take significant time away from getting the fix out for AWS.Tools.Installer.

chris-peterson commented 2 years ago

great -- thanks for the update @normj ! best of luck with the fix forward solution 🙏

normj commented 2 years ago

Version 1.0.2.3 of the AWS.Tools.Installer has been released that fixes the issue. Thank you for reporting the issue and sorry for the inconvenience. The PS Gallery's sudden refusal to accept packages that have a 0 in the 4th position in the version through us off in yesterday's build.

chris-peterson commented 2 years ago

Thank you for the quick fix!

I removed my earlier workaround and verified that everything installs correctly:

 docker run pwsh-toolbox:local pwsh -c 'Get-Module -ListAvailable' | grep 'AWS'
Binary     4.1.32                AWS.Tools.AutoScaling               Core,Desk
Binary     4.1.32                AWS.Tools.CertificateManager        Core,Desk
Binary     4.1.32                AWS.Tools.CloudWatch                Core,Desk
Binary     4.1.32                AWS.Tools.Common                    Core,Desk
Binary     4.1.32                AWS.Tools.DynamoDBv2                Core,Desk
Binary     4.1.32                AWS.Tools.EC2                       Core,Desk
Binary     4.1.32                AWS.Tools.ECR                       Core,Desk
Binary     4.1.32                AWS.Tools.ECS                       Core,Desk
Binary     4.1.32                AWS.Tools.ElasticLoadBalancingV2    Core,Desk
Binary     4.1.32                AWS.Tools.Elasticsearch             Core,Desk
Binary     4.1.32                AWS.Tools.IdentityManagement        Core,Desk
Script     1.0.2.3               AWS.Tools.Installer                 Core,Desk
Binary     4.1.32                AWS.Tools.RDS                       Core,Desk
Binary     4.1.32                AWS.Tools.Route53                   Core,Desk
Binary     4.1.32                AWS.Tools.SecurityToken             Core,Desk
Binary     4.1.32                AWS.Tools.StorageGateway            Core,Desk
github-actions[bot] commented 2 years ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.