Skip to content

Conversation

@kakakakakku
Copy link
Contributor

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.

image

Check

I fixed it using environment variable and it works good 👍

$ curl -X POST https://o4asvvo0ok.execute-api.us-east-2.amazonaws.com/prod/requests \
  -H "Content-Type: application/json" \
  -d '{
    "requestId": "REQ-001",
    "amount": 5000,
    "description": "New server purchase"
  }'
  {"message": "Request accepted"}%     
image image image

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.


**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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 \
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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😀


# 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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Here is hardcoded API Gateway URL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants