Google Apps Script wrapper for authenticated REST API requests to Amazon Web Services (AWS).
Add the contents of aws.js
and util.js
into new script files in your
project as these are required. Repeat for any additional service wrappers
(i.e. s3.js
) as desired.
Add the our existing Google Apps Script project as a Library as outlined at https://developers.google.com/apps-script/guides/libraries
Project key MUSi7a5HbvN3pxQdnYlZDjhqZNV8Hxu00
Versions of the Google Apps Script project map to tags on this Git repository.
The AWS portion is the only required section. All other files represent shortcut functions to simplify interactions with that service.
Not all services have been wrapped, nor has every function within the service API been implemented as a function.
Generic wrapper for API requests to Amazon Web Services that should be compatible with all AWS services as follows:
-
Initialize AWS variable using
AWS.init
passing access and secret keys. -
Use
AWS.request
with whichever AWS API request you need. Consult AWS documentation to ensure headers and parameters are passed correctly. This function only sets up theHost
,X-Amz-Date
,X-Amz-Target
, andAuthorization
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={},
uri='/'
);
Example:
function myFunction() {
AWS.init("MY_ACCESS_KEY", "MY_SECRET_KEY");
var responseXML = AWS.request(
'ec2',
'us-east-1',
'DescribeInstances',
{ "Version":"2015-10-01" }
);
...
}
Initialize the S3 variable using S3.init
similar to how AWS variable is
described above.
Functions implemented so far:
- listAllMyBuckets()
- getObject(bucketName, objectName, region)
- putObject(bucketName, objectName, object, region)
- deleteObject(bucketName, objectName, region)