'Artifact's permissions issue with terrafrom

I am trying to create a service account using terraform and I also want to apply multiple permissions to that account using terraform.

# create artifact register
resource "google_artifact_registry_repository" "yacht-away" {
  provider = google-beta

  location      = "asia-south1"
  repository_id = "yacht-away"
  description   = "yacht-away docker repository with iam"
  format        = "DOCKER"
}

# create service account
resource "google_service_account" "yacht-away-service-acc" {
  provider = google-beta
  account_id   = "yacht-away-service-ac"
  display_name = "Yacht Away Service Account"
}

However, I constantly see this error. I have verified the value of location everywhere it is the same as mentioned above. So probably that is not the issue. The service account being used by the terraform has project editor access and I have also tried after providing it owner access.

Error: Error when reading or editing Resource "artifactregistry repository \"projects/dhb-222614/locations/asia-south1/repositories/yacht-away\"" with IAM Member: Role "roles/artifactregistry.reader" Member "serviceAccount:[email protected]": Error retrieving IAM policy for artifactregistry repository "projects/dhb-222614/locations/asia-south1/repositories/yacht-away": googleapi: Error 403: The caller does not have permission

So I don't understand where am I going wrong.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source