Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

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

@ankitatdnv

Description

@ankitatdnv

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions