An interface to authenticate AWS api requests from within google apps scripts.
Originaly forked from smithy545/aws-apps-scripts
Script ID: 1UmToPBwCgl8rjKHqqkgthduXt36tvv4CF985DEE0WAtx9UXFgA-QJ97n
-
Create a new project in google scripts.
-
Go
Resources → Libraries
. -
Copy paste Script ID to
Add a library
field and pressAdd
. -
Select version and specify identifier as
AWS
.
-
Create a new project in google scripts.
-
Copy paste
dist/aws-request.js
in your project file and save it. -
Go
File → Manage versions
and pressSave new version
. -
You can press
Share
and make it public. -
Copy you library Script ID from
File → Project properties → Script ID
-
Use new library with you Script ID in other projects Use public library.
-
Create a new project in google scripts.
-
Create new file in you project by template
var AWS = (function () {
// Copy paste `dist/aws-request.js` content here
return { request: request }
})()
Example with lambda function invocation
var path = '/2015-03-31/functions/hello/invocations';
var event = {
name: 'Google'
};
var result = AWS.request({
accessKey: AWS_ACCESS_KEY,
secretKey: AWS_SECRET_KEY,
service: 'lambda',
region: 'eu-west-1',
method: 'POST',
path: path,
payload: event
});
Logger.log(result.getResponseCode()); // ➝ 200
Logger.log(result.getContentText()); // ➝ { "message": "Hello Google!" }
Where params
:
Field name | Type | Default value | Description |
---|---|---|---|
accessKey |
string |
N/A (required) |
AWS access key |
secretKey |
string |
N/A (required) |
AWS secret key |
service |
string |
N/A (required) |
AWS service (e.g. ec2 , iam , codecommit ) |
region |
string |
us-east-1 |
AWS region |
path |
string |
/ |
Path to api function (without query) |
query |
object |
{} |
Query string parameters (e.g. { Action: "ListUsers" } ) |
method |
string |
GET |
Http method (e.g. GET , POST ) |
headers |
object |
{} |
Http request headers Host , and X-Amz-Date are premade for you |
payload |
string or object |
"" |
Payload to send (object payload will be stringified) |
Returns HTTPResponse
ISC © Vitaliy V. Makeev