diff --git a/fixlib/fixlib/baseresources.py b/fixlib/fixlib/baseresources.py index 96820715c1..9c63a85c52 100644 --- a/fixlib/fixlib/baseresources.py +++ b/fixlib/fixlib/baseresources.py @@ -3,7 +3,7 @@ import base64 import hashlib import weakref -from abc import ABC +from abc import ABC, abstractmethod from copy import deepcopy from datetime import datetime, timezone, timedelta from enum import Enum, StrEnum, unique @@ -1633,8 +1633,9 @@ class PolicySource: class HasResourcePolicy(ABC): # returns a list of all policies that affects the resource (inline, attached, etc.) + @abstractmethod def resource_policy(self, builder: Any) -> List[Tuple[PolicySource, Json]]: - raise NotImplementedError + pass @frozen diff --git a/plugins/aws/fix_plugin_aws/resource/kinesis.py b/plugins/aws/fix_plugin_aws/resource/kinesis.py index c5c9f10fa9..f96a71127b 100644 --- a/plugins/aws/fix_plugin_aws/resource/kinesis.py +++ b/plugins/aws/fix_plugin_aws/resource/kinesis.py @@ -1,4 +1,4 @@ -from typing import ClassVar, Dict, Optional, List, Any +from typing import ClassVar, Dict, Optional, List, Any, Tuple from json import loads as json_loads from attrs import define, field @@ -8,7 +8,7 @@ from fix_plugin_aws.resource.kms import AwsKmsKey from fix_plugin_aws.aws_client import AwsClient from fix_plugin_aws.utils import ToDict -from fixlib.baseresources import HasResourcePolicy, MetricName, ModelReference +from fixlib.baseresources import HasResourcePolicy, MetricName, ModelReference, PolicySource, PolicySourceKind from fixlib.graph import Graph from fixlib.json_bender import Bender, S, Bend, bend, ForallBend from fixlib.types import Json @@ -133,6 +133,12 @@ class AwsKinesisStream(AwsResource, HasResourcePolicy): kinesis_key_id: Optional[str] = field(default=None) kinesis_policy: Optional[Json] = field(default=None) + def resource_policy(self, builder: Any) -> List[Tuple[PolicySource, Dict[str, Any]]]: + if not self.kinesis_policy or not self.arn: + return [] + + return [(PolicySource(PolicySourceKind.resource, self.arn), self.kinesis_policy)] + @classmethod def called_collect_apis(cls) -> List[AwsApiSpec]: return [