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

sweeper/backup_vault: add sweeper with concurrency #19886

Merged
merged 2 commits into from
Jun 21, 2021
Merged

Conversation

anGie44
Copy link
Contributor

@anGie44 anGie44 commented Jun 18, 2021

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for pull request followers and do not help prioritize the request

Closes #19847
Relates #15334

Output from acceptance testing:

will be covered by nightly runs

@anGie44 anGie44 requested a review from ewbankkit as a code owner June 18, 2021 13:13
@github-actions github-actions bot added service/backup Issues and PRs that pertain to the backup service. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/M Managed by automation to categorize the size of a PR. labels Jun 18, 2021
@ewbankkit
Copy link
Contributor

2021/06/18 13:05:38 [DEBUG] Running Sweeper (aws_backup_vault) in region (us-west-2)
2021/06/18 13:05:39 [INFO] Skipping Backup Vault: Default
2021/06/18 13:05:39 [ERROR] Error running Sweeper (aws_backup_vault) in region (us-west-2): 1 error occurred:
	* error sweeping Backup Vaults for us-west-2: 10 errors occurred:
	* error deleting Backup Vault (tf_acc_test_backup_vault_7012118647341857814): InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, DeleteBackupVaultInput.BackupVaultName.

	* error deleting Backup Vault (aws/efs/automatic-backup-vault): InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, DeleteBackupVaultInput.BackupVaultName.

	* error deleting Backup Vault (tf-testacc-backup-ek8qgokzsov9of): InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, DeleteBackupVaultInput.BackupVaultName.

	* error deleting Backup Vault (tf-testacc-backup-dylv32dfdsk22m): InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, DeleteBackupVaultInput.BackupVaultName.

	* error deleting Backup Vault (tf_acc_test_backup_vault_1840574367621608621): InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, DeleteBackupVaultInput.BackupVaultName.

	* error deleting Backup Vault (tf_acc_test_backup_vault_4582763099159887277): InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, DeleteBackupVaultInput.BackupVaultName.

	* error deleting Backup Vault (tf_acc_test_backup_plan_6658497300030569382): InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, DeleteBackupVaultInput.BackupVaultName.

	* error deleting Backup Vault (tf_acc_test_backup_vault_1164508845823305797): InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, DeleteBackupVaultInput.BackupVaultName.

	* error deleting Backup Vault (tf_acc_test_backup_plan_9005306000506772449): InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, DeleteBackupVaultInput.BackupVaultName.

	* error deleting Backup Vault (tf_acc_test_backup_plan_2922497242099078929): InvalidParameter: 1 validation error(s) found.
- minimum field size of 1, DeleteBackupVaultInput.BackupVaultName.

func resourceAwsBackupVaultDelete(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).backupconn
input := &backup.DeleteBackupVaultInput{
BackupVaultName: aws.String(d.Get("name").(string)),
}
_, err := conn.DeleteBackupVault(input)
if err != nil {
return fmt.Errorf("error deleting Backup Vault (%s): %s", d.Id(), err)
}
return nil
}

I'd suggest changing the Delete handler code to

	input := &backup.DeleteBackupVaultInput{
		BackupVaultName: aws.String(d.Id()),
	}

@anGie44 anGie44 force-pushed the s-backup-vault branch 2 times, most recently from 7acfb92 to bc25be9 Compare June 18, 2021 17:58
@anGie44
Copy link
Contributor Author

anGie44 commented Jun 18, 2021

@ewbankkit , also added in a condition to catch skip over backups created by EFS. or do you think there are acceptance tests related to EFS that could be adjusted to make sure their backups can be deleted later on?

@ewbankkit
Copy link
Contributor

Support for automated EFS backups are requested in #14372.
I'll add a link to this PR in the PR that addresses that issue and we can leave what you have for now.

Copy link
Contributor

@ewbankkit ewbankkit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀.

% TEST=./aws SWEEP=us-east-1,us-east-2,us-west-1,us-west-2 SWEEPARGS=-sweep-run=aws_backup_vault make sweep
WARNING: This will destroy infrastructure. Use only in development accounts.
go test ./aws -v -sweep=us-east-1,us-east-2,us-west-1,us-west-2 -sweep-run=aws_backup_vault -timeout 60m
2021/06/18 14:16:05 [DEBUG] Running Sweepers for region (us-east-1):
2021/06/18 14:16:05 [DEBUG] Running Sweeper (aws_backup_vault_notifications) in region (us-east-1)
2021/06/18 14:16:05 [INFO] AWS Auth provider used: "EnvProvider"
2021/06/18 14:16:05 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2021/06/18 14:16:05 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2021/06/18 14:16:06 [INFO] Deleting Backup Vault Notifications Default
2021/06/18 14:16:06 [DEBUG] Sweeper (aws_backup_vault) has dependency (aws_backup_vault_notifications), running..
2021/06/18 14:16:06 [DEBUG] Sweeper (aws_backup_vault_notifications) already ran in region (us-east-1)
2021/06/18 14:16:06 [DEBUG] Sweeper (aws_backup_vault) has dependency (aws_backup_vault_policy), running..
2021/06/18 14:16:06 [DEBUG] Running Sweeper (aws_backup_vault_policy) in region (us-east-1)
2021/06/18 14:16:06 [INFO] Deleting Backup Vault Policies Default
2021/06/18 14:16:06 [DEBUG] Running Sweeper (aws_backup_vault) in region (us-east-1)
2021/06/18 14:16:06 [INFO] Skipping Backup Vault: Default
2021/06/18 14:16:06 [DEBUG] Sweeper (aws_backup_vault_policy) already ran in region (us-east-1)
2021/06/18 14:16:06 Sweeper Tests ran successfully:
	- aws_backup_vault_notifications
	- aws_backup_vault_policy
	- aws_backup_vault
2021/06/18 14:16:06 [DEBUG] Running Sweepers for region (us-east-2):
2021/06/18 14:16:06 [DEBUG] Running Sweeper (aws_backup_vault_policy) in region (us-east-2)
2021/06/18 14:16:06 [INFO] AWS Auth provider used: "EnvProvider"
2021/06/18 14:16:06 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2021/06/18 14:16:06 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2021/06/18 14:16:08 [DEBUG] No Backup Vault Policies to sweep
2021/06/18 14:16:08 [DEBUG] Running Sweeper (aws_backup_vault_notifications) in region (us-east-2)
2021/06/18 14:16:08 [DEBUG] No Backup Vault Notifications to sweep
2021/06/18 14:16:08 [DEBUG] Sweeper (aws_backup_vault) has dependency (aws_backup_vault_notifications), running..
2021/06/18 14:16:08 [DEBUG] Sweeper (aws_backup_vault_notifications) already ran in region (us-east-2)
2021/06/18 14:16:08 [DEBUG] Sweeper (aws_backup_vault) has dependency (aws_backup_vault_policy), running..
2021/06/18 14:16:08 [DEBUG] Sweeper (aws_backup_vault_policy) already ran in region (us-east-2)
2021/06/18 14:16:08 [DEBUG] Running Sweeper (aws_backup_vault) in region (us-east-2)
2021/06/18 14:16:08 Sweeper Tests ran successfully:
	- aws_backup_vault_policy
	- aws_backup_vault_notifications
	- aws_backup_vault
2021/06/18 14:16:08 [DEBUG] Running Sweepers for region (us-west-1):
2021/06/18 14:16:08 [DEBUG] Running Sweeper (aws_backup_vault_policy) in region (us-west-1)
2021/06/18 14:16:08 [INFO] AWS Auth provider used: "EnvProvider"
2021/06/18 14:16:08 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2021/06/18 14:16:08 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2021/06/18 14:16:09 [DEBUG] No Backup Vault Policies to sweep
2021/06/18 14:16:09 [DEBUG] Running Sweeper (aws_backup_vault_notifications) in region (us-west-1)
2021/06/18 14:16:10 [DEBUG] No Backup Vault Notifications to sweep
2021/06/18 14:16:10 [DEBUG] Sweeper (aws_backup_vault) has dependency (aws_backup_vault_notifications), running..
2021/06/18 14:16:10 [DEBUG] Sweeper (aws_backup_vault_notifications) already ran in region (us-west-1)
2021/06/18 14:16:10 [DEBUG] Sweeper (aws_backup_vault) has dependency (aws_backup_vault_policy), running..
2021/06/18 14:16:10 [DEBUG] Sweeper (aws_backup_vault_policy) already ran in region (us-west-1)
2021/06/18 14:16:10 [DEBUG] Running Sweeper (aws_backup_vault) in region (us-west-1)
2021/06/18 14:16:10 Sweeper Tests ran successfully:
	- aws_backup_vault_policy
	- aws_backup_vault_notifications
	- aws_backup_vault
2021/06/18 14:16:10 [DEBUG] Running Sweepers for region (us-west-2):
2021/06/18 14:16:10 [DEBUG] Running Sweeper (aws_backup_vault_policy) in region (us-west-2)
2021/06/18 14:16:10 [INFO] AWS Auth provider used: "EnvProvider"
2021/06/18 14:16:10 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2021/06/18 14:16:10 [DEBUG] Trying to get account information via sts:GetCallerIdentity
2021/06/18 14:16:12 [INFO] Deleting Backup Vault Policies Default
2021/06/18 14:16:12 [INFO] Deleting Backup Vault Policies aws/efs/automatic-backup-vault
2021/06/18 14:16:13 [DEBUG] Running Sweeper (aws_backup_vault_notifications) in region (us-west-2)
2021/06/18 14:16:13 [INFO] Deleting Backup Vault Notifications Default
2021/06/18 14:16:14 [INFO] Deleting Backup Vault Notifications aws/efs/automatic-backup-vault
2021/06/18 14:16:14 [DEBUG] Sweeper (aws_backup_vault) has dependency (aws_backup_vault_notifications), running..
2021/06/18 14:16:14 [DEBUG] Sweeper (aws_backup_vault_notifications) already ran in region (us-west-2)
2021/06/18 14:16:14 [DEBUG] Sweeper (aws_backup_vault) has dependency (aws_backup_vault_policy), running..
2021/06/18 14:16:14 [DEBUG] Sweeper (aws_backup_vault_policy) already ran in region (us-west-2)
2021/06/18 14:16:14 [DEBUG] Running Sweeper (aws_backup_vault) in region (us-west-2)
2021/06/18 14:16:14 [INFO] Skipping Backup Vault: Default
2021/06/18 14:16:14 [INFO] Skipping Backup Vault: aws/efs/automatic-backup-vault
2021/06/18 14:16:14 Sweeper Tests ran successfully:
	- aws_backup_vault
	- aws_backup_vault_policy
	- aws_backup_vault_notifications
ok  	github.com/terraform-providers/terraform-provider-aws/aws	13.916s

@anGie44 anGie44 added this to the v3.47.0 milestone Jun 21, 2021
@anGie44 anGie44 merged commit c4c7650 into main Jun 21, 2021
@anGie44 anGie44 deleted the s-backup-vault branch June 21, 2021 19:27
@github-actions
Copy link

This functionality has been released in v3.47.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/backup Issues and PRs that pertain to the backup service. size/M Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement aws_backup_vault sweeper
2 participants