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

Invalid creationTimestamp when creating a regional network endpoint group with the beta api #611

Closed
sudermanjr opened this issue Aug 9, 2022 · 2 comments · Fixed by #615
Assignees
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Milestone

Comments

@sudermanjr
Copy link

sudermanjr commented Aug 9, 2022

What happened?

Got the following error message:

google-native:compute/beta:RegionNetworkEndpointGroup (REDACTED):
    error: error sending request: googleapi: Error 400: Invalid value for field 'resource.creationTimestamp': ''. Must be a match of regex '(?:[0-9a-z][0-9a-z-]{0,48})'., invalid: "https://compute.googleapis.com/compute/beta/projects/REDACTED/regions/us-central1/networkEndpointGroups" map[name:REDACTED networkEndpointType:SERVERLESS project:REDACTED region:us-central1 serverlessDeployment:map[platform:apigateway.googleapis.com resource:projects/REDACTED/locations/us-central1/gateways/REDACTED]]

Steps to reproduce

	// func NewNetworkEndpointGroup(ctx *Context, name string, args *NetworkEndpointGroupArgs, opts ...ResourceOption) (*NetworkEndpointGroup, error)
	neg, err := nativecomputebeta.NewRegionNetworkEndpointGroup(ctx, "REDACTEd-"+ctx.Stack(), &nativecomputebeta.RegionNetworkEndpointGroupArgs{
		Name:   pulumi.String("someidentifier-" + ctx.Stack()),
		Region: pulumi.String("us-central1),
		ServerlessDeployment: nativecomputebeta.NetworkEndpointGroupServerlessDeploymentArgs{
			Platform: pulumi.StringPtr("apigateway.googleapis.com"),
			Resource: apiGW.ID(), // Reference to an already created api gateway
		},
		NetworkEndpointType: nativecomputebeta.RegionNetworkEndpointGroupNetworkEndpointTypeServerless,
	})
	if err != nil {
		return err
	}

Expected Behavior

The NEG gets created

Actual Behavior

The error message from above.

Versions used

CLI          
Version      3.36.0
Go Version   go1.17.11
Go Compiler  gc

Plugins
NAME           VERSION
gcp            6.26.0
go             unknown
google-native  0.22.0

Host     
OS       darwin
Version  12.5
Arch     x86_64

This project is written in go: executable='/Users/me/.asdf/shims/go' version='1.18.3 darwin/arm64'

Dependencies:
NAME                                        VERSION
github.com/go-openapi/spec                  v0.20.6
github.com/pulumi/pulumi-gcp/sdk/v6         v6.26.0
github.com/pulumi/pulumi-google-native/sdk  v0.22.0
github.com/pulumi/pulumi/sdk/v3             v3.37.1

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

@sudermanjr sudermanjr added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Aug 9, 2022
@sudermanjr sudermanjr changed the title Invalid creationTimestamp when creating a regional network endpoint group Invalid creationTimestamp when creating a regional network endpoint group with the beta api Aug 9, 2022
@sudermanjr
Copy link
Author

sudermanjr commented Aug 9, 2022

I was able to workaround this by using the classic GCP provider and importing a manually created NEG, so not a pressing issue, but I did see the creationTimestamp issue there as well.

pulumi/pulumi-gcp#804

@viveklak
Copy link
Contributor

viveklak commented Aug 10, 2022

@sudermanjr thanks for opening the issue! In your call to create the regional NEG, you want to replace the apiGW.ID() call with apiGW.DisplayName. The error message you are seeing is coming from the Google API for Regional NEG creation where it tries to resolve the gateway from the resource reference which should just be the name of the resource and not the fully qualified name. Unfortunately this is very poorly documented by Google itself and the closest hint to this I received from looking at the google cloud console for the gateway ID. We will have to find a way to improve documentation here.

That said, investigating this issue helped identify a problem with how we were storing ids for some resources like Gateway - where the URL tracking the creation operation was being misconstrued as the identifier to retrieve the resource. The change in #615 fixes this.

I am providing an example in typescript of creating a function backend, api, api config, Gateway and NEG in typescript as reference which seems to work after the fix in #615

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


const bucket = new google.storage.v1.Bucket("bucket");

const bucketObject = new google.storage.v1.BucketObject("bucketObject", {
    name: "zip",
    bucket: bucket.name,
    source: new pulumi.asset.AssetArchive({
        ".": new pulumi.asset.FileArchive("./pythonfunc"),
    }),
});

const func = new google.cloudfunctions.v1.Function("function-py", {
    sourceArchiveUrl: pulumi.interpolate`gs://${bucket.name}/${bucketObject.name}`,
    httpsTrigger: {
        securityLevel: google.cloudfunctions.v1.HttpsTriggerSecurityLevel.SecureAlways,
    },
    entryPoint: "handler",
    timeout: "60s",
    availableMemoryMb: 128,
    runtime: "python37",
    ingressSettings: "ALLOW_ALL",
});

const invoker = new google.cloudfunctions.v1.FunctionIamPolicy("function-py-iam", {
    functionId: func.name.apply(name => name.split("/")[name.split("/").length-1]),
    bindings: [
        {
            members: ["allUsers"],
            role: "roles/cloudfunctions.invoker",
        }
    ],
}, { dependsOn: func});

const api = new google.apigateway.v1beta.Api("api2", {
    apiId: "testapiid2",
    location: "global",
})
const cfg = new google.apigateway.v1beta.Config("cfg", {
    apiConfigId: "apicfg",
    apiId: "testapiid2",
    location: "global",
    openapiDocuments: [{
        document: {
            path: "openapi2-functions.yaml",
            contents: pulumi.interpolate `# openapi2-functions.yaml
swagger: '2.0'
info:
  title: ${api.displayName}
  description: Sample API on API Gateway with a Google Cloud Functions backend
  version: 1.0.0
schemes:
  - https
produces:
  - application/json
paths:
  /hello:
    get:
      summary: Greet a user
      operationId: hello
      x-google-backend:
        address: ${func.httpsTrigger.url}
      responses:
        '200':
          description: A successful response
          schema:
            type: string
            `.apply(x => Buffer.from(x).toString('base64')),
        }
    }],
});

const gw = new google.apigateway.v1beta.Gateway("gw", {
    gatewayId: "testgateway",
    apiConfig: cfg.name,
});

const neg = new google.compute.beta.RegionNetworkEndpointGroup("neg", {
    region: "us-central1",
    networkEndpointType: "SERVERLESS",
    serverlessDeployment: {
        platform: "apigateway.googleapis.com",
        resource: gw.displayName,
    }
});


export const functionUrl = func.httpsTrigger.url;
export const negId = neg.id;

@viveklak viveklak removed the needs-triage Needs attention from the triage team label Aug 10, 2022
@viveklak viveklak self-assigned this Aug 10, 2022
@viveklak viveklak added this to the 0.76 milestone Aug 10, 2022
@pulumi-bot pulumi-bot added the resolution/fixed This issue was fixed label Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/fixed This issue was fixed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants