Skip to content
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

Allow google_project_service to accept google.project.id #7203

Closed
ademariag opened this issue Sep 7, 2020 · 4 comments · Fixed by GoogleCloudPlatform/magic-modules#3975, #7255 or hashicorp/terraform-provider-google-beta#2479

Comments

@ademariag
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to the modular-magician user, it is either in the process of being autogenerated, or is planned to be autogenerated soon. If an issue is assigned to a user, that user is claiming responsibility for the issue. If an issue is assigned to hashibot, a community member has claimed the issue already.

Terraform Version

Terraform v0.13.2
+ provider registry.terraform.io/hashicorp/google v3.37.0
+ provider registry.terraform.io/hashicorp/google-beta v3.37.0
+ provider registry.terraform.io/hashicorp/random v2.3.0
+ provider registry.terraform.io/hashicorp/template v2.1.2

Affected Resource(s)

  • google_project_service

Terraform Configuration Files

{
	"resource": {
		"google_project": {
			"project": {
				"billing_account": "008F72-XXXX-XXXXX",
				"name": "Project Name",
				"org_id": "XXXXXX",
				"project_id": "a_project"
			}
		},
		"google_project_service": {
			"enable_cloudbilling_service": {
				"project": "${google_project.project.id}",
				"service": "cloudbilling.googleapis.com"
			}
		}
	}
}

Debug Output

Error: Provider produced inconsistent result after apply                                                                                               
                                                                                                                                                       
When applying changes to google_project_service.enable_iamcredentials_service,
provider "registry.terraform.io/hashicorp/google" produced an unexpected new                                                                           
value: Root resource was present, but now absent.                                                                                                      
                                                                                                                                                       
This is a bug in the provider, which should be reported in the provider's own                                                                          
issue tracker.  

Expected Behavior

google_project_service resource created

Actual Behavior

google_project_service resource is not being created

Steps to Reproduce

  1. terraform apply

Important Factoids

  • only happens on creation
  • authenticating as a user

References

  • #0000
@ghost ghost added the bug label Sep 7, 2020
@ademariag
Copy link
Author

I think this is somehow caused by the "project" key in the resource.

if I run it without, it works, e.g.:

{
	"resource": {
		"google_project": {
			"project": {
				"billing_account": "008F72-XXXX-XXXXX",
				"name": "Project Name",
				"org_id": "XXXXXX",
				"project_id": "a_project"
			}
		},
		"google_project_service": {
			"enable_cloudbilling_service": {
				// "project": "${google_project.project.id}",   REMOVE
				"service": "cloudbilling.googleapis.com"
			}
		}
	}
}

if I re-add, I get

  # google_project_service.enable_cloudbilling_service must be replaced
-/+ resource "google_project_service" "enable_cloudbilling_service" {
        disable_on_destroy = true
      ~ id                 = "a_project/cloudbilling.googleapis.com" -> (known after apply)
      ~ project            = "a_project" -> "projects/a_project" # forces replacement
        service            = "cloudbilling.googleapis.com"
    }

@ademariag
Copy link
Author

The correct attribute to call is ${google_project.project.project_id} instead of ${google_project.project.id}

This resolves my issue, but I will leave this bug on for someone else to decide whether this behaviour is insane or working as intended.

@edwardmedia edwardmedia self-assigned this Sep 7, 2020
@edwardmedia
Copy link
Contributor

Below is what google_project provides. The formats of id and project are different. We should let google_project_service to accept both.

resource "google_project" "my_project" {
    id                  = "projects/myproject"
    name                = "myproject"
    project_id          = "myproject"
   .....
}

@ghost
Copy link

ghost commented Oct 12, 2020

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 👉 hashibot-feedback@hashicorp.com. Thanks!

@ghost ghost locked as resolved and limited conversation to collaborators Oct 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.