seagull-js/seagull

View on GitHub
packages/deploy-aws/src/aws_sdk_handler/handle_sts.ts

Summary

Maintainability
A
50 mins
Test Coverage
import { config, STS } from 'aws-sdk'

export async function getAccountId(handler: STSHandler) {
  return await handler.getAccountId()
}

export class STSHandler {
  private sts: STS

  constructor() {
    const { credentials, region } = config
    this.sts = new STS({ credentials, region })
  }

  async getAccountId() {
    const identity = await this.sts.getCallerIdentity().promise()
    return identity.Account
  }
}