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

Add-ConIf cannot be used as a value for a parameter #82

Closed
indented-automation opened this issue Jul 28, 2020 · 2 comments
Closed

Add-ConIf cannot be used as a value for a parameter #82

indented-automation opened this issue Jul 28, 2020 · 2 comments
Assignees
Labels

Comments

@indented-automation
Copy link
Collaborator

Description

JSON and YAML templates imply that is should be possible to use an If condition as the value for a parameter. However, this fails parameter validation.

Steps to reproduce

$Template = Initialize-VaporShell
$params = @{
    LogicalID      = 'AWSConfigRecorder'
    Name           = 'config-recorder'
    RoleARN        = Add-FnGetAtt -LogicalNameOfResource IamRoleAWSConfig -AttributeName Arn
    RecordingGroup = Add-VSConfigConfigurationRecorderRecordingGroup -AllSupported $true -IncludeGlobalResourceTypes (
        Add-ConIf -ConditionName IsActiveRegion -ValueIfTrue 'true' -ValueIfFalse 'false'
    )
}
$Template.AddResource((
    New-VSConfigConfigurationRecorder @params
))

Expected result

Should allow a template to be generated containing the following content:

"ConfigRecorder": {
    "Type": "AWS::Config::ConfigurationRecorder",
    "Properties": {
        "RoleARN": {
            "Fn::GetAtt": [
                "IamRoleAWSConfig ",
                "Arn"
            ]
        },
        "RecordingGroup": {
            "AllSupported": true,
            "IncludeGlobalResourceTypes": {
                "Fn::If": [
                    "IncludeGlobalResourceTypes",
                    true,
                    false
                ]
            }
        }
    }
}

Actual result

An error is raised:

Add-VSConfigConfigurationRecorderRecordingGroup:
Line |
   5 |  … dingGroup = Add-VSConfigConfigurationRecorderRecordingGroup -AllSuppo …
     |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | This parameter only accepts the following types: System.Boolean, Vaporshell.Function. The current types of the value are: Vaporshell.Condition.If, Vaporshell.Condition, System.Management.Automation.PSCustomObject, System.Object.

Related to #81 for handling of bool values in ValueIfTrue and ValueIfFalse.

@scrthq scrthq self-assigned this Jul 30, 2020
@scrthq scrthq added the bug label Jul 30, 2020
@scrthq
Copy link
Member

scrthq commented Jul 31, 2020

How's this look @indented-automation ?

image

scrthq added a commit that referenced this issue Jul 31, 2020
## 2.13.0 - 2020-07-30

* [Issue #81](#81)
    * Fixed: `Add-ConIf` parameter error message
    * Fixed: `Add-ConIf` now allows boolean values
* [Issue #82](#82)
    * Fixed: Condition Functions are now supported on any parameter that already accepts Intrinsic Functions
* Miscellaneous
    * Updated PseudoParameter list to current spec.
scrthq added a commit that referenced this issue Jul 31, 2020
## 2.13.0 - 2020-07-30

* [Issue #81](#81)
    * Fixed: `Add-ConIf` parameter error message.
    * Fixed: `Add-ConIf` now allows boolean values.
* [Issue #82](#82)
    * Fixed: Condition Functions are now supported on any parameter that already accepts Intrinsic Functions.
* Miscellaneous
    * Updated PseudoParameter list to current spec.
    * Switched default branch from `master`
@scrthq
Copy link
Member

scrthq commented Jul 31, 2020

Fix deployed with version 2.13.0.20200731!

image

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

No branches or pull requests

2 participants