1. Packages
  2. Packages
  3. Artifactory Provider
  4. API Docs
  5. PackageCleanupPolicy
Viewing docs for artifactory v8.10.4
published on Friday, Apr 10, 2026 by Pulumi
artifactory logo
Viewing docs for artifactory v8.10.4
published on Friday, Apr 10, 2026 by Pulumi

    Provides an Artifactory Package Cleanup Policy resource. This resource enable system administrators to define and customize policies based on specific criteria for removing unused binaries from across their JFrog platform. Package cleanup policies are supported on the Cloud (7.98.2) and Self-Hosted (7.98.7) platforms, with an Enterprise+ license. See Cleanup Policies for more details.

    Example Usage

    Time-based Cleanup Policy (Days)

    import * as pulumi from "@pulumi/pulumi";
    import * as artifactory from "@pulumi/artifactory";
    
    const my_cleanup_policy = new artifactory.PackageCleanupPolicy("my-cleanup-policy", {
        key: "my-cleanup-policy",
        description: "My cleanup policy",
        cronExpression: "0 0 2 ? * MON-SAT *",
        durationInMinutes: 60,
        enabled: true,
        skipTrashcan: false,
        searchCriteria: {
            packageTypes: [
                "docker",
                "gradle",
                "maven",
            ],
            repos: ["**"],
            includeAllProjects: true,
            includedProjects: [],
            includedPackages: ["**"],
            excludedPackages: ["com/jfrog/latest"],
            createdBeforeInDays: 30,
            lastDownloadedBeforeInDays: 60,
        },
    });
    
    import pulumi
    import pulumi_artifactory as artifactory
    
    my_cleanup_policy = artifactory.PackageCleanupPolicy("my-cleanup-policy",
        key="my-cleanup-policy",
        description="My cleanup policy",
        cron_expression="0 0 2 ? * MON-SAT *",
        duration_in_minutes=60,
        enabled=True,
        skip_trashcan=False,
        search_criteria={
            "package_types": [
                "docker",
                "gradle",
                "maven",
            ],
            "repos": ["**"],
            "include_all_projects": True,
            "included_projects": [],
            "included_packages": ["**"],
            "excluded_packages": ["com/jfrog/latest"],
            "created_before_in_days": 30,
            "last_downloaded_before_in_days": 60,
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-artifactory/sdk/v8/go/artifactory"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := artifactory.NewPackageCleanupPolicy(ctx, "my-cleanup-policy", &artifactory.PackageCleanupPolicyArgs{
    			Key:               pulumi.String("my-cleanup-policy"),
    			Description:       pulumi.String("My cleanup policy"),
    			CronExpression:    pulumi.String("0 0 2 ? * MON-SAT *"),
    			DurationInMinutes: pulumi.Int(60),
    			Enabled:           pulumi.Bool(true),
    			SkipTrashcan:      pulumi.Bool(false),
    			SearchCriteria: &artifactory.PackageCleanupPolicySearchCriteriaArgs{
    				PackageTypes: pulumi.StringArray{
    					pulumi.String("docker"),
    					pulumi.String("gradle"),
    					pulumi.String("maven"),
    				},
    				Repos: pulumi.StringArray{
    					pulumi.String("**"),
    				},
    				IncludeAllProjects: pulumi.Bool(true),
    				IncludedProjects:   pulumi.StringArray{},
    				IncludedPackages: pulumi.StringArray{
    					pulumi.String("**"),
    				},
    				ExcludedPackages: pulumi.StringArray{
    					pulumi.String("com/jfrog/latest"),
    				},
    				CreatedBeforeInDays:        pulumi.Int(30),
    				LastDownloadedBeforeInDays: pulumi.Int(60),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Artifactory = Pulumi.Artifactory;
    
    return await Deployment.RunAsync(() => 
    {
        var my_cleanup_policy = new Artifactory.Index.PackageCleanupPolicy("my-cleanup-policy", new()
        {
            Key = "my-cleanup-policy",
            Description = "My cleanup policy",
            CronExpression = "0 0 2 ? * MON-SAT *",
            DurationInMinutes = 60,
            Enabled = true,
            SkipTrashcan = false,
            SearchCriteria = new Artifactory.Inputs.PackageCleanupPolicySearchCriteriaArgs
            {
                PackageTypes = new[]
                {
                    "docker",
                    "gradle",
                    "maven",
                },
                Repos = new[]
                {
                    "**",
                },
                IncludeAllProjects = true,
                IncludedProjects = new() { },
                IncludedPackages = new[]
                {
                    "**",
                },
                ExcludedPackages = new[]
                {
                    "com/jfrog/latest",
                },
                CreatedBeforeInDays = 30,
                LastDownloadedBeforeInDays = 60,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.artifactory.PackageCleanupPolicy;
    import com.pulumi.artifactory.PackageCleanupPolicyArgs;
    import com.pulumi.artifactory.inputs.PackageCleanupPolicySearchCriteriaArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var my_cleanup_policy = new PackageCleanupPolicy("my-cleanup-policy", PackageCleanupPolicyArgs.builder()
                .key("my-cleanup-policy")
                .description("My cleanup policy")
                .cronExpression("0 0 2 ? * MON-SAT *")
                .durationInMinutes(60)
                .enabled(true)
                .skipTrashcan(false)
                .searchCriteria(PackageCleanupPolicySearchCriteriaArgs.builder()
                    .packageTypes(                
                        "docker",
                        "gradle",
                        "maven")
                    .repos("**")
                    .includeAllProjects(true)
                    .includedProjects()
                    .includedPackages("**")
                    .excludedPackages("com/jfrog/latest")
                    .createdBeforeInDays(30)
                    .lastDownloadedBeforeInDays(60)
                    .build())
                .build());
    
        }
    }
    
    resources:
      my-cleanup-policy:
        type: artifactory:PackageCleanupPolicy
        properties:
          key: my-cleanup-policy
          description: My cleanup policy
          cronExpression: 0 0 2 ? * MON-SAT *
          durationInMinutes: 60
          enabled: true
          skipTrashcan: false
          searchCriteria:
            packageTypes:
              - docker
              - gradle
              - maven
            repos:
              - '**'
            includeAllProjects: true
            includedProjects: []
            includedPackages:
              - '**'
            excludedPackages:
              - com/jfrog/latest
            createdBeforeInDays: 30
            lastDownloadedBeforeInDays: 60
    

    Version-based Cleanup Policy

    import * as pulumi from "@pulumi/pulumi";
    import * as artifactory from "@pulumi/artifactory";
    
    const my_version_policy = new artifactory.PackageCleanupPolicy("my-version-policy", {
        key: "my-version-policy",
        description: "Keep only latest versions",
        cronExpression: "0 0 2 ? * MON-SAT *",
        durationInMinutes: 60,
        enabled: true,
        skipTrashcan: false,
        searchCriteria: {
            packageTypes: ["maven"],
            repos: ["**"],
            includeAllProjects: true,
            includedProjects: [],
            includedPackages: ["**"],
            excludedPackages: ["com/jfrog/latest"],
            keepLastNVersions: 5,
        },
    });
    
    import pulumi
    import pulumi_artifactory as artifactory
    
    my_version_policy = artifactory.PackageCleanupPolicy("my-version-policy",
        key="my-version-policy",
        description="Keep only latest versions",
        cron_expression="0 0 2 ? * MON-SAT *",
        duration_in_minutes=60,
        enabled=True,
        skip_trashcan=False,
        search_criteria={
            "package_types": ["maven"],
            "repos": ["**"],
            "include_all_projects": True,
            "included_projects": [],
            "included_packages": ["**"],
            "excluded_packages": ["com/jfrog/latest"],
            "keep_last_n_versions": 5,
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-artifactory/sdk/v8/go/artifactory"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := artifactory.NewPackageCleanupPolicy(ctx, "my-version-policy", &artifactory.PackageCleanupPolicyArgs{
    			Key:               pulumi.String("my-version-policy"),
    			Description:       pulumi.String("Keep only latest versions"),
    			CronExpression:    pulumi.String("0 0 2 ? * MON-SAT *"),
    			DurationInMinutes: pulumi.Int(60),
    			Enabled:           pulumi.Bool(true),
    			SkipTrashcan:      pulumi.Bool(false),
    			SearchCriteria: &artifactory.PackageCleanupPolicySearchCriteriaArgs{
    				PackageTypes: pulumi.StringArray{
    					pulumi.String("maven"),
    				},
    				Repos: pulumi.StringArray{
    					pulumi.String("**"),
    				},
    				IncludeAllProjects: pulumi.Bool(true),
    				IncludedProjects:   pulumi.StringArray{},
    				IncludedPackages: pulumi.StringArray{
    					pulumi.String("**"),
    				},
    				ExcludedPackages: pulumi.StringArray{
    					pulumi.String("com/jfrog/latest"),
    				},
    				KeepLastNVersions: pulumi.Int(5),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Artifactory = Pulumi.Artifactory;
    
    return await Deployment.RunAsync(() => 
    {
        var my_version_policy = new Artifactory.Index.PackageCleanupPolicy("my-version-policy", new()
        {
            Key = "my-version-policy",
            Description = "Keep only latest versions",
            CronExpression = "0 0 2 ? * MON-SAT *",
            DurationInMinutes = 60,
            Enabled = true,
            SkipTrashcan = false,
            SearchCriteria = new Artifactory.Inputs.PackageCleanupPolicySearchCriteriaArgs
            {
                PackageTypes = new[]
                {
                    "maven",
                },
                Repos = new[]
                {
                    "**",
                },
                IncludeAllProjects = true,
                IncludedProjects = new() { },
                IncludedPackages = new[]
                {
                    "**",
                },
                ExcludedPackages = new[]
                {
                    "com/jfrog/latest",
                },
                KeepLastNVersions = 5,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.artifactory.PackageCleanupPolicy;
    import com.pulumi.artifactory.PackageCleanupPolicyArgs;
    import com.pulumi.artifactory.inputs.PackageCleanupPolicySearchCriteriaArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var my_version_policy = new PackageCleanupPolicy("my-version-policy", PackageCleanupPolicyArgs.builder()
                .key("my-version-policy")
                .description("Keep only latest versions")
                .cronExpression("0 0 2 ? * MON-SAT *")
                .durationInMinutes(60)
                .enabled(true)
                .skipTrashcan(false)
                .searchCriteria(PackageCleanupPolicySearchCriteriaArgs.builder()
                    .packageTypes("maven")
                    .repos("**")
                    .includeAllProjects(true)
                    .includedProjects()
                    .includedPackages("**")
                    .excludedPackages("com/jfrog/latest")
                    .keepLastNVersions(5)
                    .build())
                .build());
    
        }
    }
    
    resources:
      my-version-policy:
        type: artifactory:PackageCleanupPolicy
        properties:
          key: my-version-policy
          description: Keep only latest versions
          cronExpression: 0 0 2 ? * MON-SAT *
          durationInMinutes: 60
          enabled: true
          skipTrashcan: false
          searchCriteria:
            packageTypes:
              - maven
            repos:
              - '**'
            includeAllProjects: true
            includedProjects: []
            includedPackages:
              - '**'
            excludedPackages:
              - com/jfrog/latest
            keepLastNVersions: 5
    

    Properties-based Cleanup Policy

    import * as pulumi from "@pulumi/pulumi";
    import * as artifactory from "@pulumi/artifactory";
    
    const my_properties_policy = new artifactory.PackageCleanupPolicy("my-properties-policy", {
        key: "my-properties-policy",
        description: "Cleanup based on properties",
        cronExpression: "0 0 2 ? * MON-SAT *",
        durationInMinutes: 60,
        enabled: true,
        skipTrashcan: false,
        searchCriteria: {
            packageTypes: ["docker"],
            repos: ["**"],
            includeAllProjects: true,
            includedProjects: [],
            includedPackages: ["**"],
            excludedPackages: ["com/jfrog/latest"],
            includedProperties: {
                "build.name": ["my-app"],
            },
        },
    });
    
    import pulumi
    import pulumi_artifactory as artifactory
    
    my_properties_policy = artifactory.PackageCleanupPolicy("my-properties-policy",
        key="my-properties-policy",
        description="Cleanup based on properties",
        cron_expression="0 0 2 ? * MON-SAT *",
        duration_in_minutes=60,
        enabled=True,
        skip_trashcan=False,
        search_criteria={
            "package_types": ["docker"],
            "repos": ["**"],
            "include_all_projects": True,
            "included_projects": [],
            "included_packages": ["**"],
            "excluded_packages": ["com/jfrog/latest"],
            "included_properties": {
                "build.name": ["my-app"],
            },
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-artifactory/sdk/v8/go/artifactory"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := artifactory.NewPackageCleanupPolicy(ctx, "my-properties-policy", &artifactory.PackageCleanupPolicyArgs{
    			Key:               pulumi.String("my-properties-policy"),
    			Description:       pulumi.String("Cleanup based on properties"),
    			CronExpression:    pulumi.String("0 0 2 ? * MON-SAT *"),
    			DurationInMinutes: pulumi.Int(60),
    			Enabled:           pulumi.Bool(true),
    			SkipTrashcan:      pulumi.Bool(false),
    			SearchCriteria: &artifactory.PackageCleanupPolicySearchCriteriaArgs{
    				PackageTypes: pulumi.StringArray{
    					pulumi.String("docker"),
    				},
    				Repos: pulumi.StringArray{
    					pulumi.String("**"),
    				},
    				IncludeAllProjects: pulumi.Bool(true),
    				IncludedProjects:   pulumi.StringArray{},
    				IncludedPackages: pulumi.StringArray{
    					pulumi.String("**"),
    				},
    				ExcludedPackages: pulumi.StringArray{
    					pulumi.String("com/jfrog/latest"),
    				},
    				IncludedProperties: pulumi.StringArrayMap{
    					"build.name": pulumi.StringArray{
    						pulumi.String("my-app"),
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Artifactory = Pulumi.Artifactory;
    
    return await Deployment.RunAsync(() => 
    {
        var my_properties_policy = new Artifactory.Index.PackageCleanupPolicy("my-properties-policy", new()
        {
            Key = "my-properties-policy",
            Description = "Cleanup based on properties",
            CronExpression = "0 0 2 ? * MON-SAT *",
            DurationInMinutes = 60,
            Enabled = true,
            SkipTrashcan = false,
            SearchCriteria = new Artifactory.Inputs.PackageCleanupPolicySearchCriteriaArgs
            {
                PackageTypes = new[]
                {
                    "docker",
                },
                Repos = new[]
                {
                    "**",
                },
                IncludeAllProjects = true,
                IncludedProjects = new() { },
                IncludedPackages = new[]
                {
                    "**",
                },
                ExcludedPackages = new[]
                {
                    "com/jfrog/latest",
                },
                IncludedProperties = 
                {
                    { "build.name", new[]
                    {
                        "my-app",
                    } },
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.artifactory.PackageCleanupPolicy;
    import com.pulumi.artifactory.PackageCleanupPolicyArgs;
    import com.pulumi.artifactory.inputs.PackageCleanupPolicySearchCriteriaArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            var my_properties_policy = new PackageCleanupPolicy("my-properties-policy", PackageCleanupPolicyArgs.builder()
                .key("my-properties-policy")
                .description("Cleanup based on properties")
                .cronExpression("0 0 2 ? * MON-SAT *")
                .durationInMinutes(60)
                .enabled(true)
                .skipTrashcan(false)
                .searchCriteria(PackageCleanupPolicySearchCriteriaArgs.builder()
                    .packageTypes("docker")
                    .repos("**")
                    .includeAllProjects(true)
                    .includedProjects()
                    .includedPackages("**")
                    .excludedPackages("com/jfrog/latest")
                    .includedProperties(Map.of("build.name", "my-app"))
                    .build())
                .build());
    
        }
    }
    
    resources:
      my-properties-policy:
        type: artifactory:PackageCleanupPolicy
        properties:
          key: my-properties-policy
          description: Cleanup based on properties
          cronExpression: 0 0 2 ? * MON-SAT *
          durationInMinutes: 60
          enabled: true
          skipTrashcan: false
          searchCriteria:
            packageTypes:
              - docker
            repos:
              - '**'
            includeAllProjects: true
            includedProjects: []
            includedPackages:
              - '**'
            excludedPackages:
              - com/jfrog/latest
            includedProperties:
              build.name:
                - my-app
    

    Using Variables for Condition Fields

    You can use Terraform variables for condition fields (createdBeforeInDays, lastDownloadedBeforeInDays, createdBeforeInMonths, lastDownloadedBeforeInMonths, keepLastNVersions, includedProperties) and durationInMinutes. The validator will skip validation when values are unknown (variables), allowing terraform validate to pass without requiring variable values.

    Example with variables:

    import * as pulumi from "@pulumi/pulumi";
    import * as artifactory from "@pulumi/artifactory";
    
    const config = new pulumi.Config();
    const cleanupPolicyLastDownloadedBeforeInDays = config.getNumber("cleanupPolicyLastDownloadedBeforeInDays") || 60;
    const cleanupPolicyDurationInMinutes = config.getNumber("cleanupPolicyDurationInMinutes") || 120;
    const my_cleanup_policy = new artifactory.PackageCleanupPolicy("my-cleanup-policy", {
        key: "my-cleanup-policy",
        description: "My cleanup policy with variables",
        cronExpression: "0 0 2 ? * MON-SAT *",
        durationInMinutes: cleanupPolicyDurationInMinutes,
        enabled: true,
        skipTrashcan: false,
        searchCriteria: {
            packageTypes: [
                "docker",
                "generic",
                "helm",
                "helmoci",
                "nuget",
                "terraform",
            ],
            repos: ["**"],
            includeAllProjects: false,
            includedProjects: ["default"],
            includedPackages: ["**"],
            excludedPackages: ["com/jfrog/latest"],
            lastDownloadedBeforeInDays: cleanupPolicyLastDownloadedBeforeInDays,
        },
    });
    
    import pulumi
    import pulumi_artifactory as artifactory
    
    config = pulumi.Config()
    cleanup_policy_last_downloaded_before_in_days = config.get_float("cleanupPolicyLastDownloadedBeforeInDays")
    if cleanup_policy_last_downloaded_before_in_days is None:
        cleanup_policy_last_downloaded_before_in_days = 60
    cleanup_policy_duration_in_minutes = config.get_float("cleanupPolicyDurationInMinutes")
    if cleanup_policy_duration_in_minutes is None:
        cleanup_policy_duration_in_minutes = 120
    my_cleanup_policy = artifactory.PackageCleanupPolicy("my-cleanup-policy",
        key="my-cleanup-policy",
        description="My cleanup policy with variables",
        cron_expression="0 0 2 ? * MON-SAT *",
        duration_in_minutes=cleanup_policy_duration_in_minutes,
        enabled=True,
        skip_trashcan=False,
        search_criteria={
            "package_types": [
                "docker",
                "generic",
                "helm",
                "helmoci",
                "nuget",
                "terraform",
            ],
            "repos": ["**"],
            "include_all_projects": False,
            "included_projects": ["default"],
            "included_packages": ["**"],
            "excluded_packages": ["com/jfrog/latest"],
            "last_downloaded_before_in_days": cleanup_policy_last_downloaded_before_in_days,
        })
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-artifactory/sdk/v8/go/artifactory"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		cfg := config.New(ctx, "")
    		cleanupPolicyLastDownloadedBeforeInDays := float64(60)
    		if param := cfg.GetFloat64("cleanupPolicyLastDownloadedBeforeInDays"); param != 0 {
    			cleanupPolicyLastDownloadedBeforeInDays = param
    		}
    		cleanupPolicyDurationInMinutes := float64(120)
    		if param := cfg.GetFloat64("cleanupPolicyDurationInMinutes"); param != 0 {
    			cleanupPolicyDurationInMinutes = param
    		}
    		_, err := artifactory.NewPackageCleanupPolicy(ctx, "my-cleanup-policy", &artifactory.PackageCleanupPolicyArgs{
    			Key:               pulumi.String("my-cleanup-policy"),
    			Description:       pulumi.String("My cleanup policy with variables"),
    			CronExpression:    pulumi.String("0 0 2 ? * MON-SAT *"),
    			DurationInMinutes: pulumi.Float64(cleanupPolicyDurationInMinutes),
    			Enabled:           pulumi.Bool(true),
    			SkipTrashcan:      pulumi.Bool(false),
    			SearchCriteria: &artifactory.PackageCleanupPolicySearchCriteriaArgs{
    				PackageTypes: pulumi.StringArray{
    					pulumi.String("docker"),
    					pulumi.String("generic"),
    					pulumi.String("helm"),
    					pulumi.String("helmoci"),
    					pulumi.String("nuget"),
    					pulumi.String("terraform"),
    				},
    				Repos: pulumi.StringArray{
    					pulumi.String("**"),
    				},
    				IncludeAllProjects: pulumi.Bool(false),
    				IncludedProjects: pulumi.StringArray{
    					pulumi.String("default"),
    				},
    				IncludedPackages: pulumi.StringArray{
    					pulumi.String("**"),
    				},
    				ExcludedPackages: pulumi.StringArray{
    					pulumi.String("com/jfrog/latest"),
    				},
    				LastDownloadedBeforeInDays: pulumi.Float64(cleanupPolicyLastDownloadedBeforeInDays),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Artifactory = Pulumi.Artifactory;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var cleanupPolicyLastDownloadedBeforeInDays = config.GetDouble("cleanupPolicyLastDownloadedBeforeInDays") ?? 60;
        var cleanupPolicyDurationInMinutes = config.GetDouble("cleanupPolicyDurationInMinutes") ?? 120;
        var my_cleanup_policy = new Artifactory.Index.PackageCleanupPolicy("my-cleanup-policy", new()
        {
            Key = "my-cleanup-policy",
            Description = "My cleanup policy with variables",
            CronExpression = "0 0 2 ? * MON-SAT *",
            DurationInMinutes = cleanupPolicyDurationInMinutes,
            Enabled = true,
            SkipTrashcan = false,
            SearchCriteria = new Artifactory.Inputs.PackageCleanupPolicySearchCriteriaArgs
            {
                PackageTypes = new[]
                {
                    "docker",
                    "generic",
                    "helm",
                    "helmoci",
                    "nuget",
                    "terraform",
                },
                Repos = new[]
                {
                    "**",
                },
                IncludeAllProjects = false,
                IncludedProjects = new[]
                {
                    "default",
                },
                IncludedPackages = new[]
                {
                    "**",
                },
                ExcludedPackages = new[]
                {
                    "com/jfrog/latest",
                },
                LastDownloadedBeforeInDays = cleanupPolicyLastDownloadedBeforeInDays,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.artifactory.PackageCleanupPolicy;
    import com.pulumi.artifactory.PackageCleanupPolicyArgs;
    import com.pulumi.artifactory.inputs.PackageCleanupPolicySearchCriteriaArgs;
    import java.util.List;
    import java.util.ArrayList;
    import java.util.Map;
    import java.io.File;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    
    public class App {
        public static void main(String[] args) {
            Pulumi.run(App::stack);
        }
    
        public static void stack(Context ctx) {
            final var config = ctx.config();
            final var cleanupPolicyLastDownloadedBeforeInDays = config.get("cleanupPolicyLastDownloadedBeforeInDays").orElse(60);
            final var cleanupPolicyDurationInMinutes = config.get("cleanupPolicyDurationInMinutes").orElse(120);
            var my_cleanup_policy = new PackageCleanupPolicy("my-cleanup-policy", PackageCleanupPolicyArgs.builder()
                .key("my-cleanup-policy")
                .description("My cleanup policy with variables")
                .cronExpression("0 0 2 ? * MON-SAT *")
                .durationInMinutes(cleanupPolicyDurationInMinutes)
                .enabled(true)
                .skipTrashcan(false)
                .searchCriteria(PackageCleanupPolicySearchCriteriaArgs.builder()
                    .packageTypes(                
                        "docker",
                        "generic",
                        "helm",
                        "helmoci",
                        "nuget",
                        "terraform")
                    .repos("**")
                    .includeAllProjects(false)
                    .includedProjects("default")
                    .includedPackages("**")
                    .excludedPackages("com/jfrog/latest")
                    .lastDownloadedBeforeInDays(cleanupPolicyLastDownloadedBeforeInDays)
                    .build())
                .build());
    
        }
    }
    
    configuration:
      cleanupPolicyLastDownloadedBeforeInDays:
        type: number
        default: 60
      cleanupPolicyDurationInMinutes:
        type: number
        default: 120
    resources:
      my-cleanup-policy:
        type: artifactory:PackageCleanupPolicy
        properties:
          key: my-cleanup-policy
          description: My cleanup policy with variables
          cronExpression: 0 0 2 ? * MON-SAT *
          durationInMinutes: ${cleanupPolicyDurationInMinutes}
          enabled: true
          skipTrashcan: false
          searchCriteria:
            packageTypes:
              - docker
              - generic
              - helm
              - helmoci
              - nuget
              - terraform
            repos:
              - '**'
            includeAllProjects: false
            includedProjects:
              - default
            includedPackages:
              - '**'
            excludedPackages:
              - com/jfrog/latest
            lastDownloadedBeforeInDays: ${cleanupPolicyLastDownloadedBeforeInDays}
    

    Important Notes:

    • Variables with default values allow terraform validate to pass without requiring variable values
    • Variables without default values will require values to be provided during pulumi preview or pulumi up
    • The validator automatically skips validation when condition field values are unknown (variables), preventing false validation errors during terraform validate

    Validation Rules

    The cleanup policy resource enforces the following validation rules:

    1. Condition Types: A policy must use exactly one of the following condition types:

      • Time-based conditions (days-based)
      • Version-based condition (keepLastNVersions)
      • Properties-based condition (includedProperties)
    2. Mutual Exclusivity: Cannot use multiple condition types together.

    3. Zero Values: Time-based and version-based conditions must have values greater than 0.

    4. Days vs Months: Cannot use both days-based conditions (createdBeforeInDays, lastDownloadedBeforeInDays) and months-based conditions (createdBeforeInMonths, lastDownloadedBeforeInMonths) together.

    5. Properties Validation: Properties-based conditions must have exactly one key with exactly one string value.

    6. Project Configuration: When includeAllProjects is set to true, the includedProjects field can be empty array. When includeAllProjects is false, includedProjects must contain at least one project key.

    7. Project-level Policy Constraints: When projectKey is specified (project-level policy):

      • includeAllProjects must be set to false
      • includedProjects should be empty array []
      • Policy key must start with the project key value as a prefix followed by a hyphen
        • ✅ Valid: projectKey = "myproj"key = "myproj-cleanup-policy"
        • ❌ Invalid: projectKey = "myproj"key = "cleanup-policy" (missing prefix)
        • ❌ Invalid: projectKey = "myproj"key = "other-cleanup-policy" (wrong prefix)

    Supported Package Types

    The following package types are supported for cleanup policies with their respective minimum Artifactory versions:

    • alpine - Alpine Linux packages (supported from 7.108.0)
    • ansible - Ansible collections and roles (supported from 7.104.2)
    • cargo - Rust Cargo packages (supported from 7.102.0)
    • chef - Chef cookbooks (supported from 7.112.0)
    • cocoapods - CocoaPods packages (supported from 7.99.1)
    • composer - PHP Composer packages (supported from 7.116.0)
    • conan - Conan C/C++ packages (supported from 7.98.2)
    • conda - Conda packages (supported from 7.105.2)
    • debian - Debian packages (supported from 7.98.2)
    • docker - Docker images (supported from 7.98.2, version-based condition (keep_last_n_versions) from 7.115.1)
    • gems - Ruby gems (supported from 7.96.3)
    • generic - Generic packages (supported from 7.98.2, version-based conditions is not supported)
    • go - Go modules (supported from 7.98.2)
    • gradle - Gradle packages (supported from 7.98.2)
    • helm - Helm charts (supported from 7.98.2)
    • helmoci - Helm OCI charts (supported from 7.102.0, version-based conditions (keep_last_n_versions) from 7.115.1)
    • huggingfaceml - Hugging Face ML models (supported from 7.100.0)
    • machinelearning - Machine learning models (supported from 7.104.2)
    • maven - Maven packages (supported from 7.98.2)
    • npm - Node.js packages (supported from 7.98.2)
    • nuget - .NET NuGet packages (supported from 7.98.2)
    • oci - OCI images (supported from 7.90.1, version-based conditions (keep_last_n_versions) from 7.115.1)
    • puppet - Puppet modules (supported from 7.112.0)
    • pypi - Python packages (supported from 7.98.2)
    • rpm|yum - RPM packages (supported from 7.98.2)
    • sbt - Scala SBT packages (supported from 7.108.0)
    • swift - Swift packages
    • terraform - Terraform modules (supported from 7.99.1)
    • terraformbackend - Terraform backend configurations (supported from 7.103.0)

    Version Compatibility

    • The createdBeforeInDays and lastDownloadedBeforeInDays attributes are only supported in Artifactory 7.111.2 and later. For earlier versions, use createdBeforeInMonths and lastDownloadedBeforeInMonths.

    Create PackageCleanupPolicy Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new PackageCleanupPolicy(name: string, args: PackageCleanupPolicyArgs, opts?: CustomResourceOptions);
    @overload
    def PackageCleanupPolicy(resource_name: str,
                             args: PackageCleanupPolicyArgs,
                             opts: Optional[ResourceOptions] = None)
    
    @overload
    def PackageCleanupPolicy(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             key: Optional[str] = None,
                             search_criteria: Optional[PackageCleanupPolicySearchCriteriaArgs] = None,
                             cron_expression: Optional[str] = None,
                             description: Optional[str] = None,
                             duration_in_minutes: Optional[int] = None,
                             enabled: Optional[bool] = None,
                             project_key: Optional[str] = None,
                             skip_trashcan: Optional[bool] = None)
    func NewPackageCleanupPolicy(ctx *Context, name string, args PackageCleanupPolicyArgs, opts ...ResourceOption) (*PackageCleanupPolicy, error)
    public PackageCleanupPolicy(string name, PackageCleanupPolicyArgs args, CustomResourceOptions? opts = null)
    public PackageCleanupPolicy(String name, PackageCleanupPolicyArgs args)
    public PackageCleanupPolicy(String name, PackageCleanupPolicyArgs args, CustomResourceOptions options)
    
    type: artifactory:PackageCleanupPolicy
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args PackageCleanupPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args PackageCleanupPolicyArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args PackageCleanupPolicyArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args PackageCleanupPolicyArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args PackageCleanupPolicyArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    PackageCleanupPolicy Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The PackageCleanupPolicy resource accepts the following input properties:

    Key string
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    SearchCriteria PackageCleanupPolicySearchCriteria
    CronExpression string
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    Description string
    DurationInMinutes int
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    Enabled bool
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    ProjectKey string
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    SkipTrashcan bool
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.
    Key string
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    SearchCriteria PackageCleanupPolicySearchCriteriaArgs
    CronExpression string
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    Description string
    DurationInMinutes int
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    Enabled bool
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    ProjectKey string
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    SkipTrashcan bool
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.
    key String
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    searchCriteria PackageCleanupPolicySearchCriteria
    cronExpression String
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    description String
    durationInMinutes Integer
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    enabled Boolean
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    projectKey String
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    skipTrashcan Boolean
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.
    key string
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    searchCriteria PackageCleanupPolicySearchCriteria
    cronExpression string
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    description string
    durationInMinutes number
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    enabled boolean
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    projectKey string
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    skipTrashcan boolean
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.
    key str
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    search_criteria PackageCleanupPolicySearchCriteriaArgs
    cron_expression str
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    description str
    duration_in_minutes int
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    enabled bool
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    project_key str
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    skip_trashcan bool
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.
    key String
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    searchCriteria Property Map
    cronExpression String
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    description String
    durationInMinutes Number
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    enabled Boolean
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    projectKey String
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    skipTrashcan Boolean
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the PackageCleanupPolicy resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing PackageCleanupPolicy Resource

    Get an existing PackageCleanupPolicy resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: PackageCleanupPolicyState, opts?: CustomResourceOptions): PackageCleanupPolicy
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            cron_expression: Optional[str] = None,
            description: Optional[str] = None,
            duration_in_minutes: Optional[int] = None,
            enabled: Optional[bool] = None,
            key: Optional[str] = None,
            project_key: Optional[str] = None,
            search_criteria: Optional[PackageCleanupPolicySearchCriteriaArgs] = None,
            skip_trashcan: Optional[bool] = None) -> PackageCleanupPolicy
    func GetPackageCleanupPolicy(ctx *Context, name string, id IDInput, state *PackageCleanupPolicyState, opts ...ResourceOption) (*PackageCleanupPolicy, error)
    public static PackageCleanupPolicy Get(string name, Input<string> id, PackageCleanupPolicyState? state, CustomResourceOptions? opts = null)
    public static PackageCleanupPolicy get(String name, Output<String> id, PackageCleanupPolicyState state, CustomResourceOptions options)
    resources:  _:    type: artifactory:PackageCleanupPolicy    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    CronExpression string
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    Description string
    DurationInMinutes int
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    Enabled bool
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    Key string
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    ProjectKey string
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    SearchCriteria PackageCleanupPolicySearchCriteria
    SkipTrashcan bool
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.
    CronExpression string
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    Description string
    DurationInMinutes int
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    Enabled bool
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    Key string
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    ProjectKey string
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    SearchCriteria PackageCleanupPolicySearchCriteriaArgs
    SkipTrashcan bool
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.
    cronExpression String
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    description String
    durationInMinutes Integer
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    enabled Boolean
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    key String
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    projectKey String
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    searchCriteria PackageCleanupPolicySearchCriteria
    skipTrashcan Boolean
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.
    cronExpression string
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    description string
    durationInMinutes number
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    enabled boolean
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    key string
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    projectKey string
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    searchCriteria PackageCleanupPolicySearchCriteria
    skipTrashcan boolean
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.
    cron_expression str
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    description str
    duration_in_minutes int
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    enabled bool
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    key str
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    project_key str
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    search_criteria PackageCleanupPolicySearchCriteriaArgs
    skip_trashcan bool
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.
    cronExpression String
    The cron expression that determines when the policy is run, However if left empty the policy will not run automatically and can only be triggered manually.
    description String
    durationInMinutes Number
    The maximum duration (in minutes) for policy execution, after which the policy will stop running even if not completed. While setting a maximum run duration for a policy is useful for adhering to a strict cleanup schedule, it can cause the policy to stop before completion.
    enabled Boolean
    A cleanup policy must be created inactive. But if used it must be set to false. If set to true when calling this API, the API call will fail and an error message is received. Defaults to true
    key String
    An ID that is used to identify the cleanup policy. A minimum of three characters is required and can include letters, numbers, underscore and hyphen.
    projectKey String
    This attribute is used only for project-level cleanup policies, it is not used for global-level policies. When specified, the policy will be scoped to the specified project. Note: The policy key must start with this project key value as a prefix (e.g., if projectKey is "myproj", the key should be "myproj-policy-name").
    searchCriteria Property Map
    skipTrashcan Boolean
    A true value means that when this policy is executed, packages will be permanently deleted. false means that when the policy is executed packages will be deleted to the Trash Can. Defaults to false.

    Supporting Types

    PackageCleanupPolicySearchCriteria, PackageCleanupPolicySearchCriteriaArgs

    IncludedPackages List<string>
    Specify a pattern for a package name or an explicit package name on which you want the cleanup policy to run. Only one pattern or explicit name can be entered. To include all packages, use **. Example: includedPackages = ["**"]
    IncludedProjects List<string>
    Enter the project keys for the projects on which you want the policy to run. To include repositories that are not assigned to any project, enter the project key default. Can be empty when includeAllProjects is set to true.
    PackageTypes List<string>
    The package types that are cleaned up by the policy. Support: alpine, ansible, cargo, chef, cocoapods, composer, conan, conda, debian, docker, gems, generic, go, gradle, helm, helmoci, huggingfaceml, machinelearning, maven, npm, nuget, oci, puppet, pypi, sbt, swift, terraform, terraformbackend, yum.
    Repos List<string>
    Specify one or more patterns for the repository name(s) on which you want the cleanup policy to run. You can also specify explicit repository names. Specifying at least one pattern or explicit name is mandatory. Only packages in repositories that match the pattern or explicit name will be deleted. For including all repos use **. Example: repos = ["**"]
    CreatedBeforeInDays int

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 5 then packages created more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInDays condition to ensure that packages currently in use are not deleted.

    CreatedBeforeInMonths int

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 2 then packages created more than 2 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use createdBeforeInDays instead of createdBeforeInMonths. Renamed to createdBeforeInDays starting in version 7.111.2.

    ExcludedPackages List<string>
    Specify explicit package names that you want excluded from the policy. Only explicit names (and not patterns) are accepted.
    ExcludedProperties Dictionary<string, ImmutableArray<string>>
    A key-value pair applied to the lead artifact of a package. Packages with this property will be excluded from deletion.
    ExcludedRepos List<string>
    Specify patterns for repository names or explicit repository names that you want excluded from the cleanup policy.
    IncludeAllProjects bool

    Set this value to true if you want the policy to run on all Artifactory projects. The default value is false.

    ~>This parameter is relevant only on the global level, for Platform Admins.

    IncludedProperties Dictionary<string, ImmutableArray<string>>
    A key-value pair applied to the lead artifact of a package. Packages with this property will be deleted.
    KeepLastNVersions int

    Set a value for the number of latest versions to keep. The cleanup policy will remove all versions prior to the number you select here. The latest version is always excluded.

    ~>Not all package types support this condition. For information on which package types support this condition, learn more.

    LastDownloadedBeforeInDays int

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInDays condition to ensure that packages currently in use are not deleted.

    LastDownloadedBeforeInMonths int

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use lastDownloadedBeforeInDays instead of lastDownloadedBeforeInMonths. Renamed to lastDownloadedBeforeInDays starting in version 7.111.2.

    IncludedPackages []string
    Specify a pattern for a package name or an explicit package name on which you want the cleanup policy to run. Only one pattern or explicit name can be entered. To include all packages, use **. Example: includedPackages = ["**"]
    IncludedProjects []string
    Enter the project keys for the projects on which you want the policy to run. To include repositories that are not assigned to any project, enter the project key default. Can be empty when includeAllProjects is set to true.
    PackageTypes []string
    The package types that are cleaned up by the policy. Support: alpine, ansible, cargo, chef, cocoapods, composer, conan, conda, debian, docker, gems, generic, go, gradle, helm, helmoci, huggingfaceml, machinelearning, maven, npm, nuget, oci, puppet, pypi, sbt, swift, terraform, terraformbackend, yum.
    Repos []string
    Specify one or more patterns for the repository name(s) on which you want the cleanup policy to run. You can also specify explicit repository names. Specifying at least one pattern or explicit name is mandatory. Only packages in repositories that match the pattern or explicit name will be deleted. For including all repos use **. Example: repos = ["**"]
    CreatedBeforeInDays int

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 5 then packages created more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInDays condition to ensure that packages currently in use are not deleted.

    CreatedBeforeInMonths int

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 2 then packages created more than 2 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use createdBeforeInDays instead of createdBeforeInMonths. Renamed to createdBeforeInDays starting in version 7.111.2.

    ExcludedPackages []string
    Specify explicit package names that you want excluded from the policy. Only explicit names (and not patterns) are accepted.
    ExcludedProperties map[string][]string
    A key-value pair applied to the lead artifact of a package. Packages with this property will be excluded from deletion.
    ExcludedRepos []string
    Specify patterns for repository names or explicit repository names that you want excluded from the cleanup policy.
    IncludeAllProjects bool

    Set this value to true if you want the policy to run on all Artifactory projects. The default value is false.

    ~>This parameter is relevant only on the global level, for Platform Admins.

    IncludedProperties map[string][]string
    A key-value pair applied to the lead artifact of a package. Packages with this property will be deleted.
    KeepLastNVersions int

    Set a value for the number of latest versions to keep. The cleanup policy will remove all versions prior to the number you select here. The latest version is always excluded.

    ~>Not all package types support this condition. For information on which package types support this condition, learn more.

    LastDownloadedBeforeInDays int

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInDays condition to ensure that packages currently in use are not deleted.

    LastDownloadedBeforeInMonths int

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use lastDownloadedBeforeInDays instead of lastDownloadedBeforeInMonths. Renamed to lastDownloadedBeforeInDays starting in version 7.111.2.

    includedPackages List<String>
    Specify a pattern for a package name or an explicit package name on which you want the cleanup policy to run. Only one pattern or explicit name can be entered. To include all packages, use **. Example: includedPackages = ["**"]
    includedProjects List<String>
    Enter the project keys for the projects on which you want the policy to run. To include repositories that are not assigned to any project, enter the project key default. Can be empty when includeAllProjects is set to true.
    packageTypes List<String>
    The package types that are cleaned up by the policy. Support: alpine, ansible, cargo, chef, cocoapods, composer, conan, conda, debian, docker, gems, generic, go, gradle, helm, helmoci, huggingfaceml, machinelearning, maven, npm, nuget, oci, puppet, pypi, sbt, swift, terraform, terraformbackend, yum.
    repos List<String>
    Specify one or more patterns for the repository name(s) on which you want the cleanup policy to run. You can also specify explicit repository names. Specifying at least one pattern or explicit name is mandatory. Only packages in repositories that match the pattern or explicit name will be deleted. For including all repos use **. Example: repos = ["**"]
    createdBeforeInDays Integer

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 5 then packages created more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInDays condition to ensure that packages currently in use are not deleted.

    createdBeforeInMonths Integer

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 2 then packages created more than 2 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use createdBeforeInDays instead of createdBeforeInMonths. Renamed to createdBeforeInDays starting in version 7.111.2.

    excludedPackages List<String>
    Specify explicit package names that you want excluded from the policy. Only explicit names (and not patterns) are accepted.
    excludedProperties Map<String,List<String>>
    A key-value pair applied to the lead artifact of a package. Packages with this property will be excluded from deletion.
    excludedRepos List<String>
    Specify patterns for repository names or explicit repository names that you want excluded from the cleanup policy.
    includeAllProjects Boolean

    Set this value to true if you want the policy to run on all Artifactory projects. The default value is false.

    ~>This parameter is relevant only on the global level, for Platform Admins.

    includedProperties Map<String,List<String>>
    A key-value pair applied to the lead artifact of a package. Packages with this property will be deleted.
    keepLastNVersions Integer

    Set a value for the number of latest versions to keep. The cleanup policy will remove all versions prior to the number you select here. The latest version is always excluded.

    ~>Not all package types support this condition. For information on which package types support this condition, learn more.

    lastDownloadedBeforeInDays Integer

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInDays condition to ensure that packages currently in use are not deleted.

    lastDownloadedBeforeInMonths Integer

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use lastDownloadedBeforeInDays instead of lastDownloadedBeforeInMonths. Renamed to lastDownloadedBeforeInDays starting in version 7.111.2.

    includedPackages string[]
    Specify a pattern for a package name or an explicit package name on which you want the cleanup policy to run. Only one pattern or explicit name can be entered. To include all packages, use **. Example: includedPackages = ["**"]
    includedProjects string[]
    Enter the project keys for the projects on which you want the policy to run. To include repositories that are not assigned to any project, enter the project key default. Can be empty when includeAllProjects is set to true.
    packageTypes string[]
    The package types that are cleaned up by the policy. Support: alpine, ansible, cargo, chef, cocoapods, composer, conan, conda, debian, docker, gems, generic, go, gradle, helm, helmoci, huggingfaceml, machinelearning, maven, npm, nuget, oci, puppet, pypi, sbt, swift, terraform, terraformbackend, yum.
    repos string[]
    Specify one or more patterns for the repository name(s) on which you want the cleanup policy to run. You can also specify explicit repository names. Specifying at least one pattern or explicit name is mandatory. Only packages in repositories that match the pattern or explicit name will be deleted. For including all repos use **. Example: repos = ["**"]
    createdBeforeInDays number

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 5 then packages created more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInDays condition to ensure that packages currently in use are not deleted.

    createdBeforeInMonths number

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 2 then packages created more than 2 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use createdBeforeInDays instead of createdBeforeInMonths. Renamed to createdBeforeInDays starting in version 7.111.2.

    excludedPackages string[]
    Specify explicit package names that you want excluded from the policy. Only explicit names (and not patterns) are accepted.
    excludedProperties {[key: string]: string[]}
    A key-value pair applied to the lead artifact of a package. Packages with this property will be excluded from deletion.
    excludedRepos string[]
    Specify patterns for repository names or explicit repository names that you want excluded from the cleanup policy.
    includeAllProjects boolean

    Set this value to true if you want the policy to run on all Artifactory projects. The default value is false.

    ~>This parameter is relevant only on the global level, for Platform Admins.

    includedProperties {[key: string]: string[]}
    A key-value pair applied to the lead artifact of a package. Packages with this property will be deleted.
    keepLastNVersions number

    Set a value for the number of latest versions to keep. The cleanup policy will remove all versions prior to the number you select here. The latest version is always excluded.

    ~>Not all package types support this condition. For information on which package types support this condition, learn more.

    lastDownloadedBeforeInDays number

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInDays condition to ensure that packages currently in use are not deleted.

    lastDownloadedBeforeInMonths number

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use lastDownloadedBeforeInDays instead of lastDownloadedBeforeInMonths. Renamed to lastDownloadedBeforeInDays starting in version 7.111.2.

    included_packages Sequence[str]
    Specify a pattern for a package name or an explicit package name on which you want the cleanup policy to run. Only one pattern or explicit name can be entered. To include all packages, use **. Example: includedPackages = ["**"]
    included_projects Sequence[str]
    Enter the project keys for the projects on which you want the policy to run. To include repositories that are not assigned to any project, enter the project key default. Can be empty when includeAllProjects is set to true.
    package_types Sequence[str]
    The package types that are cleaned up by the policy. Support: alpine, ansible, cargo, chef, cocoapods, composer, conan, conda, debian, docker, gems, generic, go, gradle, helm, helmoci, huggingfaceml, machinelearning, maven, npm, nuget, oci, puppet, pypi, sbt, swift, terraform, terraformbackend, yum.
    repos Sequence[str]
    Specify one or more patterns for the repository name(s) on which you want the cleanup policy to run. You can also specify explicit repository names. Specifying at least one pattern or explicit name is mandatory. Only packages in repositories that match the pattern or explicit name will be deleted. For including all repos use **. Example: repos = ["**"]
    created_before_in_days int

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 5 then packages created more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInDays condition to ensure that packages currently in use are not deleted.

    created_before_in_months int

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 2 then packages created more than 2 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use createdBeforeInDays instead of createdBeforeInMonths. Renamed to createdBeforeInDays starting in version 7.111.2.

    excluded_packages Sequence[str]
    Specify explicit package names that you want excluded from the policy. Only explicit names (and not patterns) are accepted.
    excluded_properties Mapping[str, Sequence[str]]
    A key-value pair applied to the lead artifact of a package. Packages with this property will be excluded from deletion.
    excluded_repos Sequence[str]
    Specify patterns for repository names or explicit repository names that you want excluded from the cleanup policy.
    include_all_projects bool

    Set this value to true if you want the policy to run on all Artifactory projects. The default value is false.

    ~>This parameter is relevant only on the global level, for Platform Admins.

    included_properties Mapping[str, Sequence[str]]
    A key-value pair applied to the lead artifact of a package. Packages with this property will be deleted.
    keep_last_n_versions int

    Set a value for the number of latest versions to keep. The cleanup policy will remove all versions prior to the number you select here. The latest version is always excluded.

    ~>Not all package types support this condition. For information on which package types support this condition, learn more.

    last_downloaded_before_in_days int

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInDays condition to ensure that packages currently in use are not deleted.

    last_downloaded_before_in_months int

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use lastDownloadedBeforeInDays instead of lastDownloadedBeforeInMonths. Renamed to lastDownloadedBeforeInDays starting in version 7.111.2.

    includedPackages List<String>
    Specify a pattern for a package name or an explicit package name on which you want the cleanup policy to run. Only one pattern or explicit name can be entered. To include all packages, use **. Example: includedPackages = ["**"]
    includedProjects List<String>
    Enter the project keys for the projects on which you want the policy to run. To include repositories that are not assigned to any project, enter the project key default. Can be empty when includeAllProjects is set to true.
    packageTypes List<String>
    The package types that are cleaned up by the policy. Support: alpine, ansible, cargo, chef, cocoapods, composer, conan, conda, debian, docker, gems, generic, go, gradle, helm, helmoci, huggingfaceml, machinelearning, maven, npm, nuget, oci, puppet, pypi, sbt, swift, terraform, terraformbackend, yum.
    repos List<String>
    Specify one or more patterns for the repository name(s) on which you want the cleanup policy to run. You can also specify explicit repository names. Specifying at least one pattern or explicit name is mandatory. Only packages in repositories that match the pattern or explicit name will be deleted. For including all repos use **. Example: repos = ["**"]
    createdBeforeInDays Number

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 5 then packages created more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInDays condition to ensure that packages currently in use are not deleted.

    createdBeforeInMonths Number

    The cleanup policy will delete packages based on how long ago they were created. For example, if this parameter is 2 then packages created more than 2 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the createdBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use createdBeforeInDays instead of createdBeforeInMonths. Renamed to createdBeforeInDays starting in version 7.111.2.

    excludedPackages List<String>
    Specify explicit package names that you want excluded from the policy. Only explicit names (and not patterns) are accepted.
    excludedProperties Map<List<String>>
    A key-value pair applied to the lead artifact of a package. Packages with this property will be excluded from deletion.
    excludedRepos List<String>
    Specify patterns for repository names or explicit repository names that you want excluded from the cleanup policy.
    includeAllProjects Boolean

    Set this value to true if you want the policy to run on all Artifactory projects. The default value is false.

    ~>This parameter is relevant only on the global level, for Platform Admins.

    includedProperties Map<List<String>>
    A key-value pair applied to the lead artifact of a package. Packages with this property will be deleted.
    keepLastNVersions Number

    Set a value for the number of latest versions to keep. The cleanup policy will remove all versions prior to the number you select here. The latest version is always excluded.

    ~>Not all package types support this condition. For information on which package types support this condition, learn more.

    lastDownloadedBeforeInDays Number

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 days ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInDays condition to ensure that packages currently in use are not deleted.

    lastDownloadedBeforeInMonths Number

    The cleanup policy will delete packages based on how long ago they were downloaded. For example, if this parameter is 5 then packages downloaded more than 5 months ago will be deleted as part of the policy.

    ~>JFrog recommends using the lastDownloadedBeforeInMonths condition to ensure that packages currently in use are not deleted.

    Deprecated: Use lastDownloadedBeforeInDays instead of lastDownloadedBeforeInMonths. Renamed to lastDownloadedBeforeInDays starting in version 7.111.2.

    Import

    $ pulumi import artifactory:index/packageCleanupPolicy:PackageCleanupPolicy my-cleanup-policy my-policy
    
    $ pulumi import artifactory:index/packageCleanupPolicy:PackageCleanupPolicy my-cleanup-policy my-policy:myproj
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    artifactory pulumi/pulumi-artifactory
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the artifactory Terraform Provider.
    artifactory logo
    Viewing docs for artifactory v8.10.4
    published on Friday, Apr 10, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.