Ed Walsh
asked on
Copy everything from an S3 Folder to a local drive on an EC2 Instance using Powershell
I have a folder in an S3 Bucket ( ppq-meta/sql ). Using powershell I want to copy everything in that S3 Bucket "ppq-meta" folder "sql" to a local drive z:\test\. This will be run on an EC2 instance, it already has AWS Powershell installed. Names for S3 bucket and for folder are in lowercase, I remember it being case sensitive.
I know I can do this with aws-cli but don't want to install aws-cli on instance:
What I have tried in Powershell is below, but it keeps giving me errors.
Error:
What am I doing wrong?
I know I can do this with aws-cli but don't want to install aws-cli on instance:
aws s3 cp s3://ppq-meta/sql z:\test --recursive
What I have tried in Powershell is below, but it keeps giving me errors.
Copy-S3Object -AccessKey Enter-Access-Key-Here -SecretKey Enter-Secret-Key-Here -BucketName ppq-meta -KeyPrefix sql -key "*.*" -LocalFolder z:\test
Error:
Copy-S3Object : A parameter cannot be found that matches parameter name 'KeyPrefix'.
At line:1 char:120
+ ... tName ppq-meta -KeyPrefix sql -key "*.*" -LocalFolder z:\test
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Copy-S3Object], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Amazon.PowerShell.Cmdlets.S3.CopyS3ObjectCmdlet
What am I doing wrong?
ASKER
@David Johnson, that didn't help same error. I also tried with single quotes ' and no quotes same results.
Copy-S3Object : A parameter cannot be found that matches parameter name 'KeyPrefix'.
At line:1 char:120
+ ... tName ppq-meta -KeyPrefix "sql" -key "*.*" -LocalFolder z:\test
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Copy-S3Object], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Amazon.PowerShell.Cmdlets.S3.CopyS3ObjectCmdlet
Are you using AWS Tools for Windows PowerShell or AWS Tools for PowerShell Core?
command works for AWS tools for Windows Powershell AFAIK
command works for AWS tools for Windows Powershell AFAIK
ASKER
I have the AWS Powershell Module that comes pre-installed with EC2 instances.
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 3.1.20.0 AWSPowerShell {Add-ASAAttachmentsToSet, Add-ASACommunicationToCase, Add-ASInstances, Add-ASLoadBalancer...}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Answers provided did not work, I continued to research issue and found the correct solution. Posting solution for any user who comes across the same issue that I had.
-KeyPrefix "sql"
https://docs.aws.amazon.com/powershell/latest/reference/items/Copy-S3Object.html