1
votes

I am trying to create an instance inside Google cloud using terraform and continue to run into a 'compute.subnetworks.use' permission error whenever I apply. The segement of code in question is below:

network_interface {
    subnetwork_project = "hp-cof-st-core-sbx-dev"
    subnetwork = "net-cof-st-core-sbx-dev-entfacing-ue4-1"


  }

I want to create an instance using a subnet through "the network shared with me setting". An example of how the it is configured through the portal is given below:

Configuration within the google portal 1

Whenever I attempt to configure this within terraform i am given the following message:

Error: Error applying plan:

1 error(s) occurred:

  • google_compute_instance.default: 1 error(s) occurred:

  • google_compute_instance.default: Error creating instance: googleapi: Error 403: Required 'compute.subnetworks.use' permission for 'projects/hp-cof-st-core-sbx-dev/regions/us-east4-a/subnetworks/net-cof-st-core-sbx-dev-entfacing-ue4-1', forbidden

1
If it's solved, please share the solution to the community - Ajit Singh

1 Answers

2
votes

The service account you are using to create the instance must have the editor or admin role to create an instance. You can update this by going to the IAM and Admin menu and changing the role to Editor or Admin.