lambda-durable-human-approval-sam: Fix hardcoded API Gateway URL by using environment variable#2921
Open
kakakakakku wants to merge 2 commits intoaws-samples:mainfrom
Open
Conversation
kakakakakku
commented
Feb 1, 2026
|
|
||
| **Important:** Please check the [AWS documentation](https://docs.aws.amazon.com/lambda/latest/dg/durable-functions.html) for regions currently supported by AWS Lambda durable functions. | ||
|
|
||
| Learn more about this pattern at Serverless Land Patterns: https://serverlessland.com/patterns/lambda-durable-hitl-approval-sam |
Contributor
Author
There was a problem hiding this comment.
note: It's wrong url
| Monitor the durable function: | ||
| ```bash | ||
| aws logs tail /aws/lambda/lambda-durable-hitl-approval-ApprovalFunction-XXXXX \ | ||
| aws logs tail /aws/lambda/lambda-durable-human-approval-ApprovalFunction \ |
Contributor
Author
There was a problem hiding this comment.
note: Update CloudWatch Logs log group name because I set FunctionName in SAM template
| Variables: | ||
| APPROVAL_TOPIC_ARN: !Ref ApprovalTopic | ||
| CALLBACK_TABLE_NAME: !Ref CallbackTable | ||
| API_BASE_URL: !Sub 'https://${ApprovalApi}.execute-api.${AWS::Region}.amazonaws.com/prod' |
Contributor
Author
There was a problem hiding this comment.
note: To pass the API_BASE_URL environment variable to the Lambda function, we needed to resolve a circular dependency between the Lambda function and API Gateway. To break this cycle, we explicitly set the Lambda FunctionName and manually constructed the ARN in the API Gateway integration URI. This reduces the dependency to a one-way reference from the Lambda function to API Gateway, resolving the circular dependency😀
kakakakakku
commented
Feb 1, 2026
|
|
||
| # Get API Gateway URL from environment or construct it | ||
| region = os.environ.get('AWS_REGION', 'us-east-2') | ||
| api_base_url = f"https://w8a9tempjb.execute-api.{region}.amazonaws.com/prod" |
Contributor
Author
There was a problem hiding this comment.
note: Here is hardcoded API Gateway URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available:
N/A
Description of changes:
Hi😀 Thanks for the useful patterns!
While testing lambda-durable-human-approval-sam, I could not access to the Approval URL because url was hardcoded in Python code like below.
Check
I fixed it using environment variable and it works good 👍
Thank you😀
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.