hashicorp / terraform-cdk

Define infrastructure resources using programming constructs and provision them using HashiCorp Terraform
https://www.terraform.io/cdktf
Mozilla Public License 2.0
4.88k stars 455 forks source link

NewRelic provider: How to pass policy_id parameter to NrqlAlertCondition #3642

Closed saleemjaffer closed 5 months ago

saleemjaffer commented 5 months ago

Expected Behavior

I am trying to create an NrqlAlertCondition. This requires a policy_id parameter.

Before creation of NrqlAlertCondition, I am creating an AlertPolicy. I should be able to pass id of the AlertPolicy to policy_id of NrqlAlertCondition

Actual Behavior

policy_id of NrqlAlertCondition accepts an int or float. The policy.id that we get from AlertPolicy is a string like ${TfToken[TOKEN.244]} and hence can't typecast and pass this to policy_id

Steps to Reproduce

  1. Create a NewRelic alert policy.
  2. Create a NewRelic alert condition using the Id of the policy created in the previous step.

Versions

language: python
cdktf-cli: 0.20.7
node: v20.14.0
cdktf: 0.20.7
constructs: 10.3.0
jsii: 1.98.0
terraform: 1.7.5
arch: arm64
os: darwin 23.3.0
python: Python 3.9.7
pip: pip 21.2.3 from /Users/saleem.majeeth/.pyenv/versions/3.9.7/envs/playground-3.9.7/lib/python3.9/site-packages/pip (python 3.9)
pipenv: pipenv, version 2023.12.1
providers
cdktf-cdktf-provider-newrelic (PREBUILT)
        terraform provider version: 3.37.1 
        prebuilt provider version: 12.8.1
        cdktf version: ^0.20.0

Providers

newrelic/newrelic │ 3.37.1 │ ^0.20.0 │ │ cdktf-cdktf-provider-newrelic │ 12.8.1

Gist

No response

Possible Solutions

No response

Workarounds

No response

Anything Else?

No response

References

https://github.com/newrelic/terraform-provider-newrelic/issues/1940

Help Wanted

Community Note

DanielMSchmidt commented 5 months ago

Hey, I think this page about Tokens might help you. You can typecast, it's just not the native language typecast but you have to use the typecast on the Token class, it has a bunch of static methods to get from type a to b.

saleemjaffer commented 5 months ago

@DanielMSchmidt I tried the same earlier, and I am getting huge negative numbers.

⠙  Processing
[2024-06-13T15:56:13.186] [ERROR] default - ╷
│ Error: Attribute must be a whole number, got -1.8881545897087635e+289
│ 
│   with newrelic_nrql_alert_condition.oaac_test_dev_test-group_23730378,
│   on cdk.tf.json line 5908, in resource.newrelic_nrql_alert_condition.oaac_test_dev_test-group_23730378:
│ 5908:         "policy_id": -1.8881545897087635e+289
│ 
dev  ╷
     │ Error: Attribute must be a whole number, got -1.8881545897087635e+289
     │ 
     │   with newrelic_nrql_alert_condition.oaac_test_dev_test-group_23730378 (oaac_test_dev_test-group_23730378),
     │   on cdk.tf.json line 5908, in resource.newrelic_nrql_alert_condition.oaac_test_dev_test-group_23730378 (oaac_test_dev_test-group_23730378):
     │ 5908:         "policy_id": -1.8881545897087635e+289
     │ 
     ╵
github-actions[bot] commented 3 months ago

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've found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.