Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting the delimiter parameter for Get-S3ObjectV2 should return a collection of objects #234

Open
githpuk opened this issue Oct 15, 2021 · 4 comments
Assignees
Labels
doc-developerguide documentation This is a problem with documentation. feature-request A feature should be added or improved. module/powershell-cmdlets p2 This is a standard priority issue queued

Comments

@githpuk
Copy link

githpuk commented Oct 15, 2021

Currently setting the delimiter property when calling the PowerShell cmdlet Get-S3ObjectV2 appears to have no effect and requires accessing the $AWSHistory cmdlet buffer to determine results, returned as CommonPrefixes. This makes little sense (to me anyway) when it could return a collection of the objects matching the delimiter.

Instead I propose that it return a Contents collection of objects that match the delimiter.

This would allow requesting a list of "folders" simply by setting the parameter to '/'

This would allow easy iteration through s3 folders which would both simplify and reduce the amount of PowerShell script required for, in my case, a lambda function as no access to $AWSHistory would be needed.

@githpuk githpuk added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Oct 15, 2021
@ashishdhingra
Copy link
Contributor

Hi @githpuk,

Thanks for submitting feature request. Could you please confirm if the Delimiter parameter is working as per requested behavior in earlier Get-S3Object CmdLet (which uses ListObjects API operation)? The new Get-S3ObjectV2 CmdLet uses ListObjectsV2 API operation which also supports Delimiter parameter. Both ListObject and ListObjectV2 API operations mention delimiter as a character you use to group keys. The way delimiter is used is controlled by the service API and modifying the default behavior could be a breaking change for existing customer.

Thanks,
Ashish

@ashishdhingra ashishdhingra added response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. and removed needs-triage This issue or PR still needs to be triaged. labels Oct 15, 2021
@githpuk
Copy link
Author

githpuk commented Oct 18, 2021

Hi @ashishdhingra

Get-S3Object works the same as Get-S3ObjectV2 when it comes to delimiter behaviour. I'm not suggesting that you change existing behaviour rather enhance the PowerShell cmdlet to behave in a more typical PowerShell manner. From a PowerShell user perspective, having to access $AWSHistory to get the results of a call is atypical. Calling Get-S3Object or Get-S3ObjectV2 with the delimiter set returns $null, implying nothing matched when this is not the case as the results are within $AWSHistory.

Hope that's a bit clearer.

@github-actions github-actions bot removed the response-requested Waiting on additional info and feedback. Will move to "closing-soon" in 7 days. label Oct 19, 2021
@jberezanski
Copy link

It seems it is possible to obtain the list of "folders", without reaching to $AWSHistory, by using -Select:

PS> Get-S3Object -BucketName my-bucket -Delimiter '/' -Select CommonPrefixes
Prefix1/
Prefix2/

However, this is certainly not intuitive. It would help if such an example was added to the documentation of Get-S3Object/Get-S3ObjectV2.

@ashishdhingra ashishdhingra added the p2 This is a standard priority issue label Dec 21, 2022
@ashishdhingra ashishdhingra added documentation This is a problem with documentation. doc-developerguide queued and removed needs-review labels Apr 7, 2023
@jnunn-aws
Copy link
Contributor

AWS Tools for PowerShell is designed to simplify the majority of cmdlet invocations by unwrapping AWS response objects so that the single-most pertinent property is passed to the pipeline/host. This creates edge cases where some additional properties might be discarded by default.

As Jakub pointed out, the -Select parameter is provided to override this behavior including returning the entire response object if needed. The user guide and cmdlet examples have highlighted the $AWSHistory variable as the primary workaround.

We will revise documentation to increase recommendation of the -Select parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-developerguide documentation This is a problem with documentation. feature-request A feature should be added or improved. module/powershell-cmdlets p2 This is a standard priority issue queued
Projects
None yet
Development

No branches or pull requests

4 participants