sparse-intern-71089
09/02/2021, 9:50 PMbored-table-20691
09/02/2021, 9:51 PMalert_policy.id()
is an output type, it’s value is not known at program execution time (unless you apply
it). You would typically register it as an output.breezy-piano-61073
09/03/2021, 1:03 AMprint("alert_policy.id=" + alert_policy.id.apply(lambda id: id) )
And when you say resister output, do you mean something like this:
pulumi.export('policyid', alert_policy.id)
bored-table-20691
09/03/2021, 1:49 AMbored-table-20691
09/03/2021, 1:49 AMbored-table-20691
09/03/2021, 1:49 AMbreezy-piano-61073
09/03/2021, 2:22 AMresource1 = x(...)
resource2 = y(resource1.id, ...)
It seems like a very basic thing to do, and I read in the doc that when you provide the output of one resource as an input to another, Pulumi should work the dependencies out and the value should be available when it is needed. But that doesn’t seem to be the case here.
I did try the apply code I wrote above, but it returns the same error, the input to resource2 (which is an output of resource1) still does not have a value.breezy-piano-61073
09/03/2021, 2:24 AMbored-table-20691
09/03/2021, 3:13 AMbreezy-piano-61073
09/03/2021, 3:29 AMimport pulumi
import pulumi_newrelic as newrelic
import pprint
alert_policy=newrelic.AlertPolicy("DAI-SHARED-DEV-OPERATIONS-WORKFLOW-CREATED",
incident_preference="PER_POLICY",
name="DAI-SHARED-DEV-OPERATIONS-WORKFLOW-CREATED")
############################################################################
# simple ping/check for healthcheck and text check for correctness
#
healthcheck_synthetics_monitor = newrelic.synthetics.Monitor(
"api.us.digital.cloud healthchecks (script created)",
frequency=5,
locations=[
"AWS_US_EAST_1",
"AWS_US_WEST_1",
"AWS_EU_WEST_1"
],
status="ENABLED",
type="SIMPLE",
uri="<https://api.us.digitalai.cloud/core/monitoring/healthcheck>",
validation_string='{"response": {"healthy": true,'
)
multiLocationAlertCondition1 = newrelic.synthetics.MultiLocationAlertCondition(
"Alert Condition 1 (script created)",
enabled=True,
entities = [healthcheck_synthetics_monitor.id],
policy_id = alert_policy.id, ##### PROBLEM IS HERE #######################################
violation_time_limit_seconds = 3600,
critical = newrelic.synthetics.MultiLocationAlertConditionCriticalArgs(threshold = 3),
warning = newrelic.synthetics.MultiLocationAlertConditionWarningArgs(threshold=1)
)
When run, I get this:
➜ pulumi up -y
Previewing update (dai-shared-dev-us-west-2):
Type Name Plan Info
pulumi:pulumi:Stack dai-palumi-dai-shared-dev-us-west-2
+ ├─ newrelic:synthetics:Monitor api.us.digital.cloud healthchecks (script created) create
└─ newrelic:synthetics:MultiLocationAlertCondition Alert Condition 1 (script created) 1 error
Diagnostics:
newrelic:synthetics:MultiLocationAlertCondition (Alert Condition 1 (script created)):
error: newrelic:synthetics/multiLocationAlertCondition:MultiLocationAlertCondition resource 'Alert Condition 1 (script created)' has a problem: Attribute must be a whole number, got 1510434. Examine values at 'MultiLocationAlertCondition.PolicyId'.
Funny thing is, Pulumi is complaining “Attribute must be a whole number, got 1510434”, and 1510434 is clearly a whole number if I remember my math correctly. And I did check NewRelic, the created AlertPolicy does have the value of 1510434.bored-table-20691
09/03/2021, 3:55 AMpolicyid = alertpolicy.id.apply(lambda myid: int(myid))
And then try and pass policyid to the alert you’re creatingbreezy-piano-61073
09/07/2021, 1:01 PMbored-table-20691
09/07/2021, 2:41 PM