Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes debug logging of CfnResource #198

Merged
merged 1 commit into from
Nov 5, 2024

Conversation

t0yv0
Copy link
Member

@t0yv0 t0yv0 commented Nov 4, 2024

Before this change, logging could generate "not supported" errors in the stream.

I1104 14:23:22.081768   66128 eventsink.go:59] CfnResource aws-native:ec2:SubnetRouteTableAssociation:
{"routeTableId":"Calling [toJSON] on an [Output<T>] is not supported.\n\nTo get the value of an Output as a JSON value
or JSON string consider either:\n    1: o.apply(v => v.toJSON())\n    2: o.apply(v => JSON.stringify(v))\n\nSee
https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\nThis function may throw in a future version of
@pulumi/pulumi.","subnetId":"Calling [toJSON] on an [Output<T>] is not supported.\n\nTo get the value of an Output as a
JSON value or JSON string consider either:\n    1: o.apply(v => v.toJSON())\n    2: o.apply(v =>
JSON.stringify(v))\n\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\nThis function may throw
in a future version of @pulumi/pulumi."}, ["awsId","routeTableId","subnetId"]

After the change, debug logging should happen only after the outputs are resolved.

There is a slight downside for unknowns - debug logging will not happen when some of the properties are unknown anymore, because this will make pulumi.output(x) unknown and will not call debug in apply.

Note also that running programs under PULUMI_DEBUG_GRPC="$PWD/log.json" environment variable should also make it possible to observe how the underlying resources are constructed in terms of calls to the backing provider, including observing unknowns.

Before this change, logging could generate "not supported" errors in the stream.

    I1104 14:23:22.081768   66128 eventsink.go:59] CfnResource aws-native:ec2:SubnetRouteTableAssociation:
    {"routeTableId":"Calling [toJSON] on an [Output<T>] is not supported.\n\nTo get the value of an Output as a JSON value
    or JSON string consider either:\n    1: o.apply(v => v.toJSON())\n    2: o.apply(v => JSON.stringify(v))\n\nSee
    https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\nThis function may throw in a future version of
    @pulumi/pulumi.","subnetId":"Calling [toJSON] on an [Output<T>] is not supported.\n\nTo get the value of an Output as a
    JSON value or JSON string consider either:\n    1: o.apply(v => v.toJSON())\n    2: o.apply(v =>
    JSON.stringify(v))\n\nSee https://www.pulumi.com/docs/concepts/inputs-outputs for more details.\nThis function may throw
    in a future version of @pulumi/pulumi."}, ["awsId","routeTableId","subnetId"]

After the change, debug logging should happen only after the outputs are resolved.

There is a slight downside for unknowns - debug logging will not happen when some of the properties are unknown anymore,
because this will make `pulumi.output(x)` unknown and will not call `debug` in `apply`.

Note also that running programs under PULUMI_DEBUG_GRPC="$PWD/log.json" environment variable should also make it
possible to observe how the underlying resources are constructed in terms of calls to the backing provider, including
observing unknowns.
@t0yv0 t0yv0 requested review from corymhall and flostadler November 4, 2024 20:00
Copy link
Contributor

@flostadler flostadler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@t0yv0 t0yv0 merged commit 6f291ff into main Nov 5, 2024
11 checks passed
@t0yv0 t0yv0 deleted the t0yv0/fix-debug-logging-of-cfn-resource branch November 5, 2024 16:45
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v1.0.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants