terraform-provider-newrelic
terraform-provider-newrelic copied to clipboard
Resource `newrelic_browser_application`: Often rm only returns `application_id` on second apply
In https://github.com/newrelic/terraform-provider-newrelic/issues/2577 the ability for newrelic_browser_application
to return the created application_id
was added, and was released in 3.35.2.
However, I'm not seeing the created application_id
being consistently returned on the first apply. Sometimes it is, sometimes it isn't, and a second apply shows the state updating the application_id. Checked with 3.35.2 and 3.38.1.
From the debug log when it fails, it looks like a newrelic query doesn't find the created mutation. As it works sometimes, I guess newrelic takes a while to create the resource.
I've attached a minimal main.tf with an output which I'm using to prove the bug.
Terraform Version
terraform -version
Terraform v1.7.5
on darwin_arm64
+ provider registry.terraform.io/newrelic/newrelic v3.38.1
Affected Resource(s)
-
newrelic_browser_application
Terraform Configuration
See attached main.tf for full file, but:
terraform {
required_providers {
newrelic = {
source = "newrelic/newrelic"
version = "3.38.1"
}
}
}
resource "newrelic_browser_application" "web" {
name = "my-dev-piran-test3"
cookies_enabled = true
distributed_tracing_enabled = true
loader_type = "SPA"
}
Actual Behavior
application_id
not always available after NewRelic Browser resource is created (it mostly fails).
Expected Behavior
application_id
to always be available after NewRelic Browser resource is created.
Steps to Reproduce
The first apply I get:
% terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# newrelic_browser_application.web will be created
+ resource "newrelic_browser_application" "web" {
+ account_id = (known after apply)
+ application_id = (known after apply)
+ cookies_enabled = true
+ distributed_tracing_enabled = true
+ guid = (known after apply)
+ id = (known after apply)
+ js_config = (known after apply)
+ loader_type = "SPA"
+ name = "my-dev-piran-test"
}
Plan: 1 to add, 0 to change, 0 to destroy.
Changes to Outputs:
+ newrelic_browser_account_id = (known after apply)
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
newrelic_browser_application.web: Creating...
newrelic_browser_application.web: Creation complete after 2s [id=NDMxxxxxxxxxxxxxxxxxxxxxx]
Apply complete! Resources: 1 added, 0 changed, 0 destroyed.
pdb@Chapel tmp % terraform output newrelic_browser_account_id
╷
│ Warning: No outputs found
On the second apply, the state gets updated with the application_id, and the output is set:
% terraform apply
newrelic_browser_application.web: Refreshing state... [id=NDMxxxxxxxxxxxxxxxxxxxxxx]
Note: Objects have changed outside of Terraform
Terraform detected the following changes made outside of Terraform since the last "terraform apply" which may have affected this plan:
# newrelic_browser_application.web has changed
~ resource "newrelic_browser_application" "web" {
+ application_id = "1588967118"
id = "NDMxxxxxxxxxxxxxxxxxxxxxx"
name = "my-dev-piran-test3"
# (5 unchanged attributes hidden)
}
Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Changes to Outputs:
+ newrelic_browser_account_id = "1588967118"
You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.
...
I would expect the application_id
to be available immediately after the resource has been created in the first apply. It sometimes is, but not usually.
Debug Output
Debug log from a similarly failing first apply is in: https://gist.github.com/piran-cabiri/bcd4b82be1efb681dad3d2474edde506
References
newrelic_browser_application
's application_id
return created in response to https://github.com/newrelic/terraform-provider-newrelic/issues/2577