📝AWS Configuration

The module provides a service for configuring the AWS SDK.

Imports

import { AwsConfigurationService } from 'niro-health';

Environment Variables

Do you create variables an .env file.

name
description

AWS_ACCESS_KEY_ID

Access key id of the aws.

AWS_SECRET_ACCESS_KEY

Secret of the access key in aws.

Check the example file.

.env
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY

Method of Use

To use this module, you need to inject it into the desired service.

import { Module } from '@nestjs/common';
import {
  AwsConfigurationService,
  ConfigurationService,
  ValidatorRegexpService,
  StringExService,
} from 'niro-health';
import { AppController } from './app.controller';
import { AppService } from './app.service';

@Module({
  controllers: [AppController],
  providers: [
    AppService,
    {
      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 { IAwsConfigurationService } from 'niro-health';

@Injectable()
export class AppService {
  constructor(
    @Inject('IAwsConfigurationService')
    private readonly awsConfigurationService: IAwsConfigurationService,
  ) {}

  async options() {
    return this.awsConfigurationService.options();
  }
}

With dependencies

You will need to inject the following interfaces.

Interface
Service

IConfigurationService

IValidatorRegexpService

Properties

Property
Scope
Description

_apiVersion

private

The AWS API version to use.

_region

private

The AWS region to use.

_httpOptions

private

The AWS HTTP options to use.

_credentials

private

The AWS credentials to use.

Methods

Method
Scope
Description

_loadCredentials

private

Load the AWS credentials from the configuration service.

set apiVersion

public

Set the AWS API version.

get apiVersion

public

Get the AWS API version.

set region

public

Set the AWS region.

get region

public

Get the AWS region.

set credentials

public

Set the AWS credentials.

get credentials

public

Get the AWS credentials.

options

public

Get the AWS configuration options.

Last updated