import os
import json
import urllib3
http = urllib3.PoolManager()
ALB_DNS = os.environ.get("LB_DNS", "internal-xxx-alb-xxxxx.ap-northeast-1.elb.amazonaws.com")
PATH = "/v1/distributed-processing"
def lambda_handler(event, context):
url = f"http://{ALB_DNS}{PATH}"
payload = {"salesCode": "01"} # 你的 ECS API 需要的 body
try:
resp = http.request(
"POST",
url,
body=json.dumps(payload).encode("utf-8"),
headers={"Content-Type": "application/json"},
timeout=urllib3.Timeout(connect=2.0, read=10.0)
)
return {
"statusCode": resp.status,
"body": resp.data.decode("utf-8")
}
except Exception as e:
return {
"statusCode": 500,
"body": str(e)
}
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme