Skip to content

Commit 42eb680

Browse files
authored
Merge pull request #2944 from slobodan-proglove/fix/gateway-url-hardcoded-on-lambda-durable-human-approval-sam
Fixed hardcoded API Gateway URL in the lambda-durable-human-approval-sam pattern.
2 parents d71516b + 4ad1c9b commit 42eb680

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lambda-durable-human-approval-sam/src/lambda_function.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ def lambda_handler(event, context: DurableContext):
2828
amount = body.get('amount', 0)
2929
description = body.get('description', 'No description')
3030

31-
# Get API Gateway URL from environment or construct it
32-
region = os.environ.get('AWS_REGION', 'us-east-2')
33-
api_base_url = f"https://w8a9tempjb.execute-api.{region}.amazonaws.com/prod"
31+
# Get API Gateway URL from environment variable
32+
api_base_url = os.environ.get('API_BASE_URL')
33+
if not api_base_url:
34+
raise ValueError("API_BASE_URL environment variable is not set")
3435

3536
print(f"Starting approval workflow for request: {request_id}")
3637
print(f"API Base URL: {api_base_url}")

lambda-durable-human-approval-sam/template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Resources:
6868
Variables:
6969
APPROVAL_TOPIC_ARN: !Ref ApprovalTopic
7070
CALLBACK_TABLE_NAME: !Ref CallbackTable
71+
API_BASE_URL: !Sub 'https://${ApprovalApi}.execute-api.${AWS::Region}.amazonaws.com/prod'
7172
Policies:
7273
- SNSPublishMessagePolicy:
7374
TopicName: !GetAtt ApprovalTopic.TopicName

0 commit comments

Comments
 (0)