{ "info": { "author": "Eamonn Faherty", "author_email": "python-packages@designandsolve.co.uk", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "## Background\nThe AWS platform allows you to log API calls using [AWS CloudTrial](https://aws.amazon.com/cloudtrail).\n\nYou can use tools like [AWS Config](https://aws.amazon.com/config/) and [CaptialOne's CloudCustodian](https://github.com/cloud-custodian/cloud-custodian) \nto create security controls that react to these events.\n\n## The problem \nThere is not much documentation on the structure of the events. \n\n## What is this?\nThe structure of the events from CloudTrail are similar to responses seen when using boto3. \nBoto3 is powered by the botocore library. \nThe botocore library contains a data directory that describes the API calls (requests and responses).\nThis library allows you to interact with the data directories of botocore to see the API request and responses.\nThis is to help you write custom AWS Config rules and or CloudCustodian policies.\n\n## Examples\nRunning ```cloudtrail-schema``` with no arguements will list the services/sources:\n```yaml\nServices:\n- acm\n- acm-pca\n- alexaforbusiness\n- amplify\n- apigateway\n- apigatewaymanagementapi\n- apigatewayv2\n```\n\nRunning ```cloudtrail-schema iam``` with a service will list the operations/events:\n```yaml\nOperations:\n- AddClientIDToOpenIDConnectProvider\n- AddRoleToInstanceProfile\n- AddUserToGroup\n- AttachGroupPolicy\n- AttachRolePolicy\n- AttachUserPolicy\n- ChangePassword\n```\n\nRunning with a service and event ```cloudtrail-schema iam.CreatePolicy.output``` give the following output:\n```\nDescription\n------\n
Creates a new managed policy for your AWS account.
This operation creates a policy version with a version identifier of v1 and sets v1 as the policy's default version. For more information about policy versions, see Versioning for Managed Policies in the IAM User Guide.
For more information about managed policies in general, see Managed Policies and Inline Policies in the IAM User Guide.
\n\n\nResult\n------\n{\n \"policy\": {\n \"policyName\": {\n \"type\": \"string\",\n \"max\": 128,\n \"min\": 1,\n \"pattern\": \"[\\\\w+=,.@-]+\"\n },\n \"policyId\": {\n \"type\": \"string\",\n \"max\": 128,\n \"min\": 16,\n \"pattern\": \"[\\\\w]+\"\n },\n \"arn\": {\n \"type\": \"string\",\n \"documentation\": \"The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources.
For more information about ARNs, go to Amazon Resource Names (ARNs) and AWS Service Namespaces in the AWS General Reference.
\",\n \"max\": 2048,\n \"min\": 20\n },\n \"path\": {\n \"type\": \"string\",\n \"pattern\": \"((/[A-Za-z0-9\\\\.,\\\\+@=_-]+)*)/\"\n },\n \"defaultVersionId\": {\n \"type\": \"string\",\n \"pattern\": \"v[1-9][0-9]*(\\\\.[A-Za-z0-9-]*)?\"\n },\n \"attachmentCount\": {\n \"type\": \"integer\"\n },\n \"permissionsBoundaryUsageCount\": {\n \"type\": \"integer\"\n },\n \"isAttachable\": {\n \"type\": \"boolean\"\n },\n \"description\": {\n \"type\": \"string\",\n \"max\": 1000\n },\n \"createDate\": {\n \"type\": \"timestamp\"\n },\n \"updateDate\": {\n \"type\": \"timestamp\"\n }\n }\n}\n```\n\n\n### Writing a CloudCustodian policy\nWhen you view a event response using this tool you can translate it easily into a a CloudCustodian policy:\n\n```\n# cloudtrail-schema iam.CreatePolicy.output\n\nDescription\n------\nCreates a new managed policy for your AWS account.
This operation creates a policy version with a version identifier of v1 and sets v1 as the policy's default version. For more information about policy versions, see Versioning for Managed Policies in the IAM User Guide.
For more information about managed policies in general, see Managed Policies and Inline Policies in the IAM User Guide.
\n\n\nResult\n------\n{\n \"policy\": {\n \"policyName\": {\n \"type\": \"string\",\n \"max\": 128,\n \"min\": 1,\n \"pattern\": \"[\\\\w+=,.@-]+\"\n },\n \"policyId\": {\n \"type\": \"string\",\n \"max\": 128,\n \"min\": 16,\n \"pattern\": \"[\\\\w]+\"\n },\n \"arn\": {\n \"type\": \"string\",\n \"documentation\": \"The Amazon Resource Name (ARN). ARNs are unique identifiers for AWS resources.
For more information about ARNs, go to Amazon Resource Names (ARNs) and AWS Service Namespaces in the AWS General Reference.
\",\n \"max\": 2048,\n \"min\": 20\n },\n \"path\": {\n \"type\": \"string\",\n \"pattern\": \"((/[A-Za-z0-9\\\\.,\\\\+@=_-]+)*)/\"\n },\n \"defaultVersionId\": {\n \"type\": \"string\",\n \"pattern\": \"v[1-9][0-9]*(\\\\.[A-Za-z0-9-]*)?\"\n },\n \"attachmentCount\": {\n \"type\": \"integer\"\n },\n \"permissionsBoundaryUsageCount\": {\n \"type\": \"integer\"\n },\n \"isAttachable\": {\n \"type\": \"boolean\"\n },\n \"description\": {\n \"type\": \"string\",\n \"max\": 1000\n },\n \"createDate\": {\n \"type\": \"timestamp\"\n },\n \"updateDate\": {\n \"type\": \"timestamp\"\n }\n }\n}\n\n```\n\nYou use the argument to decide the mode.events.source and mode.events.event:\n\nsource: iam.amazonaws.com\nevent: CreatePolicy\n\nFull example:\n\n```yaml\npolicies:\n - name: iam-has-allow-all-policy\n description: |\n Notify when a policy is created using allow all\n resource: iam-policy\n mode:\n type: cloudtrail\n events:\n - source: iam.amazonaws.com\n event: CreatePolicy\n ids: \"responseElements.policy.policyId\"\n\n```\n\nThe json returned from the app can be used to write filters. The json returned\nis the same as the structure available from responseElements. You can write the \nfollowing policy as an example:\n\nRunning: ```cloudtrail-schema ec2.CreateVpcPeeringConnection.output``` results in\n\n```\nDescription\n------\nRequests a VPC peering connection between two VPCs: a requester VPC that you own and an accepter VPC with which to create the connection. The accepter VPC can belong to another AWS account and can be in a different Region to the requester VPC. The requester VPC and accepter VPC cannot have overlapping CIDR blocks.
Limitations and rules apply to a VPC peering connection. For more information, see the limitations section in the VPC Peering Guide.
The owner of the accepter VPC must accept the peering request to activate the peering connection. The VPC peering connection request expires after 7 days, after which it cannot be accepted or rejected.
If you create a VPC peering connection request between VPCs with overlapping CIDR blocks, the VPC peering connection has a status of failed.