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

Draft: adjust public API #31

Merged
merged 7 commits into from Apr 29, 2022
Merged

Draft: adjust public API #31

merged 7 commits into from Apr 29, 2022

Conversation

pgavlin
Copy link
Member

@pgavlin pgavlin commented Apr 28, 2022

The proposed public API requires that users subclass pulumicdk.Stack
(which is itself a subclass of cdk.Stack) and call this.synth() at the
end of the subclass's constructor. synth is provided by
pulumicdk.Stack and does the work of creating a Pulumi component
resource, synthesizing the CDK resources, etc.

@pgavlin
Copy link
Member Author

pgavlin commented Apr 28, 2022

Note that I've opened this as a draft for discussion.

Copy link
Contributor

@viveklak viveklak left a comment

Choose a reason for hiding this comment

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

Looks crisper and cleaner for a CDK user IMO.

@pgavlin pgavlin marked this pull request as ready for review April 29, 2022 19:01
@pgavlin
Copy link
Member Author

pgavlin commented Apr 29, 2022

cc @eladb for visibility

The proposed public API requires that users subclass pulumicdk.Stack
(which is itself a subclass of cdk.Stack) and call `this.synth()` at the
end of the subclass's constructor. `synth` is provided by
`pulumicdk.Stack` and does the work of creating a Pulumi component
resource, synthesizing the CDK resources, etc.
@pgavlin pgavlin merged commit 6ef9dc3 into main Apr 29, 2022
@pulumi-bot pulumi-bot deleted the pgavlin/stack-api branch April 29, 2022 21:16
new CfnOutput(this, 'url', { value: service.serviceUrl });
this.url = this.asOutput(service.serviceUrl);

this.synth();
}
}

const stack = new pulumicdk.Stack('teststack', AppRunnerStack);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I expected this to be new AppRunnerStack('teststack'), no?

new CfnOutput(this, 'url', { value: service.serviceUrl });
this.url = this.asOutput(service.serviceUrl);

this.synth();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way to at least discover that the stack was not synthesized and emit an error?

Copy link
Collaborator

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Looks much more idiomatic! Love it.

The requirement to perform this.synth() is a bit of a bummer. Is there a way to at least discover that a stack was not synthed? Maybe an exit hook with some global ugliness?

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.

None yet

3 participants