-
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
Add tab view in Playground/Tutorial to show either the simulator map view or lists of generated resources in the different clouds #2495
Comments
I love the direction, just missing a way to download the artifacts |
this site https://www.convertsimple.com/convert-json-to-hcl/ uses https://github.com/vgsantoniazzi/js-hcl-parser which I think enough for our needs |
let's start by supporting the following:
example:
|
@skorfmann will help us with the "right" way to convert json->HCL I showed him https://www.convertsimple.com/convert-json-to-hcl/ and he didn't approve |
AWS resource icons link |
Yes, the syntax which is produced by these tools is neither idiomatic nor functional Terraform HCL config, but looks like some weird JSON like syntax (maybe HCL v1?). I think the challenge is, that the default use case is going from HCL to JSON for machine readable formats. The other way around is super rare. See this issue from the lib that’s being used in cdktf for hcl2json tasks tmccombs/hcl2json#2 - Plus, there's another issue in cdktf essentially requesting the same thing: hashicorp/terraform-cdk#225. TL;DR: HCL is a toolkit to build languages where Terraform HCL is a specific implementation of it. Converting from HCL -> JSON is straightforward, going reverse needs type information from the Terraform provider in some cases. So, let's take a wing generated Lambda function as an example, the converted JSON from this tool looks like this: "aws_lambda_function" "root_env0_cloudQueueAddConsumer3915c5ec_D9C8326B" {
"//" "metadata" {
"path" = "root/Default/env0/cloud.Queue-AddConsumer-3915c5ec/Default"
"uniqueId" = "root_env0_cloudQueueAddConsumer3915c5ec_D9C8326B"
}
"environment" "variables" {
"BUCKET_NAME_90d3f186" = "${aws_s3_bucket.root_env0_cloudBucket_DA9B7293.bucket}"
"BUCKET_NAME_90d3f186_IS_PUBLIC" = "false"
"WING_FUNCTION_NAME" = "cloud-Queue-AddConsumer-3915c5ec-c83da7e5"
}
"function_name" = "cloud-Queue-AddConsumer-3915c5ec-c83da7e5"
"handler" = "index.handler"
"publish" = true
"role" = "${aws_iam_role.root_env0_cloudQueueAddConsumer3915c5ec_IamRole_54033248.arn}"
"runtime" = "nodejs18.x"
"s3_bucket" = "${aws_s3_bucket.root_Code_02F3C603.bucket}"
"s3_key" = "${aws_s3_object.root_env0_cloudQueueAddConsumer3915c5ec_S3Object_F86765F2.key}"
"timeout" = 30
"vpc_config" = {
"security_group_ids" = []
"subnet_ids" = []
} vs the one you’d actually want to have
As you can see, it’s not too far off in terms of general structure. (compare the tf resource as well https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) One way could be to do some postprocessing. There are a few things that would need to be done:
The difficult part can be seen here:
which looks like this in JSON
Another way could be, to actually build a dedicated TF JSON -> Terrform HCL converter. Here's an example to do this for Terraform Probably depends on how important this really is in the end. |
Done |
Feature Spec
Users are now better able to understand that Wing is not a toy when playing in the playground or doing a tutorial because they see in a clear way that we generate real cloud code
Use Cases
To show users we are not a toy. The simulator compiles so fast, users might not understand this is real cloud code
Implementation Notes
@eladb has thoughts on exactly what this should look like
Component
Playground, Tutorial
Community Notes
The text was updated successfully, but these errors were encountered: