Skip to content

Unable to Delete Guardduty Malware protection Plan for S3

0

Hi I am currently in learning phase of usage of Guardduty . I created an S3 bucket and enabled guardduty scan and then enabled the guardduty malware protection plan for s3 , now when I try to delete/disable the plan , it gives me an error on the console as well as on Cloudshell. I also tried to delete the plan using aws cli.

Error - The request was rejected because the provided IAM role cannot be assumed by the service. I tried to edit the plan to change the Role , but no luck. So the I tried to delete the s3 bucket, which I was able to do successfully. However I still cannot delete Guardduty Malware protection plan

Is there something that I can do to remove the plan ?

asked a year ago386 views

2 Answers
0

To resolve your issue with deleting the GuardDuty Malware Protection plan for S3, you'll need to use the AWS CLI with the correct Malware Protection plan ID. Since the bucket has already been deleted, you're experiencing an error because the service can't validate against a non-existent bucket or the IAM role may have been modified.

Here's how to delete the Malware Protection plan:

  1. First, retrieve the Malware Protection plan ID by running:
aws guardduty list-malware-protection-plans --region your-region

Replace "your-region" with your specific AWS region.

  1. Once you have the plan ID, delete it using:
aws guardduty delete-malware-protection-plan --malware-protection-plan-id your-plan-id

Replace "your-plan-id" with the ID you obtained in the previous step.

If you're still encountering issues, it might be related to IAM role permissions or eventual consistency after deleting the bucket. In some cases, you may need to wait a few minutes for the changes to propagate through AWS systems before attempting to delete the protection plan again.

For Infrastructure as Code deployments, it's recommended to declare resource dependencies to ensure proper sequencing when creating or deleting resources. This helps avoid issues with eventual consistency when managing GuardDuty Malware Protection plans.
Sources
Disabling Malware Protection for S3 for a protected bucket - Amazon GuardDuty
Troubleshooting IAM role permissions error - Amazon GuardDuty

answered a year ago

0

Looking at your issue, I think I know what is happening. Since you've already deleted the S3 bucket, the error you're seeing is likely because GuardDuty can't validate against the deleted bucket, or there might be some IAM role conflicts.

Let me share an easier way to delete the plan using AWS CLI:

  1. First, get your Malware Protection plan ID:
aws guardduty list-malware-protection-plans --region your-region
  1. Then use that ID to delete the plan:
aws guardduty delete-malware-protection-plan --malware-protection-plan-id your-plan-id

If it still doesn't work right away, give it a few minutes and try again. AWS sometimes needs some time for these changes to sync up across their systems (they call it eventual consistency).

Oh, and a small tip for the future - if you're using Infrastructure as Code, it's better to set up proper resource dependencies. That way, when you're creating or deleting resources, everything happens in the right order and you avoid these kinds of stuck states.

Hope this helps solve your problem! Let me know if you run into any other issues.

AWS

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.