This message was deleted.
s
This message was deleted.
b
do you have an existing key you want to use, or generate a new key?
h
I want to generate a new one
Copy code
const sshKey = new tls.PrivateKey("bastion", {
  algorithm: "RSA",
})

const sshKey = new SshPublicKey('test', {
    expirationTimeUsec: '250000',
    key: sshKey.publicKeyOpenssh,
    project: 'example',
    user: '<mailto:----@univision.net|----@univision.net>',
});
1
h
Thanks I am going to try
I got same error
b
this worked for me
Copy code
// Create a GCP resource (Storage Bucket)
const sshKey = new tls.PrivateKey("example",{
    algorithm: "RSA",
})

const gcloudKey = new gcp.oslogin.SshPublicKey("example",{
    key: sshKey.publicKeyOpenssh,
    user: "<mailto:lbriggs@pulumi.com|lbriggs@pulumi.com>",
})
h
now, It works, do you know how to see the key created to connect after the vm creation?
b
add this to your code
Copy code
export const privateKey = sshKey.privateKeyOpenssh
Then run
pulumi up
Then run
pulumi stack outputs --show-secrets
h
Thanks for your help
Sorry for asking so much, do you know how to associate the public key to a compute instance, I am trying to pass on the metadata but it doesn't works
Copy code
metadata: {
    'enable-oslogin': "true",
    'ssh-keys': '<mailto:----@univision.net|----@univision.net>' +":"+ sshKey.key
},
Got the following error: Calling [toString] on an [Output<T>] is not supported.
b
you will need to use an
apply
h
I tried
Copy code
metadata: {
    'enable-oslogin': "true",
    'ssh-keys': '<mailto:----@univision.net|----@univision.net>' +":"+ sshKey.key.apply(v => v.toString())
},
b
try
Copy code
'ssh-keys': pulumi.interpolate`--- +":" ssh.key
h
now it works! thanks