### 実現したいこと

AdminInitiateAuthCommandを使ってユーザー情報を取得したい

### 前提

  * ローカルでは動きますが、Dockerでは動きません。
  * node.jsのバージョン: 18.13.0

### 発生している問題・エラーメッセージ

```

    Could not load credentials from any providers
    
```

### 該当のソースコード

```

    // main.ts
    import {
      CognitoIdentityProviderClient,
      AdminInitiateAuthCommand,
      AdminInitiateAuthCommandInput,
    } from '@aws-sdk/client-cognito-identity-provider'
    import { createHmac } from 'crypto'
    
    const makeSecretHash = (username, client_id, client_secret) => {
      const secretHash = createHmac('sha256', client_secret)
        .update(`${username}${client_id}`)
        .digest('base64')
    
      return secretHash
    }
    
    const COGNITO_API_VERSION = '2016-04-18'
    const COGNITO_USER_POOL_ID = process.env.COGNITO_USER_POOL_ID
    const COGNITO_CLIENT_ID = process.env.COGNITO_CLIENT_ID
    const COGNITO_CLIENT_SECRET = process.env.COGNITO_CLIENT_SECRET
    const AWS_REGION = process.env.AWS_REGION
    const MY_USERNAME = process.env.MY_USERNAME
    const MY_PASSWORD = process.env.MY_PASSWORD
    
    const client = new CognitoIdentityProviderClient({
      apiVersion: COGNITO_API_VERSION,
      region: AWS_REGION,
    })
    
    /**
     * IDトークンを取得
     */
    const getIdToken = async (): Promise<void> => {
      const params: AdminInitiateAuthCommandInput = {
        UserPoolId: COGNITO_USER_POOL_ID,
        ClientId: COGNITO_CLIENT_ID,
        AuthFlow: 'ADMIN_USER_PASSWORD_AUTH',
        AuthParameters: {
          USERNAME: MY_USERNAME,
          PASSWORD: MY_PASSWORD,
          SECRET_HASH: makeSecretHash(
            MY_USERNAME,
            COGNITO_CLIENT_ID,
            COGNITO_CLIENT_SECRET
          ),
        },
      }
      const adminAuthCommand = new AdminInitiateAuthCommand(params)
      try {
        const data = await client.send(adminAuthCommand)
        console.log(data)
        console.log(data.Session)
        // process data.
      } catch (error) {
        console.log(params)
        console.log(error.message)
      } finally {
        // finally.
      }
    }
    
    getIdToken()
    
    
```

docker-compose.yml

```

    version: '3'
    
    services:app:
        container_name: 'fuga-app'
        tty: true
        image: node:18.13.0-bullseye-slim
        ports:
          - '3000:3000'
          - '3333:3333'
          - '5555:5555'
        volumes:
          - ./app:/srv/app:rw
        working_dir: /srv/app
        networks:
          - fuga-tier
    
    networks:
      fuga-tier:
        driver: bridge
    
```

### 試したこと

  * Dockerのimage変更
  * node.jsバージョンの変更
CC BY-SA 4.0
2023-02-01T05:42:13.980
93652
2023-02-01T05:42:13.980
50689
question
javascript aws docker node.js docker-compose
Docker環境でのみnode.jsのaws-sdkでcognitoのユーザー情報取得ができない