-
Notifications
You must be signed in to change notification settings - Fork 0
/
handler.py
37 lines (29 loc) · 992 Bytes
/
handler.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import json
import logging
from textwrap import dedent
import cedarpy
from config import get_stage
logger = logging.getLogger(__name__)
def hello_cedarpy(event: dict, context: dict) -> dict:
"""The hello_cedarpy function just verifies cedarpy can be loaded and executed correctly by formatting a policy"""
input_policies: str = dedent("""
permit(
principal,
action == Action::"edit",
resource
)
when {
resource.owner == principal
};
""")
output_policies = cedarpy.format_policies(input_policies)
logger.info(f"successfully formatted policies using cedarpy (stage={get_stage()}):\n{output_policies}")
body = {
"message": "Go hello-photos! cedarpy is at your service!",
"input": event
}
response = {
"statusCode": 200,
"body": json.dumps(body)
}
return response