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

eager-wall-56838

02/26/2024, 5:03 PM
Can anyone give a working example of using cleanupPolicy with ArtifactRegistry on the native sdk? It's currently a map of strings to strings and the schema for the string is not specified anywhere. I get that the feature is experimental and using a string avoids breaking changes in the typescript sense but at least some examples or a schema for the string should be provided in these cases. It was introduced in https://github.com/pulumi/pulumi-google-native/pull/935. cc @happy-parrot-60128 @tall-librarian-49374
For example, I've tried:
Copy code
export const dockerRegistry = new gcloud.artifactregistry.v1.Repository(
  "registry",
  {
    project: config.projectId,
    location: "us",
    format: gcloud.artifactregistry.v1.RepositoryFormat.Docker,
    repositoryId: dockerRegistryId,
    // See <https://cloud.google.com/artifact-registry/docs/repositories/cleanup-policy#json>
    cleanupPolicies: {
      "delete-pull-request-images": JSON.stringify(
        {
          id: "delete-pull-request-images",
          action: "DELETE",
          condition: {
            older_than: "432000s",
            tag_prefixes: ["pr-"]
          },
        }
      ),
    },
    cleanupPolicyDryRun: true,
  },
  {
    ignoreChanges: ["createTime", "updateTime"],
  },
)
But you get a generic 400 error and can't tell what went wrong.