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

Cannot import ServiceAccount #981

Open
solomonshorser opened this issue May 8, 2024 · 1 comment
Open

Cannot import ServiceAccount #981

solomonshorser opened this issue May 8, 2024 · 1 comment
Labels
kind/bug Some behavior is incorrect or out of spec

Comments

@solomonshorser
Copy link

What happened?

I am trying to import an existing ServiceAccount for use in our stack. Since I know that for this stack, the SA will often exist before I use Pulumi to create any infrastructure, I tried to import the SA in code. Unfortunately, it returns an error:

  google-native:iam/v1:ServiceAccount (my-sa):
        error: Preview failed: property "projectsId"/"project" not found

Example

Code that caused this error:

    import * as native from "@pulumi/google-native";
...
...
...
        // in some cases, pulumi will create the SA
        if (createNewGcpServiceAccount) {
            return new native.iam.v1.ServiceAccount(name, {
                accountId: name,
                displayName: "my SA",
                project: args.project,
            }, { parent: this });
        } else {
        // but most of the time now, I expect to import an existing SA
            return new native.iam.v1.ServiceAccount(name, {
                accountId: name,
                displayName: "my SA",
                project: args.project,
            }, { parent: this, import: `projects/${project}/serviceAccounts/${serviceAccountId}` });
        }

...I did at one point try using native.iam.v1.getServiceAccountOuptut to get an existing service account, but the problem is I need the service account to be a proper Pulumi Resource - getServiceAccountOuptut returns an interface that has the values I need but I can't use that in dependsOn for other resources that depend on the service account.

Output of pulumi about

CLI
Version      3.115.1
Go Version   go1.22.2
Go Compiler  gc

Plugins
KIND      NAME           VERSION
resource  command        0.9.2
resource  gcp            7.21.0
resource  gcp            7.21.0
resource  gcp            7.15.0
resource  google-native  0.32.0
resource  google-native  0.32.0
resource  google-native  0.32.0
resource  kubernetes     4.11.0
resource  kubernetes     4.11.0
resource  kubernetes     4.9.1
resource  kubernetes     3.30.2
resource  kubernetes     3.30.2
language  nodejs         unknown

Host
OS       darwin
Version  13.6.6
Arch     x86_64

This project is written in nodejs: executable='/usr/local/bin/node' version='v20.3.0'



Dependencies:
NAME                              VERSION
@pulumi/command                   v0.9.2
@pulumi/gcp                       v7.21.0
@pulumi/google-native             v0.32.0
@typescript-eslint/parser         2.34.0
eslint                            6.8.0
@pulumi/kubernetes                v4.11.0
@types/node                       12.20.55
@typescript-eslint/eslint-plugin  2.34.0

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

@solomonshorser solomonshorser added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels May 8, 2024
@mjeffryes
Copy link
Contributor

mjeffryes commented May 14, 2024

Hi @solomonshorser. My best guess is that what's happening is that the preview is broken because the import doesn't run during preview and returns some malformed outputs rather than unknowns like it should. You could test this by running pulumi up --skip-preview to force it to skip ahead to the full update (as long as you are comfortable with running an actual update in this environment).

Like I mentioned on #983 I can't really promise we'll have time dig in here soon, so you may want to try moving to use pulumi-gcp instead if you are able to.

@mjeffryes mjeffryes removed the needs-triage Needs attention from the triage team label May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec
Projects
None yet
Development

No branches or pull requests

2 participants