Search code examples
amazon-web-servicesamazon-s3aws-cli

How do you get the latest version of an s3 object using aws cli?


Using the AWS CLI, how do I output a most recent VersionId string of an S3 object?


Solution

  • Simplifying @rynop's command:

    aws s3api list-object-versions --bucket us-east-1--aws-blueprint.mydomain.com --prefix my/object/key.ext --query 'Versions[?IsLatest].[VersionId]' --output text