generated from NASA-AMMOS/slim-starterkit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
raise error when no regex matches url payload
- use tempfile for lambda handler configuration - use python docker to run lambda package build - add unit tests to assert exception raised when no regex matches
- Loading branch information
Showing
5 changed files
with
64 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,20 @@ | ||
import os | ||
from tempfile import mkstemp | ||
|
||
from ..router import Router | ||
from ..utils.logger import logger | ||
|
||
|
||
def lambda_handler(event, context): | ||
logger.info("context: %s", context) | ||
|
||
# TODO: Should use either AppConfig or retrieve router config from S3 location. | ||
# For now, reading router config body from ROUTER_CFG env variable then writing | ||
# to local file. | ||
router_cfg = os.environ["ROUTER_CFG"] | ||
router_file = "/tmp/router.yaml" | ||
with open(router_file, "w", encoding="utf-8") as f: | ||
fd, router_file = mkstemp(prefix="router_", suffix=".yaml", text=True) | ||
with os.fdopen(fd, "w") as f: | ||
f.write(router_cfg) | ||
router = Router(router_file) | ||
os.unlink(router_file) | ||
return router.execute_actions(event["payload"]) |
This file contains 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
This file contains 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
This file contains 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