Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for IAM roles instead of access tokens #207

Closed
rkutca opened this issue Nov 5, 2020 · 3 comments
Closed

Support for IAM roles instead of access tokens #207

rkutca opened this issue Nov 5, 2020 · 3 comments
Labels
invalid This doesn't seem right

Comments

@rkutca
Copy link

rkutca commented Nov 5, 2020

Iḿ submitting a bug


[ ] Regression 
[x] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead post your question on Stack Overflow.

Current behavior

Currently when trying to connect with DynamoDB from an EC2 instance, with IAM role assigned nestjs-dynamoose still cant connect with DynamoDB. However, there already is support for this feature in the official Dynamoose documentation and it seems that currently passing accesstokens should be optional (and thus support IAM roles):


export interface DynamooseModuleOptions {
  aws?: {
    accessKeyId?: string;
    secretAccessKey?: string;
    region?: string;
  };
  local?: boolean | string;
  model?: ModelOptionsOptional;
  logger?: boolean | LoggerService;
}

However, even when leaving this empty, and assigning IAM roles to the EC2 instance, we cannot connect with DynamoDB.

Expected behavior

IAM roles on an instance should always be taken into consideration when trying to connect with DynamoDB.

Environment

node@14.9.0
nestjs@7.4.4

@chit786
Copy link

chit786 commented Nov 5, 2020

+1

1 similar comment
@munkacsitomi
Copy link

+1

@hardyscc
Copy link
Owner

hardyscc commented Nov 6, 2020

It is already supported, the access key is totally optional,
please see dynamoose/dynamoose#273

here is the internal code for your reference

function initialization(options: DynamooseModuleOptions) {
  if (options.aws) {
    aws.sdk.config.update(options.aws);
  }
  if (options.local) {
    if (typeof options.local === 'boolean') {
      aws.ddb.local();
    } else {
      aws.ddb.local(options.local);
    }
  }
  if (options.model) {
    model.defaults.set(options.model);
  }
  if (options.logger) {
    let loggerService: LoggerService;
    if (typeof options.logger === 'boolean') {
      loggerService = new Logger(DynamooseModule.name);
    } else {
      loggerService = options.logger;
    }
    logger.providers.add(new LoggerProvider(loggerService));
  }
}

@hardyscc hardyscc added the invalid This doesn't seem right label Nov 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

4 participants