pulumi / pulumi-google-native

Apache License 2.0
70 stars 18 forks source link

google-native:recaptchaenterprise/v1:Key creation fails #928

Open bindermuehle opened 1 year ago

bindermuehle commented 1 year ago

What happened?

creating a recaptcha enterprise key failed with following message:

google-native:recaptchaenterprise/v1:Key (primary):
    error: object retrieval failure after successful create / read state: googleapi: Error 400: Invalid Key resource name 'projects/<PROJECT_NAME>/keys/primary-7fd671d'. Should be projects/{project ID or number}/keys/{site key id, 40 character long}

Expected Behavior

the key gets created and registered

Steps to reproduce

import * as pulumi from "@pulumi/pulumi";
import * as google_native from "@pulumi/google-native";

const config = new pulumi.Config();
const projectName = "YOUR_PROJECT_ID";
const keyName = "YOUR_DISPLAY_NAME";

// Create a google-native.recaptchaenterprise/v1.Key resource
const recaptchaKey = new google_native.recaptchaenterprise.v1.Key(keyName, {
    project: projectName,
    displayName: keyName,
    webSettings: {
        allowAllDomains: true,
        integrationType: "CHECKBOX", 
    },
});

// Export the name of the key
export const recaptchaKeyName = recaptchaKey.name;

Output of pulumi about

CLI Version 3.81.0 Go Version go1.21.1 Go Compiler gc

Plugins NAME VERSION gcp 6.65.0 google-native 0.31.1 nodejs unknown random 4.13.2

Host OS darwin Version 13.1 Arch arm64

This project is written in nodejs: executable='/Users/user/.nvm/versions/node/v18.16.1/bin/node' version='v18.16.1'

Dependencies: NAME VERSION @pulumi/gcp 6.65.0 @pulumi/google-native 0.31.1 @pulumi/pulumi 3.81.0 @pulumi/random 4.13.2 @types/node 16.18.38

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

mikhailshilkov commented 1 year ago

Thank you for reporting this @bindermuehle! It looks like auto-naming doesn't produce the valid format here.

As a workaround, could you try specifying the name explicitly?

const recaptchaKey = new google_native.recaptchaenterprise.v1.Key(keyName, {
    project: projectName,
    displayName: keyName,
    name: "specify the full key id in the required format",
    webSettings: {
        allowAllDomains: true,
        integrationType: "CHECKBOX", 
    },
});
bindermuehle commented 1 year ago

the format of the name is as following. "projects/{project}/keys/{key}". I'm not sure how to generate the key. reading through the API it seems the key has to be created using the API

https://pkg.go.dev/cloud.google.com/go/recaptchaenterprise/v2/apiv1/recaptchaenterprisepb#Key

lukehoban commented 9 months ago

Note that this resources is now supported in Google Classic as well. In general, it is likely best to use that in the near term.

https://www.pulumi.com/registry/packages/gcp/api-docs/recaptcha/enterprisekey/