Giter VIP home page Giter VIP logo

helpful-aws-scripts's Introduction

helpful-aws-scripts

some helpful aws scripts

AWS Quicksight get dashboard

const AWS = require('aws-sdk');
const https = require('https');
const fs = require('fs')
AWS.config.region = 'us-east-1'

const quicksightParams = {
  AwsAccountId: '000000000000',
  DashboardId: '000000-0000-0000-0000-000000000',
	IdentityType: 'IAM',
	apiConfig: require('./quicksight-2018-04-01.min.json'),
}

// optional
AWS.config.loadFromPath('./credentials.json')


sts.assumeRole({
  DurationSeconds: 3600,
  RoleArn: 'arn:aws:iam::0123456789012:role/Quicksight-dashboard-embedded',
  // ExternalId: '1234567-1234-1234-1234-123456789012',
  RoleSessionName: 'embeddingsession'

}, function(err, newSession) {
  if (err) {
    console.log('Cannot assume role');
    console.log(err, err.stack);
  } else {

	// Now set temporary credentials seeded from the master credentials
	  AWS.config.credentials = new AWS.Credentials({
	      accessKeyId: newSession.Credentials.AccessKeyId,
	      secretAccessKey: newSession.Credentials.SecretAccessKey,
	      sessionToken: newSession.Credentials.SessionToken
	  })

	  const quicksight = new AWS.Service(quicksightParams)
	  AWS.config.region = "us-east-1";


	  const newSts = new AWS.STS()
	  newSts.getCallerIdentity({}, function(err, data) {
	    if (err) console.log(err, err.stack);
	    else
	      console.log(data);
	  })

	  quicksight.getDashboardEmbedUrl({
	      'AwsAccountId': '0123456789012',
	      'DashboardId': '',
	      'IdentityType': 'IAM',
	      'ResetDisabled': true,
	      'SessionLifetimeInMinutes': 100,
	      'UndoRedoDisabled': false
	  }, function(err, data) {
	    if (err) console.log(err, err.stack);
	    else     console.log(data.EmbedUrl);
	  })
  }
})

helpful-aws-scripts's People

Contributors

yefriddavid avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

bikalnepal

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.