BackupPolicy

Provides a Click House Backup Policy resource.

For information about Click House Backup Policy and how to use it, see What is Backup Policy.

NOTE: Available in v1.147.0+.

NOTE: Only the cloud database ClickHouse cluster version 20.3 supports data backup.

Example Usage

Basic Usage

using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var defaultRegions = Output.Create(AliCloud.ClickHouse.GetRegions.InvokeAsync(new AliCloud.ClickHouse.GetRegionsArgs
        {
            Current = true,
        }));
        var defaultNetworks = Output.Create(AliCloud.Vpc.GetNetworks.InvokeAsync(new AliCloud.Vpc.GetNetworksArgs
        {
            NameRegex = "default-NODELETING",
        }));
        var defaultSwitches = Output.Tuple(defaultNetworks, defaultRegions).Apply(values =>
        {
            var defaultNetworks = values.Item1;
            var defaultRegions = values.Item2;
            return Output.Create(AliCloud.Vpc.GetSwitches.InvokeAsync(new AliCloud.Vpc.GetSwitchesArgs
            {
                VpcId = defaultNetworks.Ids?[0],
                ZoneId = defaultRegions.Regions?[0]?.ZoneIds?[0]?.ZoneId,
            }));
        });
        var defaultDbCluster = new AliCloud.ClickHouse.DbCluster("defaultDbCluster", new AliCloud.ClickHouse.DbClusterArgs
        {
            DbClusterVersion = "20.3.10.75",
            Status = "Running",
            Category = "Basic",
            DbClusterClass = "S8",
            DbClusterNetworkType = "vpc",
            DbClusterDescription = @var.Name,
            DbNodeGroupCount = 1,
            PaymentType = "PayAsYouGo",
            DbNodeStorage = "500",
            StorageType = "cloud_essd",
            VswitchId = defaultSwitches.Apply(defaultSwitches => defaultSwitches.Vswitches?[0]?.Id),
        });
        var example = new AliCloud.ClickHouse.BackupPolicy("example", new AliCloud.ClickHouse.BackupPolicyArgs
        {
            DbClusterId = defaultDbCluster.Id,
            PreferredBackupPeriods = 
            {
                "Monday",
                "Friday",
            },
            PreferredBackupTime = "00:00Z-01:00Z",
            BackupRetentionPeriod = 7,
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/clickhouse"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		defaultRegions, err := clickhouse.GetRegions(ctx, &clickhouse.GetRegionsArgs{
			Current: pulumi.BoolRef(true),
		}, nil)
		if err != nil {
			return err
		}
		defaultNetworks, err := vpc.GetNetworks(ctx, &vpc.GetNetworksArgs{
			NameRegex: pulumi.StringRef("default-NODELETING"),
		}, nil)
		if err != nil {
			return err
		}
		defaultSwitches, err := vpc.GetSwitches(ctx, &vpc.GetSwitchesArgs{
			VpcId:  pulumi.StringRef(defaultNetworks.Ids[0]),
			ZoneId: pulumi.StringRef(defaultRegions.Regions[0].ZoneIds[0].ZoneId),
		}, nil)
		if err != nil {
			return err
		}
		defaultDbCluster, err := clickhouse.NewDbCluster(ctx, "defaultDbCluster", &clickhouse.DbClusterArgs{
			DbClusterVersion:     pulumi.String("20.3.10.75"),
			Status:               pulumi.String("Running"),
			Category:             pulumi.String("Basic"),
			DbClusterClass:       pulumi.String("S8"),
			DbClusterNetworkType: pulumi.String("vpc"),
			DbClusterDescription: pulumi.Any(_var.Name),
			DbNodeGroupCount:     pulumi.Int(1),
			PaymentType:          pulumi.String("PayAsYouGo"),
			DbNodeStorage:        pulumi.String("500"),
			StorageType:          pulumi.String("cloud_essd"),
			VswitchId:            pulumi.String(defaultSwitches.Vswitches[0].Id),
		})
		if err != nil {
			return err
		}
		_, err = clickhouse.NewBackupPolicy(ctx, "example", &clickhouse.BackupPolicyArgs{
			DbClusterId: defaultDbCluster.ID(),
			PreferredBackupPeriods: pulumi.StringArray{
				pulumi.String("Monday"),
				pulumi.String("Friday"),
			},
			PreferredBackupTime:   pulumi.String("00:00Z-01:00Z"),
			BackupRetentionPeriod: pulumi.Int(7),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.clickhouse.ClickhouseFunctions;
import com.pulumi.alicloud.clickhouse.inputs.GetRegionsArgs;
import com.pulumi.alicloud.vpc.VpcFunctions;
import com.pulumi.alicloud.cloudconnect.inputs.GetNetworksArgs;
import com.pulumi.alicloud.vpc.inputs.GetSwitchesArgs;
import com.pulumi.alicloud.clickhouse.DbCluster;
import com.pulumi.alicloud.clickhouse.DbClusterArgs;
import com.pulumi.alicloud.clickhouse.BackupPolicy;
import com.pulumi.alicloud.clickhouse.BackupPolicyArgs;
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 defaultRegions = ClickhouseFunctions.getRegions(GetRegionsArgs.builder()
            .current(true)
            .build());

        final var defaultNetworks = VpcFunctions.getNetworks(GetNetworksArgs.builder()
            .nameRegex("default-NODELETING")
            .build());

        final var defaultSwitches = VpcFunctions.getSwitches(GetSwitchesArgs.builder()
            .vpcId(defaultNetworks.applyValue(getNetworksResult -> getNetworksResult.ids()[0]))
            .zoneId(defaultRegions.applyValue(getRegionsResult -> getRegionsResult.regions()[0].zoneIds()[0].zoneId()))
            .build());

        var defaultDbCluster = new DbCluster("defaultDbCluster", DbClusterArgs.builder()        
            .dbClusterVersion("20.3.10.75")
            .status("Running")
            .category("Basic")
            .dbClusterClass("S8")
            .dbClusterNetworkType("vpc")
            .dbClusterDescription(var_.name())
            .dbNodeGroupCount("1")
            .paymentType("PayAsYouGo")
            .dbNodeStorage("500")
            .storageType("cloud_essd")
            .vswitchId(defaultSwitches.applyValue(getSwitchesResult -> getSwitchesResult.vswitches()[0].id()))
            .build());

        var example = new BackupPolicy("example", BackupPolicyArgs.builder()        
            .dbClusterId(defaultDbCluster.id())
            .preferredBackupPeriods(            
                "Monday",
                "Friday")
            .preferredBackupTime("00:00Z-01:00Z")
            .backupRetentionPeriod(7)
            .build());

    }
}
import pulumi
import pulumi_alicloud as alicloud

default_regions = alicloud.clickhouse.get_regions(current=True)
default_networks = alicloud.vpc.get_networks(name_regex="default-NODELETING")
default_switches = alicloud.vpc.get_switches(vpc_id=default_networks.ids[0],
    zone_id=default_regions.regions[0].zone_ids[0].zone_id)
default_db_cluster = alicloud.clickhouse.DbCluster("defaultDbCluster",
    db_cluster_version="20.3.10.75",
    status="Running",
    category="Basic",
    db_cluster_class="S8",
    db_cluster_network_type="vpc",
    db_cluster_description=var["name"],
    db_node_group_count=1,
    payment_type="PayAsYouGo",
    db_node_storage="500",
    storage_type="cloud_essd",
    vswitch_id=default_switches.vswitches[0].id)
example = alicloud.clickhouse.BackupPolicy("example",
    db_cluster_id=default_db_cluster.id,
    preferred_backup_periods=[
        "Monday",
        "Friday",
    ],
    preferred_backup_time="00:00Z-01:00Z",
    backup_retention_period=7)
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const defaultRegions = alicloud.clickhouse.getRegions({
    current: true,
});
const defaultNetworks = alicloud.vpc.getNetworks({
    nameRegex: "default-NODELETING",
});
const defaultSwitches = Promise.all([defaultNetworks, defaultRegions]).then(([defaultNetworks, defaultRegions]) => alicloud.vpc.getSwitches({
    vpcId: defaultNetworks.ids?[0],
    zoneId: defaultRegions.regions?[0]?.zoneIds?[0]?.zoneId,
}));
const defaultDbCluster = new alicloud.clickhouse.DbCluster("defaultDbCluster", {
    dbClusterVersion: "20.3.10.75",
    status: "Running",
    category: "Basic",
    dbClusterClass: "S8",
    dbClusterNetworkType: "vpc",
    dbClusterDescription: _var.name,
    dbNodeGroupCount: 1,
    paymentType: "PayAsYouGo",
    dbNodeStorage: "500",
    storageType: "cloud_essd",
    vswitchId: defaultSwitches.then(defaultSwitches => defaultSwitches.vswitches?[0]?.id),
});
const example = new alicloud.clickhouse.BackupPolicy("example", {
    dbClusterId: defaultDbCluster.id,
    preferredBackupPeriods: [
        "Monday",
        "Friday",
    ],
    preferredBackupTime: "00:00Z-01:00Z",
    backupRetentionPeriod: 7,
});
resources:
  defaultDbCluster:
    type: alicloud:clickhouse:DbCluster
    properties:
      dbClusterVersion: 20.3.10.75
      status: Running
      category: Basic
      dbClusterClass: S8
      dbClusterNetworkType: vpc
      dbClusterDescription: ${var.name}
      dbNodeGroupCount: 1
      paymentType: PayAsYouGo
      dbNodeStorage: 500
      storageType: cloud_essd
      vswitchId: ${defaultSwitches.vswitches[0].id}
  example:
    type: alicloud:clickhouse:BackupPolicy
    properties:
      dbClusterId: ${defaultDbCluster.id}
      preferredBackupPeriods:
        - Monday
        - Friday
      preferredBackupTime: 00:00Z-01:00Z
      backupRetentionPeriod: 7
variables:
  defaultRegions:
    Fn::Invoke:
      Function: alicloud:clickhouse:getRegions
      Arguments:
        current: true
  defaultNetworks:
    Fn::Invoke:
      Function: alicloud:vpc:getNetworks
      Arguments:
        nameRegex: default-NODELETING
  defaultSwitches:
    Fn::Invoke:
      Function: alicloud:vpc:getSwitches
      Arguments:
        vpcId: ${defaultNetworks.ids[0]}
        zoneId: ${defaultRegions.regions[0].zoneIds[0].zoneId}

Create BackupPolicy Resource

new BackupPolicy(name: string, args: BackupPolicyArgs, opts?: CustomResourceOptions);
@overload
def BackupPolicy(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 backup_retention_period: Optional[int] = None,
                 db_cluster_id: Optional[str] = None,
                 preferred_backup_periods: Optional[Sequence[str]] = None,
                 preferred_backup_time: Optional[str] = None)
@overload
def BackupPolicy(resource_name: str,
                 args: BackupPolicyArgs,
                 opts: Optional[ResourceOptions] = None)
func NewBackupPolicy(ctx *Context, name string, args BackupPolicyArgs, opts ...ResourceOption) (*BackupPolicy, error)
public BackupPolicy(string name, BackupPolicyArgs args, CustomResourceOptions? opts = null)
public BackupPolicy(String name, BackupPolicyArgs args)
public BackupPolicy(String name, BackupPolicyArgs args, CustomResourceOptions options)
type: alicloud:clickhouse:BackupPolicy
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args BackupPolicyArgs
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 BackupPolicyArgs
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 BackupPolicyArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args BackupPolicyArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args BackupPolicyArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

BackupPolicy Resource Properties

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

Inputs

The BackupPolicy resource accepts the following input properties:

DbClusterId string

The id of the DBCluster.

PreferredBackupPeriods List<string>

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

PreferredBackupTime string

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

BackupRetentionPeriod int

Data backup days. Valid values: 7 to 730.

DbClusterId string

The id of the DBCluster.

PreferredBackupPeriods []string

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

PreferredBackupTime string

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

BackupRetentionPeriod int

Data backup days. Valid values: 7 to 730.

dbClusterId String

The id of the DBCluster.

preferredBackupPeriods List<String>

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

preferredBackupTime String

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

backupRetentionPeriod Integer

Data backup days. Valid values: 7 to 730.

dbClusterId string

The id of the DBCluster.

preferredBackupPeriods string[]

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

preferredBackupTime string

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

backupRetentionPeriod number

Data backup days. Valid values: 7 to 730.

db_cluster_id str

The id of the DBCluster.

preferred_backup_periods Sequence[str]

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

preferred_backup_time str

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

backup_retention_period int

Data backup days. Valid values: 7 to 730.

dbClusterId String

The id of the DBCluster.

preferredBackupPeriods List<String>

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

preferredBackupTime String

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

backupRetentionPeriod Number

Data backup days. Valid values: 7 to 730.

Outputs

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

Id string

The provider-assigned unique ID for this managed resource.

Status string

The status of the resource.

Id string

The provider-assigned unique ID for this managed resource.

Status string

The status of the resource.

id String

The provider-assigned unique ID for this managed resource.

status String

The status of the resource.

id string

The provider-assigned unique ID for this managed resource.

status string

The status of the resource.

id str

The provider-assigned unique ID for this managed resource.

status str

The status of the resource.

id String

The provider-assigned unique ID for this managed resource.

status String

The status of the resource.

Look up Existing BackupPolicy Resource

Get an existing BackupPolicy 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?: BackupPolicyState, opts?: CustomResourceOptions): BackupPolicy
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        backup_retention_period: Optional[int] = None,
        db_cluster_id: Optional[str] = None,
        preferred_backup_periods: Optional[Sequence[str]] = None,
        preferred_backup_time: Optional[str] = None,
        status: Optional[str] = None) -> BackupPolicy
func GetBackupPolicy(ctx *Context, name string, id IDInput, state *BackupPolicyState, opts ...ResourceOption) (*BackupPolicy, error)
public static BackupPolicy Get(string name, Input<string> id, BackupPolicyState? state, CustomResourceOptions? opts = null)
public static BackupPolicy get(String name, Output<String> id, BackupPolicyState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
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:
BackupRetentionPeriod int

Data backup days. Valid values: 7 to 730.

DbClusterId string

The id of the DBCluster.

PreferredBackupPeriods List<string>

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

PreferredBackupTime string

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

Status string

The status of the resource.

BackupRetentionPeriod int

Data backup days. Valid values: 7 to 730.

DbClusterId string

The id of the DBCluster.

PreferredBackupPeriods []string

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

PreferredBackupTime string

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

Status string

The status of the resource.

backupRetentionPeriod Integer

Data backup days. Valid values: 7 to 730.

dbClusterId String

The id of the DBCluster.

preferredBackupPeriods List<String>

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

preferredBackupTime String

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

status String

The status of the resource.

backupRetentionPeriod number

Data backup days. Valid values: 7 to 730.

dbClusterId string

The id of the DBCluster.

preferredBackupPeriods string[]

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

preferredBackupTime string

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

status string

The status of the resource.

backup_retention_period int

Data backup days. Valid values: 7 to 730.

db_cluster_id str

The id of the DBCluster.

preferred_backup_periods Sequence[str]

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

preferred_backup_time str

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

status str

The status of the resource.

backupRetentionPeriod Number

Data backup days. Valid values: 7 to 730.

dbClusterId String

The id of the DBCluster.

preferredBackupPeriods List<String>

DBCluster Backup period. A list of DBCluster Backup period. Valid values: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"].

preferredBackupTime String

DBCluster backup time, in the format of HH:mmZ-HH:mmZ. Time setting interval is one hour. China time is 8 hours behind it.

status String

The status of the resource.

Import

Click House Backup Policy can be imported using the id, e.g.

 $ pulumi import alicloud:clickhouse/backupPolicy:BackupPolicy example <db_cluster_id>

Package Details

Repository
https://github.com/pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.