-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provider ignores project setting - uses remote state project #2283
Comments
Isn't you problem that your credentials are from Like this one: #2194 |
@Chupaka Those credentials were generated from the Service Account in the Another thing I noticed is that the issue only seems to be with resource creation. Adding a data source returns the correct information about the configured project: locals {
project = "prod-888888"
}
terraform {
backend "gcs" {
credentials = "~/.gcloud/terraform-key.json"
project = "devtools-219114"
bucket = "mynewco-terraform-state"
}
}
provider "google" {
credentials = "${file("~/.gcloud/terraform-key.json")}"
project = "${local.project}"
region = "${var.google_region}"
version = "~> 1.19"
}
data "google_project" "project" {}
output "project_name" {
value = "${data.google_project.project.name}"
}
output "project_id" {
value = "${data.google_project.project.id}"
} produces the following output... $ terraform apply -auto-approve
data.google_project.project: Refreshing state...
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
Outputs:
project_id = prod-888888
project_name = prod |
I'm having some trouble recreating this issue - using essentially different values for the config you gave, I am able to generate resources under my I'm also a little confused - your debug logs show PUT "/v1/projects/prod-888888/topics/test-topic", which is your local.project. |
@emilymye Yeah, I saw that too but the operation does fail and the fail message spits out the project id of the devtools project. I just ran it again and and verified the project numbers. It feels like something is defaulting to the originating project for the service account key. Perhaps it's just in the error logging since we are seeing a |
Oh weird - actually, your debug logs are saying the Cloud Pub/Sub API hasn't been enabled for 999999999999 ( I assume you redacted this ID). If this was a different error than the one you saw, could you send me the logs from that error? As for this one, could you add a |
And as a final comment, you should probably be using |
@emilymye Sorry for the delay. Yes, I redacted the ID. The error you mentioned is the same one I saw. It's trying to create resources including the Thanks for the suggestion on using |
@emilymye We hit this problem again today on a fresh project set up using this guide. Interestingly, this issue seems to be isolated to creating |
@kevinohara80 You may have run into the same problem that I described here. Try enabling |
@sergei-ivanov Thanks for the link. They definitely look related. Unfortunately we had to move our project to AWS because we've encountered so many API issues. |
Hi @kevinohara80, I'm sorry to hear that! I'm going to go ahead and close this issue because it doesn't seem like there's anything to do here. I've talked to teams at Google about getting better docs about which project APIs have to be enabled on, but in the meantime, it's the one that the service account comes from, rather than the one that the resource is being created in. I hope that you're able to get things working with GCP, and if you have any other questions please keep filing issues or join us in the terraform channel in the GCP slack! |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks! |
Community Note
Terraform Version
v0.11.8
Affected Resource(s)
All
google_*
resourcesTerraform Configuration Files
variables.tf
main.tf
Debug Output
Debug Log
Expected Behavior
I have two GCP projects set up, one called
devops-tools
and another calledprod-888888
. I have the terraform backend configured to use thedevops-tools
project for remote state. When I configure a GCP provider to use theprod
project, I expect all subsequent resources to be created in that project.Actual Behavior
When the above terraform is applied, terraform is attempting to create the resources in the
devops-tools' (project id 999999999999) project despite the provider being configured to utilize the
prod-888888` project.Steps to Reproduce
devtools
andprod
~/.gcloud/terraform-key.json
locallyprod
project through Google IAMterraform apply
Important Factoids
It's important to note that the Service Account Key is for a Service Account that originates from the devtools-tools project. However, this service account was also added to the prod-8888 project so the credentials are valid. It seems as if terraform is simply ignoring the
project
configuration from the provider and also the resources.The text was updated successfully, but these errors were encountered: