📝AWS STS
The module that provides the service to assume a role in AWS STS service.
Imports
import { AwsStsService } from 'niro-health';
Method of Use
To use this module, you need to inject it into the desired service.
import { Module } from '@nestjs/common';
import {
AwsStsService,
AwsConfigurationService,
ConfigurationService,
ValidatorRegexpService,
StringExService,
} from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';
@Module({
controllers: [AppController],
providers: [
AppService,
{
provide: 'IAwsStsService',
useClass: AwsStsService,
},
{
provide: 'IAwsConfigurationService',
useClass: AwsConfigurationService,
},
{
provide: 'IConfigurationService',
useClass: ConfigurationService,
},
{
provide: 'IValidatorRegexpService',
useClass: ValidatorRegexpService,
},
{
provide: 'IStringExService',
useClass: StringExService,
},
],
})
export class AppModule {}
Injecting the module into our service.
import { Inject, Injectable } from '@nestjs/common';
import type { IAwsStsService } from 'niro-health';
@Injectable()
export class AppService {
constructor(
@Inject('IAwsStsService')
private readonly awsStsService: IAwsStsService,
) {}
async saveRole() {
return await this.awsStsService.saveRole({
roleArn: 'arn:aws:iam::123456789012:role/role-name',
externalId: 'external-id',
sessionName: 'session-name',
});
}
}
With dependencies
You will need to inject the following interfaces.
IAwsConfigurationService
IConfigurationService
IValidatorRegexpService
IStringExService
Properties
_role3rdParty
private
The role 3rd party.
Methods
set role3rdParty
private
Save the role 3rd party.
get role3rdParty
private
Get the role 3rd party.
_normalizeVariableByAccessKeyId
private
Normalize the variable name by role access key id.
_normalizeVariableBySecretAccessKey
private
Normalize the variable name by role secret access key.
_normalizeVariableBySessionToken
private
Normalize the variable name by role session token.
_normalizeVariableByExpiration
private
Normalize the variable name by role expiration.
_saveEnvRole
private
Save the role in environment variables.
_getEnvRole
private
Get the role in environment variables.
saveRole
public
Save the role 3rd party.
assumeRole
public
Assume the role 3rd party.
Last updated