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
236 stars 78 forks source link

Install-AWSToolsModule Does not work in windows docker container #118

Closed bo67192 closed 4 years ago

bo67192 commented 4 years ago

Hello,

I'm trying to test the AWS.Tools modules in a windows docker container. I'm using

mcr.microsoft.com/windows/servercore:1803

And running

docker run -it -v "$($home)/.aws:c:\users\containeradministrator\.aws" mcr.microsoft.com/windows/servercore:1803  powershell

Then I try

Install-Module -Name AWS.Tools.Installer (and accept the prompts)

Then I ran

Install-AWSToolsModule AWS.Tools.EC2 (and accept prompts)

But afterwards running Get-ec2instance doesn't work.

If I run

install-module AWS.Tools.Common
install-module AWS.Tools.EC2

I can run Get-ec2instance without issue.

Any suggestions?

matteo-prosperi commented 4 years ago

Hello, thanks for opening this issue. If you are able to provide the -Verbose output for Install-AWSToolsModule, I would love to try and figure out why this is failing.

I don't think you really need to use AWS.Tools.Installer, though. AWS.Tools.Installer is especially useful to support the update of multiple AWS.Tools modules or the installation of a new module on top of an existing set of other preinstalled modules. If I understand your problem correctly, being in a container, you will always only install a set of AWS.Tools modules on a "clean" container, you will never have to update them. So using Install-Module is simpler and likely faster in this context.

bo67192 commented 4 years ago

@matteo-prosperi using the same docker run command as before

docker run -it -v "$($home)/.aws:c:\users\containeradministrator\.aws" mcr.microsoft.com/windows/servercore:1803  powershell

And then running (and accepting the prompts)

Install-Module -Name AWS.Tools.Installer -verbose

I get this

PS C:\> Install-Module -Name AWS.Tools.Installer -verbose

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program
Files\PackageManagement\ProviderAssemblies' or 'C:\Users\ContainerAdministrator\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running
'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y
VERBOSE: Installing NuGet provider.
VERBOSE: Using the provider 'Bootstrap' for searching packages.
VERBOSE: Finding the package 'Bootstrap::FindPackage' 'NuGet','','2.8.5.201','''.
VERBOSE: Installing the package 'https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag'.
VERBOSE: Installed the package 'nuget' to 'C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll'.
VERBOSE: Importing the package provider NuGet
VERBOSE: The provider 'NuGet' has already been imported. Trying to import it again.
VERBOSE: Loading an assembly 'C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll'.
VERBOSE: Imported provider 'C:\Program Files\PackageManagement\ProviderAssemblies\nuget\2.8.5.208\Microsoft.PackageManagement.NuGetProvider.dll' .
VERBOSE: The provider 'NuGet' has already been imported. Trying to import it again.
VERBOSE: Importing package provider 'NuGet'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='AWS.Tools.Installer'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'AWS.Tools.Installer'.
VERBOSE: Performing the operation "Install-Module" on target "Version '1.0.1.0' of module 'AWS.Tools.Installer'".

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to
install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y
VERBOSE: The installation scope is specified to be 'AllUsers'.
VERBOSE: The specified module will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'AWS.Tools.Installer' with version '1.0.1.0' from the repository 'https://www.powershellgallery.com/api/v2'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='AWS.Tools.Installer'' for ''.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PowerShellGet'' for ''.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='PackageManagement'' for ''.
VERBOSE: InstallPackage' - name='PackageManagement', version='1.4.6',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\1482514289'
VERBOSE: DownloadPackage' - name='PackageManagement', version='1.4.6',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\1482514289\PackageManagement\PackageManagement.nupkg',
uri='https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.6'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.6'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/PackageManagement/1.4.6'.
VERBOSE: Completed downloading 'PackageManagement'.
VERBOSE: Hash for package 'PackageManagement' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='PackageManagement', version='1.4.6',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\1482514289'
VERBOSE: InstallPackage' - name='PowerShellGet', version='2.2.3',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\1482514289'
VERBOSE: DownloadPackage' - name='PowerShellGet', version='2.2.3',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\1482514289\PowerShellGet\PowerShellGet.nupkg',
uri='https://www.powershellgallery.com/api/v2/package/PowerShellGet/2.2.3'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/PowerShellGet/2.2.3'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/PowerShellGet/2.2.3'.
VERBOSE: Completed downloading 'PowerShellGet'.
VERBOSE: Hash for package 'PowerShellGet' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='PowerShellGet', version='2.2.3',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\1482514289'
VERBOSE: InstallPackage' - name='AWS.Tools.Installer', version='1.0.1.0',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\1482514289'
VERBOSE: DownloadPackage' - name='AWS.Tools.Installer', version='1.0.1.0',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\1482514289\AWS.Tools.Installer\AWS.Tools.Installer.nupkg',
 uri='https://www.powershellgallery.com/api/v2/package/AWS.Tools.Installer/1.0.1'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/AWS.Tools.Installer/1.0.1'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/AWS.Tools.Installer/1.0.1'.
VERBOSE: Completed downloading 'AWS.Tools.Installer'.
VERBOSE: Hash for package 'AWS.Tools.Installer' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='AWS.Tools.Installer', version='1.0.1.0',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\1482514289'
VERBOSE: Found the catalog file 'PackageManagement.cat' in the module 'PackageManagement' contents.
VERBOSE: Valid authenticode signature found in the catalog file 'PackageManagement.cat' for the module 'PackageManagement'.
VERBOSE: Validating the 'PackageManagement' module files for catalog signing using the catalog file 'PackageManagement.cat'.
VERBOSE: The catalog signature in 'PackageManagement.cat' of the module 'PackageManagement' is valid and matches with the hash generated from the module contents.
VERBOSE: For publisher validation, current module 'PackageManagement' with version '1.4.6' with publisher name 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond,
S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: For publisher validation, using the previously-installed module 'PackageManagement' with version '1.0.0.1' under 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1'
with publisher name 'CN=Microsoft Root Certificate Authority 2010, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: Publisher 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of the new module 'PackageManagement' with version '1.4.6' matches with
the publisher 'CN=Microsoft Root Certificate Authority 2010, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of the previously-installed module 'PackageManagement' with version '1.0.0.1'.
Both versions are signed with a Microsoft root certificate.
VERBOSE: Installing the dependency module 'PackageManagement' with version '1.4.6' for the module 'AWS.Tools.Installer'.
VERBOSE: Module 'PackageManagement' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.6'.
VERBOSE: Found the catalog file 'PowerShellGet.cat' in the module 'PowerShellGet' contents.
VERBOSE: Valid authenticode signature found in the catalog file 'PowerShellGet.cat' for the module 'PowerShellGet'.
VERBOSE: Validating the 'PowerShellGet' module files for catalog signing using the catalog file 'PowerShellGet.cat'.
VERBOSE: The catalog signature in 'PowerShellGet.cat' of the module 'PowerShellGet' is valid and matches with the hash generated from the module contents.
VERBOSE: For publisher validation, current module 'PowerShellGet' with version '2.2.3' with publisher name 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond,
S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: For publisher validation, using the previously-installed module 'PowerShellGet' with version '1.0.0.1' under 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1' with
publisher name 'CN=Microsoft Root Certificate Authority 2010, O=Microsoft Corporation, L=Redmond, S=Washington, C=US'. Is this module signed by Microsoft: 'True'.
VERBOSE: Publisher 'CN=Microsoft Root Certificate Authority 2011, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of the new module 'PowerShellGet' with version '2.2.3' matches with the
publisher 'CN=Microsoft Root Certificate Authority 2010, O=Microsoft Corporation, L=Redmond, S=Washington, C=US' of the previously-installed module 'PowerShellGet' with version '1.0.0.1'. Both
versions are signed with a Microsoft root certificate.
VERBOSE: Installing the dependency module 'PowerShellGet' with version '2.2.3' for the module 'AWS.Tools.Installer'.
VERBOSE: Module 'PowerShellGet' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.3'.
VERBOSE: Catalog file 'AWS.Tools.Installer.cat' is not found in the contents of the module 'AWS.Tools.Installer' being installed.
VERBOSE: Valid authenticode signature found in the file 'AWS.Tools.Installer.psd1' for the module 'AWS.Tools.Installer'.
VERBOSE: Module 'AWS.Tools.Installer' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\AWS.Tools.Installer\1.0.1.0'.

And then running

Install-Module -Name AWS.Tools.EC2 -verbose

I get this

PS C:\> Install-Module -Name AWS.Tools.EC2 -verbose
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='AWS.Tools.EC2'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'AWS.Tools.EC2'.
VERBOSE: Performing the operation "Install-Module" on target "Version '4.0.2.0' of module 'AWS.Tools.EC2'".

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to
install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): Y
VERBOSE: The installation scope is specified to be 'AllUsers'.
VERBOSE: The specified module will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading module 'AWS.Tools.EC2' with version '4.0.2.0' from the repository 'https://www.powershellgallery.com/api/v2'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='AWS.Tools.EC2'' for ''.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='AWS.Tools.Common'' for ''.
VERBOSE: InstallPackage' - name='AWS.Tools.Common', version='4.0.2.0',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\887940566'
VERBOSE: DownloadPackage' - name='AWS.Tools.Common', version='4.0.2.0',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\887940566\AWS.Tools.Common\AWS.Tools.Common.nupkg',
uri='https://www.powershellgallery.com/api/v2/package/AWS.Tools.Common/4.0.2'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/AWS.Tools.Common/4.0.2'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/AWS.Tools.Common/4.0.2'.
VERBOSE: Completed downloading 'AWS.Tools.Common'.
VERBOSE: Hash for package 'AWS.Tools.Common' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='AWS.Tools.Common', version='4.0.2.0',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\887940566'
VERBOSE: InstallPackage' - name='AWS.Tools.EC2', version='4.0.2.0',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\887940566'
VERBOSE: DownloadPackage' - name='AWS.Tools.EC2', version='4.0.2.0',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\887940566\AWS.Tools.EC2\AWS.Tools.EC2.nupkg',
uri='https://www.powershellgallery.com/api/v2/package/AWS.Tools.EC2/4.0.2'
VERBOSE: Downloading 'https://www.powershellgallery.com/api/v2/package/AWS.Tools.EC2/4.0.2'.
VERBOSE: Completed downloading 'https://www.powershellgallery.com/api/v2/package/AWS.Tools.EC2/4.0.2'.
VERBOSE: Completed downloading 'AWS.Tools.EC2'.
VERBOSE: Hash for package 'AWS.Tools.EC2' does not match hash provided from the server.
VERBOSE: InstallPackageLocal' - name='AWS.Tools.EC2', version='4.0.2.0',destination='C:\Users\ContainerAdministrator\AppData\Local\Temp\887940566'
VERBOSE: Catalog file 'AWS.Tools.Common.cat' is not found in the contents of the module 'AWS.Tools.Common' being installed.
VERBOSE: Valid authenticode signature found in the file 'AWS.Tools.Common.psd1' for the module 'AWS.Tools.Common'.
VERBOSE: Installing the dependency module 'AWS.Tools.Common' with version '4.0.2.0' for the module 'AWS.Tools.EC2'.
VERBOSE: Module 'AWS.Tools.Common' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\AWS.Tools.Common\4.0.2.0'.
VERBOSE: Catalog file 'AWS.Tools.EC2.cat' is not found in the contents of the module 'AWS.Tools.EC2' being installed.
VERBOSE: Valid authenticode signature found in the file 'AWS.Tools.EC2.psd1' for the module 'AWS.Tools.EC2'.
VERBOSE: Module 'AWS.Tools.EC2' was installed successfully to path 'C:\Program Files\WindowsPowerShell\Modules\AWS.Tools.EC2\4.0.2.0'.

Fair point on never needing to upgrade inside of the container, but it's nice that it handles the dependencies for you. Is this documentation open source that I could add a note about using Install-Module when you're in a docker container?

bo67192 commented 4 years ago

Actually, this is working for me now

Get-EC2Ins and tab auto completes and loads the module. Works much faster than the old version.

I'll close this. Thanks to whoever fixed it!