This article will elaborate on the method of generating session tokens.
Generating Session Tokens
To generate the session tokens for AWS, you need to ensure that the AWS CLI tools are installed on your machine and that the AWS credentials are configured with your AWS CLI. So, let’s move to the first step, ensuring that the AWS CLI tools are installed on your machine. For this, open up either a command prompt or a PowerShell, and then type in the following command inside that:
When you execute this command, you will see the following output on the terminal:
This confirms that you have AWS CLI tools installed on your machine. However, if the AWS CLi tools are not installed, click here to install AWS CLI.
After that, you need to configure the AWS Credentials. Type the following command inside the PowerShell:
After that, you will be asked to provide your AWS Access Key ID, Secret Access Key, Preferred Region, and the default output format:
So provide these details in the PowerShell when they are asked. After that, your AWS credentials have been configured. After that, you can move on to get your session token.
To generate a new session token type, the following command:
Once you type that command, you will have to wait for a few seconds, then you will get the following output on the terminal:
As you can see, you get your session token on the PowerShell. This session token includes things:
- Access Key ID
- Secret Access Key
- Session Token
- Expiration Date for the Session Token
You can provide these details to the user to whom you want to provide access to AWS services.
Generate Session Token for a Specific Duration
The “get-session-token” command can also be used to generate a Session Token for a specific duration. To do this, you need to use the “–duration-seconds” flag to specify the duration in the form of seconds. Use the following command to generate the aws session tokens for 1800 seconds (30mins):
You will get the following output:
You have successfully generated an AWS Session Token for 30 mins.
Conclusion
The AWS Session Tokens can be easily generated with the AWS CLI. To do that, use the “aws sts get-session-token” command in either the command prompt or the PowerShell, and after a few seconds, you will have the details of your Session Tokens. You can also generate the session tokens for a specific amount of time using the “–duration-seconds” flags with the previous command. This Post has taught you to generate AWS Sessions Tokens.