rich-whale-93740
08/09/2024, 7:00 AMOutput
😅
def _setup_alert_manager_config(
self, sns_topics: list[SnsTopic]
) -> AlertManagerDefinition:
......
return pulumi.Output.json_dumps(alert_manager_config_dict).apply(
lambda config_json_str: self._create_alert_manager_definition(
config_json_str
)
)
def _create_alert_manager_definition(
self, alert_manager_config_json_str: str
) -> AlertManagerDefinition:
config = {}
......
Towards the end of the stack, we call _setup_alert_manager_config
. When running pulumi preview
, it doesn't reach the lambda
in pulumi.Output.json_dumps
. Any idea? Is there a way for me to force waiting for the pulumi.Output.json_dump
to finish?rich-whale-93740
08/09/2024, 7:35 AMrun_with_unknowns=True
to the apply
, then it runs and fails with this:
File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/json/__init__.py", line 339, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not Unknown
So looks like config_json_str
is Unknown
. But why? alert_manager_config_dict
's definition includes Output
as one of the values in the dict. But that should be fine?dry-keyboard-94795
08/09/2024, 7:53 AMrich-whale-93740
08/09/2024, 7:55 AMAn apply generally only runs when usedWhat is the definition of
used
?dry-keyboard-94795
08/09/2024, 7:55 AMrich-whale-93740
08/09/2024, 8:04 AMOutput
), then deserialize it as YAML, which would be used as an input to create resource. Any suggestion how to do that?rich-whale-93740
08/09/2024, 8:17 AMapply
dry-keyboard-94795
08/09/2024, 8:17 AMAlertManagerDefinition("name", config=pulumi.Output.json_dumps(alert_manager_config_dict))
Remember that json is valid yaml if it's expecting a yaml stringrich-whale-93740
08/09/2024, 8:17 AMrich-whale-93740
08/09/2024, 8:18 AMdry-keyboard-94795
08/09/2024, 8:19 AMalert_manager_config_dict.apply(yaml.dumps)
rich-whale-93740
08/09/2024, 8:30 AMalert_manager_defintion = pulumi.Output.json_dumps(alert_manager_config_dict).apply(
lambda config_json_str: self._create_alert_manager_definition(
config_json_str
)
)
return AlertManagerDefinition(
f"amp-rule-group-{self._stack}",
workspace_id=self._amp_workspace.id,
definition=alert_manager_defintion,
opts=ResourceOptions(provider=self._provider),
)
It ended up with empty string in AlertManagerDefinition
. _create_alert_manager_definition
returns the serialized yaml. I added logging in _create_alert_manager_definition
, but nothing printsrich-whale-93740
08/09/2024, 8:33 AMalert_manager_config_dict
looks like this:
"sns_configs": [
{
"topic_arn": topic.arn,
For some reason, topic.arn.is_known()
shows false
<Task finished name='Task-633' coro=<Output.__init__.<locals>.is_value_known() done, defined at /Users/dennis.pan.117/code/iac/observability/venv/lib/python3.11/site-packages/pulumi/output.py:121> result=False>
I think that causes the apply
to not do anythingrich-whale-93740
08/09/2024, 8:33 AMtopic.arn
is used by other resources creation, and those were all finedry-keyboard-94795
08/09/2024, 9:47 AM.apply(json.dumps)
work?faint-pager-13674
08/21/2024, 2:25 PMcomponentResource
to wrap this functionality and make this new custom resource a dependency for that the other resource.