-
Notifications
You must be signed in to change notification settings - Fork 220
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
POST creates attributes that PUT expects #190
Comments
Hi @arun-a-nayagam, |
Hi @jgrumboe - Thank you for the reply, yes an update_data will be very helpful. |
Don't know honestly, but see here: #182 (comment) |
@jgrumboe, I did try to test your provider.
But I get this error, Error: Self-referential block How do I refer to the values that's returned by the original POST call? |
Have you tried using |
Hi @jgrumboe I had raised the same issue on hashicorp support site, This was their reply,
I am going to try implementing a "data http" call to get the api key and secret and assign it to variables. |
Thanks for asking support. |
Hi @jgrumboe while I was trying to implement data http I realised, I need the bearer token to be able make that call. |
Could you post an example resource block how you call |
Hi @jgrumboe, a bit like this,
Provider block is like this,
|
I see. AFAIK it's not possible in Terraform to access provider attributes/arguments directly. There would need to be something implemented in a data source way, like the aws-provider did with the default_tags https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/default_tags |
@jgrumboe I used provider http-full and got the access token explicitly. That works fine. But even a data http to get the key and secret and use that in update_data block is having the same cyclic issue. Here's the code,
If I remove the depends_on on restapi_object.app_scripted_demo_client, data resource fails as that gets executed before restapi_object.app_scripted_demo_client |
You could try to use https://registry.terraform.io/providers/SvenHamers/oauth instead of |
So the |
The issue is not them using the same oauth_token, in fact I generate a different token using http-full provider.
Because it needs to wait for restapi_object to be created before it can query for key and secret and that creates the circular dependency. |
So, just that I get it right: the ApiKey and Keysecret are available after the restapi_object was created and are specific to the object itself? Just as side note: you don't need to add a resource to |
Ok, I was able to solve the circular dependency issue by using a data external and wrap the API call error with a dummy response.
get_key_details.py
Would be nice to see the update_data feature merged into the master code. @jgrumboe thanks for all your suggestions and help. |
Hi @arun-a-nayagam |
Hi @jgrumboe,
When the POST happens using data block the resource is null. I don't think, with terracurl I will be able to give some default response when there's an error. |
@arun-a-nayagam |
Thank you for the update, yes already using 1.18.0 |
Hi,
I have an API that is creating few attributes when the POST call is made,
/Applications is where the POST call is made and at that time it creates an apiKey and apiSecret attributes.
Now whenever an update is made to the resource - /Applications/{id}, it is expecting the apiKey and apiSecret to be passed.
Is there a way to conditionally say when a PUT is made pass these extra attributes from the POST calls response?
Love the simplicity of this provider but stuck with this issue. Hopefully this is possible.
The text was updated successfully, but these errors were encountered: