Example #1
0
    def put_subscription_filter(
        self, filter_name, filter_pattern, destination_arn, role_arn
    ):
        creation_time = int(unix_time_millis())

        # only one subscription filter can be associated with a log group
        if self.subscription_filters:
            if self.subscription_filters[0]["filterName"] == filter_name:
                creation_time = self.subscription_filters[0]["creationTime"]
            else:
                raise LimitExceededException()

        for stream in self.streams.values():
            stream.destination_arn = destination_arn
            stream.filter_name = filter_name

        self.subscription_filters = [
            {
                "filterName": filter_name,
                "logGroupName": self.name,
                "filterPattern": filter_pattern,
                "destinationArn": destination_arn,
                "roleArn": role_arn,
                "distribution": "ByLogStream",
                "creationTime": creation_time,
            }
        ]
Example #2
0
 def put_resource_policy(self, policy_name, policy_doc):
     """Creates/updates resource policy and return policy object"""
     if policy_name in self.resource_policies:
         policy = self.resource_policies[policy_name]
         policy.update(policy_doc)
         return policy
     if len(self.resource_policies) == MAX_RESOURCE_POLICIES_PER_REGION:
         raise LimitExceededException()
     policy = LogResourcePolicy(policy_name, policy_doc)
     self.resource_policies[policy_name] = policy
     return policy
Example #3
0
    def put_resource_policy(self, policy_name, policy_doc):
        """Create resource policy and return dict of policy name and doc."""
        if len(self.resource_policies) == MAX_RESOURCE_POLICIES_PER_REGION:
            raise LimitExceededException()

        policy = {
            "policyName": policy_name,
            "policyDocument": policy_doc,
            "lastUpdatedTime": int(unix_time_millis()),
        }
        self.resource_policies[policy_name] = policy
        return {"resourcePolicy": policy}