Hey guys ... using the Go framework for Pulumi and...
# golang
d
Hey guys ... using the Go framework for Pulumi and so far enjoying it very much. I've run into an issue though trying to create a logMetric in GCP. The error is
unrecognized resource type (Check): gcp:logging/metric:Metric
. From what I can tell this is an error coming back from a grpc call against what I assume is the pulumi server. Any ideas? I haven't tried other languages and won't; will just go back to terraform 😞.
g
Can you share your code?
d
Copy code
args := pLogging.MetricArgs{
		BucketOptions: map[string]interface{}{
			"exponentialBuckets": map[string]interface{}{
				"numFiniteBuckets": 64,
				"growthFactor":     2,
				"scale":            0.01,
			},
		},
		Description:     logMetric.description,
		Filter:          "resource.type=\"container\"\nresource.labels.cluster_name=\"redacted\"\nresource.labels.project_id=\"private\"\nresource.labels.zone:\"eyes-only\"\nresource.labels.container_name=\"nothing-to-see-here\"\nresource.labels.namespace_id=\"namespace\"\n\"Leaving \"\n",
		LabelExtractors: nil,
		MetricDescriptor: map[string]interface{}{
			"metric_kind": "DELTA",
			"value_type":  "DISTRIBUTION",
			"unit":        "1",
		},
		Name:           logMetric.name,
		Project:        logMetric.project,
		ValueExtractor: "",
	}

metricConfig, err := pLogging.NewMetric(ctx, logMetric.displayName, &args)
if err != nil {
		return err
	}
	ctx.Export(logMetric.displayName, metricConfig.Name())
g
Hmm, I don't get that error. I do get an error but it is actually talking to the Google API.
I get
error: Plan apply failed: Error creating Metric: googleapi: Error 400: A value extractor is required for a DISTRIBUTION value type or a GAUGE metric kind.
pLogging in your code is `pLogging "``github.com/pulumi/pulumi-gcp/sdk/go/gcp/logging``"` ?
d
Thanks @gentle-diamond-70147, yes.
g
Which version of pulumi-gcp are you using?
d
v1.4.1
I traced it to a similar point where it seems to be doing a grpc call to AWS, was guessing it's the pulumi backend.
I have this wrapped in a function within the pulumi.Run(), which has a bunch of other stuff within the stack. I haven't tried pulling this out to a separate stack.
g
Yea, the pulumi client persists the state to the Pulumi Console which runs on AWS.
That might be good to try - pull out that one particular resource to a separate app to see what you get.
My program was using 1.5.0 of pulumi-gcp, you could try that version too.
d
Same error when updating go.mod to use v1.5.0
Other resource types within the same context work
g
@broad-dog-22463 any ideas on this one?
d
Let me pull it into a separate stack. Certainly could be user error
Same error in new project