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

Get-EC2IBDistributionConfiguration DistributionConfigurationArn parameter validation #150

Closed indented-automation closed 2 years ago

indented-automation commented 4 years ago

Get-EC2IBDistributionConfiguration fails to validate a valid ARN.

Expected Behavior

The command below should return one or more distribution configuration objects.

Get-EC2IBDistributionConfigurationList | Get-EC2IBDistributionConfiguration

Current Behavior

107|PS> get-EC2IBDistributionConfigurationlist | get-ec2ibdistributionconfiguration
Get-EC2IBDistributionConfiguration: The value supplied for parameter 'distributionConfigurationArn' is not valid. 'distributionConfigurationArn' must match pattern ^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):distribution-configuration/[a-z0-9-_]+$

Possible Solution

I expect the regex was supposed to be:

^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):distribution-configuration/[a-z0-9\-_]+$

or

^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):distribution-configuration/[a-z0-9_-]+$

The - character is only literal in a character class when it is at the beginning or end of the class.

Steps to Reproduce (for bugs)

A distribution configuration must exist to reproduce this. Must be created in the UI.

Context

Trying to manage EC2 Image Builder configuration in code.

Your Environment

indented-automation commented 4 years ago

Also applies to New-EC2IBImageRecipe and probably a few others. I imagine the regex is a common resource.

austoonz commented 4 years ago

In a similar repsonse to #152 - this is due to response objects using the property name "Arn", and the cmdlets using the full property name in their request objects.

To work around this one:

Get-EC2IBDistributionConfigurationList -Select DistributionConfigurationSummaryList.Arn |
    Get-EC2IBDistributionConfiguration

As with #152, this would need aliases added to cmdlets to accept Arn. (I am assuming that would work... I have definitely not tested if that's the case).

ashishdhingra commented 3 years ago

Hi @indented-automation,

Please confirm if the inputs provided above work for you.

Thanks, Ashish

indented-automation commented 3 years ago

It works, but this is counter-intuitive or I wouldn't have raised the issue in the first place. It's not a great design and it's not very user-friendly.

On Fri, 24 Jul 2020 at 01:12, ashishdhingra notifications@github.com wrote:

Hi @indented-automation https://github.com/indented-automation,

Please confirm if the inputs provided above work for you.

Thanks, Ashish

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aws/aws-tools-for-powershell/issues/150#issuecomment-663292326, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADB3UDU27H7KYCJJD2DVKLLR5DGXLANCNFSM4MQBDOTQ .

github-actions[bot] commented 2 years ago

We have noticed this issue has not recieved attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.