Skip to content

Commit 9685967

Browse files
committed
Extract region constant
1 parent 65a2e7b commit 9685967

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/main/php/xp/lambda/RunLambda.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
* @see https://docs.aws.amazon.com/de_de/lambda/latest/dg/runtimes-api.html
1212
*/
1313
class RunLambda {
14-
const TRACE_ID= 'Root=1-5bef4de7-ad49b0e87f6ef6c87fc2e700;Parent=9a9197af755a6419;Sampled=1';
14+
const TRACE= 'Root=1-5bef4de7-ad49b0e87f6ef6c87fc2e700;Parent=9a9197af755a6419;Sampled=1';
15+
const REGION= 'test-local-1';
1516

1617
private $impl, $events;
1718

@@ -30,7 +31,7 @@ public function __construct($handler= 'Handler', ... $events) {
3031
/** Runs this command */
3132
public function run(): int {
3233
$name= $this->impl->getSimpleName();
33-
$region= getenv('AWS_REGION') ?: 'test-local-1';
34+
$region= getenv('AWS_REGION') ?: self::REGION;
3435
$functionArn= "arn:aws:lambda:{$region}:123456789012:function:{$name}";
3536
$deadlineMs= (time() + 900) * 1000;
3637
$environment= $_ENV + ['AWS_LAMBDA_FUNCTION_NAME' => $name, 'AWS_REGION' => $region];
@@ -48,7 +49,7 @@ public function run(): int {
4849
$headers= [
4950
'Lambda-Runtime-Aws-Request-Id' => [UUID::randomUUID()->hashCode()],
5051
'Lambda-Runtime-Invoked-Function-Arn' => [$functionArn],
51-
'Lambda-Runtime-Trace-Id' => [self::TRACE_ID],
52+
'Lambda-Runtime-Trace-Id' => [self::TRACE],
5253
'Lambda-Runtime-Deadline-Ms' => [$deadlineMs],
5354
'Content-Length' => [strlen($event)],
5455
];

0 commit comments

Comments
 (0)