o
g
Do you have a link to this example? It looks like that may have been auto-generated from a TF example
o
sure
hold please….
w
o
oh interesting
w
The variable being the same name will be fixed once https://github.com/pulumi/tf2pulumi/pull/60 is rolled out to all the providers (next day or two).
w
You should be able to just rename one of them for now.
o
yeah ok - makes sense
just so I understand, this call isn’t using the node sdk?
just the native Pulumi stuff which brought it in from TF?
w
Yes - this is just a native Pulumi SDK thing - documented at the link above.
o
roger
will that regenerate the docs?
example still doesn’t work
type mismatch
g
@white-balloon-205 It looks like the
getAccountKeyArgs
are expecting a
string
rather than an
Input<string>
for the name. Seems like that example wouldn't work without updating that type as well
o
I think this will work?
const sysdigAccountDef = iam.createServiceAccount( config.project, config.containerSecurityScanner ); const sysdigAccountKey = new gcp.serviceAccount.Key(“sysdigkey”, { serviceAccountId: sysdigAccountDef.name }); const sysdigGetAccountKey = pulumi.output( gcp.serviceAccount.getAccountKey({ name:
Copy code
projects/${projectNumber}/serviceAccounts/${
        sysdigAccountDef.accountId
      }/keys/${sysdigAccountKey.id}
, publicKeyType: “TYPE_X509_PEM_FILE” }) );
not sure about that last attribute of the key name/path
example says it wants the id of the key but the id I show above is a Pulumi ID
w
This works for me:
Copy code
import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

const myaccount = new gcp.serviceAccount.Account("myaccount", {
    accountId: "dev-foo-account",
});
const mykeyKey = new gcp.serviceAccount.Key("mykey", {
    serviceAccountId: myaccount.name,
});
const mykeyAccountKey = mykeyKey.name.apply(keyname => gcp.serviceAccount.getAccountKey({
    name: keyname,
    publicKeyType: "TYPE_X509_PEM_FILE",
}));

export const publicKey = mykeyAccountKey.apply(hmm => hmm.publicKey);
👍 1
o
You do it that way so you aren’t dealing with output strings?
the apply is taking the object and “converts” to string?
ok interesting
what’s the accepted programming model for doing an export like the above inside a conditional
i.e. if (some criteria) do the above
sorry this is Typescripty stuff, not Pulumi
w
Copy code
export let foo;
if (something) {
  foo = mykeyAccountKey.apply(hmm => hmm.publicKey);
}
Or set another default value in the initializer if that makes sense.
o
ah ok
sure I’ll give it a go
basically trying to figure out a way to export the JSON creds file for service accounts