# AWS Configuration

### Imports

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

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

{% endtab %}

{% tab title="Module" %}

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

{% endtab %}

{% tab title="Interface" %}

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

{% endtab %}
{% endtabs %}

### Environment Variables

Do you create variables an `.env` file.

<table><thead><tr><th width="291">name</th><th width="460">description</th></tr></thead><tbody><tr><td><code>AWS_ACCESS_KEY_ID</code></td><td><code>Access key id of the aws.</code></td></tr><tr><td><code>AWS_SECRET_ACCESS_KEY</code></td><td><code>Secret of the access key in aws.</code></td></tr></tbody></table>

Check the example file.

{% code title=".env" %}

```properties
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
```

{% endcode %}

### 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 {
  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 {}
```

{% endcode %}

Injecting the module into our service.

```typescript
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`   | [Link to Service documentation](https://guilhermesantos.gitbook.io/niro-health/modules/configuration)    |
| `IValidatorRegexpService` | [Link to Service documentation](https://guilhermesantos.gitbook.io/niro-health/modules/validator-regexp) |
| `IStringExService`        | [Link to Service documentation](https://guilhermesantos.gitbook.io/niro-health/modules/stringex)         |

### Properties

<table><thead><tr><th>Property</th><th width="122.33333333333331" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><code>_apiVersion</code></td><td align="center"><code>private</code></td><td><code>The AWS API version to use.</code></td></tr><tr><td><code>_region</code></td><td align="center"><code>private</code></td><td><code>The AWS region to use.</code></td></tr><tr><td><code>_httpOptions</code></td><td align="center"><code>private</code></td><td><code>The AWS HTTP options to use.</code></td></tr><tr><td><code>_credentials</code></td><td align="center"><code>private</code></td><td><code>The AWS credentials to use.</code></td></tr></tbody></table>

### Methods

<table><thead><tr><th>Method</th><th width="118.33333333333331" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><code>_loadCredentials</code></td><td align="center"><code>private</code></td><td><code>Load the AWS credentials from the configuration service.</code></td></tr><tr><td><mark style="color:blue;">set</mark> <code>apiVersion</code></td><td align="center"><code>public</code></td><td><code>Set the AWS API version.</code></td></tr><tr><td><mark style="color:blue;">get</mark> <code>apiVersion</code></td><td align="center"><code>public</code></td><td><code>Get the AWS API version.</code></td></tr><tr><td><mark style="color:blue;">set</mark> <code>region</code></td><td align="center"><code>public</code></td><td><code>Set the AWS region.</code></td></tr><tr><td><mark style="color:blue;">get</mark> <code>region</code></td><td align="center"><code>public</code></td><td><code>Get the AWS region.</code></td></tr><tr><td><mark style="color:blue;">set</mark> <code>credentials</code></td><td align="center"><code>public</code></td><td><code>Set the AWS credentials.</code></td></tr><tr><td><mark style="color:blue;">get</mark> <code>credentials</code></td><td align="center"><code>public</code></td><td><code>Get the AWS credentials.</code></td></tr><tr><td><code>options</code></td><td align="center"><code>public</code></td><td><code>Get the AWS configuration options.</code></td></tr></tbody></table>
