terraform-provider-newrelic
terraform-provider-newrelic copied to clipboard
policy_id should be string not int
Please include the following with your bug report
- [ ] Your New Relic
provider
configuration (sensitive details redacted) - [x] A list of affected resources and/or data sources
- [x] The configuration of the resources and/or data sources related to the bug report (i.e. from the list mentioned above)
- [x] Description of the current behavior (the bug)
- [x] Description of the expected behavior
- [ ] Any related log output
Terraform Version
Run terraform -v
to show the version. If you are not running the latest version of Terraform, please upgrade because your issue may have already been fixed.
Affected Resource(s)
Please list the resources as a list, for example:
-
newrelic_alert_policy
-
newrelic_alert_condition
Terraform Configuration
Hello. I am using terraform-cdk, and it is auto-generating the types. However for
const newrelicAlertPolicy = new newrelic.AlertPolicy(
this,
stage,
{
incidentPreference: "PER_CONDITION",
name: `${stage}`,
}
);
new newrelic.SyntheticsAlertCondition(
this,
`${stage}_${endpoint.name}_alert_condition`,
{
monitorId: newrelicSyntheticsMonitor.id,
name: endpoint.name,
// @ts-ignore
policyId: newrelicAlertPolicy.id,
}
);
the policyId is of type number, while the policy.id is of type string.
Actual Behavior
should not require // @ts-ignore
policyId
should match the alertPolicy.id
type
Expected Behavior
types do not match -> // @ts-ignore
is required
Steps to Reproduce
- generate cdktf project
- add newrelic provider
- add sample code
- remove
// @ts-ignore
Reference
https://github.com/newrelic/terraform-provider-newrelic/blob/6fc1373ad30136bd84691c6a2bc7a25e9ced3bbc/newrelic/resource_newrelic_alert_condition.go#L90
@jaecktec Thank you for reporting this issue. We'll look into making the policy ID types match to avoid this in the future.
Hi @jaecktec, Is this issue still relevant?
Yes. I just checked with cdktf and nr provider 3.7.1 and it still has that incompatibility.
Sure we will look into it. For CDK please try using tonumber as a workaround for now.
There isn't much to do on terraform side, hence closing this issue. Please open a new issue if you encounter any other issues or questions.
There is something to do from terraform side... Adjusting the type.. Should I create a PR?
Hi @jaecktec, the newrelic_synthetics_alert_condition
resource is a legacy resource and will likely not be receiving any updates. It calls an old legacy API which has been deprecated. Our documentation recommends switching to use newrelic_nrql_alert_condition
. Hope this helps 🙂
Hi @jaecktec, the
newrelic_synthetics_alert_condition
resource is a legacy resource and will likely not be receiving any updates. It calls an old legacy API which has been deprecated. Our documentation recommends switching to usenewrelic_nrql_alert_condition
. Hope this helps 🙂
this does not help. the newrelic_nrql_alert_condition
resource also defines policy_id
as number
type, which doesn't match with the policy.id
(which is of string
type)
https://github.com/newrelic/terraform-provider-newrelic/blob/6fc1373ad30136bd84691c6a2bc7a25e9ced3bbc/newrelic/resource_newrelic_nrql_alert_condition.go#L106
When used with CDKTF in TypeScript, we have to cast the value like this
const alertPolicy = new AlertPolicy(this, 'alert-policy', {
name: 'some-policy',
incidentPreference: 'PER_POLICY',
});
new NrqlAlertCondition(this, 'error-rate', {
policyId: alertPolicy.id as unknown as number,
...
});
@jackie-linz this would not work since alertPolicy.id
is a tokenized string.
@jaecktec I am still facing this issue. Were you able to find a solution?
@saleemjaffer I kept the //@ts-ignore