diff --git a/aws_lambda_powertools/utilities/data_classes/__init__.py b/aws_lambda_powertools/utilities/data_classes/__init__.py index 076616b95d2..c619104fda8 100644 --- a/aws_lambda_powertools/utilities/data_classes/__init__.py +++ b/aws_lambda_powertools/utilities/data_classes/__init__.py @@ -5,6 +5,7 @@ from .alb_event import ALBEvent from .api_gateway_proxy_event import APIGatewayProxyEvent, APIGatewayProxyEventV2 from .appsync_resolver_event import AppSyncResolverEvent +from .aws_config_rule_event import AWSConfigRuleEvent from .cloud_watch_custom_widget_event import CloudWatchDashboardCustomWidgetEvent from .cloud_watch_logs_event import CloudWatchLogsEvent from .code_pipeline_job_event import CodePipelineJobEvent @@ -43,5 +44,6 @@ "SNSEvent", "SQSEvent", "event_source", + "AWSConfigRuleEvent", "VPCLatticeEvent", ] diff --git a/aws_lambda_powertools/utilities/data_classes/aws_config_rule_event.py b/aws_lambda_powertools/utilities/data_classes/aws_config_rule_event.py new file mode 100644 index 00000000000..2bfa2df61c5 --- /dev/null +++ b/aws_lambda_powertools/utilities/data_classes/aws_config_rule_event.py @@ -0,0 +1,361 @@ +from __future__ import annotations + +import json +from typing import Any, Dict, List, Optional + +from aws_lambda_powertools.utilities.data_classes.common import DictWrapper + + +def get_invoke_event( + invoking_event: dict, +) -> AWSConfigConfigurationChanged | AWSConfigScheduledNotification | AWSConfigOversizedConfiguration: + """ + Returns the corresponding event object based on the messageType in the invoking event. + + Parameters + ---------- + invoking_event: dict + The invoking event received. + + Returns + ------- + AWSConfigConfigurationChanged | AWSConfigScheduledNotification | AWSConfigOversizedConfiguration: + The event object based on the messageType in the invoking event. + """ + + message_type = invoking_event.get("messageType") + + if message_type == "ScheduledNotification": + return AWSConfigScheduledNotification(invoking_event) + + if message_type == "OversizedConfigurationItemChangeNotification": + return AWSConfigOversizedConfiguration(invoking_event) + + # Default return is AWSConfigConfigurationChanged event + return AWSConfigConfigurationChanged(invoking_event) + + +class AWSConfigConfigurationChanged(DictWrapper): + @property + def configuration_item_diff(self) -> Dict: + """The configuration item diff of the ConfigurationItemChangeNotification event.""" + return self["configurationItemDiff"] + + @property + def configuration_item(self) -> AWSConfigConfigurationItemChanged: + """The configuration item of the ConfigurationItemChangeNotification event.""" + return AWSConfigConfigurationItemChanged(self["configurationItem"]) + + @property + def raw_configuration_item(self) -> Dict: + """The raw configuration item of the ConfigurationItemChangeNotification event.""" + return self["configurationItem"] + + @property + def record_version(self) -> str: + """The record version of the ConfigurationItemChangeNotification event.""" + return self["recordVersion"] + + @property + def message_type(self) -> str: + """The message type of the ConfigurationItemChangeNotification event.""" + return self["messageType"] + + @property + def notification_creation_time(self) -> str: + """The notification creation time of the ConfigurationItemChangeNotification event.""" + return self["notificationCreationTime"] + + +class AWSConfigConfigurationItemChanged(DictWrapper): + @property + def related_events(self) -> List: + """The related events of the ConfigurationItemChangeNotification event.""" + return self["relatedEvents"] + + @property + def relationships(self) -> List: + """The relationships of the ConfigurationItemChangeNotification event.""" + return self["relationships"] + + @property + def configuration(self) -> Dict: + """The configuration of the ConfigurationItemChangeNotification event.""" + return self["configuration"] + + @property + def supplementary_configuration(self) -> Dict: + """The supplementary configuration of the ConfigurationItemChangeNotification event.""" + return self["supplementaryConfiguration"] + + @property + def tags(self) -> Dict: + """The tags of the ConfigurationItemChangeNotification event.""" + return self["tags"] + + @property + def configuration_item_version(self) -> str: + """The configuration item version of the ConfigurationItemChangeNotification event.""" + return self["configurationItemVersion"] + + @property + def configuration_item_capture_time(self) -> str: + """The configuration item capture time of the ConfigurationItemChangeNotification event.""" + return self["configurationItemCaptureTime"] + + @property + def configuration_state_id(self) -> str: + """The configuration state id of the ConfigurationItemChangeNotification event.""" + return self["configurationStateId"] + + @property + def accountid(self) -> str: + """The accountid of the ConfigurationItemChangeNotification event.""" + return self["awsAccountId"] + + @property + def configuration_item_status(self) -> str: + """The configuration item status of the ConfigurationItemChangeNotification event.""" + return self["configurationItemStatus"] + + @property + def resource_type(self) -> str: + """The resource type of the ConfigurationItemChangeNotification event.""" + return self["resourceType"] + + @property + def resource_id(self) -> str: + """The resource id of the ConfigurationItemChangeNotification event.""" + return self["resourceId"] + + @property + def resource_name(self) -> str: + """The resource name of the ConfigurationItemChangeNotification event.""" + return self["resourceName"] + + @property + def resource_arn(self) -> str: + """The resource arn of the ConfigurationItemChangeNotification event.""" + return self["ARN"] + + @property + def region(self) -> str: + """The region of the ConfigurationItemChangeNotification event.""" + return self["awsRegion"] + + @property + def availability_zone(self) -> str: + """The availability zone of the ConfigurationItemChangeNotification event.""" + return self["availabilityZone"] + + @property + def configuration_state_md5_hash(self) -> str: + """The md5 hash of the state of the ConfigurationItemChangeNotification event.""" + return self["configurationStateMd5Hash"] + + @property + def resource_creation_time(self) -> str: + """The resource creation time of the ConfigurationItemChangeNotification event.""" + return self["resourceCreationTime"] + + +class AWSConfigScheduledNotification(DictWrapper): + @property + def accountid(self) -> str: + """The accountid of the ScheduledNotification event.""" + return self["awsAccountId"] + + @property + def notification_creation_time(self) -> str: + """The notification creation time of the ScheduledNotification event.""" + return self["notificationCreationTime"] + + @property + def record_version(self) -> str: + """The record version of the ScheduledNotification event.""" + return self["recordVersion"] + + @property + def message_type(self) -> str: + """The message type of the ScheduledNotification event.""" + return self["messageType"] + + +class AWSConfigOversizedConfiguration(DictWrapper): + @property + def configuration_item_summary(self) -> AWSConfigOversizedConfigurationItemSummary: + """The configuration item summary of the OversizedConfiguration event.""" + return AWSConfigOversizedConfigurationItemSummary(self["configurationItemSummary"]) + + @property + def raw_configuration_item_summary(self) -> str: + """The raw configuration item summary of the OversizedConfiguration event.""" + return self["configurationItemSummary"] + + @property + def message_type(self) -> str: + """The message type of the OversizedConfiguration event.""" + return self["messageType"] + + @property + def notification_creation_time(self) -> str: + """The notification creation time of the OversizedConfiguration event.""" + return self["notificationCreationTime"] + + @property + def record_version(self) -> str: + """The record version of the OversizedConfiguration event.""" + return self["recordVersion"] + + +class AWSConfigOversizedConfigurationItemSummary(DictWrapper): + @property + def change_type(self) -> str: + """The change type of the OversizedConfiguration event.""" + return self["changeType"] + + @property + def configuration_item_version(self) -> str: + """The configuration item version of the OversizedConfiguration event.""" + return self["configurationItemVersion"] + + @property + def configuration_item_capture_time(self) -> str: + """The configuration item capture time of the OversizedConfiguration event.""" + return self["configurationItemCaptureTime"] + + @property + def configuration_state_id(self) -> str: + """The configuration state id of the OversizedConfiguration event.""" + return self["configurationStateId"] + + @property + def accountid(self) -> str: + """The accountid of the OversizedConfiguration event.""" + return self["awsAccountId"] + + @property + def configuration_item_status(self) -> str: + """The configuration item status of the OversizedConfiguration event.""" + return self["configurationItemStatus"] + + @property + def resource_type(self) -> str: + """The resource type of the OversizedConfiguration event.""" + return self["resourceType"] + + @property + def resource_id(self) -> str: + """The resource id of the OversizedConfiguration event.""" + return self["resourceId"] + + @property + def resource_name(self) -> str: + """The resource name of the OversizedConfiguration event.""" + return self["resourceName"] + + @property + def resource_arn(self) -> str: + """The resource arn of the OversizedConfiguration event.""" + return self["ARN"] + + @property + def region(self) -> str: + """The region of the OversizedConfiguration event.""" + return self["awsRegion"] + + @property + def availability_zone(self) -> str: + """The availability zone of the OversizedConfiguration event.""" + return self["availabilityZone"] + + @property + def configuration_state_md5_hash(self) -> str: + """The state md5 hash of the OversizedConfiguration event.""" + return self["configurationStateMd5Hash"] + + @property + def resource_creation_time(self) -> str: + """The resource creation time of the OversizedConfiguration event.""" + return self["resourceCreationTime"] + + +class AWSConfigRuleEvent(DictWrapper): + """Events for AWS Config Rules + Documentation: + -------------- + - https://docs.aws.amazon.com/config/latest/developerguide/evaluate-config_develop-rules_lambda-functions.html + """ + + def __init__(self, data: Dict[str, Any]): + super().__init__(data) + self._invoking_event: Optional[Any] = None + self._rule_parameters: Optional[Any] = None + + @property + def version(self) -> str: + """The version of the event.""" + return self["version"] + + @property + def invoking_event( + self, + ) -> AWSConfigConfigurationChanged | AWSConfigScheduledNotification | AWSConfigOversizedConfiguration: + """The invoking payload of the event.""" + if self._invoking_event is None: + self._invoking_event = self["invokingEvent"] + + return get_invoke_event(json.loads(self._invoking_event)) + + @property + def raw_invoking_event(self) -> str: + """The raw invoking payload of the event.""" + return self["invokingEvent"] + + @property + def rule_parameters(self) -> Dict: + """The parameters of the event.""" + if self._rule_parameters is None: + self._rule_parameters = self["ruleParameters"] + + return json.loads(self._rule_parameters) + + @property + def result_token(self) -> str: + """The result token of the event.""" + return self["resultToken"] + + @property + def event_left_scope(self) -> bool: + """The left scope of the event.""" + return self["eventLeftScope"] + + @property + def execution_role_arn(self) -> str: + """The execution role arn of the event.""" + return self["executionRoleArn"] + + @property + def config_rule_arn(self) -> str: + """The arn of the rule of the event.""" + return self["configRuleArn"] + + @property + def config_rule_name(self) -> str: + """The name of the rule of the event.""" + return self["configRuleName"] + + @property + def config_rule_id(self) -> str: + """The id of the rule of the event.""" + return self["configRuleId"] + + @property + def accountid(self) -> str: + """The accountid of the event.""" + return self["accountId"] + + @property + def evalution_mode(self) -> Optional[str]: + """The evalution mode of the event.""" + return self.get("evaluationMode") diff --git a/docs/utilities/data_classes.md b/docs/utilities/data_classes.md index 64557db6063..dcdca921ef6 100644 --- a/docs/utilities/data_classes.md +++ b/docs/utilities/data_classes.md @@ -84,6 +84,7 @@ Log Data Event for Troubleshooting | [Application Load Balancer](#application-load-balancer) | `ALBEvent` | | [AppSync Authorizer](#appsync-authorizer) | `AppSyncAuthorizerEvent` | | [AppSync Resolver](#appsync-resolver) | `AppSyncResolverEvent` | +| [AWS Config Rule](#aws-config-rule) | `AWSConfigRuleEvent` | | [CloudWatch Dashboard Custom Widget](#cloudwatch-dashboard-custom-widget) | `CloudWatchDashboardCustomWidgetEvent` | | [CloudWatch Logs](#cloudwatch-logs) | `CloudWatchLogsEvent` | | [CodePipeline Job Event](#codepipeline-job) | `CodePipelineJobEvent` | @@ -462,6 +463,26 @@ In this example, we also use the new Logger `correlation_id` and built-in `corre } ``` +### AWS Config Rule + +=== "aws_config_rule.py" + ```python hl_lines="3 11" + --8<-- "examples/event_sources/src/aws_config_rule.py" + ``` + +=== "Event - ItemChanged" + ```json + --8<-- "examples/event_sources/src/aws_config_rule_item_changed.json" + ``` +=== "Event - Oversized" + ```json + --8<-- "examples/event_sources/src/aws_config_rule_oversized.json" + ``` +=== "Event - ScheduledNotification" + ```json + --8<-- "examples/event_sources/src/aws_config_rule_scheduled.json" + ``` + ### CloudWatch Dashboard Custom Widget === "app.py" diff --git a/examples/event_sources/src/aws_config_rule.py b/examples/event_sources/src/aws_config_rule.py new file mode 100644 index 00000000000..b81ae39bd25 --- /dev/null +++ b/examples/event_sources/src/aws_config_rule.py @@ -0,0 +1,17 @@ +from aws_lambda_powertools import Logger +from aws_lambda_powertools.utilities.data_classes import ( + AWSConfigRuleEvent, + event_source, +) +from aws_lambda_powertools.utilities.typing import LambdaContext + +logger = Logger() + + +@event_source(data_class=AWSConfigRuleEvent) +def lambda_handler(event: AWSConfigRuleEvent, context: LambdaContext): + message_type = event.invoking_event.message_type + + logger.info(f"Logging {message_type} event rule", invoke_event=event.raw_invoking_event) + + return {"Success": "OK"} diff --git a/examples/event_sources/src/aws_config_rule_item_changed.json b/examples/event_sources/src/aws_config_rule_item_changed.json new file mode 100644 index 00000000000..cbf7abf67aa --- /dev/null +++ b/examples/event_sources/src/aws_config_rule_item_changed.json @@ -0,0 +1,13 @@ +{ + "version":"1.0", + "invokingEvent":"{\"configurationItemDiff\":{\"changedProperties\":{\"Configuration.InstanceType\":{\"previousValue\":\"t2.micro\",\"updatedValue\":\"t2.medium\",\"changeType\":\"UPDATE\"},\"Configuration.State.Name\":{\"previousValue\":\"running\",\"updatedValue\":\"stopped\",\"changeType\":\"UPDATE\"},\"Configuration.StateTransitionReason\":{\"previousValue\":\"\",\"updatedValue\":\"User initiated (2023-04-27 15:01:07 GMT)\",\"changeType\":\"UPDATE\"},\"Configuration.StateReason\":{\"previousValue\":null,\"updatedValue\":{\"code\":\"Client.UserInitiatedShutdown\",\"message\":\"Client.UserInitiatedShutdown: User initiated shutdown\"},\"changeType\":\"CREATE\"},\"Configuration.CpuOptions.CoreCount\":{\"previousValue\":1,\"updatedValue\":2,\"changeType\":\"UPDATE\"}},\"changeType\":\"UPDATE\"},\"configurationItem\":{\"relatedEvents\":[],\"relationships\":[{\"resourceId\":\"eipalloc-0ebb4367662263cc1\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::EIP\",\"name\":\"Is attached to ElasticIp\"},{\"resourceId\":\"eni-034dd31c4b17ada8c\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::NetworkInterface\",\"name\":\"Contains NetworkInterface\"},{\"resourceId\":\"eni-09a604c0ec356b06f\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::NetworkInterface\",\"name\":\"Contains NetworkInterface\"},{\"resourceId\":\"sg-0fb295a327d9b4835\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::SecurityGroup\",\"name\":\"Is associated with SecurityGroup\"},{\"resourceId\":\"subnet-cad1f2f4\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::Subnet\",\"name\":\"Is contained in Subnet\"},{\"resourceId\":\"vol-0a288b5eb9fea4b30\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::Volume\",\"name\":\"Is attached to Volume\"},{\"resourceId\":\"vpc-2d96be57\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::VPC\",\"name\":\"Is contained in Vpc\"}],\"configuration\":{\"amiLaunchIndex\":0,\"imageId\":\"ami-09d95fab7fff3776c\",\"instanceId\":\"i-042dd005362091826\",\"instanceType\":\"t2.medium\",\"kernelId\":null,\"keyName\":\"mihaec2\",\"launchTime\":\"2023-04-27T14:57:16.000Z\",\"monitoring\":{\"state\":\"disabled\"},\"placement\":{\"availabilityZone\":\"us-east-1e\",\"affinity\":null,\"groupName\":\"\",\"partitionNumber\":null,\"hostId\":null,\"tenancy\":\"default\",\"spreadDomain\":null,\"hostResourceGroupArn\":null},\"platform\":null,\"privateDnsName\":\"ip-172-31-78-41.ec2.internal\",\"privateIpAddress\":\"172.31.78.41\",\"productCodes\":[],\"publicDnsName\":\"ec2-3-232-229-57.compute-1.amazonaws.com\",\"publicIpAddress\":\"3.232.229.57\",\"ramdiskId\":null,\"state\":{\"code\":80,\"name\":\"stopped\"},\"stateTransitionReason\":\"User initiated (2023-04-27 15:01:07 GMT)\",\"subnetId\":\"subnet-cad1f2f4\",\"vpcId\":\"vpc-2d96be57\",\"architecture\":\"x86_64\",\"blockDeviceMappings\":[{\"deviceName\":\"/dev/xvda\",\"ebs\":{\"attachTime\":\"2020-05-30T15:21:58.000Z\",\"deleteOnTermination\":true,\"status\":\"attached\",\"volumeId\":\"vol-0a288b5eb9fea4b30\"}}],\"clientToken\":\"\",\"ebsOptimized\":false,\"enaSupport\":true,\"hypervisor\":\"xen\",\"iamInstanceProfile\":{\"arn\":\"arn:aws:iam::0123456789012:instance-profile/AmazonSSMRoleForInstancesQuickSetup\",\"id\":\"AIPAS5S4WFUBL72S3QXW5\"},\"instanceLifecycle\":null,\"elasticGpuAssociations\":[],\"elasticInferenceAcceleratorAssociations\":[],\"networkInterfaces\":[{\"association\":{\"carrierIp\":null,\"ipOwnerId\":\"0123456789012\",\"publicDnsName\":\"ec2-3-232-229-57.compute-1.amazonaws.com\",\"publicIp\":\"3.232.229.57\"},\"attachment\":{\"attachTime\":\"2020-05-30T15:21:57.000Z\",\"attachmentId\":\"eni-attach-0a7e75dc9c1c291a0\",\"deleteOnTermination\":true,\"deviceIndex\":0,\"status\":\"attached\",\"networkCardIndex\":0},\"description\":\"\",\"groups\":[{\"groupName\":\"minhaec2\",\"groupId\":\"sg-0fb295a327d9b4835\"}],\"ipv6Addresses\":[],\"macAddress\":\"06:cf:00:c2:17:db\",\"networkInterfaceId\":\"eni-034dd31c4b17ada8c\",\"ownerId\":\"0123456789012\",\"privateDnsName\":\"ip-172-31-78-41.ec2.internal\",\"privateIpAddress\":\"172.31.78.41\",\"privateIpAddresses\":[{\"association\":{\"carrierIp\":null,\"ipOwnerId\":\"0123456789012\",\"publicDnsName\":\"ec2-3-232-229-57.compute-1.amazonaws.com\",\"publicIp\":\"3.232.229.57\"},\"primary\":true,\"privateDnsName\":\"ip-172-31-78-41.ec2.internal\",\"privateIpAddress\":\"172.31.78.41\"}],\"sourceDestCheck\":true,\"status\":\"in-use\",\"subnetId\":\"subnet-cad1f2f4\",\"vpcId\":\"vpc-2d96be57\",\"interfaceType\":\"interface\"},{\"association\":null,\"attachment\":{\"attachTime\":\"2020-11-26T23:46:04.000Z\",\"attachmentId\":\"eni-attach-0e6d150ebbd19966e\",\"deleteOnTermination\":false,\"deviceIndex\":1,\"status\":\"attached\",\"networkCardIndex\":0},\"description\":\"MINHAEC2AAAAAA\",\"groups\":[{\"groupName\":\"minhaec2\",\"groupId\":\"sg-0fb295a327d9b4835\"},{\"groupName\":\"default\",\"groupId\":\"sg-88105fa0\"}],\"ipv6Addresses\":[],\"macAddress\":\"06:0a:62:00:64:5f\",\"networkInterfaceId\":\"eni-09a604c0ec356b06f\",\"ownerId\":\"0123456789012\",\"privateDnsName\":\"ip-172-31-70-9.ec2.internal\",\"privateIpAddress\":\"172.31.70.9\",\"privateIpAddresses\":[{\"association\":null,\"primary\":true,\"privateDnsName\":\"ip-172-31-70-9.ec2.internal\",\"privateIpAddress\":\"172.31.70.9\"}],\"sourceDestCheck\":true,\"status\":\"in-use\",\"subnetId\":\"subnet-cad1f2f4\",\"vpcId\":\"vpc-2d96be57\",\"interfaceType\":\"interface\"}],\"outpostArn\":null,\"rootDeviceName\":\"/dev/xvda\",\"rootDeviceType\":\"ebs\",\"securityGroups\":[{\"groupName\":\"minhaec2\",\"groupId\":\"sg-0fb295a327d9b4835\"}],\"sourceDestCheck\":true,\"spotInstanceRequestId\":null,\"sriovNetSupport\":null,\"stateReason\":{\"code\":\"Client.UserInitiatedShutdown\",\"message\":\"Client.UserInitiatedShutdown: User initiated shutdown\"},\"tags\":[{\"key\":\"projeto\",\"value\":\"meetup\"},{\"key\":\"Name\",\"value\":\"Minha\"},{\"key\":\"CentroCusto\",\"value\":\"TI\"},{\"key\":\"Setor\",\"value\":\"Desenvolvimento\"}],\"virtualizationType\":\"hvm\",\"cpuOptions\":{\"coreCount\":2,\"threadsPerCore\":1},\"capacityReservationId\":null,\"capacityReservationSpecification\":{\"capacityReservationPreference\":\"open\",\"capacityReservationTarget\":null},\"hibernationOptions\":{\"configured\":false},\"licenses\":[],\"metadataOptions\":{\"state\":\"applied\",\"httpTokens\":\"optional\",\"httpPutResponseHopLimit\":1,\"httpEndpoint\":\"enabled\"},\"enclaveOptions\":{\"enabled\":false},\"bootMode\":null},\"supplementaryConfiguration\":{},\"tags\":{\"projeto\":\"meetup\",\"Setor\":\"Desenvolvimento\",\"CentroCusto\":\"TI\",\"Name\":\"Minha\"},\"configurationItemVersion\":\"1.3\",\"configurationItemCaptureTime\":\"2023-04-27T15:03:11.636Z\",\"configurationStateId\":1682607791636,\"awsAccountId\":\"0123456789012\",\"configurationItemStatus\":\"OK\",\"resourceType\":\"AWS::EC2::Instance\",\"resourceId\":\"i-042dd005362091826\",\"resourceName\":null,\"ARN\":\"arn:aws:ec2:us-east-1:0123456789012:instance/i-042dd005362091826\",\"awsRegion\":\"us-east-1\",\"availabilityZone\":\"us-east-1e\",\"configurationStateMd5Hash\":\"\",\"resourceCreationTime\":\"2023-04-27T14:57:16.000Z\"},\"notificationCreationTime\":\"2023-04-27T15:03:13.332Z\",\"messageType\":\"ConfigurationItemChangeNotification\",\"recordVersion\":\"1.3\"}", + "ruleParameters":"{\"desiredInstanceType\": \"t2.micro\"}", + "resultToken":"eyJlbmNyeXB0ZWREYXRhIjpbLTQxLDEsLTU3LC0zMCwtMTIxLDUzLDUyLDQ1LC01NywtOCw3MywtODEsLTExNiwtMTAyLC01MiwxMTIsLTQ3LDU4LDY1LC0xMjcsMTAyLDUsLTY5LDQ0LC0xNSwxMTQsNDEsLTksMTExLC0zMCw2NSwtNzUsLTM1LDU0LDEwNSwtODksODYsNDAsLTEwNSw5OCw2NSwtMTE5LC02OSwyNCw2NiwtMjAsODAsLTExMiwtNzgsLTgwLDQzLC01NywzMCwt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123456789012:role/aws-service-role/config.amazonaws.com/AWSServiceRoleForConfig", + "configRuleArn":"arn:aws:config:us-east-1:0123456789012:config-rule/config-rule-i9y8j9", + "configRuleName":"MyRule", + "configRuleId":"config-rule-i9y8j9", + "accountId":"0123456789012", + "evaluationMode":"DETECTIVE" + } diff --git a/examples/event_sources/src/aws_config_rule_oversized.json b/examples/event_sources/src/aws_config_rule_oversized.json new file mode 100644 index 00000000000..5eaef4e0015 --- /dev/null +++ b/examples/event_sources/src/aws_config_rule_oversized.json @@ -0,0 +1,12 @@ +{ + "invokingEvent": "{\"configurationItemSummary\": {\"changeType\": \"UPDATE\",\"configurationItemVersion\": \"1.2\",\"configurationItemCaptureTime\":\"2016-10-06T16:46:16.261Z\",\"configurationStateId\": 0,\"awsAccountId\":\"123456789012\",\"configurationItemStatus\": \"OK\",\"resourceType\": \"AWS::EC2::Instance\",\"resourceId\":\"i-00000000\",\"resourceName\":null,\"ARN\":\"arn:aws:ec2:us-west-2:123456789012:instance/i-00000000\",\"awsRegion\": \"us-west-2\",\"availabilityZone\":\"us-west-2a\",\"configurationStateMd5Hash\":\"8f1ee69b287895a0f8bc5753eca68e96\",\"resourceCreationTime\":\"2016-10-06T16:46:10.489Z\"},\"messageType\":\"OversizedConfigurationItemChangeNotification\", \"notificationCreationTime\": \"2016-10-06T16:46:16.261Z\", \"recordVersion\": \"1.0\"}", + "ruleParameters": "{\"myParameterKey\":\"myParameterValue\"}", + "resultToken": "myResultToken", + "eventLeftScope": false, + "executionRoleArn": "arn:aws:iam::123456789012:role/config-role", + "configRuleArn": "arn:aws:config:us-east-2:123456789012:config-rule/config-rule-ec2-managed-instance-inventory", + "configRuleName": "change-triggered-config-rule", + "configRuleId": "config-rule-0123456", + "accountId": "123456789012", + "version": "1.0" +} diff --git a/examples/event_sources/src/aws_config_rule_scheduled.json b/examples/event_sources/src/aws_config_rule_scheduled.json new file mode 100644 index 00000000000..f21ed9fe57f --- /dev/null +++ b/examples/event_sources/src/aws_config_rule_scheduled.json @@ -0,0 +1,13 @@ +{ + "version":"1.0", + "invokingEvent":"{\"awsAccountId\":\"0123456789012\",\"notificationCreationTime\":\"2023-04-27T13:26:17.741Z\",\"messageType\":\"ScheduledNxotification\",\"recordVersion\":\"1.0\"}", + "ruleParameters":"{\"test\":\"x\"}", + "resultToken":"eyJlbmNyeXB0ZWREYXRhIjpbLTQyLDEyNiw1MiwtMzcsLTI5LDExNCwxMjYsLTk3LDcxLDIyLC0xMTAsMTEyLC0zMSwtOTMsLTQ5LC0xMDEsODIsMyw1NCw0OSwzLC02OSwtNzEsLTcyLDYyLDgxLC03MiwtODEsNTAsMzUsLTUwLC03NSwtMTE4LC0xMTgsNzcsMTIsLTEsMTQsMTIwLC03MCwxMTAsLTMsNTAsLTYwLDEwNSwtNTcsNDUsMTAyLC0xMDksLTYxLC0xMDEsLTYxLDQsNDcsLTg0LC0yNSwxMTIsNTQsLTcxLC0xMDksNDUsMTksMTIzLC0yNiwxMiwtOTYsLTczLDU0LC0xMDksOTIsNDgsLTU5LC04MywtMzIsODIsLTM2LC05MCwxOSw5OCw3Nyw3OCw0MCw4MCw3OCwtMTA1LDg3LC0xMTMsLTExNiwtNzIsMzAsLTY4LC00MCwtODksMTA5LC0xMDgsLTEyOCwyMiw3Miw3NywtMjEsNzYsODksOTQsLTU5LDgxLC0xMjEsLTEwNywtNjcsNjMsLTcsODIsLTg5LC00NiwtMzQsLTkyLDEyMiwtOTAsMTcsLTEyMywyMCwtODUsLTU5LC03MCw4MSwyNyw2Miw3NCwtODAsODAsMzcsNDAsMTE2LDkxLC0yNCw1MSwtNDEsLTc5LDI4LDEyMCw1MywtMTIyLC04MywxMjYsLTc4LDI1LC05OCwtMzYsMTMsMzIsODYsLTI1LDQ4LDMsLTEwMiwtMTYsMjQsLTMsODUsNDQsLTI4LDE0LDIyLDI3LC0xMjIsMTE4LDEwMSw3Myw1LDE4LDU4LC02NCwyMywtODYsLTExNCwyNCwwLDEwMCwyLDExNywtNjIsLTExOSwtMT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LTU2LDUxLC0xNSwtMzYsNjEsLTk0LC03OSwtNDUsMTI2LC03NywtMTA1LC0yLC05MywtNiw4LC0zLDYsLTQyLDQ2LDEyNSw1LC05OCwxMyw2NywtMTAsLTEzLC05NCwtNzgsLTEyNywxMjEsLTI2LC04LC0xMDEsLTkxLDEyMSwtNDAsLTEyNCwtNjQsODQsLTcyLDYzLDE5LC04NF0sIm1hdGVyaWFsU2V0U2VyaWFsTnVtYmVyIjoxLCJpdlBhcmFtZXRlclNwZWMiOnsiaXYiOlszLC0xMCwtODUsMTE0LC05MCwxMTUsNzcsNTUsNTQsMTUsMzgsODQsLTExNiwxNCwtNDAsMjhdfX0=", + "eventLeftScope":false, + "executionRoleArn":"arn:aws:iam::0123456789012:role/aws-service-role/config.amazonaws.com/AWSServiceRoleForConfig", + "configRuleArn":"arn:aws:config:us-east-1:0123456789012:config-rule/config-rule-pdmyw1", + "configRuleName":"rule-ec2-test", + "configRuleId":"config-rule-pdmyw1", + "accountId":"0123456789012", + "evaluationMode":"DETECTIVE" + } diff --git a/tests/events/awsConfigRuleConfigurationChanged.json b/tests/events/awsConfigRuleConfigurationChanged.json new file mode 100644 index 00000000000..cbf7abf67aa --- /dev/null +++ b/tests/events/awsConfigRuleConfigurationChanged.json @@ -0,0 +1,13 @@ +{ + "version":"1.0", + "invokingEvent":"{\"configurationItemDiff\":{\"changedProperties\":{\"Configuration.InstanceType\":{\"previousValue\":\"t2.micro\",\"updatedValue\":\"t2.medium\",\"changeType\":\"UPDATE\"},\"Configuration.State.Name\":{\"previousValue\":\"running\",\"updatedValue\":\"stopped\",\"changeType\":\"UPDATE\"},\"Configuration.StateTransitionReason\":{\"previousValue\":\"\",\"updatedValue\":\"User initiated (2023-04-27 15:01:07 GMT)\",\"changeType\":\"UPDATE\"},\"Configuration.StateReason\":{\"previousValue\":null,\"updatedValue\":{\"code\":\"Client.UserInitiatedShutdown\",\"message\":\"Client.UserInitiatedShutdown: User initiated shutdown\"},\"changeType\":\"CREATE\"},\"Configuration.CpuOptions.CoreCount\":{\"previousValue\":1,\"updatedValue\":2,\"changeType\":\"UPDATE\"}},\"changeType\":\"UPDATE\"},\"configurationItem\":{\"relatedEvents\":[],\"relationships\":[{\"resourceId\":\"eipalloc-0ebb4367662263cc1\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::EIP\",\"name\":\"Is attached to ElasticIp\"},{\"resourceId\":\"eni-034dd31c4b17ada8c\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::NetworkInterface\",\"name\":\"Contains NetworkInterface\"},{\"resourceId\":\"eni-09a604c0ec356b06f\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::NetworkInterface\",\"name\":\"Contains NetworkInterface\"},{\"resourceId\":\"sg-0fb295a327d9b4835\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::SecurityGroup\",\"name\":\"Is associated with SecurityGroup\"},{\"resourceId\":\"subnet-cad1f2f4\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::Subnet\",\"name\":\"Is contained in Subnet\"},{\"resourceId\":\"vol-0a288b5eb9fea4b30\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::Volume\",\"name\":\"Is attached to Volume\"},{\"resourceId\":\"vpc-2d96be57\",\"resourceName\":null,\"resourceType\":\"AWS::EC2::VPC\",\"name\":\"Is contained in Vpc\"}],\"configuration\":{\"amiLaunchIndex\":0,\"imageId\":\"ami-09d95fab7fff3776c\",\"instanceId\":\"i-042dd005362091826\",\"instanceType\":\"t2.medium\",\"kernelId\":null,\"keyName\":\"mihaec2\",\"launchTime\":\"2023-04-27T14:57:16.000Z\",\"monitoring\":{\"state\":\"disabled\"},\"placement\":{\"availabilityZone\":\"us-east-1e\",\"affinity\":null,\"groupName\":\"\",\"partitionNumber\":null,\"hostId\":null,\"tenancy\":\"default\",\"spreadDomain\":null,\"hostResourceGroupArn\":null},\"platform\":null,\"privateDnsName\":\"ip-172-31-78-41.ec2.internal\",\"privateIpAddress\":\"172.31.78.41\",\"productCodes\":[],\"publicDnsName\":\"ec2-3-232-229-57.compute-1.amazonaws.com\",\"publicIpAddress\":\"3.232.229.57\",\"ramdiskId\":null,\"state\":{\"code\":80,\"name\":\"stopped\"},\"stateTransitionReason\":\"User initiated (2023-04-27 15:01:07 GMT)\",\"subnetId\":\"subnet-cad1f2f4\",\"vpcId\":\"vpc-2d96be57\",\"architecture\":\"x86_64\",\"blockDeviceMappings\":[{\"deviceName\":\"/dev/xvda\",\"ebs\":{\"attachTime\":\"2020-05-30T15:21:58.000Z\",\"deleteOnTermination\":true,\"status\":\"attached\",\"volumeId\":\"vol-0a288b5eb9fea4b30\"}}],\"clientToken\":\"\",\"ebsOptimized\":false,\"enaSupport\":true,\"hypervisor\":\"xen\",\"iamInstanceProfile\":{\"arn\":\"arn:aws:iam::0123456789012:instance-profile/AmazonSSMRoleForInstancesQuickSetup\",\"id\":\"AIPAS5S4WFUBL72S3QXW5\"},\"instanceLifecycle\":null,\"elasticGpuAssociations\":[],\"elasticInferenceAcceleratorAssociations\":[],\"networkInterfaces\":[{\"association\":{\"carrierIp\":null,\"ipOwnerId\":\"0123456789012\",\"publicDnsName\":\"ec2-3-232-229-57.compute-1.amazonaws.com\",\"publicIp\":\"3.232.229.57\"},\"attachment\":{\"attachTime\":\"2020-05-30T15:21:57.000Z\",\"attachmentId\":\"eni-attach-0a7e75dc9c1c291a0\",\"deleteOnTermination\":true,\"deviceIndex\":0,\"status\":\"attached\",\"networkCardIndex\":0},\"description\":\"\",\"groups\":[{\"groupName\":\"minhaec2\",\"groupId\":\"sg-0fb295a327d9b4835\"}],\"ipv6Addresses\":[],\"macAddress\":\"06:cf:00:c2:17:db\",\"networkInterfaceId\":\"eni-034dd31c4b17ada8c\",\"ownerId\":\"0123456789012\",\"privateDnsName\":\"ip-172-31-78-41.ec2.internal\",\"privateIpAddress\":\"172.31.78.41\",\"privateIpAddresses\":[{\"association\":{\"carrierIp\":null,\"ipOwnerId\":\"0123456789012\",\"publicDnsName\":\"ec2-3-232-229-57.compute-1.amazonaws.com\",\"publicIp\":\"3.232.229.57\"},\"primary\":true,\"privateDnsName\":\"ip-172-31-78-41.ec2.internal\",\"privateIpAddress\":\"172.31.78.41\"}],\"sourceDestCheck\":true,\"status\":\"in-use\",\"subnetId\":\"subnet-cad1f2f4\",\"vpcId\":\"vpc-2d96be57\",\"interfaceType\":\"interface\"},{\"association\":null,\"attachment\":{\"attachTime\":\"2020-11-26T23:46:04.000Z\",\"attachmentId\":\"eni-attach-0e6d150ebbd19966e\",\"deleteOnTermination\":false,\"deviceIndex\":1,\"status\":\"attached\",\"networkCardIndex\":0},\"description\":\"MINHAEC2AAAAAA\",\"groups\":[{\"groupName\":\"minhaec2\",\"groupId\":\"sg-0fb295a327d9b4835\"},{\"groupName\":\"default\",\"groupId\":\"sg-88105fa0\"}],\"ipv6Addresses\":[],\"macAddress\":\"06:0a:62:00:64:5f\",\"networkInterfaceId\":\"eni-09a604c0ec356b06f\",\"ownerId\":\"0123456789012\",\"privateDnsName\":\"ip-172-31-70-9.ec2.internal\",\"privateIpAddress\":\"172.31.70.9\",\"privateIpAddresses\":[{\"association\":null,\"primary\":true,\"privateDnsName\":\"ip-172-31-70-9.ec2.internal\",\"privateIpAddress\":\"172.31.70.9\"}],\"sourceDestCheck\":true,\"status\":\"in-use\",\"subnetId\":\"subnet-cad1f2f4\",\"vpcId\":\"vpc-2d96be57\",\"interfaceType\":\"interface\"}],\"outpostArn\":null,\"rootDeviceName\":\"/dev/xvda\",\"rootDeviceType\":\"ebs\",\"securityGroups\":[{\"groupName\":\"minhaec2\",\"groupId\":\"sg-0fb295a327d9b4835\"}],\"sourceDestCheck\":true,\"spotInstanceRequestId\":null,\"sriovNetSupport\":null,\"stateReason\":{\"code\":\"Client.UserInitiatedShutdown\",\"message\":\"Client.UserInitiatedShutdown: User initiated shutdown\"},\"tags\":[{\"key\":\"projeto\",\"value\":\"meetup\"},{\"key\":\"Name\",\"value\":\"Minha\"},{\"key\":\"CentroCusto\",\"value\":\"TI\"},{\"key\":\"Setor\",\"value\":\"Desenvolvimento\"}],\"virtualizationType\":\"hvm\",\"cpuOptions\":{\"coreCount\":2,\"threadsPerCore\":1},\"capacityReservationId\":null,\"capacityReservationSpecification\":{\"capacityReservationPreference\":\"open\",\"capacityReservationTarget\":null},\"hibernationOptions\":{\"configured\":false},\"licenses\":[],\"metadataOptions\":{\"state\":\"applied\",\"httpTokens\":\"optional\",\"httpPutResponseHopLimit\":1,\"httpEndpoint\":\"enabled\"},\"enclaveOptions\":{\"enabled\":false},\"bootMode\":null},\"supplementaryConfiguration\":{},\"tags\":{\"projeto\":\"meetup\",\"Setor\":\"Desenvolvimento\",\"CentroCusto\":\"TI\",\"Name\":\"Minha\"},\"configurationItemVersion\":\"1.3\",\"configurationItemCaptureTime\":\"2023-04-27T15:03:11.636Z\",\"configurationStateId\":1682607791636,\"awsAccountId\":\"0123456789012\",\"configurationItemStatus\":\"OK\",\"resourceType\":\"AWS::EC2::Instance\",\"resourceId\":\"i-042dd005362091826\",\"resourceName\":null,\"ARN\":\"arn:aws:ec2:us-east-1:0123456789012:instance/i-042dd005362091826\",\"awsRegion\":\"us-east-1\",\"availabilityZone\":\"us-east-1e\",\"configurationStateMd5Hash\":\"\",\"resourceCreationTime\":\"2023-04-27T14:57:16.000Z\"},\"notificationCreationTime\":\"2023-04-27T15:03:13.332Z\",\"messageType\":\"ConfigurationItemChangeNotification\",\"recordVersion\":\"1.3\"}", + "ruleParameters":"{\"desiredInstanceType\": \"t2.micro\"}", + "resultToken":"eyJlbmNyeXB0ZWREYXRhIjpbLTQxLDEsLTU3LC0zMCwtMTIxLDUzLDUyLDQ1LC01NywtOCw3MywtODEsLTExNiwtMTAyLC01MiwxMTIsLTQ3LDU4LDY1LC0xMjcsMTAyLDUsLTY5LDQ0LC0xNSwxMTQsNDEsLTksMTExLC0zMCw2NSwtNzUsLTM1LDU0LDEwNSwtODksODYsNDAsLTEwNSw5OCw2NSwtMTE5LC02OSwyNCw2NiwtMjAsODAsLTExMiwtNz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"executionRoleArn":"arn:aws:iam::0123456789012:role/aws-service-role/config.amazonaws.com/AWSServiceRoleForConfig", + "configRuleArn":"arn:aws:config:us-east-1:0123456789012:config-rule/config-rule-i9y8j9", + "configRuleName":"MyRule", + "configRuleId":"config-rule-i9y8j9", + "accountId":"0123456789012", + "evaluationMode":"DETECTIVE" + } diff --git a/tests/events/awsConfigRuleOversizedConfiguration.json b/tests/events/awsConfigRuleOversizedConfiguration.json new file mode 100644 index 00000000000..5eaef4e0015 --- /dev/null +++ b/tests/events/awsConfigRuleOversizedConfiguration.json @@ -0,0 +1,12 @@ +{ + "invokingEvent": "{\"configurationItemSummary\": {\"changeType\": \"UPDATE\",\"configurationItemVersion\": \"1.2\",\"configurationItemCaptureTime\":\"2016-10-06T16:46:16.261Z\",\"configurationStateId\": 0,\"awsAccountId\":\"123456789012\",\"configurationItemStatus\": \"OK\",\"resourceType\": \"AWS::EC2::Instance\",\"resourceId\":\"i-00000000\",\"resourceName\":null,\"ARN\":\"arn:aws:ec2:us-west-2:123456789012:instance/i-00000000\",\"awsRegion\": \"us-west-2\",\"availabilityZone\":\"us-west-2a\",\"configurationStateMd5Hash\":\"8f1ee69b287895a0f8bc5753eca68e96\",\"resourceCreationTime\":\"2016-10-06T16:46:10.489Z\"},\"messageType\":\"OversizedConfigurationItemChangeNotification\", \"notificationCreationTime\": \"2016-10-06T16:46:16.261Z\", \"recordVersion\": \"1.0\"}", + "ruleParameters": "{\"myParameterKey\":\"myParameterValue\"}", + "resultToken": "myResultToken", + "eventLeftScope": false, + "executionRoleArn": "arn:aws:iam::123456789012:role/config-role", + "configRuleArn": "arn:aws:config:us-east-2:123456789012:config-rule/config-rule-ec2-managed-instance-inventory", + "configRuleName": "change-triggered-config-rule", + "configRuleId": "config-rule-0123456", + "accountId": "123456789012", + "version": "1.0" +} diff --git a/tests/events/awsConfigRuleScheduled.json b/tests/events/awsConfigRuleScheduled.json new file mode 100644 index 00000000000..02ce2a0700c --- /dev/null +++ b/tests/events/awsConfigRuleScheduled.json @@ -0,0 +1,13 @@ +{ + "version":"1.0", + "invokingEvent":"{\"awsAccountId\":\"0123456789012\",\"notificationCreationTime\":\"2023-04-27T13:26:17.741Z\",\"messageType\":\"ScheduledNotification\",\"recordVersion\":\"1.0\"}", + "ruleParameters":"{\"test\":\"x\"}", + "resultToken":"eyJlbmNyeXB0ZWREYXRhIjpbLTQyLDEyNiw1MiwtMzcsLTI5LDExNCwxMjYsLTk3LDcxLDIyLC0xMTAsMTEyLC0zMSwtOTMsLTQ5LC0xMDEsODIsMyw1NCw0OSwzLC02OSwtNzEsLTcyLDYyLDgxLC03MiwtODEsNTAsMzUsLTUwLC03NSwtMTE4LC0xMTgsNzcsMTIsLTEsMTQsMTIwLC03MCwxMTAsLTMsNTAsLTYwLDEwNSwtNTcsNDUsMTAyLC0xMDksLTYxLC0xMDEsLTYxLDQsNDcsLTg0LC0yNSwxMTIsNTQsLTcxLC0xMDksNDUsMTksMTIzLC0yNiwxMiwtOTYsLTczLDU0LC0xMDksOTIsNDgsLTU5LC04MywtMzIsODIsLTM2LC05MCwxOSw5OCw3Nyw3OCw0MCw4MCw3OCwtMTA1LDg3LC0xMTMsLTExNiwtNzIsMzAsLTY4LC00MCwtODksMTA5LC0xMDgsLTEyOCwyMiw3Miw3NywtMjEsNzYsODksOTQsLTU5LDgxLC0xMjEsLTEwNywtNjcsNjMsLTcsODIsLTg5LC00NiwtMzQsLTkyLDEyMiwtOTAsMTcsLTEyMywyMCwtODUsLTU5LC03MCw4MSwyNyw2Miw3NCwtODAsODAsMzcsNDAsMTE2LDkxLC0yNCw1MSwtNDEsLTc5LDI4LDEyMCw1MywtMTIyLC04MywxMjYsLTc4LDI1LC05OCwtMzYsMTMsMzIsODYsLTI1LDQ4LDMsLTEwMiwtMTYsMjQsLTMsODUsNDQsLTI4LDE0LDIyLDI3LC0xMjIsMTE4LDEwMSw3Myw1LDE4LDU4LC02NCwyMywtODYsLTExNCwyNCwwLDEwMCwyLDExNywtNjIsLTEx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wtNTAsLTU2LDUxLC0xNSwtMzYsNjEsLTk0LC03OSwtNDUsMTI2LC03NywtMTA1LC0yLC05MywtNiw4LC0zLDYsLTQyLDQ2LDEyNSw1LC05OCwxMyw2NywtMTAsLTEzLC05NCwtNzgsLTEyNywxMjEsLTI2LC04LC0xMDEsLTkxLDEyMSwtNDAsLTEyNCwtNjQsODQsLTcyLDYzLDE5LC04NF0sIm1hdGVyaWFsU2V0U2VyaWFsTnVtYmVyIjoxLCJpdlBhcmFtZXRlclNwZWMiOnsiaXYiOlszLC0xMCwtODUsMTE0LC05MCwxMTUsNzcsNTUsNTQsMTUsMzgsODQsLTExNiwxNCwtNDAsMjhdfX0=", + "eventLeftScope":false, + "executionRoleArn":"arn:aws:iam::0123456789012:role/aws-service-role/config.amazonaws.com/AWSServiceRoleForConfig", + "configRuleArn":"arn:aws:config:us-east-1:0123456789012:config-rule/config-rule-pdmyw1", + "configRuleName":"rule-ec2-test", + "configRuleId":"config-rule-pdmyw1", + "accountId":"0123456789012", + "evaluationMode":"DETECTIVE" + } diff --git a/tests/functional/test_data_classes.py b/tests/functional/test_data_classes.py index 23f4b18e53d..a811a779255 100644 --- a/tests/functional/test_data_classes.py +++ b/tests/functional/test_data_classes.py @@ -14,6 +14,7 @@ APIGatewayProxyEvent, APIGatewayProxyEventV2, AppSyncResolverEvent, + AWSConfigRuleEvent, CloudWatchDashboardCustomWidgetEvent, CloudWatchLogsEvent, CodePipelineJobEvent, @@ -2044,6 +2045,176 @@ def test_api_gateway_route_arn_parser(): assert details.arn == arn + "/" +def test_aws_config_rule_configuration_changed(): + """Check AWS Config ConfigurationItemChangeNotification event""" + event = AWSConfigRuleEvent(load_event("awsConfigRuleConfigurationChanged.json")) + + invoking_event = json.loads(event["invokingEvent"]) + + assert event.rule_parameters == json.loads(event["ruleParameters"]) + assert event.raw_invoking_event == event["invokingEvent"] + assert event.result_token == event["resultToken"] + assert event.event_left_scope == event["eventLeftScope"] + assert event.execution_role_arn == event["executionRoleArn"] + assert event.config_rule_arn == event["configRuleArn"] + assert event.config_rule_name == event["configRuleName"] + assert event.config_rule_id == event["configRuleId"] + assert event.accountid == event["accountId"] + assert event.version == event["version"] + assert event.evalution_mode == event["evaluationMode"] + assert event.invoking_event.message_type == invoking_event["messageType"] + assert event.invoking_event.raw_configuration_item == invoking_event["configurationItem"] + assert event.invoking_event.record_version == invoking_event["recordVersion"] + assert event.invoking_event.notification_creation_time == invoking_event["notificationCreationTime"] + assert event.invoking_event.configuration_item_diff == invoking_event["configurationItemDiff"] + assert ( + event.invoking_event.configuration_item.related_events == invoking_event["configurationItem"]["relatedEvents"] + ) + assert event.invoking_event.configuration_item.relationships == invoking_event["configurationItem"]["relationships"] + assert event.invoking_event.configuration_item.configuration == invoking_event["configurationItem"]["configuration"] + assert ( + event.invoking_event.configuration_item.supplementary_configuration + == invoking_event["configurationItem"]["supplementaryConfiguration"] + ) + assert event.invoking_event.configuration_item.tags == invoking_event["configurationItem"]["tags"] + assert ( + event.invoking_event.configuration_item.configuration_item_version + == invoking_event["configurationItem"]["configurationItemVersion"] + ) + assert ( + event.invoking_event.configuration_item.configuration_item_capture_time + == invoking_event["configurationItem"]["configurationItemCaptureTime"] + ) + assert ( + event.invoking_event.configuration_item.configuration_state_id + == invoking_event["configurationItem"]["configurationStateId"] + ) + assert event.invoking_event.configuration_item.accountid == invoking_event["configurationItem"]["awsAccountId"] + assert ( + event.invoking_event.configuration_item.configuration_item_status + == invoking_event["configurationItem"]["configurationItemStatus"] + ) + assert event.invoking_event.configuration_item.resource_type == invoking_event["configurationItem"]["resourceType"] + assert event.invoking_event.configuration_item.resource_id == invoking_event["configurationItem"]["resourceId"] + assert event.invoking_event.configuration_item.resource_name == invoking_event["configurationItem"]["resourceName"] + assert event.invoking_event.configuration_item.resource_arn == invoking_event["configurationItem"]["ARN"] + assert event.invoking_event.configuration_item.region == invoking_event["configurationItem"]["awsRegion"] + assert ( + event.invoking_event.configuration_item.availability_zone + == invoking_event["configurationItem"]["availabilityZone"] + ) + assert ( + event.invoking_event.configuration_item.configuration_state_md5_hash + == invoking_event["configurationItem"]["configurationStateMd5Hash"] + ) + assert ( + event.invoking_event.configuration_item.resource_creation_time + == invoking_event["configurationItem"]["resourceCreationTime"] + ) + + +def test_aws_config_rule_oversized_configuration(): + """Check AWS Config OversizedConfigurationItemChangeNotification event""" + event = AWSConfigRuleEvent(load_event("awsConfigRuleOversizedConfiguration.json")) + + invoking_event = json.loads(event["invokingEvent"]) + + assert event.rule_parameters == json.loads(event["ruleParameters"]) + assert event.raw_invoking_event == event["invokingEvent"] + assert event.result_token == event["resultToken"] + assert event.event_left_scope == event["eventLeftScope"] + assert event.execution_role_arn == event["executionRoleArn"] + assert event.config_rule_arn == event["configRuleArn"] + assert event.config_rule_name == event["configRuleName"] + assert event.config_rule_id == event["configRuleId"] + assert event.accountid == event["accountId"] + assert event.version == event["version"] + assert event.invoking_event.message_type == invoking_event["messageType"] + assert event.invoking_event.notification_creation_time == invoking_event["notificationCreationTime"] + assert event.invoking_event.record_version == invoking_event["recordVersion"] + assert event.invoking_event.raw_configuration_item_summary == invoking_event["configurationItemSummary"] + assert ( + event.invoking_event.configuration_item_summary.change_type + == invoking_event["configurationItemSummary"]["changeType"] + ) + assert ( + event.invoking_event.configuration_item_summary.configuration_item_version + == invoking_event["configurationItemSummary"]["configurationItemVersion"] + ) + assert ( + event.invoking_event.configuration_item_summary.configuration_item_capture_time + == invoking_event["configurationItemSummary"]["configurationItemCaptureTime"] + ) + assert ( + event.invoking_event.configuration_item_summary.configuration_state_id + == invoking_event["configurationItemSummary"]["configurationStateId"] + ) + assert ( + event.invoking_event.configuration_item_summary.accountid + == invoking_event["configurationItemSummary"]["awsAccountId"] + ) + assert ( + event.invoking_event.configuration_item_summary.configuration_item_status + == invoking_event["configurationItemSummary"]["configurationItemStatus"] + ) + assert ( + event.invoking_event.configuration_item_summary.resource_type + == invoking_event["configurationItemSummary"]["resourceType"] + ) + assert ( + event.invoking_event.configuration_item_summary.resource_id + == invoking_event["configurationItemSummary"]["resourceId"] + ) + assert ( + event.invoking_event.configuration_item_summary.resource_name + == invoking_event["configurationItemSummary"]["resourceName"] + ) + assert ( + event.invoking_event.configuration_item_summary.resource_arn + == invoking_event["configurationItemSummary"]["ARN"] + ) + assert ( + event.invoking_event.configuration_item_summary.region + == invoking_event["configurationItemSummary"]["awsRegion"] + ) + assert ( + event.invoking_event.configuration_item_summary.availability_zone + == invoking_event["configurationItemSummary"]["availabilityZone"] + ) + assert ( + event.invoking_event.configuration_item_summary.configuration_state_md5_hash + == invoking_event["configurationItemSummary"]["configurationStateMd5Hash"] + ) + assert ( + event.invoking_event.configuration_item_summary.resource_creation_time + == invoking_event["configurationItemSummary"]["resourceCreationTime"] + ) + + +def test_aws_config_rule_scheduled(): + """Check AWS Config ScheduledNotification event""" + event = AWSConfigRuleEvent(load_event("awsConfigRuleScheduled.json")) + + invoking_event = json.loads(event["invokingEvent"]) + + assert event.rule_parameters == json.loads(event["ruleParameters"]) + assert event.raw_invoking_event == event["invokingEvent"] + assert event.result_token == event["resultToken"] + assert event.event_left_scope == event["eventLeftScope"] + assert event.execution_role_arn == event["executionRoleArn"] + assert event.config_rule_arn == event["configRuleArn"] + assert event.config_rule_name == event["configRuleName"] + assert event.config_rule_id == event["configRuleId"] + assert event.accountid == event["accountId"] + assert event.version == event["version"] + assert event.evalution_mode == event["evaluationMode"] + assert event.invoking_event.message_type == invoking_event["messageType"] + assert event.invoking_event.accountid == invoking_event["awsAccountId"] + assert event.invoking_event.notification_creation_time == invoking_event["notificationCreationTime"] + assert event.invoking_event.message_type == invoking_event["messageType"] + assert event.invoking_event.record_version == invoking_event["recordVersion"] + + def test_vpc_lattice_event(): event = VPCLatticeEvent(load_event("vpcLatticeEvent.json"))