title: How to run aws configure on Amazon AWS EC2 automatically without interaction without prompt?
body: <p>I'm trying to set up Amazon AWS EC2 instance to talk to s3. The basic command is </p>
  
  <pre><code>aws configure
  </code></pre>
  
  <p>then follow the prompt to enter</p>
  
  <pre><code>AWS Access Key ID [None]: my-20-digit-id
  AWS Secret Access Key [None]: my-40-digit-secret-key
  Default region name [None]: us-east-1
  Default output format [None]: text
  </code></pre>
  
  <p>However, what I really want is to have the command </p>
  
  <pre><code>aws configure
  </code></pre>
  
  <p>automatically without interaction, i.e., no prompt and wait for input</p>
  
  <p>I know there are files at</p>
  
  <pre><code>~.aws/credentials
  ~.aws/config
  </code></pre>
  
  <p>where I put those 4 key=value pairs. And the "credentials" file looks like</p>
  
  <pre><code>[default]
  aws_secret_access_key = my-40-digit-secret-key
  aws_access_key_id = my-20-digit-id
  </code></pre>
  
  <p>while the "config" file looks like</p>
  
  <pre><code>[default]
  region = us-east-1
  output = text
  </code></pre>
  
  <p>However, with those file at ~/.aws/, I get into ~/.aws/, and at the command line, I type and enter command </p>
  
  <pre><code>aws configure
  </code></pre>
  
  <p>I still got the prompt to ask me</p>
  
  <pre><code>AWS Access Key ID [None]:
  AWS Secret Access Key [None]:
  Default region name [None]:
  Default output format [None]:
  </code></pre>
  
  <p>If I don't enter valid values at prompt, I won't be able to connect to s3, for example via command</p>
  
  <pre><code>aws s3 ls s3://mybucket
  </code></pre>
  
  <p>I turned help to amazon aws documentation pages. At this page, it mentions this option</p>
  
  <p>"Command line options – region, output format and profile can be specified as command options to override default settings."</p>
  
  <p>as the first option for aws configure</p>
  
  <p><a href="https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html" rel="noreferrer">https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html</a></p>
  
  <p>However, it didn't mention how to use the command line options. I tried something like this</p>
  
  <pre><code>aws configure --region us-east-1
  </code></pre>
  
  <p>but I still got</p>
  
  <pre><code>AWS Access Key ID [None]:
  AWS Secret Access Key [None]:
  Default region name [None]:
  Default output format [None]:
  </code></pre>
  
  <p>exactly like I have no option of "--region us-east-1"</p>
  
  <p>If I try to </p>
  
  <pre><code>aws configure --aws_access_key_id my-20-digit-id --aws_secret_access_key my-40-digit-secret-key --region us-east-1
  </code></pre>
  
  <p>I get this</p>
  
  <pre><code>usage: aws [options] &lt;command&gt; &lt;subcommand&gt; [parameters]
  aws: error: argument subcommand: Invalid choice, valid choices are:
  </code></pre>
  
  <p>How I can run the command </p>
  
  <pre><code>aws configure
  </code></pre>
  
  <p>automatically, no prompt, no interaction.</p>
  
  <p>Please help! TIA</p>
  
  <p>Edit and response to helloV, as the format in main post is much clearer than comment.
  I tried the command helloV mentioned, but I got error</p>
  
  <pre><code>aws configure set aws_access_key_id my-20-digit-id
  usage: aws [options] &lt;command&gt; &lt;subcommand&gt; [parameters]
  aws: error: argument subcommand: Invalid choice, valid choices are:
  </code></pre>
  
  <p>Thanks though.
  Continue on "aws configure set"
  On another EC2 instance where I've already set connection to s3, I enter</p>
  
  <pre><code>aws configure set region us-east-1
  </code></pre>
  
  <p>runs and returns to command prompt ">"</p>
  
  <pre><code>aws configure set aws_access_key_id my-20-digit-id
  </code></pre>
  
  <p>runs and returns to command prompt ">"</p>
  
  <pre><code>aws configure set aws_secret_access_key my-40-digit-secret-key
  </code></pre>
  
  <p>runs and returns to command prompt ">"</p>
  
  <pre><code>aws configure
  </code></pre>
  
  <p>runs but comes with prompts and waits for interaction</p>
  
  <pre><code>AWS Access Key ID [****************ABCD]:
  AWS Secret Access Key [****************1234]:
  Default region name [us-east-1]:
  Default output format [text]:
  </code></pre>
  
  <p>helloV:
  here is my screen looks like</p>
  
  <pre><code>ubuntu@ip-11111:~/.aws$ more config
  [default]
  region = us-east-1
  output = text
  ubuntu@ip-11111:~/.aws$ more credentials
  [default]
  aws_secret_access_key = my-40-digit-secret-key
  aws_access_key_id = my-20-digit-id
  ubuntu@ip-11111:~/.aws$ aws s3 ls s3://
  </code></pre>
  
  <p>I got this</p>
  
  <pre><code>Unable to locate credentials. You can configure credentials by running "aws configure".
  </code></pre>
  
  <p>After this, I run</p>
  
  <pre><code>aws configure list
    Name                    Value             Type    Location
    ----                    -----             ----    --------
  profile                &lt;not set&gt;             None    None
  access_key                &lt;not set&gt;             None    None
  secret_key                &lt;not set&gt;             None    None
  region                us-east-1      config_file    ~/.aws/config
  </code></pre>
  
  <p>Looks like it does not check ~/.aws/credentials file, but ~/.aws/config file is in the list.</p>