Skip to content
This repository has been archived by the owner on Oct 21, 2023. It is now read-only.

Get-TemplateValidation fails with no error #68

Closed
indented-automation opened this issue Feb 25, 2020 · 6 comments
Closed

Get-TemplateValidation fails with no error #68

indented-automation opened this issue Feb 25, 2020 · 6 comments

Comments

@indented-automation
Copy link
Collaborator

Description

Get-TemplateValidation appears to fail, but does not return an error, script stack trace, or exception stack trace that can be used to fix the problem.

Steps to reproduce

$template = Initialize-Vaporshell
$params = @{
    LogicalId          = 'vpc'
    CidrBlock          = '10.0.0.0/24'
    EnableDnsHostnames = $true
    EnableDnsSupport   = $true
}
$template.AddResource((
    New-VSEC2VPC @params
))
$params = @{
    Path               = 'c:\temp\test.json'
    VaporShellTemplate = $template
    Force              = $true
    ValidateTemplate   = $true
    Verbose            = $true
}
Export-VaporShell @params

Expected output

An error message describing the problem it has with the template.

Actual output

VERBOSE: Converting template object to JSON
Get-TemplateValidation :
At C:\Users\chris\documents\WindowsPowerShell\Modules\VaporShell\2.10.1.20200220\VaporShell.psm1:650 char:13
+             Get-TemplateValidation -TemplateBody ($Final -join "`n")
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-TemplateValidation], Exception
    + FullyQualifiedErrorId : Get-TemplateValidation

VERBOSE: Exporting template to: c:\temp\test.json

Environment information

Name                           Value
----                           -----
PSVersion                      5.1.18362.628
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.18362.628
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

20|PS> Get-Module VaporShell, AWSPowerShell | Select-Object Name, Version

Name          Version
----          -------
AWSPowerShell 4.0.4.0
VaporShell    2.10.1.20200220
@indented-automation
Copy link
Collaborator Author

Okay, root cause is that I don't have a credentials file and was hoping having one. I have my credentials stored elsewhere.

However, the lack of error is frustrating and seems to be caused by this in ProcessRequest4:

        catch {
           return (New-VSError -String "$($Error[0].Exception.Message)")
        }

If I change this to the following, I get a useful error message.

        catch {
           return (New-VSError -String "$($_.Exception.Message)")
        }

Can't say why $Error is empty, but $_ is much more specific in catch anyway.

@indented-automation
Copy link
Collaborator Author

Last comment, sorry for extending the thread!

Given that this problem is in a generic function, does VaporShell support loading credentials from the environment variables? Will I bump into problems given that everything I do will be under an assumed role?

@scrthq
Copy link
Member

scrthq commented Feb 25, 2020

@indented-automation heyo! Thanks for opening this up!! It's been designed so far with the Shared Credentials file in mind, but it's using the AWS .NET SDK under the hood for any of the SDK related commands.

Thanks for the note about the catch failing with no data, definitely worth flipping if that provides the expected error output 🙂

Regarding the environment variables, that should be doable after a little work. Ultimately, assuming a role should grant you a session token still (at least that's how I'm doing it with AssumeRoleWithSAML). I'll likely want to expand the parameters available on the SDK calls to include the standard credential params.

When you assume a role, are you using the AWS .NET SDK to do so, whether directly or through one of the AWS modules? If so, are you using the .NET Credential Store to store those session credentials that the SDK uses by default?

@indented-automation
Copy link
Collaborator Author

indented-automation commented Feb 25, 2020 via email

@scrthq
Copy link
Member

scrthq commented Feb 28, 2020

@indented-automation - Let me know how this build works for you!

VaporShell-2.11.0.20200228.zip

scrthq added a commit that referenced this issue Mar 4, 2020
## 2.11.0 - 2020-03-04

* [Issue #69](#69) + [PR #70](#70) - _Thanks, [@indented-automation](https://github.com/indented-automation)!!!_
  * Started `VaporShell.Core` class library to include with the module, first class being `TransformTagAttribute` to cleanly convert `Tags` parameter input to the appropriate format if not already.
  * Added Pester tests to confirm Tag transforms are working as expected.
* [Issue #68](#68) - _Thanks, [@indented-automation](https://github.com/indented-automation) and [@austoonz](https://github.com/austoonz)!!!_
  * Surfaced errors better on AWS SDK errors so the actual error is visible.
  * Added the `FallbackCredentialFactory` to better support running in environments where credentials files are not a practical option.
* Miscellaneous
  * Updated PseudoParameter list to current spec.
  * Added newer intrinsic functions `Add-FnCidr` and `Add-FnTransform`.
@scrthq scrthq mentioned this issue Mar 4, 2020
scrthq added a commit that referenced this issue Mar 4, 2020
## 2.11.0 - 2020-03-04

* [Issue #69](#69) + [PR #70](#70) - _Thanks, [@indented-automation](https://github.com/indented-automation)!!!_
  * Started `VaporShell.Core` class library to include with the module, first class being `TransformTagAttribute` to cleanly convert `Tags` parameter input to the appropriate format if not already.
  * Added Pester tests to confirm Tag transforms are working as expected.
* [Issue #68](#68) - _Thanks, [@indented-automation](https://github.com/indented-automation) and [@austoonz](https://github.com/austoonz)!!!_
  * Surfaced errors better on AWS SDK errors so the actual error is visible.
  * Added the `FallbackCredentialFactory` to better support running in environments where credentials files are not a practical option.
* Miscellaneous
  * Updated PseudoParameter list to current spec.
  * Added newer intrinsic functions `Add-FnCidr` and `Add-FnTransform`.
@scrthq
Copy link
Member

scrthq commented Mar 4, 2020

Deployed in 2.11.0.x!

@scrthq scrthq closed this as completed Mar 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants