Remove IAM user from group in terraform state file

I think this is mainly a problem with trying to do this in Bash or other shell where quotes and brackets are special characters need to be escaped, perhaps combined with the way Terraform CLI parses arguments.

This should work:

terraform state rm aws_iam_group_membership.testgroup-group-membership\[\"testuser\"\]

Notice that I'm escaping both the brackets and the quotes. There may be a "cleaner" way to do it with single quotes, but I fixed my issue with the above before I had a chance to try it:

terraform state rm 'aws_iam_group_membership.testgroup-group-membership["testuser"]'