-
Notifications
You must be signed in to change notification settings - Fork 10
cdktn: synthesis succeeds if resource is added with app's scope #57
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Expected Behavior
For resources attached to scope=App(), I'd expect CDKTF to either deploy it within some root/unnamed stack, or fail fast since this resource isn't created under any stack.
Actual Behavior
CDKTF succeeds during synthesis, and doesn't deploy the resource anywhere.
Steps to Reproduce
See this piece of code:
from cdktn import App
from cdktn_provider_google.project_iam_member import ProjectIamMember
ProjectIamMember(
scope=app,
id_="some-iam-member",
member=...,
project=...
role=...
)Versions
cdktn: 0.22.0
cdktn-cli: 0.22.0
Providers
cdktn-provider-google==17.0.0
Gist
No response
Possible Solutions
I don't know what's the proper solution yet, given that ideally we'd fail fast for all supported languages.
Workarounds
In my case, I use Python. I added extra validation as a subclass of App, like:
class ValidatedApp(App):
def synth(self) -> None:
orphans = []
for node in self.node.find_all():
if isinstance(node, (App, TerraformStack)):
continue
try:
find_terraform_stack(node)
except ValueError:
orphans.append(Node.of(node).path)
if orphans:
bullet_list = "\n".join(f" - {path}" for path in orphans)
raise ValueError(
"Found constructs outside of a TerraformStack "
"(did you pass scope=app instead of scope=stack?):\n" + bullet_list
)
super().synth()Anything Else?
No response
References
No response
Help Wanted
- I'm interested in contributing a fix myself
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working