> For the complete documentation index, see [llms.txt](https://guilhermesantos.gitbook.io/niro-health/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guilhermesantos.gitbook.io/niro-health/modules/aws-sts.md).

# AWS STS

The module that provides the service to assume a role in AWS STS service.

### Imports

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

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

{% endtab %}

{% tab title="Module" %}

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

{% endtab %}

{% tab title="Interface" %}

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

{% endtab %}
{% endtabs %}

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

{% endcode %}

Injecting the module into our service.

```typescript
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.

| Interface                  | Service                                                                    |
| -------------------------- | -------------------------------------------------------------------------- |
| `IAwsConfigurationService` | [Link to Service documentation](/niro-health/modules/aws-configuration.md) |
| `IConfigurationService`    | [Link to Service documentation](/niro-health/modules/configuration.md)     |
| `IValidatorRegexpService`  | [Link to Service documentation](/niro-health/modules/validator-regexp.md)  |
| `IStringExService`         | [Link to Service documentation](/niro-health/modules/stringex.md)          |

### Properties

<table><thead><tr><th>Property</th><th width="125.33333333333331" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><code>_role3rdParty</code></td><td align="center"><code>private</code></td><td><code>The role 3rd party.</code></td></tr></tbody></table>

### Methods

<table><thead><tr><th width="404.3333333333333">Method</th><th width="114" align="center">Scope</th><th>Description</th></tr></thead><tbody><tr><td><mark style="color:blue;">set</mark> <code>role3rdParty</code></td><td align="center"><code>private</code></td><td><code>Save the role 3rd party.</code></td></tr><tr><td><mark style="color:blue;">get</mark> <code>role3rdParty</code></td><td align="center"><code>private</code></td><td><code>Get the role 3rd party.</code></td></tr><tr><td><code>_normalizeVariableByAccessKeyId</code></td><td align="center"><code>private</code></td><td><code>Normalize the variable name by role access key id.</code></td></tr><tr><td><code>_normalizeVariableBySecretAccessKey</code></td><td align="center"><code>private</code></td><td><code>Normalize the variable name by role secret access key.</code></td></tr><tr><td><code>_normalizeVariableBySessionToken</code></td><td align="center"><code>private</code></td><td><code>Normalize the variable name by role session token.</code></td></tr><tr><td><code>_normalizeVariableByExpiration</code></td><td align="center"><code>private</code></td><td><code>Normalize the variable name by role expiration.</code></td></tr><tr><td><code>_saveEnvRole</code></td><td align="center"><code>private</code></td><td><code>Save the role in environment variables.</code></td></tr><tr><td><code>_getEnvRole</code></td><td align="center"><code>private</code></td><td><code>Get the role in environment variables.</code></td></tr><tr><td><code>saveRole</code></td><td align="center"><code>public</code></td><td><code>Save the role 3rd party.</code></td></tr><tr><td><code>assumeRole</code></td><td align="center"><code>public</code></td><td><code>Assume the role 3rd party.</code></td></tr></tbody></table>
