-
Notifications
You must be signed in to change notification settings - Fork 198
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
fix(platforms): unable to perform awscdk context lookups #6286
Conversation
In order to fix #6279, we need synthesis to be triggered by the CDK CLI instead of directly from the Wing CLI. This is actually really easy to do. All you need is to create a `cdk.json` file (or use one from `cdk init`) and modify the `app` and the `output` options like so: ```json { "app": "CDK_STACK_NAME='MyStack' wing compile --platform @winglang/platform-awscdk main.w", "output": "target/main.awscdk" } ``` Then, you can simply use `cdk deploy`, `cdk diff`, `cdk synth` as if it was a normal CDK app. No need to explicitly interact with the Wing CLI in this case. To allow context lookups, we need to support specifying the stack's AWS environment (account/region), so two new environment variables have been added: `CDK_AWS_ACCOUNT` and `CDK_AWS_REGION`. These can be set together with `CDK_STACK_NAME` in the `cdk.json` file mentioned above.
Thanks for opening this pull request! 🎉
|
BenchmarksComparison to Baseline ⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
⬜ Within 1.5 standard deviations Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI. Results
Last Updated (UTC) 2024-04-21 20:14 |
The *new* best practice as described in winglang/wing#6286 is to configure a `cdk.json` file to use `wing compile` as the CDK app. This standardizes the usage through the CDK CLI and enables all CDK features like context lookups, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for tackling this one @eladb, I think we should ship this for necessity. I do want to continue the conversation around this flow and if we can/should make this more "wing" native feeling. Ill make some notes and add a topic proposal to a team time.
Happy to continue the discussion. The way I see it, the Wing CLI is currently focused on compilation, local development and testing. Deployment is out of scope and ideally should be as idiomatic as possible (and as standard as possible) to the target platform. Which is why I think that for CDK users this is better and more idiomatic DX because that's exactly how they work with any CDK language, and I don't think Wing should be different. If/when we decide that the Wing CLI will own deployment, we will need hooks at the platform level to support it and that's where we will need to execute the CDK CLI (or the Terraform CLI), so context lookups will be solved there. There's a lot of value in not dealing with the huge surface area of these provisioning tools right now. |
Thanks for contributing, @eladb! This PR will now be added to the merge queue, or immediately merged if |
You know, when I first started my line of thinking here, my mind thought that the current deployment modus operandi was to run |
Congrats! 🚀 This was released in Wing 0.71.4. |
In order to fix #6279, we need synthesis to be triggered by the CDK CLI instead of directly from the Wing CLI.
This is actually really easy to do. All you need is to create a
cdk.json
file (or use one fromcdk init
) and modify theapp
and theoutput
options like so:Then, you can simply use
cdk deploy
,cdk diff
,cdk synth
as if it was a normal CDK app. No need to explicitly interact with the Wing CLI in this case.To allow context lookups, we need to support specifying the stack's AWS environment (account/region), so two new environment variables have been added:
CDK_AWS_ACCOUNT
andCDK_AWS_REGION
. These can be set together withCDK_STACK_NAME
in thecdk.json
file mentioned above.Checklist
pr/e2e-full
label if this feature requires end-to-end testingBy submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.