pulumi / pulumi-gcp

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

Importing a gcp.serviceAccount.Key resource is missing a field in the generated state and code #922

Open aryehb opened 1 year ago

aryehb commented 1 year ago

What happened?

Importing a gcp.serviceAccount.Key resource is missing the serviceAccountId field in the generated state and code.

Steps to reproduce

Import a gcp.serviceAccount.Key resource:

pulumi import -f import.json

import.json:

{
  "resources": [
    {
      "type": "gcp:serviceAccount/key:Key",
      "name": "myKey",
      "id": "projects/PROJECT/serviceAccounts/SERVICE-ACCOUNT-NAME@PROJECT.iam.gserviceaccount.com/keys/KEY-ID"
    }
  ]
}

Expected Behavior

I expected the state to be imported properly with the serviceAccountId property. If necessary, the generated code should include the serviceAccountId property as well.

Actual Behavior

I received the following warning when importing:

    warning: One or more imported inputs failed to validate. This is almost certainly a bug in the `gcp` provider. The import will still proceed, but you will need to edit the generated code after copying it into your program.
    warning: gcp:serviceAccount/key:Key resource 'KEY-NAME' has a problem: Missing required argument: The argument "service_account_id" is required, but no definition was found.. Examine values at 'Key.ServiceAccountId'.

Generated state:

                {
                    "urn": "urn:pulumi:STACK-NAME::STACK-NAME::gcp:serviceAccount/key:Key::myKey",
                    "custom": true,
                    "id": "projects/PROJECT/serviceAccounts/SERVICE-ACCOUNT-Name@PROJECT.iam.gserviceaccount.com/keys/KEY-ID",
                    "type": "gcp:serviceAccount/key:Key",
                    "inputs": {
                        "__defaults": []
                    },
                    "outputs": {
                        "id": "projects/PROJECT/serviceAccounts/SERVICE-ACCOUNT-Name@PROJECT.iam.gserviceaccount.com/keys/KEY-ID",
                        "keyAlgorithm": "KEY_ALG_RSA_2048",
                        "name": "projects/PROJECT/serviceAccounts/SERVICE-ACCOUNT-Name@PROJECT.iam.gserviceaccount.com/keys/KEY-ID",
                        "privateKeyType": "TYPE_GOOGLE_CREDENTIALS_FILE",
                        "publicKey": "REDACTED",
                        "publicKeyType": "TYPE_X509_PEM_FILE"
                    },
                    "parent": "urn:pulumi:STACK-NAME::STACK-NAME::pulumi:pulumi:Stack::STACK-NAME",
                    "protect": true,
                    "provider": "urn:pulumi:live::pulumi-live::pulumi:providers:gcp::default_6_39_0::e6e7ca32-1d66-4bda-bddf-467802bdeb70"
                }

There is no serviceAccountId property in the state.

Generated Typescript code:

const myKey = new gcp.serviceaccount.Key("myKey", {serviceAccountId: ""}, {
    protect: true,
});

There is a serviceAccountId property, but it's empty.

Output of pulumi about

CLI
Version 3.41.1
Go Version go1.19.1
Go Compiler gc

Plugins
NAME VERSION
gcp 6.39.0
nodejs unknown

Host
OS ubuntu
Version 20.04
Arch x86_64

Dependencies:
NAME VERSION
@pulumi/gcp 6.39.0
@pulumi/pulumi 3.40.2
@types/node 18.7.23

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

lblackstone commented 1 year ago

@aryehb Could you update the issue with more information about how you tried to import the service account key?

aryehb commented 1 year ago

@lblackstone Updated.

GeoffMillerAZ commented 8 months ago

issue on same resource import problem: #1517