Undefined array key "database"

2024-09-29

エラー内容

api-1  | [2024-09-29 09:41:37] local.ERROR: Undefined array key "database" {"exception":"[object] (ErrorException(code: 0): Undefined array key \"database\" at /var/task/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:75)
api-1  | #0 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/HandleExceptions.php(256): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->handleError(2, 'Undefined array...', '/var/task/vendo...', 75)
api-1  | #1 /var/task/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(75): Illuminate\\Foundation\\Bootstrap\\HandleExceptions->Illuminate\\Foundation\\Bootstrap\\{closure}(2, 'Undefined array...', '/var/task/vendo...', 75)
api-1  | #2 /var/task/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php(51): Illuminate\\Database\\Connectors\\ConnectionFactory->createSingleConnection(Array)
api-1  | #3 /var/task/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(167): Illuminate\\Database\\Connectors\\ConnectionFactory->make(Array, 'dynamodb')
api-1  | #4 /var/task/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php(93): Illuminate\\Database\\DatabaseManager->makeConnection('dynamodb')
api-1  | #5 /var/task/vendor/laravel/framework/src/Illuminate/Session/SessionManager.php(108): Illuminate\\Database\\DatabaseManager->connection('dynamodb')
api-1  | #6 /var/task/vendor/laravel/framework/src/Illuminate/Session/SessionManager.php(95): Illuminate\\Session\\SessionManager->getDatabaseConnection()
api-1  | #7 /var/task/vendor/laravel/framework/src/Illuminate/Support/Manager.php(106): Illuminate\\Session\\SessionManager->createDatabaseDriver()
api-1  | #8 /var/task/vendor/laravel/framework/src/Illuminate/Support/Manager.php(80): Illuminate\\Support\\Manager->createDriver('database')
api-1  | #9 /var/task/vendor/laravel/framework/src/Illuminate/Session/SessionServiceProvider.php(52): Illuminate\\Support\\Manager->driver()
api-1  | #10 /var/task/vendor/laravel/framework/src/Illuminate/Container/Container.php(931): Illuminate\\Session\\SessionServiceProvider->Illuminate\\Session\\{closure}(Object(Illuminate\\Foundation\\Application), Array)
api-1  | #11 /var/task/vendor/laravel/framework/src/Illuminate/Container/Container.php(815): Illuminate\\Container\\Container->build(Object(Closure))
api-1  | #12 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1046): Illuminate\\Container\\Container->resolve('session.store', Array, true)
api-1  | #13 /var/task/vendor/laravel/framework/src/Illuminate/Container/Container.php(751): Illuminate\\Foundation\\Application->resolve('session.store', Array)
api-1  | #14 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1028): Illuminate\\Container\\Container->make('session.store', Array)
api-1  | #15 /var/task/vendor/laravel/framework/src/Illuminate/Container/Container.php(1570): Illuminate\\Foundation\\Application->make('session.store')
api-1  | #16 /var/task/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php(122): Illuminate\\Container\\Container->offsetGet('session.store')
api-1  | #17 /var/task/vendor/laravel/framework/src/Illuminate/Container/Container.php(931): Illuminate\\Routing\\RoutingServiceProvider->Illuminate\\Routing\\{closure}(Object(Illuminate\\Foundation\\Application), Array)
api-1  | #18 /var/task/vendor/laravel/framework/src/Illuminate/Container/Container.php(815): Illuminate\\Container\\Container->build(Object(Closure))
api-1  | #19 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1046): Illuminate\\Container\\Container->resolve('redirect', Array, true)
api-1  | #20 /var/task/vendor/laravel/framework/src/Illuminate/Container/Container.php(751): Illuminate\\Foundation\\Application->resolve('redirect', Array)
api-1  | #21 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1028): Illuminate\\Container\\Container->make('redirect', Array)
api-1  | #22 /var/task/vendor/laravel/framework/src/Illuminate/Container/Container.php(1570): Illuminate\\Foundation\\Application->make('redirect')
api-1  | #23 /var/task/vendor/laravel/framework/src/Illuminate/Routing/RoutingServiceProvider.php(180): Illuminate\\Container\\Container->offsetGet('redirect')
api-1  | #24 /var/task/vendor/laravel/framework/src/Illuminate/Container/Container.php(931): Illuminate\\Routing\\RoutingServiceProvider->Illuminate\\Routing\\{closure}(Object(Illuminate\\Foundation\\Application), Array)
api-1  | #25 /var/task/vendor/laravel/framework/src/Illuminate/Container/Container.php(815): Illuminate\\Container\\Container->build(Object(Closure))
api-1  | #26 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1046): Illuminate\\Container\\Container->resolve('Illuminate\\\\Cont...', Array, true)
api-1  | #27 /var/task/vendor/laravel/framework/src/Illuminate/Container/Container.php(751): Illuminate\\Foundation\\Application->resolve('Illuminate\\\\Cont...', Array)
api-1  | #28 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1028): Illuminate\\Container\\Container->make('Illuminate\\\\Cont...', Array)
api-1  | #29 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(124): Illuminate\\Foundation\\Application->make('Illuminate\\\\Cont...', Array)
api-1  | #30 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(817): app('Illuminate\\\\Cont...')
api-1  | #31 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(891): response()
api-1  | #32 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(812): Illuminate\\Foundation\\Exceptions\\Handler->renderHttpException(Object(Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException))
api-1  | #33 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(703): Illuminate\\Foundation\\Exceptions\\Handler->prepareResponse(Object(Illuminate\\Http\\Request), Object(Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException))
api-1  | #34 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(592): Illuminate\\Foundation\\Exceptions\\Handler->renderExceptionResponse(Object(Illuminate\\Http\\Request), Object(Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException))
api-1  | #35 /var/task/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(51): Illuminate\\Foundation\\Exceptions\\Handler->render(Object(Illuminate\\Http\\Request), Object(Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException))
api-1  | #36 /var/task/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(146): Illuminate\\Routing\\Pipeline->handleException(Object(Illuminate\\Http\\Request), Object(Symfony\\Component\\HttpKernel\\Exception\\NotFoundHttpException))
api-1  | #37 /var/task/vendor/bref/laravel-bridge/src/Http/Middleware/ServeStaticAssets.php(26): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
api-1  | #38 /var/task/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Bref\\LaravelBridge\\Http\\Middleware\\ServeStaticAssets->handle(Object(Illuminate\\Http\\Request), Object(Closure))
api-1  | #39 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
api-1  | #40 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ConvertEmptyStringsToNull.php(31): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
api-1  | #41 /var/task/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\ConvertEmptyStringsToNull->handle(Object(Illuminate\\Http\\Request), Object(Closure))
api-1  | #42 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php(21): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
api-1  | #43 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TrimStrings.php(51): Illuminate\\Foundation\\Http\\Middleware\\TransformsRequest->handle(Object(Illuminate\\Http\\Request), Object(Closure))
api-1  | #44 /var/task/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\TrimStrings->handle(Object(Illuminate\\Http\\Request), Object(Closure))
api-1  | #45 /var/task/vendor/laravel/framework/src/Illuminate/Http/Middleware/ValidatePostSize.php(27): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
api-1  | #46 /var/task/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\ValidatePostSize->handle(Object(Illuminate\\Http\\Request), Object(Closure))
api-1  | #47 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php(110): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
api-1  | #48 /var/task/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Foundation\\Http\\Middleware\\PreventRequestsDuringMaintenance->handle(Object(Illuminate\\Http\\Request), Object(Closure))
api-1  | #49 /var/task/vendor/laravel/framework/src/Illuminate/Http/Middleware/HandleCors.php(49): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
api-1  | #50 /var/task/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\HandleCors->handle(Object(Illuminate\\Http\\Request), Object(Closure))
api-1  | #51 /var/task/vendor/laravel/framework/src/Illuminate/Http/Middleware/TrustProxies.php(57): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
api-1  | #52 /var/task/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(183): Illuminate\\Http\\Middleware\\TrustProxies->handle(Object(Illuminate\\Http\\Request), Object(Closure))
api-1  | #53 /var/task/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php(119): Illuminate\\Pipeline\\Pipeline->Illuminate\\Pipeline\\{closure}(Object(Illuminate\\Http\\Request))
api-1  | #54 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(176): Illuminate\\Pipeline\\Pipeline->then(Object(Closure))
api-1  | #55 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php(145): Illuminate\\Foundation\\Http\\Kernel->sendRequestThroughRouter(Object(Illuminate\\Http\\Request))
api-1  | #56 /var/task/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(1188): Illuminate\\Foundation\\Http\\Kernel->handle(Object(Illuminate\\Http\\Request))
api-1  | #57 /var/task/public/index.php(17): Illuminate\\Foundation\\Application->handleRequest(Object(Illuminate\\Http\\Request))
api-1  | #58 {main}
api-1  | "} 

解決方法

'dynamodb' => [
    'driver' => 'dynamodb',
    'key' => env('AWS_ACCESS_KEY_ID'),
    'secret' => env('AWS_SECRET_ACCESS_KEY'),
    'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
    'table' => env('DYNAMODB_TABLE'),
    'endpoint' => env('DYNAMODB_ENDPOINT'),
    'database' => env('DB_DATABASE', ''), // これを追加
],

dockerのコンテナを落として、再度立ち上げる(多分キャッシュ消すだけで大丈夫: php artisan config:clear