diff --git a/github/resource_github_emu_group_mapping.go b/github/resource_github_emu_group_mapping.go index f9c47fa68..299c7acee 100644 --- a/github/resource_github_emu_group_mapping.go +++ b/github/resource_github_emu_group_mapping.go @@ -85,6 +85,11 @@ func resourceGithubEMUGroupMappingRead(d *schema.ResourceData, meta interface{}) group, resp, err := client.Teams.GetExternalGroup(ctx, orgName, id64) if err != nil { + if resp != nil && resp.StatusCode == 404 { + // If the group is not found, remove it from state + d.SetId("") + return nil + } return err }