Open jbrook opened 11 months ago
@jbrook I think this is expected. project is optional if it is provided by the provider defaults. One way or the other, you still need to provide these config values. This rule is applied on other fields like region, zone, etc.
Did I misunderstand your issue?
I think so - I provided the project via the provider defaults (GOOGLE_CLOUD_PROJECT environment variable). The fleet
block didn't use it.
OH I see what you meant now. Thanks @jbrook
Here is the questionable code.
Thanks James and Edward for looking into this issue!
The project
field under the fleet block is different from the cluster project by concept. It could be the cluster project, or it could also be a different project. Therefore, user needs to provide an explicit value of fleet project in order to register the cluster to that fleet project. The provider defaults (GOOGLE_CLOUD_PROJECT
) will not be used automatically as fleet project.
As you mentioned, the error message (internal error) does seems confusing. We will work on improving the error handling here.
GKE cluster creation fails when relying on the provider's default project and setting an empty
fleet
block.Community Note
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 tohashibot
, a community member has claimed the issue already.Terraform Version
Terraform v1.6.5 on linux_amd64
Affected Resource(s)
gooogle_container_cluster
Terraform Configuration Files
Debug Output
https://gist.github.com/jbrook/40626e57c1062f2d46a4f0a0b26676dd
Panic Output
n/a
Expected Behavior
A GKE Autopilot cluster should be created. It should be a member of a Fleet using the cluster's project.
Actual Behavior
Cluster creation fails with an obscure timeout error:
Terraform debug log shows that it's an API error. No project ID is sent when POSTing to the GKE API to create a cluster:
The API responds with a 500 error triggered by an Anthos entitlement check. Note that the cause is an invalid resource name because the project ID is missing:
The GKE Operations logs in Cloud Logging only show "Internal Error" "13" making this hard to debug.
It seems that the GKE API does not accept an empty project ID when creating a cluster. The provider documentation for the
fleet
block says that theproject
argument is optional.The project should be set to the provider default project when calling the API.
Cluster creation succeeds when setting the project name in the
fleet
block using the google_project datasource as follows:Steps to Reproduce
GOOGLE_CLOUD_PROJECT=my-project-name terraform apply
Important Factoids
References
0000
b/315120659