# AWS Core

### Imports

{% tabs %}
{% tab title="Service" %}

```typescript
import { AwsCoreService } from 'niro-health';
```

{% endtab %}

{% tab title="Module" %}

```typescript
import { AwsCoreModule } from 'niro-health';
```

{% endtab %}

{% tab title="Interface" %}

```typescript
import type { IAwsCoreService } from 'niro-health';
```

{% endtab %}
{% endtabs %}

### Application Variables

<table><thead><tr><th width="208">name</th><th width="229">example</th><th width="126">reference</th><th>description</th></tr></thead><tbody><tr><td><code>aws_api_version</code></td><td><code>latest</code> | <code>2015-03-31</code></td><td><a href="https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/Lambda.html">API Version</a></td><td><code>AWS API version from the configuration.</code></td></tr><tr><td><code>aws_region</code></td><td><code>us-east-1</code></td><td><a href="https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/RegionsAndAZs.html">Regions List</a></td><td><code>AWS region from the configuration.</code></td></tr></tbody></table>

#### How to set variable

You can set the application variable in your main module and/or in the module that will inject the service.

```typescript
import { Inject, Injectable } from '@nestjs/common';
import type { IConfigurationService } from 'niro-health';

@Injectable()
export class AppService {
  constructor(
    @Inject('IConfigurationService')
    private readonly configurationService: IConfigurationService,
  ) {
  this.initialize();
}

  async initialize() {
    this.configurationService.setVariable('aws_api_version', 'latest');
    this.configurationService.setVariable('aws_region', 'us-east-1');
  }
}
```

### Method of Use

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

{% code overflow="wrap" %}

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

@Module({
  controllers: [AppController],
  providers: [
    AppService,
    {
      provide: 'IAwsCoreServiceImpl',
      useClass: AwsCoreService,
    },
    {
      provide: 'IAwsConfigurationService',
      useClass: AwsConfigurationService,
    },
    {
      provide: 'IAwsStsService',
      useClass: AwsStsService,
    },
    {
      provide: 'IConfigurationService',
      useClass: ConfigurationService,
    },
    {
      provide: 'IValidatorRegexpService',
      useClass: ValidatorRegexpService,
    },
    {
      provide: 'IStringExService',
      useClass: StringExService,
    },
  ],
})
export class AppModule {}
```

{% endcode %}

Injecting the module into our service.

```typescript
import { Inject, Injectable } from '@nestjs/common';
import type { IAwsCoreServiceImpl } from 'niro-health';

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

  async configuration() {
    return await this.awsCoreService.configuration();
  }
}
```

### With dependencies

You will need to inject the following interfaces.

<table><thead><tr><th width="308">Interface</th><th>Service</th></tr></thead><tbody><tr><td><code>IConfigurationService</code></td><td><a href="configuration">Link to Service documentation</a></td></tr><tr><td><code>IValidatorRegexpService</code></td><td><a href="validator-regexp">Link to Service documentation</a></td></tr><tr><td><code>IStringExService</code></td><td><a href="stringex">Link to Service documentation</a></td></tr><tr><td><code>IAwsConfigurationService</code></td><td><a href="aws-configuration">Link to Service documentation</a></td></tr><tr><td><code>IAwsStsService</code></td><td><a href="aws-sts">Link to Service documentation</a></td></tr></tbody></table>

### Properties

<table><thead><tr><th>Property</th><th width="114.33333333333331" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><mark style="color:blue;">get</mark> <code>_apiVersion</code></td><td align="center"><code>private</code></td><td><code>Get the AWS API version from the configuration.</code></td></tr><tr><td><mark style="color:blue;">get</mark> <code>_region</code></td><td align="center"><code>private</code></td><td><code>Get the AWS region from the configuration.</code></td></tr><tr><td><mark style="color:blue;">get</mark> <code>_httpOptions</code></td><td align="center"><code>private</code></td><td><code>Get the AWS HTTP options.</code></td></tr><tr><td><mark style="color:blue;">get</mark> <code>_credentials</code></td><td align="center"><code>private</code></td><td><code>Get the AWS configuration service.</code></td></tr><tr><td><mark style="color:blue;">get</mark> <code>_sts</code></td><td align="center"><code>private</code></td><td><code>Get the AWS STS service.</code></td></tr></tbody></table>

### Methods

<table><thead><tr><th>Method</th><th width="113.33333333333331" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><code>initialize</code></td><td align="center"><code>private</code></td><td><code>Initialize the AWS configuration.</code></td></tr><tr><td><code>client</code></td><td align="center"><code>public</code></td><td><code>Get the client for the AWS services.</code></td></tr><tr><td><code>setRole3rdParty</code></td><td align="center"><code>public</code></td><td><code>Set the role for the 3rd party.</code></td></tr><tr><td><code>configuration</code></td><td align="center"><code>public</code></td><td><code>Get the AWS configuration.</code></td></tr></tbody></table>
