pulumi / pulumi-yaml

YAML language provider for Pulumi
Apache License 2.0
38 stars 11 forks source link

error: azure-native:dbforpostgresql:Server resource 'postgresServer' has a problem: 'version' should be of type 'string' but got a number #577

Open pyousefi opened 2 months ago

pyousefi commented 2 months ago

What happened?

Deploying a postgresql server where the version number is in a config variable as a string (in quotes) is being returned as a number.

Example

Pulumi.dev.yaml:

config:
  storageSizeGB: 512
  version: '14' | "14" 

Pulumi.yaml: version: ${version}

Output of pulumi about

CLI Version 3.115.2 Go Version go1.22.2 Go Compiler gc

Plugins KIND NAME VERSION language yaml unknown

Host OS Microsoft Windows 10 Pro Version 10.0.19045 Build 19045 Arch x86_64

This project is written in yaml

Current Stack: bookerdimaio/pu-yaml-az-postgres/dev

TYPE URN pulumi:pulumi:Stack urn:pulumi:dev::pu-yaml-az-postgres::pulumi:pulumi:Stack::pu-yaml-az-postgres-dev pulumi:providers:azure-native urn:pulumi:dev::pu-yaml-az-postgres::pulumi:providers:azure-native::default azure-native:dbforpostgresql:Server urn:pulumi:dev::pu-yaml-az-postgres::azure-native:dbforpostgresql:Server::postgresServer

Found no pending operations associated with dev

Backend Name pulumi.com URL https://app.pulumi.com/bookerdimaio User bookerdimaio Organizations bookerdimaio Token type organization: bookerdimaio Token type pouya-admin

No dependencies found

Pulumi locates its logs in C:\Users\pyous\AppData\Local\Temp by default

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

justinvp commented 1 month ago

Thanks for opening the issue and sorry for the trouble!

I was able to reproduce this with the following program and setting the config via pulumi config set version 14:

name: azurenativenum
runtime: yaml
resources:
  resourceGroup:
    type: azure-native:resources:ResourceGroup
  server:
    type: azure-native:dbforpostgresql:Server
    properties:
      resourceGroupName: ${resourceGroup.name}
      version: ${version}

In the meantime, you can workaround by passing the value through fn::toJSON which will cast the number to a string (e.g. fn::toJSON: ${version}):

name: azurenativenum
runtime: yaml
resources:
  resourceGroup:
    type: azure-native:resources:ResourceGroup
  server:
    type: azure-native:dbforpostgresql:Server
    properties:
      resourceGroupName: ${resourceGroup.name}
      version:
        fn::toJSON: ${version}