https://pulumi.com logo
#google-cloud
Title
# google-cloud
b

breezy-agency-13977

12/08/2023, 2:23 PM
I am new to Pulumi and got my fist stack deployed to Google Cloud Run 2 days ago. All the sudden I am getting an error that
Label key 'pulumiLabels.%' violates format constraints
. Does anyone know what would be causing this? I don't have any labels setup on my service configuration.
Copy code
package main

import (
	"<http://github.com/pulumi/pulumi-docker/sdk/v3/go/docker|github.com/pulumi/pulumi-docker/sdk/v3/go/docker>"
	"<http://github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/cloudrun|github.com/pulumi/pulumi-gcp/sdk/v6/go/gcp/cloudrun>"
	"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
	"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi/config|github.com/pulumi/pulumi/sdk/v3/go/pulumi/config>"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		projectID := "projectId"
		region := "region"
		appName := "appname"
		garPublishAddress := pulumi.Sprintf("%s-docker.pkg.dev/%s/%s/api", region, projectID, appName)

		// Build and publish the Docker image for the Go application
		appImage, err := docker.NewImage(ctx, appName, &docker.ImageArgs{
			Registry:  docker.ImageRegistryArgs{},
			ImageName: garPublishAddress,
			Build: &docker.DockerBuildArgs{
				Context:    pulumi.String("./"),
				Dockerfile: pulumi.String("./Dockerfile"),
			}})
		if err != nil {
			return err
		}

		// Deploy the Docker image to Cloud Run
		_, err = cloudrun.NewService(ctx, appName, &cloudrun.ServiceArgs{
			AutogenerateRevisionName: pulumi.Bool(true),
			Location:                 pulumi.String(region),
			Name:                     pulumi.String(appName),
			Project:                  pulumi.String(projectID),
			Template: &cloudrun.ServiceTemplateArgs{
				Spec: &cloudrun.ServiceTemplateSpecArgs{
					Containers: cloudrun.ServiceTemplateSpecContainerArray{
						&cloudrun.ServiceTemplateSpecContainerArgs{
							Image: appImage.ImageName,
							Ports: cloudrun.ServiceTemplateSpecContainerPortArray{
								&cloudrun.ServiceTemplateSpecContainerPortArgs{
									Name:          pulumi.String("http1"),
									ContainerPort: <http://pulumi.Int|pulumi.Int>(8080),
								},
							},
							Resources: &cloudrun.ServiceTemplateSpecContainerResourcesArgs{
								Limits: pulumi.StringMap(map[string]pulumi.StringInput{
									"cpu":    pulumi.String("1"),
									"memory": pulumi.String("512Mi"),
								}),
							},
						},
					},
				},
				Metadata: &cloudrun.ServiceTemplateMetadataArgs{
					Annotations: pulumi.StringMap(map[string]pulumi.StringInput{
						"<http://run.googleapis.com/cloudsql-instances|run.googleapis.com/cloudsql-instances>": pulumi.String("cloudsql-instance"),
					}),
				},
			},
			Traffics: cloudrun.ServiceTrafficArray{
				&cloudrun.ServiceTrafficArgs{
					Percent:        <http://pulumi.Int|pulumi.Int>(100),
					LatestRevision: pulumi.Bool(true),
				},
			},
		})

		if err != nil {
			return err
		}

		// Export the URL of the Cloud Run service
		ctx.Export("url", service.Statuses.Index(<http://pulumi.Int|pulumi.Int>(0)).Url())
		return nil
	})
}
Logs I. can see in google cloud. How can I set a pulumiLabel so it isn't 0?
Copy code
Label key 'pulumiLabels.%' violates format constraints. The key must start with a lowercase character, can only contain lowercase letters, numeric characters, underscores and dashes. The key can be at most 63 characters long. International characters are allowed.
Copy code
labels: {
pulumiLabels.%: "0"
<http://cloud.googleapis.com/location|cloud.googleapis.com/location>: "us-central1"
}
s

stocky-table-84961

12/13/2023, 10:01 AM
I keep getting the following error message when trying to deploy a container with github actions: denied: Permission "artifactregistry.repositories.uploadArtifacts" denied on resource "projects/-/locations/europe-west4/repositories/-" (or it may not exist). I have added the following roles with getIAMPolicy({}): roles/iam.serviceAccountAdmin, roles/iam.workloadIdentityUser, roles/iam.serviceAccountTokerCreator, roles/editor. To the service account Last thing I have: gcloud auth configure-docker $ARTIFACTORY_HOST In the github.workflow which seems to be working.
3 Views