An interface to authenticate AWS api requests from within google apps scripts.
How to use:
-
Create a new project in google scripts.
-
Copy paste aws.js into it's own file in your project and save it.
-
Open up a new a file and setup the AWS variable with AWS.init.
-
Use AWS.request with whatever AWS API request you need! Make sure the headers and parameters are correctly set up, though. This function only sets up the Host, X-Amz-Date, X-Amz-Target, and Authorization headers by default.
Note: X-Amz-Target is (as far as I know) only used in POST requests and it is set to the "action" parameter provided by default.
Command usage:
AWS.request(service, region, action, params={}, method='GET', payload='', headers={"Host": GeneratedHost, "X-Amz-Date": GeneratedX-Amz-Date, "X-Amz-Target": action}, uri='/')
Example:
function myFunction() {
AWS.init("MY_ACCESS_KEY", "MY_SECRET_KEY");
var instanceXML = AWS.request('ec2', 'us-east-1', 'DescribeInstances', {"Version":"2015-10-01"});
...
}