title: aws cli copy between S3 regions on EC2
body: <p>I am trying to copy between two S3 buckets in different regions using the Command Line Interface on an EC2 server.</p>
  
  <p>region info:<br>
  EC2 instance: us-west-2<br>
  S3 origin: us-east-1<br>
  S3 destination: us-west-2<br></p>
  
  <p>The following commands work perfectly from the EC2 server: <br>
  <code>aws s3 cp s3://n-virginia/origin s3://n-virginia/destination  --recursive  --source-region us-east-1 --region us-east-1 --profile my_profile</code><br><br>
  <code>aws s3 cp s3://oregon/origin s3://oregon/destination  --recursive  --source-region us-west-2 --region us-west-2 --profile my_profile</code><br><br></p>
  
  <p>I need to run the following command from the EC2 server:<br>
  <code>aws s3 cp s3://n-virginia/origin s3://oregon/destination  --recursive  --source-region us-east-1 --region us-west-2 --profile my_profile</code> <br><br> </p>
  
  <p>If I run that command from a local machine it works, but if I run it from the EC2 server that I used for the previous two commands I get the following error:</p>
  
  <p>Error:<code>"A client error (AccessDenied) occurred when calling the CopyObject operation: VPC endpoints do not support cross-region requests"</code></p>
  
  <p>I am able to copy the files from the origin bucket to the EC2 server, and then copy from the EC2 server to the destination bucket, but this is not an acceptable solution in production. I don't understand why it will work on a local machine but not on the EC2 server ("my_profile" is identical on both machines)</p>