| by Arround The Web | No comments

What are the Environment Variables to Configure the AWS CLI?

Amazon has a load of cloud services for various solutions and uses. It offers a ton of cloud services and applications to help users architect their own solutions. It has an interactive interface to access the services and tools on the platform. AWS services and applications can also be accessed and used through the AWS Command Line Interface (CLI).

This article will be a brief introduction to the AWS CLI and the environment variables required to configure the AWS CLI.

What is AWS CLI?

It is an open-source command line tool to access your AWS account and use the services and applications just like the console. With the help of a few commands, users can create their solutions with any graphical interface such as in AWS Console. It is quite easy and simple to install AWS CLI.

Before using AWS CLI, there are a few environment variables that are configured. This article will explain the environment variables and how to configure them.

What are the Environment Variables to Configure the AWS CLI?

To use AWS services, variables are required according to their given environment called environment variables. These variables are configured before using the AWS services through CLI. Some of these variables are given below:

Let us discuss these configuration variables for CLI in detail and how they are used:

AWS_ACCESS_KEY_ID

This variable holds the access key id which is a unique identifier of your requests with your AWS account. Open CMD and set this variable using the command given below:

set AWS_ACCESS_KEY_ID=<Your Access Key ID>

 
The access key id is set now. There will be no responsive output to the command as shown in the figure below:


Let us head to the next environment variable:

AWS_SECRET_ACCESS_KEY

This variable holds the corresponding pass key to the above-mentioned “Key_ID”. The following command configures this pass key:

set AWS_SECRET_ACCESS_KEY=<Your secret key>

 
This command also has no visible output on the screen but this environment variable is set. Refer to the image below:


Let us head to the next environment variable:

AWS_DEFAULT_REGION

This environment variable defines the region of your AWS account. Use the code below to set the desired region:

set AWS_DEFAULT_REGION==<Your region>

 
See the below image for a better understanding:


Let us move on to the next environment variable:

AWS_SESSION_TOKEN

This variable comes into play when security credentials are required on a temporary basis. Security Token Service (STS) serves the purpose of allowing temporary access with the help of session tokens. Use the below command to set the session token:

set AWS_SESSION_TOKEN=<Your Session Token>

 
See the below image for a better understanding:


Let us head to the next variable in line:

AWS_DEFAULT_OUTPUT

This configuration variable sets the output data type. The default output data type is JSON. Let us change this to text. See the code below:

set AWS_DEFAULT_OUTPUT=text

 
Again, there is no visible output of the command but the output data type has been changed to text. See the below image for a better understanding:


There is another way where all the above environment variables can be configured with one command except for “AWS_SESSION_TOKEN”. Use the command below:

aws configure

 
The below output can be seen on the screen:


Provide the details according to the fields.

Miscellaneous

There are a ton of other environment variables that can be set when using different services of AWS. The variables that are discussed above are the core and fundamental variables. Click here to view all the variables that can be configured using AWS CLI.

The commands we used in the above scenarios are supported by the “WINDOWS” terminal, i.e., “CMD”. Let us see the Linux commands to configure AWS CLI environment variables.

Linux

The process of configuring AWS CLI environment variables is the same. The commands are the same as Windows. For “Linux” simply replace “set” with “export” in the commands that are given above.

This article has concisely explained the environment variable to configure the AWS CLI.

Conclusion

AWS CLI provides a powerful solution to use AWS cloud services without the console. There are a number of environment variables, such as “AWS_ACCESS_KEY_ID”, “AWS_SECRET_ACCESS_KEY”, “AWS_DEFAULT_REGION”, “AWS_SESSION_TOKEN”, and “AWS_DEFAULT_OUTPUT” that can be set with the help of AWS CLI. This article is a tutorial for configuring AWS CLI environment variables.

Share Button

Source: linuxhint.com

Leave a Reply