Questions tagged [aws-cli]

The AWS Command Line Interface (CLI) is a unified tool to manage AWS services.

The AWS Command Line Interface (CLI) is a unified tool to manage AWS services. Multiple AWS services can be controlled via the command line and various actions can be automated through this tool.

Questions involving an alternate implementation for Windows PowerShell, AWS Tools for PowerShell, should be tagged with instead.

Resources

4345 questions
48
votes
6 answers

A client error (400) occurred when calling the HeadObject operation: Bad Request Completed 1 part(s) with ... file(s) remaining

I'm trying to copy a file from a private s3-bucket via cli to my ec2 instance. The ec2 is in the same region as the bucket and has the following IAM role attached (AmazonS3FullAccess): { "Version": "2012-10-17", "Statement": [ { "Effect":…
shootoke
  • 959
  • 1
  • 7
  • 8
46
votes
7 answers

Is there any way to get s3 uri from aws web console?

I want to download a directory from my s3. When I need a file, the s3 management console (aws web console) allows me to download it, but when a directory, I have to use aws-cli, like: $ aws s3 cp s3://mybucket/mydirectory/ . --recursive My question…
keisuke
  • 2,123
  • 4
  • 20
  • 31
46
votes
5 answers

Check if file exists in s3 using ls and wildcard

Seems so simple, but not getting the syntax right. I want to know if a file exists in my s3 bucket using wildcards. Something like aws s3 ls s3://my-bucket/folder/*myfile* The goal is to see if a file called 2016_myfile.txt or a file called…
Nicros
  • 5,031
  • 12
  • 57
  • 101
46
votes
8 answers

How to cp file only if it does not exist, throw error otherwise?

aws s3 cp "dist/myfile" "s3://my-bucket/production/myfile" It always copies myfile to s3 - I would like to copy file ONLY if it does no exist, throw error otherwise. How I can do it? Or at least how I can use awscli to check if file exists?
user606521
  • 14,486
  • 30
  • 113
  • 204
44
votes
27 answers

How to resolve: 'Unable to resolve AWS account to use. It must be either configured when you define your CDK or through the environment'

I am trying to run CDK commands to check the diff of my local and remote stack. I am using the following command. cdk diff --profile saml I am getting the following error message Unable to resolve AWS account to use. It must be either configured…
44
votes
1 answer

aws s3 replace file atomically

Environment I copied a file, ./barname.bin, to s3, using the command aws s3 cp ./barname.bin s3://fooname/barname.bin I have a different file, ./barname.1.bin that I want to upload in place of that file How can I upload and replace (overwrite)…
ThorSummoner
  • 16,657
  • 15
  • 135
  • 147
43
votes
6 answers

How to normalize a private key stored on AWS secrets manager

EDIT: AS OF Feb 2020, AWS SEEMS TO have FIXED THIS BUG. THE BASE64ing and other wise is no longer needed. I have my secret stored as a string but of course when aws stores the secret it removes white space and line breaks. On top of it it wraps the…
Josh Beauregard
  • 2,498
  • 2
  • 20
  • 37
43
votes
4 answers

AccessDeniedException: Unable to determine service/operation name to be authorized

Using AWS CLI aws --version aws-cli/1.11.21 Python/2.7.12 Darwin/15.3.0 botocore/1.4.78 Creating a POST method for API Gateway as explained at https://github.com/arun-gupta/serverless/tree/master/aws/microservice#post-method. This method can be…
Arun Gupta
  • 3,965
  • 5
  • 31
  • 39
43
votes
3 answers

Downloading the latest file in an S3 bucket using AWS CLI?

I have an S3 bucket that contains database backups. I am creating a script to download the latest backup (and eventually restore it somewhere else), but I'm not sure how to go about only grabbing the most recent file from a bucket. Is it possible to…
Abe Miessler
  • 82,532
  • 99
  • 305
  • 486
43
votes
6 answers

How to create folder on S3 from Ec2 instance

I want to create folder in S3 bucket from Ec2 instacne . I tried the put object but its not working . Is there any way of creating folder on s3 from ec2 instace using cli.
Shrikant
  • 753
  • 2
  • 10
  • 16
43
votes
2 answers

How can I get list of only running instances when using ec2-describe-tags

How can I get list of only running instances when using ec2-describe-tags. I am using my command like this: ec2-describe-tags --filter "resource-type=instance" --filter "value=somevalue" --filter "key=key"
user1788294
  • 1,823
  • 4
  • 24
  • 30
40
votes
6 answers

What is the difference between AWS_DEFAULT_REGION and AWS_REGION system variables?

Some examples in internet have AWS_DEFAULT_REGION env variable set but some others AWS_REGION. What is the difference? Which services use one or another?
Cherry
  • 31,309
  • 66
  • 224
  • 364
40
votes
6 answers

How to run aws configure on Amazon AWS EC2 automatically without interaction without prompt?

I'm trying to set up Amazon AWS EC2 instance to talk to s3. The basic command is aws configure then follow the prompt to enter AWS Access Key ID [None]: my-20-digit-id AWS Secret Access Key [None]: my-40-digit-secret-key Default region name…
Tony Xu
  • 3,031
  • 4
  • 32
  • 43
39
votes
1 answer

AWS CLI config file vs. credentials file

I understand the AWS CLI can make use of the config and credentials files for storing it's local profile configurations. Does anyone know of any general guidance and or best practice with regards to what should go in each file?
PicoutputCls
  • 1,392
  • 1
  • 12
  • 24
39
votes
1 answer

Download s3 bucket files on user's local using aws cli

How to download simple storage service(s3) bucket files directly on user's local machine?
Axxy
  • 431
  • 1
  • 4
  • 3