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

Azurerm first experience with c# dotnet and typescript #1898

Open
cveld opened this issue Jun 24, 2022 · 3 comments
Open

Azurerm first experience with c# dotnet and typescript #1898

cveld opened this issue Jun 24, 2022 · 3 comments
Labels
bug Something isn't working language/c# C# language issues priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. size/large estimated < 1 month upstream/jsii Pending upstream work on JSII ux/configuration ux/debugging

Comments

@cveld
Copy link

cveld commented Jun 24, 2022

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

Terraform cdk seems to be a great initiative to open up even more great infrastructure as code scenarios!

One use case I am in particular exploring currently is intellisense in vscode on adding configurations.

At the very core using a terraform file, I played with declaring an azurerm resource.
e.g.

resource "azurerm_storage_account" "storageaccount" {
    name = "mystorageaccount"
    location = "westeurope"
    accountTier: "Standard",
    accountReplicationType: "LRS"
}

Installed hashicorp and Microsoft terraform extensions in vscode in order to get intellisense.
The behavior is that it is not reporting the missing required properties, and it does not show the valid values on e.g. accountTier and accountReplicationType.

So I started to explore the intellisense when using terraform cdk.
I created this ticket to get your feedback on my thinking and maybe it helps you to steer the direction of your product.

cdktf & Language Versions

nodejs:
"cdktf": "0.11.2"
"azurerm@~> 2.0.0"

dotnet:
HashiCorp.Cdktf; Version="0.11.2"
HashiCorp.Cdktf.Providers.Azurerm; Version="0.8.2"

Actual Behavior for TypeScript

  • I like that missing required properties are reported design-time. It is unfortunate that the way typescript reports this is quite user-unfriendly, i.e. it shows a big ball of text explaining a type mismatch due to some missing properties.
  • It is unfortunate that it does not show the valid values on e.g. accountTier and accountReplicationType. Maybe because the azurerm provider is not reporting the list of values.

Actual Behavior for c# dotnet

  • missing required properties are not reported. Maybe this is something that can be added with the new .NET 7 init feature?
  • it does not show the valid values on e.g. accountTier and accountReplicationType.

I will also test this out with bicep. If intellisense is great over there, maybe you can work together with the bicep team to improve the azurerm experience in the terraform space.

@cveld cveld added bug Something isn't working new Un-triaged issue labels Jun 24, 2022
@jsteinich
Copy link
Collaborator

There are a couple related issues in the upstream jsii library pertaining to to the required properties:

The valid values you mention aren't available in the provider schema that is used to generate provider bindings. They are sometimes present in the provider source code or in documentation; however, that gets pretty messy to incorporate.

As much as I would like to recommend C# (I use it myself), you'll likely find TypeScript to be a smoother experience.

@cveld
Copy link
Author

cveld commented Jun 26, 2022 via email

@jsteinich
Copy link
Collaborator

Where/how is the azurerm provider schema produced?

The schema comes from a Terraform cli command

And where/how is cdk consuming this?

The resulting schema is parsed and used to generate TypeScript code. That code is then processed by jsii to generate code for other languages.

And off topic, how is the vscode terraform language server consuming this?

I'm not sure, but am also curious. I have seen that the IntelliJ platform Terraform plugin also has more information in certain cases. One possibility is that it is actually reading the go source code of the provider.

In the meanwhile I tested with Bicep and it does provide completion. Maybe in future Bicep metadata can be used to populate terraform metadata.

That may be possible if Bicep aligns close enough with the Terraform provider.

It is painful to see that the c# issues are already open for so long

I believe c# is the least used CDK language so it does tend to get less attention. Despite some limitations, it is still very powerful to work with.

@DanielMSchmidt DanielMSchmidt added upstream/jsii Pending upstream work on JSII priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. ux/debugging language/c# C# language issues ux/configuration size/large estimated < 1 month and removed new Un-triaged issue labels Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working language/c# C# language issues priority/important-longterm Medium priority, to be worked on within the following 1-2 business quarters. size/large estimated < 1 month upstream/jsii Pending upstream work on JSII ux/configuration ux/debugging
Projects
None yet
Development

No branches or pull requests

3 participants