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

cdktf conditional statements and Aliased Provider requirement not synthesized correctly #272

Open
1 task
ankitatdnv opened this issue Sep 14, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@ankitatdnv
Copy link

Description

I have created a cdktf construct where ResourceGroup resource is created with name having conditional statement as follows:

let resGrp = new resourceGroup.ResourceGroup(this, "resGrp", {
                location: input.location,
                name: input.existingRgName == ""? `${input.namePrefix}-${input.appName}-${input.environmentName}-rg` : input.existingRgName,
                tags: input.tags,
                provider: input.provider
            });

But after synthesizing it removes conditional statement and generates following output:

{
    "azurerm_resource_group": {
      "static-app_resGrp_E3D22600": {
        "//": {
          "metadata": {
            "path": "az-static-app/static-app/resGrp",
            "uniqueId": "static-app_resGrp_E3D22600"
          }
        },
        "location": "${var.location}",
        "name": "${var.existingRgName}",
        "provider": "azurerm",
        "tags": "${var.tags}"
      }
    }

Also I have passed an Alias azurerm provider requirement, but after synthesis, it's not taking the alias name, instead just taking the name of the provider.

let azurermProvider = new ProviderRequirement(this, "azurerm", "~> 3.70.0", "hashicorp/azurerm");
let providerAlias = new TFModuleVariable(this, "providerAlias", {
      type: "string",
      default: ""    
    });
azurermProvider.alias = providerAlias.value;

Synthesized output:

"azurerm_resource_group": {
      "static-app_resGrp_E3D22600": {
        "//": {
          "metadata": {
            "path": "az-static-app/static-app/resGrp",
            "uniqueId": "static-app_resGrp_E3D22600"
          }
        },
        "location": "${var.location}",
        "name": "${var.existingRgName}",
        "provider": "azurerm",
        "tags": "${var.tags}"
      }
    }

Versions

language: null
cdktf-cli: 0.18.0
node: v18.17.1
terraform: 1.5.2
arch: x64
os: win32 10.0.19045

Providers

No response

Gist

No response

Possible Solutions

No response

Workarounds

No response

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
@ankitatdnv ankitatdnv added the bug Something isn't working label Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant