Last active
August 21, 2018 03:20
-
-
Save chochinlu/0323a0f2d2e8cc9d4539afa02d1a7044 to your computer and use it in GitHub Desktop.
aws-sdk ReasonML binding testing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const AWS = require("aws-sdk"); | |
const credentials = new AWS.SharedIniFileCredentials({ | |
profile: "xxx-dev" | |
}); | |
AWS.config.credentials = credentials; | |
const LAMBDA_REGION = "ap-southeast-1"; | |
AWS.config.update({ region: LAMBDA_REGION }); | |
const params = { | |
limit: 2 | |
// logGroupNamePrefix: '', | |
}; | |
const cloudwatchlogs = new AWS.CloudWatchLogs({ apiVersion: "2014-03-28" }); | |
cloudwatchlogs.describeLogGroups(params, (err, data) => { | |
if (err) console.log(err, err.stack); | |
else console.log(data); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type credentialObj = {. "profile": string}; | |
[@bs.deriving abstract] | |
type awsConfig = {mutable credentials: credentialObj}; | |
type aws = {. config: awsConfig}; | |
[@bs.obj] | |
external makeCredentialObj : (~profile: string) => credentialObj = ""; | |
[@bs.module "aws-sdk"] [@bs.new] | |
external sharedIniFileCredentials : credentialObj => credentialObj = | |
"SharedIniFileCredentials"; | |
let c = makeCredentialObj(~profile="xxxx-dev") |> sharedIniFileCredentials; | |
/* AWS.config.credentials = credentials; */ | |
[@bs.val] [@bs.scope "AwsSdk"] external config : awsConfig = ""; | |
config |. credentialsSet(c); | |
type regionObj = {. "region": string}; | |
[@bs.obj] external makeRegionObj : (~region: string) => regionObj = ""; | |
[@bs.module "aws-sdk"] [@bs.scope "config"] | |
external update : regionObj => aws = ""; | |
let s_LAMBDA_REGION = "ap-southeast-1"; | |
makeRegionObj(~region=s_LAMBDA_REGION) |> update; | |
type watchlogObj = {. "apiVersion": string}; | |
[@bs.obj] | |
external makeWatchlogObj : (~apiVersion: string, unit) => watchlogObj = ""; | |
[@bs.module "aws-sdk"] [@bs.new] | |
external cloudWatchLogs : watchlogObj => aws = "CloudWatchLogs"; | |
let logsAction = | |
makeWatchlogObj(~apiVersion="2014-03-28", ()) |> cloudWatchLogs; | |
Js.log(logsAction); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment