28 lines
639 B
Python
28 lines
639 B
Python
import dictdiffer
|
|
from arnparse import arnparse
|
|
from aws_lambda_powertools.shared.json_encoder import Encoder
|
|
|
|
|
|
def table_from_arn(arn: str) -> str:
|
|
arn_ = arnparse(arn)
|
|
return arn_.resource.split('/')[0]
|
|
|
|
|
|
def diff(first: dict, second: dict) -> list[str]:
|
|
result = dictdiffer.diff(first, second)
|
|
changed = []
|
|
|
|
for record in result:
|
|
type_, path, _ = record
|
|
if type_ == 'change':
|
|
changed.append(path)
|
|
|
|
return changed
|
|
|
|
|
|
class JSONEncoder(Encoder):
|
|
def default(self, obj):
|
|
if isinstance(obj, set):
|
|
return list(obj)
|
|
return super(__class__, self).default(obj)
|