Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

aws - fsx - rds - register aws_backup count filter #8494

Merged
merged 9 commits into from
May 4, 2023
3 changes: 3 additions & 0 deletions c7n/resources/fsx.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from c7n.filters import Filter
from c7n.filters.kms import KmsRelatedFilter
from c7n.filters.vpc import SubnetFilter
from c7n.filters.backup import ConsecutiveAwsBackupsFilter


class DescribeFSx(DescribeSource):
Expand Down Expand Up @@ -444,3 +445,5 @@ def process(self, resources, event=None):
class Subnet(SubnetFilter):

RelatedIdsExpression = 'SubnetIds[]'

FSx.filter_registry.register('consecutive-aws-backups', ConsecutiveAwsBackupsFilter)
4 changes: 4 additions & 0 deletions c7n/resources/rds.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
merge_dict_list, filter_empty)
from c7n.resources.kms import ResourceKmsKeyAlias
from c7n.resources.securityhub import PostFinding
from c7n.filters.backup import ConsecutiveAwsBackupsFilter

log = logging.getLogger('custodian.rds')

Expand Down Expand Up @@ -1893,6 +1894,9 @@ class resource_type(TypeInfo):
augment = universal_augment


RDS.filter_registry.register('consecutive-aws-backups', ConsecutiveAwsBackupsFilter)


@filters.register('consecutive-snapshots')
class ConsecutiveSnapshots(Filter):
"""Returns instances where number of consective daily snapshots is
Expand Down
4 changes: 4 additions & 0 deletions c7n/resources/rdscluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
type_schema, local_session, snapshot_identifier, chunks)

from c7n.resources.rds import ParameterFilter
from c7n.filters.backup import ConsecutiveAwsBackupsFilter

log = logging.getLogger('custodian.rds-cluster')

Expand Down Expand Up @@ -606,6 +607,9 @@ def process_snapshot_set(self, client, snapshots_set):
continue


RDSCluster.filter_registry.register('consecutive-aws-backups', ConsecutiveAwsBackupsFilter)


@RDSCluster.filter_registry.register('consecutive-snapshots')
class ConsecutiveSnapshots(Filter):
"""Returns RDS clusters where number of consective daily snapshots is equal to/or greater
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"status_code": 200,
"data": {
"RecoveryPoints": [
{
"RecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:b2f7c59b-2a92-4dbd-814f-ed35e175c259",
"StatusMessage": "Done",
"EncryptionKeyArn": "arn:aws:kms:us-east-1:123456789012:key/4dee567f-437f-4c94-9aac-5aa1259678e1",
"CreationDate": {
"hour": 14,
"__class__": "datetime",
"month": 9,
"second": 52,
"microsecond": 776000,
"year": 2022,
"day": 9,
"minute": 4
},
"Status": "COMPLETED",
"BackupVaultName": "Default",
"BackupSizeBytes": 11910
},
{
"RecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:60520946-70e2-4a79-a55d-cb1a414b4aba",
"StatusMessage": "Done",
"CreationDate": {
"hour": 22,
"__class__": "datetime",
"month": 9,
"second": 52,
"microsecond": 776000,
"year": 2022,
"day": 8,
"minute": 4
},
"Status": "COMPLETED",
"BackupSizeBytes": 11910
},
{
"RecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:5847ea9a-e0e4-4965-8545-58d441690f49",
"StatusMessage": "Done",
"CreationDate": {
"hour": 17,
"__class__": "datetime",
"month": 9,
"second": 52,
"microsecond": 776000,
"year": 2022,
"day": 7,
"minute": 4
},
"Status": "COMPLETED",
"BackupSizeBytes": 512
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"status_code": 200,
"data": {
"RecoveryPoints": [
{
"RecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:60520946-70e2-4a79-a55d-ad36eb25780e",
"StatusMessage": "Done",
"CreationDate": {
"hour": 22,
"__class__": "datetime",
"month": 9,
"second": 52,
"microsecond": 776000,
"year": 2022,
"day": 8,
"minute": 4
},
"Status": "COMPLETED",
"BackupSizeBytes": 11910
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{
"status_code": 200,
"data": {
"ResponseMetadata": {},
"FileSystems": [
{
"OwnerId": "123456789012",
"CreationTime": "2023-04-13T09:50:09.998000-07:00",
"FileSystemId": "fs-0123fa8a4567ac2eb",
"FileSystemType": "LUSTRE",
"Lifecycle": "AVAILABLE",
"StorageCapacity": 1200,
"StorageType": "SSD",
"VpcId": "vpc-0c77dff256ea3253",
"SubnetIds": [
"subnet-08b2a97a1234567"
],
"NetworkInterfaceIds": [
"eni-07c1eefd22a562034",
"eni-0c13defd22a562034"
],
"DNSName": "fs-0123fa8a4567ac2eb.fsx.us-west-2.amazonaws.com",
"KmsKeyId": "arn:aws:kms:us-west-2:123456789012:key/758f08a1-cd22-4d21-b000-412334ad23cfab81",
"ResourceARN": "arn:aws:fsx:us-west-2:123456789012:file-system/fs-0123fa8a4567ac2eb",
"Tags": [
{
"Key": "Name",
"Value": "test-backup"
},
{
"Key": "backup_enabled",
"Value": "True"
}
],
"LustreConfiguration": {
"WeeklyMaintenanceStartTime": "2:08:30",
"DeploymentType": "PERSISTENT_2",
"PerUnitStorageThroughput": 125,
"MountName": "swaa5bev",
"CopyTagsToBackups": false,
"DataCompressionType": "NONE",
"LogConfiguration": {
"Level": "WARN_ERROR",
"Destination": "arn:aws:logs:us-west-2:123456789012:log-group:/aws/fsx/lustre:log-stream:datarepo_fs-0123fa8a4567ac2eb"
},
"RootSquashConfiguration": {
"RootSquash": "0:0",
"NoSquashNids": []
}
},
"FileSystemTypeVersion": "2.12"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"status_code": 200,
"data": {
"RecoveryPoints": [
{
"RecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:b2f7c59b-2a92-4dbd-814f-ed35e175c259",
"StatusMessage": "Done",
"EncryptionKeyArn": "arn:aws:kms:us-east-1:123456789012:key/4dee567f-437f-4c94-9aac-5aa1259678e1",
"CreationDate": {
"hour": 14,
"__class__": "datetime",
"month": 9,
"second": 52,
"microsecond": 776000,
"year": 2022,
"day": 9,
"minute": 4
},
"Status": "COMPLETED",
"BackupVaultName": "Default",
"BackupSizeBytes": 11910
},
{
"RecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:60520946-70e2-4a79-a55d-cb1a414b4aba",
"StatusMessage": "Done",
"CreationDate": {
"hour": 22,
"__class__": "datetime",
"month": 9,
"second": 52,
"microsecond": 776000,
"year": 2022,
"day": 8,
"minute": 4
},
"Status": "COMPLETED",
"BackupSizeBytes": 11910
},
{
"RecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:5847ea9a-e0e4-4965-8545-58d441690f49",
"StatusMessage": "Done",
"CreationDate": {
"hour": 17,
"__class__": "datetime",
"month": 9,
"second": 52,
"microsecond": 776000,
"year": 2022,
"day": 7,
"minute": 4
},
"Status": "COMPLETED",
"BackupSizeBytes": 512
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"status_code": 200,
"data": {
"RecoveryPoints": [
{
"RecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:60520946-70e2-4a79-a55d-ad36eb25780e",
"StatusMessage": "Done",
"CreationDate": {
"hour": 22,
"__class__": "datetime",
"month": 9,
"second": 52,
"microsecond": 776000,
"year": 2022,
"day": 8,
"minute": 4
},
"Status": "COMPLETED",
"BackupSizeBytes": 11910
}
]
}
}