dbt-labs / terraform-provider-dbtcloud

dbt Cloud Terraform Provider
https://registry.terraform.io/providers/dbt-labs/dbtcloud
MIT License
80 stars 18 forks source link

enhance log messages when importing/creating deployment environments without credential_id #173

Closed justbldwn closed 8 months ago

justbldwn commented 11 months ago

i was recently working through importing environments for a project and hit the below error when importing 2 deployment environments.

Error: POST
url: https://cloud.getdbt.com/api/v3/accounts/[account_id]/projects/[project_id]/environments/[environment_id]/,
status: 500,
body: {
    "status":{
        "code":500,
        "is_success":false,
        "user_message":"There was a server error. Please contact support!",
        "developer_message":""
    },
    "data":null
}

after looking into this without any log context, the cause of the error seemed to be due to the credential_id not being properly set in the environment module when importing the environment. once i added a configuration for the credential_id to be set on deployment environments, the environment import worked and this error went away.

as a QoL feature, and one that could help reduce the research for not having the environment setup properly, can the log message be updated here to provide info that a deployment environment requires a credential_id if it's not provided when either importing/creating environments? thanks!

b-per commented 11 months ago

OK, so there are a couple of things here 😊

Today, the provider is reporting the exact error as it comes from dbt Cloud. I agree that those could definitely be a bit more descriptive but this is not something that is handled on the Terraform side.

Then, the second point might be to update Terraform to make the credential_id mandatory in the case that the environment is a deployment one. This is not something that is gracefully achievable with the Terraform Plugin SDK v2 (the one used for this provider), but might be better handled in the Plugin Framework which I am thinking of migrating to at some point.

But I definitely get the point and will try to reproduce this exact use case and think of how to make the resolution more obvious.

justbldwn commented 11 months ago

thanks @b-per ! that helps to explain what's happening for us. fwiw, we did update our module to ensure that credential_id is passed in when the environment type is "deployment", so we should be okay moving forward (hopefully 😄 ).

do you know where in dbt Cloud the error comes from? if so, is it something that could be an oss contribution? would be more than happy to try and take a look if so.

b-per commented 11 months ago

This is part of the proprietary code of dbt Cloud so there is no external contribution possible. I can pass the feedback to the team though.

github-actions[bot] commented 8 months ago

This issue has been marked as Stale because it has been open for 90 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.