Reputation: 2001
I am learning Terraform with GCP and trying to authenticate using service account (keys.json) and create a gcs bucket using terraform.
provider "google" {
project = "terraform-gcp-401813"
region = "asia-south1"
zone = "asia-south1-a"
credentials = "keys.json"
}
resource "google_storage_bucket" "GCS1" {
location = "asia-south1"
name = "bucket-using-tf"
}
I am getting below error while terraform apply
google_storage_bucket.GCS1: Creating...
╷
│ Error: googleapi: Error 403: xxxxxxxxxxxxxxx.iam.gserviceaccount.com does not have storage.buckets.create access to the Google Cloud project. Permission 'storage.buckets.create' denied on resource (or it may not exist)., forbidden
│
│ with google_storage_bucket.GCS1,
│ on main.tf line 8, in resource "google_storage_bucket" "GCS1":
│ 8: resource "google_storage_bucket" "GCS1" {
As error suggest I given Storage Admin permission direclty to client_email in key.json
file using IAM Admin Panel but still its keeps on giving same error. Am I missing any steps? Thanks in adavace!
Upvotes: -1
Views: 1230
Reputation: 2001
My Bad! I had given storage admin permission in default GCP project. I had to select the correct project from dropdown menu and then give the role to credential email.
Upvotes: 1