-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[aws][feat] Integrate Backup Service collection (#2106)
- Loading branch information
Showing
16 changed files
with
1,341 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
from fix_plugin_aws.resource.backup import ( | ||
AwsBackupJob, | ||
AwsBackupPlan, | ||
AwsBackupVault, | ||
AwsBackupRecoveryPoint, | ||
AwsBackupProtectedResource, | ||
AwsBackupReportPlan, | ||
AwsBackupRestoreTestingPlan, | ||
AwsBackupLegalHold, | ||
AwsBackupRestoreJob, | ||
AwsBackupCopyJob, | ||
AwsBackupFramework, | ||
) | ||
from test.resources import round_trip_for, build_graph | ||
|
||
|
||
def test_backup_jobs() -> None: | ||
round_trip_for(AwsBackupJob) | ||
|
||
|
||
def test_backup_plans() -> None: | ||
round_trip_for(AwsBackupPlan) | ||
|
||
|
||
def test_backup_vaults() -> None: | ||
round_trip_for(AwsBackupVault) | ||
|
||
|
||
def test_backup_recovery_points() -> None: | ||
builder = build_graph(AwsBackupVault) | ||
assert len(list(builder.nodes(AwsBackupRecoveryPoint))) > 0 | ||
|
||
|
||
def test_backup_protected_resources() -> None: | ||
round_trip_for(AwsBackupProtectedResource) | ||
|
||
|
||
def test_backup_report_plans() -> None: | ||
round_trip_for(AwsBackupReportPlan) | ||
|
||
|
||
def test_backup_restore_testing_plans() -> None: | ||
round_trip_for(AwsBackupRestoreTestingPlan) | ||
|
||
|
||
def test_backup_legal_holds() -> None: | ||
round_trip_for(AwsBackupLegalHold) | ||
|
||
|
||
def test_backup_restore_jobs() -> None: | ||
round_trip_for(AwsBackupRestoreJob) | ||
|
||
|
||
def test_backup_copy_jobs() -> None: | ||
round_trip_for(AwsBackupCopyJob) | ||
|
||
|
||
def test_backup_frameworks() -> None: | ||
round_trip_for(AwsBackupFramework) |
39 changes: 39 additions & 0 deletions
39
plugins/aws/test/resources/files/backup/list-backup-jobs.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
{ | ||
"BackupJobs": [ | ||
{ | ||
"BackupJobId": "1234567890abcdef", | ||
"CreationDate": "2023-03-15T12:34:56.789Z", | ||
"AccountId": "123456789012", | ||
"BackupVaultName": "MyBackupVault", | ||
"BackupVaultArn": "arn:aws:backup:us-east-1:123456789012:vault:MyBackupVault", | ||
"RecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45", | ||
"ResourceArn": "arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0", | ||
"CompletionDate": "2023-03-15T13:34:56.789Z", | ||
"State": "COMPLETED", | ||
"StatusMessage": "Backup completed successfully", | ||
"PercentDone": 100, | ||
"BackupSizeInBytes": 1024, | ||
"IamRoleArn": "arn:aws:iam::123456789012:role/BackupRole", | ||
"CreatedBy": { | ||
"BackupPlanId": "arn:aws:backup:us-east-1:123456789012:plan:8F81F553-3A74-4A3F-B93D-B3360DC80C50", | ||
"BackupPlanArn": "arn:aws:backup:us-east-1:123456789012:plan:8F81F553-3A74-4A3F-B93D-B3360DC80C50", | ||
"BackupPlanVersion": "1234567890abcdef", | ||
"BackupRuleId": "MyBackupRule" | ||
}, | ||
"ExpectedCompletionDate": "2023-03-15T13:34:56.789Z", | ||
"StartBy": "2023-03-15T12:34:56.789Z", | ||
"ResourceType": "EC2", | ||
"BytesTransferred": 1024, | ||
"BackupOptions": { | ||
"WindowsVSS": "enabled" | ||
}, | ||
"BackupType": "FULL", | ||
"ParentJobId": "1234567890abcdef", | ||
"IsParent": true, | ||
"ResourceName": "MyEC2Instance", | ||
"InitiationDate": "2023-03-15T12:34:56.789Z", | ||
"MessageCategory": "SUCCESS" | ||
} | ||
], | ||
"NextToken": "foo" | ||
} |
23 changes: 23 additions & 0 deletions
23
plugins/aws/test/resources/files/backup/list-backup-plans.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"NextToken": "foo", | ||
"BackupPlansList": [ | ||
{ | ||
"BackupPlanId": "8F81F553-3A74-4A3F-B93D-B3360DC80C50", | ||
"BackupPlanArn": "arn:aws:backup:us-east-1:123456789012:plan:8F81F553-3A74-4A3F-B93D-B3360DC80C50", | ||
"BackupPlanName": "MyBackupPlan", | ||
"CreationDate": "2023-03-15T12:34:56.789Z", | ||
"DeletionDate": "2023-03-16T12:34:56.789Z", | ||
"VersionId": "1234567890abcdef", | ||
"CreatorRequestId": "my-unique-request-id", | ||
"LastExecutionDate": "2023-03-14T12:34:56.789Z", | ||
"AdvancedBackupSettings": [ | ||
{ | ||
"ResourceType": "EC2", | ||
"BackupOptions": { | ||
"WindowsVSS": "enabled" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
} |
17 changes: 17 additions & 0 deletions
17
plugins/aws/test/resources/files/backup/list-backup-vaults.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"BackupVaultList": [ | ||
{ | ||
"BackupVaultName": "MyBackupVault", | ||
"BackupVaultArn": "arn:aws:backup:us-east-1:123456789012:vault:MyBackupVault", | ||
"CreationDate": "2023-03-15T12:34:56.789Z", | ||
"EncryptionKeyArn": "arn:aws:kms:us-east-1:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab", | ||
"CreatorRequestId": "my-unique-request-id", | ||
"NumberOfRecoveryPoints": 10, | ||
"Locked": false, | ||
"MinRetentionDays": 30, | ||
"MaxRetentionDays": 365, | ||
"LockDate": "2023-03-16T12:34:56.789Z" | ||
} | ||
], | ||
"NextToken": "foo" | ||
} |
36 changes: 36 additions & 0 deletions
36
plugins/aws/test/resources/files/backup/list-copy-jobs.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"CopyJobs": [ | ||
{ | ||
"CopyJobId": "1234567890abcdef", | ||
"CreationDate": "2023-03-15T12:34:56.789Z", | ||
"AccountId": "123456789012", | ||
"SourceBackupVaultArn": "arn:aws:backup:us-east-1:123456789012:vault:MySourceVault", | ||
"SourceRecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45", | ||
"DestinationBackupVaultArn": "arn:aws:backup:us-east-1:123456789012:vault:MyDestinationVault", | ||
"DestinationRecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:2EB3B5E7-9EB0-435A-A80B-108B488B0D45", | ||
"ResourceArn": "arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0", | ||
"CompletionDate": "2023-03-15T13:34:56.789Z", | ||
"State": "COMPLETED", | ||
"StatusMessage": "Copy completed successfully", | ||
"BackupSizeInBytes": 1024, | ||
"IamRoleArn": "arn:aws:iam::123456789012:role/BackupRole", | ||
"CreatedBy": { | ||
"BackupPlanId": "arn:aws:backup:us-east-1:123456789012:plan:8F81F553-3A74-4A3F-B93D-B3360DC80C50", | ||
"BackupPlanArn": "arn:aws:backup:us-east-1:123456789012:plan:8F81F553-3A74-4A3F-B93D-B3360DC80C50", | ||
"BackupPlanVersion": "1234567890abcdef", | ||
"BackupRuleId": "MyBackupRule" | ||
}, | ||
"ResourceType": "EC2", | ||
"ParentJobId": "1234567890abcdef", | ||
"IsParent": true, | ||
"CompositeMemberIdentifier": "MyEC2Instance", | ||
"NumberOfChildJobs": 1, | ||
"ChildJobsInState": { | ||
"COMPLETED": 1 | ||
}, | ||
"ResourceName": "MyEC2Instance", | ||
"MessageCategory": "SUCCESS" | ||
} | ||
], | ||
"NextToken": "foo" | ||
} |
13 changes: 13 additions & 0 deletions
13
plugins/aws/test/resources/files/backup/list-frameworks.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"Frameworks": [ | ||
{ | ||
"FrameworkArn": "arn:aws:backup:us-east-1:123456789012:framework:MyFramework", | ||
"FrameworkName": "MyFramework", | ||
"FrameworkDescription": "My framework description", | ||
"NumberOfControls": 10, | ||
"CreationTime": "2023-03-15T12:34:56.789Z", | ||
"DeploymentStatus": "COMPLETED" | ||
} | ||
], | ||
"NextToken": "foo" | ||
} |
14 changes: 14 additions & 0 deletions
14
plugins/aws/test/resources/files/backup/list-legal-holds.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"NextToken": "foo", | ||
"LegalHolds": [ | ||
{ | ||
"LegalHoldId": "1234567890abcdef", | ||
"CreationDate": "2023-03-15T12:34:56.789Z", | ||
"Title": "My Legal Hold", | ||
"Status": "ACTIVE", | ||
"Description": "My legal hold description", | ||
"LegalHoldArn": "arn:aws:backup:us-east-1:123456789012:legal-hold:1234567890abcdef", | ||
"CancellationDate": "2023-03-16T12:34:56.789Z" | ||
} | ||
] | ||
} |
13 changes: 13 additions & 0 deletions
13
plugins/aws/test/resources/files/backup/list-protected-resources.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"Results": [ | ||
{ | ||
"ResourceArn": "arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0", | ||
"ResourceName": "MyEC2Instance", | ||
"ResourceType": "EC2", | ||
"LastBackupTime": "2023-03-15T12:34:56.789Z", | ||
"LastBackupVaultArn": "arn:aws:backup:us-east-1:123456789012:vault:MyBackupVault", | ||
"LastRecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45" | ||
} | ||
], | ||
"NextToken": "foo" | ||
} |
42 changes: 42 additions & 0 deletions
42
.../aws/test/resources/files/backup/list-recovery-points-by-backup-vault__MyBackupVault.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"NextToken": "foo", | ||
"RecoveryPoints": [ | ||
{ | ||
"RecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45", | ||
"CreationDate": "2023-03-15T12:34:56.789Z", | ||
"BackupVaultName": "MyBackupVault", | ||
"BackupVaultArn": "arn:aws:backup:us-east-1:123456789012:vault:MyBackupVault", | ||
"SourceBackupVaultArn": "arn:aws:backup:us-east-1:123456789012:vault:MyBackupVault", | ||
"ResourceArn": "arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0", | ||
"ResourceType": "EC2", | ||
"RecoveryPointCreatedBy": { | ||
"BackupPlanId": "arn:aws:backup:us-east-1:123456789012:plan:8F81F553-3A74-4A3F-B93D-B3360DC80C50", | ||
"BackupPlanArn": "arn:aws:backup:us-east-1:123456789012:plan:8F81F553-3A74-4A3F-B93D-B3360DC80C50", | ||
"BackupPlanVersion": "1234567890abcdef", | ||
"BackupRuleId": "MyBackupRule" | ||
}, | ||
"IamRoleArn": "arn:aws:iam::123456789012:role/BackupRole", | ||
"Status": "COMPLETED", | ||
"StatusMessage": "Recovery point created successfully", | ||
"CompletionDate": "2023-03-15T13:34:56.789Z", | ||
"BackupSizeInBytes": 1024, | ||
"CalculatedLifecycle": { | ||
"MoveToColdStorageAt": "2023-03-22T12:34:56.789Z", | ||
"DeleteAt": "2023-03-29T12:34:56.789Z" | ||
}, | ||
"Lifecycle": { | ||
"MoveToColdStorageAfterDays": 7, | ||
"DeleteAfterDays": 14, | ||
"OptInToArchiveForSupportedResources": true | ||
}, | ||
"EncryptionKeyArn": "arn:aws:kms:us-east-1:123456789012:key/1234abcd-12ab-34cd-56ef-1234567890ab", | ||
"IsEncrypted": true, | ||
"LastRestoreTime": "2023-03-16T12:34:56.789Z", | ||
"ParentRecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45", | ||
"CompositeMemberIdentifier": "MyEC2Instance", | ||
"IsParent": false, | ||
"ResourceName": "MyEC2Instance", | ||
"VaultType": "STANDARD" | ||
} | ||
] | ||
} |
42 changes: 42 additions & 0 deletions
42
plugins/aws/test/resources/files/backup/list-report-plans.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"ReportPlans": [ | ||
{ | ||
"ReportPlanArn": "arn:aws:backup:us-east-1:123456789012:report-plan:MyReportPlan", | ||
"ReportPlanName": "MyReportPlan", | ||
"ReportPlanDescription": "My report plan description", | ||
"ReportSetting": { | ||
"ReportTemplate": "RESOURCE_COMPLIANCE_REPORT", | ||
"FrameworkArns": [ | ||
"arn:aws:backup:us-east-1:123456789012:framework:MyFramework" | ||
], | ||
"NumberOfFrameworks": 1, | ||
"Accounts": [ | ||
"123456789012" | ||
], | ||
"OrganizationUnits": [ | ||
"ou-1234567890abcdef0" | ||
], | ||
"Regions": [ | ||
"us-east-1" | ||
] | ||
}, | ||
"DeploymentStatus": "DEPLOYED", | ||
"ReportDeliveryChannel": { | ||
"S3BucketName": "my-report-bucket", | ||
"S3KeyPrefix": "backup-reports", | ||
"Formats": [ | ||
"CSV", | ||
"JSON" | ||
] | ||
}, | ||
"CreatedBy": { | ||
"RestoreTestingPlanArn": "arn:aws:backup:us-east-1:123456789012:restore-testing-plan:MyRestoreTestingPlan" | ||
}, | ||
"PlanDeploymentStatus": "COMPLETED", | ||
"CreationTime": "2023-03-15T12:34:56.789Z", | ||
"LastAttemptedExecutionTime": "2023-03-16T12:34:56.789Z", | ||
"LastSuccessfulExecutionTime": "2023-03-15T12:34:56.789Z" | ||
} | ||
], | ||
"NextToken": "foo" | ||
} |
28 changes: 28 additions & 0 deletions
28
plugins/aws/test/resources/files/backup/list-restore-jobs.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"RestoreJobs": [ | ||
{ | ||
"RestoreJobId": "1234567890abcdef", | ||
"CreationDate": "2023-03-15T12:34:56.789Z", | ||
"AccountId": "123456789012", | ||
"RecoveryPointArn": "arn:aws:backup:us-east-1:123456789012:recovery-point:1EB3B5E7-9EB0-435A-A80B-108B488B0D45", | ||
"CompletionDate": "2023-03-15T13:34:56.789Z", | ||
"Status": "COMPLETED", | ||
"StatusMessage": "Restore completed successfully", | ||
"PercentDone": 100, | ||
"BackupSizeInBytes": 1024, | ||
"IamRoleArn": "arn:aws:iam::123456789012:role/BackupRole", | ||
"ExpectedCompletionTimeMinutes": 60, | ||
"CreatedResourceArn": "arn:aws:ec2:us-east-1:123456789012:instance/i-1234567890abcdef0", | ||
"ResourceType": "EC2", | ||
"RecoveryPointCreationDate": "2023-03-15T12:34:56.789Z", | ||
"CreatedBy": { | ||
"RestoreTestingPlanArn": "arn:aws:backup:us-east-1:123456789012:restore-testing-plan:MyRestoreTestingPlan" | ||
}, | ||
"ValidationStatus": "SUCCESSFUL", | ||
"ValidationStatusMessage": "Restore validation successful", | ||
"DeletionStatus": "SUCCESSFUL", | ||
"DeletionStatusMessage": "Restore test data deleted successfully" | ||
} | ||
], | ||
"NextToken": "foo" | ||
} |
15 changes: 15 additions & 0 deletions
15
plugins/aws/test/resources/files/backup/list-restore-testing-plans.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"NextToken": "foo", | ||
"RestoreTestingPlans": [ | ||
{ | ||
"RestoreTestingPlanArn": "arn:aws:backup:us-east-1:123456789012:restore-testing-plan:MyRestoreTestingPlan", | ||
"RestoreTestingPlanName": "MyRestoreTestingPlan", | ||
"CreationTime": "2023-03-15T12:34:56.789Z", | ||
"LastUpdateTime": "2023-03-16T12:34:56.789Z", | ||
"LastExecutionTime": "2023-03-15T12:34:56.789Z", | ||
"ScheduleExpression": "cron(0 0 * * ? *)", | ||
"ScheduleExpressionTimezone": "UTC", | ||
"StartWindowHours": 24 | ||
} | ||
] | ||
} |
Oops, something went wrong.