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

Cannot pipe from Get-EC2IBComponentList to Get-EC2IBComponent #152

Closed indented-automation closed 2 years ago

indented-automation commented 4 years ago

It should be possible to pipe from Get-EC2IBComponentList to Get-EC2IBComponent.

Expected Behavior

The pipeline should correctly provide a value for the ARN needed by Get-EC2IBComponent.

Current Behavior

As the ComponentBuildVersionArn is suffixed with a numeric value Get-EC2IBComponentList cannot be effectively used to find the required ARN for a component. The trailing value must be guessed.

Steps to Reproduce (for bugs)

Get-EC2IBComponentList | Get-EC2IBComponent

Throws the error:

Get-EC2IBComponent: The value supplied for parameter 'componentBuildVersionArn' is not valid. 'componentBuildVersionArn' must match pattern ^arn:aws[^:]*:imagebuilder:[^:]+:(?:\d{12}|aws):component/[a-z0-9-_]+/\d+\.\d+\.\d+/\d+$

Please note that this command is also affected by the bug in #150

Context

Trying to manage EC2 Image Builder configuration in code.

Your Environment

austoonz commented 4 years ago

This does not work directly for a few reasons.

  1. Get-EC2IBComponentList returns an array of ComponentVersion objects (per the ListComponents API).
  2. Get-EC2IBComponent takes an input of a "ComponentBuildVersionArn" (as you can see in the GetComponent API reference.

To do this today, your best bet is to use the -Select parameter across a few cmdlets:

Get-EC2IBComponentList -Select ComponentVersionList.Arn | 
    Get-EC2IBComponentBuildVersionList -Select ComponentSummaryList.Arn | 
    Get-EC2IBComponent

For the SDK team - could we add an alias to these parameters to accept Arn? Eg, Get-EC2IBComponentBuildVersionList -> "ComponentVersionArn" accepts an alias of "Arn" Get-EC2IBComponent -> "ComponentBuildVersionArn" accepts an alias of "Arn"

This should enable:

Get-EC2IBComponentList | Get-EC2IBComponentBuildVersionList | Get-EC2IBComponent
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

As with the related issue.

This works, but it's counter-intuitive and not user-friendly.

Chris

On Fri, 24 Jul 2020 at 01:15, 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/152#issuecomment-663293126, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADB3UDX5K25OABU5QDTK2G3R5DHCFANCNFSM4MQB5AIA .

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.