$parameter_path, 'Recursive' => true, 'WithDecryption' => true, 'MaxResults' => 500, ]; if ($next_token) { $params['NextToken'] = $next_token; } return $ssm->getParametersByPath($params); } function get_all_parameters() { $parameter_path = getenv('AWS_PARAMETER_PATH'); if (empty($parameter_path)) { return []; } $ssm = new SsmClient(['region' => getenv('AWS_REGION')]); $next_token = null; while(true) { $response = get_parameters_by_path($ssm, $parameter_path, $next_token); foreach ($response['Parameters'] as $parameter) { yield $parameter['Name'] => $parameter['Value']; } if (!empty($response['NextToken'])) { $next_token = $response['NextToken']; continue; } break; } return []; } foreach (get_all_parameters() as $name => $value) { $basename = pathinfo($name, PATHINFO_BASENAME); echo "{mb_strtoupper($basename)}=\"${value}\"\n"; }