pulumi / pulumi-gcp

A Google Cloud Platform (GCP) Pulumi resource package, providing multi-language access to GCP
Apache License 2.0
183 stars 53 forks source link

Possible data type discrepancy for `gcp.compute.BackendService` #814

Closed aureq closed 1 year ago

aureq commented 2 years ago

What happened?

While using our doc examples, it seems like there's a data type discrepancy for the healthChecks property.

Right now, the healthChecks property is of type pulumi.Input<string> but this doesn't seem to be right according to upstream TF provider doc or the Google API resource definition.

Steps to reproduce

  1. Use the code below
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

export = async () => {

    const defaultHttpHealthCheck = new gcp.compute.HttpHealthCheck("defaulthttphealthcheck", {
        requestPath: "/",
        checkIntervalSec: 1,
        timeoutSec: 1,
    });

    const defaultBackendService = new gcp.compute.BackendService("defaultBackendService", {
        healthChecks: [defaultHttpHealthCheck.id],
        enableCdn: true,
        cdnPolicy: {
            cacheMode: "CACHE_ALL_STATIC",
            defaultTtl: 3600,
            clientTtl: 7200,
            maxTtl: 10800,
            negativeCaching: true,
            signedUrlCacheMaxAgeSec: 7200,
        },
    });

    return {

    }
}

Expected Behavior

  1. The code should pass vscode linting
  2. The code should deploy correctly

Actual Behavior

  1. The code fails to pass linting with the error Type 'Output<string>[]' is not assignable to type 'Input<string> | undefined'.ts(2322)
  2. The code fails to deploy
  3. I'm unable to provide more than one health check if I remove the []

Versions used

$ pulumi about
CLI          
Version      3.32.1
Go Version   go1.17.9
Go Compiler  gc

Plugins
NAME    VERSION
gcp     6.24.0
nodejs  unknown

Host     
OS       debian
Version  11.3
Arch     x86_64

This project is written in nodejs (/usr/local/bin/node v16.15.0)

Current Stack: dev

TYPE                                         URN
pulumi:pulumi:Stack                          urn:pulumi:dev::gcp-ts-backend-service::pulumi:pulumi:Stack::gcp-ts-backend-service-dev
pulumi:providers:gcp                         urn:pulumi:dev::gcp-ts-backend-service::pulumi:providers:gcp::default_6_24_0
gcp:compute/httpHealthCheck:HttpHealthCheck  urn:pulumi:dev::gcp-ts-backend-service::gcp:compute/httpHealthCheck:HttpHealthCheck::defaulthttphealthcheck
gcp:compute/backendService:BackendService    urn:pulumi:dev::gcp-ts-backend-service::gcp:compute/backendService:BackendService::defaultbackendservice

Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/aureq
User           aureq
Organizations  aureq, team-ce, menfin, demo, pulumi

NAME            VERSION
@pulumi/gcp     6.24.0
@pulumi/pulumi  3.32.1
@types/node     14.18.18

Pulumi locates its logs in /tmp by default

Additional context

Removing the [] as shown below allows the deployment to complete.

...
    const defaultBackendService = new gcp.compute.BackendService("defaultbackendservice", {
        healthChecks: defaultHttpHealthCheck.id,
        enableCdn: true,
        cdnPolicy: {
            cacheMode: "CACHE_ALL_STATIC",
            defaultTtl: 3600,
            clientTtl: 7200,
            maxTtl: 10800,
            negativeCaching: true,
            signedUrlCacheMaxAgeSec: 7200,
        },
    });

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).

mikhailshilkov commented 1 year ago

Hi @aureq Sorry we never responded to you here.

The upstream provider says

Currently at most one health check can be specified.

The code also defines it as MaxItems:1: https://github.com/hashicorp/terraform-provider-google-beta/blob/b3ebec364de8e2daf7afc0006fa5b0a86093ff83/google-beta/services/compute/resource_compute_backend_service.go#L642-L651

Because of that, TF Bridge maps the property to a simple string, since multiple values aren't accepted anyway.

I'll go ahead and close this issue as by-design.