How to execute a script in your AWS account
Table of Contents
ToggleFor this article i will be using WSL (Windows subsystem for Linux) and i will show you how to execute a script in AWS account.
What will you need :
- access to an AWS account to retrieve the set of credentials
- the script you want to execute
1. Set AWS Credentials in WSL
How to set AWS credentials in your WSL ?
1. Inside WSL type the command aws configure
. It will prompt to add the: access key ID, secret access key, default region and output format (e.g. json)
2. After setting the credentials proceed with the following command vim ~/.aws/credentials
to add also the session token to the credentials file. On the opened file, insert a new line -> aws_session_token= <insert token here>.
* to save press Esc,
type :wq!
and hit Enter
3. Test with an AWS cli command ( e.g. aws s3 ls ). It should list you all the buckets present in that respective account.
2. Create and execute the script in AWS
1. Create the script that you need. Remember the .sh file always has in the first line #!/bin/bash expression.
2. Make the file executable with the following comand :
chmod +x <filename>
. E.g. chmod +x script-test.sh
3. Last step would be to execute the script with the following command : .<filename>
. In my case would be .script-test.sh