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

gcp.ImportSSHKeyE requires projectId #1035

Closed
shawnritchie opened this issue Nov 22, 2021 · 0 comments · Fixed by #1487
Closed

gcp.ImportSSHKeyE requires projectId #1035

shawnritchie opened this issue Nov 22, 2021 · 0 comments · Fixed by #1487
Labels
bug Something isn't working GCP p:queued

Comments

@shawnritchie
Copy link

I m getting an error while doing gcp.ImportSSHKeyE which is mentioning that the projectId is missing, after analyzing the code I made the following local modification and this worked. I m not sure if I am missing maybe some local configuration but form the examples I saw it doesn't seem so.

Problematic function: https://github.com/gruntwork-io/terratest/blob/master/modules/gcp/oslogin.go#L41

func ImportSSHKeyE(t t.TestingT, user, project, key string) error {
	ctx := context.Background()
	service, err := gcp.NewOSLoginServiceE(t)
	if err != nil {
		return err
	}

	parent := fmt.Sprintf("users/%s", user)

	sshPublicKey := &oslogin.SshPublicKey{
		Key: key,
	}

	_, err = service.Users.ImportSshPublicKey(parent, sshPublicKey).ProjectId(project).Context(ctx).Do()
	if err != nil {
		return err
	}

	return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working GCP p:queued
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants