aws-toolbox.psm1

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
$ErrorActionPreference = 'Stop'

# .NET compression libraries
'System.IO.Compression', 'System.IO.Compression.FileSystem' |
Foreach-Object {
    [System.Reflection.Assembly]::LoadWithPartialName($_) | Out-Null
}

# Get public and private function definition files.
$Public = @( Get-ChildItem -Path ([IO.Path]::Combine($PSScriptRoot, "Public", "*.ps1")) -Recurse -ErrorAction SilentlyContinue )
$Private = @( Get-ChildItem -Path ([IO.Path]::Combine($PSScriptRoot, "Private", "*.ps1")) -Recurse -ErrorAction SilentlyContinue )

# Dot source the files
foreach ($import in @($Public + $Private))
{
    try
    {
        . $import.FullName
    }
    catch
    {
        Write-Error -Message "Failed to import function $($import.FullName): $_"
    }
}

# Check what authentication is available
if (-not ((Test-ATEC2IsRunningInEC2) -or $null -ne (Get-Item variable:StoredAWSCredentials -ErrorAction SilentlyContinue) -or $null -ne (Get-AWSCredential -ProfileName default)))
{
    Write-Warning "No credential found. Please use Set-AWSCredential or Initialize-AWSDefaultConfiguration to set a credential before using commands in this module"
}

$script:PluginConfig = Import-PluginConfiguration
$script:moduleConfig = Import-AwsToolboxConfiguration

# Export public functions
Export-ModuleMember -Function $Public.Basename