1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. ecs
  5. EcsAutoSnapshotPolicyAttachment
Alibaba Cloud v3.95.0 published on Thursday, Feb 12, 2026 by Pulumi
alicloud logo
Alibaba Cloud v3.95.0 published on Thursday, Feb 12, 2026 by Pulumi

    Provides a ECS Auto Snapshot Policy Attachment resource.

    Automatic snapshot policy Mount relationship.

    For information about ECS Auto Snapshot Policy Attachment and how to use it, see What is Auto Snapshot Policy Attachment.

    NOTE: Available since v1.122.0.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "terraform-example";
    const _default = alicloud.getZones({
        availableResourceCreation: "VSwitch",
    });
    const defaultAutoSnapshotPolicy = new alicloud.ecs.AutoSnapshotPolicy("default", {
        autoSnapshotPolicyName: name,
        repeatWeekdays: [
            "1",
            "2",
            "3",
        ],
        retentionDays: 1,
        timePoints: [
            "1",
            "2",
            "3",
        ],
    });
    const defaultEcsDisk = new alicloud.ecs.EcsDisk("default", {
        zoneId: _default.then(_default => _default.zones?.[0]?.id),
        size: 500,
    });
    const defaultEcsAutoSnapshotPolicyAttachment = new alicloud.ecs.EcsAutoSnapshotPolicyAttachment("default", {
        autoSnapshotPolicyId: defaultAutoSnapshotPolicy.id,
        diskId: defaultEcsDisk.id,
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.get_zones(available_resource_creation="VSwitch")
    default_auto_snapshot_policy = alicloud.ecs.AutoSnapshotPolicy("default",
        auto_snapshot_policy_name=name,
        repeat_weekdays=[
            "1",
            "2",
            "3",
        ],
        retention_days=1,
        time_points=[
            "1",
            "2",
            "3",
        ])
    default_ecs_disk = alicloud.ecs.EcsDisk("default",
        zone_id=default.zones[0].id,
        size=500)
    default_ecs_auto_snapshot_policy_attachment = alicloud.ecs.EcsAutoSnapshotPolicyAttachment("default",
        auto_snapshot_policy_id=default_auto_snapshot_policy.id,
        disk_id=default_ecs_disk.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
    	"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, "")
    		name := "terraform-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		_default, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
    			AvailableResourceCreation: pulumi.StringRef("VSwitch"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultAutoSnapshotPolicy, err := ecs.NewAutoSnapshotPolicy(ctx, "default", &ecs.AutoSnapshotPolicyArgs{
    			AutoSnapshotPolicyName: pulumi.String(name),
    			RepeatWeekdays: pulumi.StringArray{
    				pulumi.String("1"),
    				pulumi.String("2"),
    				pulumi.String("3"),
    			},
    			RetentionDays: pulumi.Int(1),
    			TimePoints: pulumi.StringArray{
    				pulumi.String("1"),
    				pulumi.String("2"),
    				pulumi.String("3"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		defaultEcsDisk, err := ecs.NewEcsDisk(ctx, "default", &ecs.EcsDiskArgs{
    			ZoneId: pulumi.String(_default.Zones[0].Id),
    			Size:   pulumi.Int(500),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = ecs.NewEcsAutoSnapshotPolicyAttachment(ctx, "default", &ecs.EcsAutoSnapshotPolicyAttachmentArgs{
    			AutoSnapshotPolicyId: defaultAutoSnapshotPolicy.ID(),
    			DiskId:               defaultEcsDisk.ID(),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using AliCloud = Pulumi.AliCloud;
    
    return await Deployment.RunAsync(() => 
    {
        var config = new Config();
        var name = config.Get("name") ?? "terraform-example";
        var @default = AliCloud.GetZones.Invoke(new()
        {
            AvailableResourceCreation = "VSwitch",
        });
    
        var defaultAutoSnapshotPolicy = new AliCloud.Ecs.AutoSnapshotPolicy("default", new()
        {
            AutoSnapshotPolicyName = name,
            RepeatWeekdays = new[]
            {
                "1",
                "2",
                "3",
            },
            RetentionDays = 1,
            TimePoints = new[]
            {
                "1",
                "2",
                "3",
            },
        });
    
        var defaultEcsDisk = new AliCloud.Ecs.EcsDisk("default", new()
        {
            ZoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones[0]?.Id)),
            Size = 500,
        });
    
        var defaultEcsAutoSnapshotPolicyAttachment = new AliCloud.Ecs.EcsAutoSnapshotPolicyAttachment("default", new()
        {
            AutoSnapshotPolicyId = defaultAutoSnapshotPolicy.Id,
            DiskId = defaultEcsDisk.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.AlicloudFunctions;
    import com.pulumi.alicloud.inputs.GetZonesArgs;
    import com.pulumi.alicloud.ecs.AutoSnapshotPolicy;
    import com.pulumi.alicloud.ecs.AutoSnapshotPolicyArgs;
    import com.pulumi.alicloud.ecs.EcsDisk;
    import com.pulumi.alicloud.ecs.EcsDiskArgs;
    import com.pulumi.alicloud.ecs.EcsAutoSnapshotPolicyAttachment;
    import com.pulumi.alicloud.ecs.EcsAutoSnapshotPolicyAttachmentArgs;
    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 name = config.get("name").orElse("terraform-example");
            final var default = AlicloudFunctions.getZones(GetZonesArgs.builder()
                .availableResourceCreation("VSwitch")
                .build());
    
            var defaultAutoSnapshotPolicy = new AutoSnapshotPolicy("defaultAutoSnapshotPolicy", AutoSnapshotPolicyArgs.builder()
                .autoSnapshotPolicyName(name)
                .repeatWeekdays(            
                    "1",
                    "2",
                    "3")
                .retentionDays(1)
                .timePoints(            
                    "1",
                    "2",
                    "3")
                .build());
    
            var defaultEcsDisk = new EcsDisk("defaultEcsDisk", EcsDiskArgs.builder()
                .zoneId(default_.zones()[0].id())
                .size(500)
                .build());
    
            var defaultEcsAutoSnapshotPolicyAttachment = new EcsAutoSnapshotPolicyAttachment("defaultEcsAutoSnapshotPolicyAttachment", EcsAutoSnapshotPolicyAttachmentArgs.builder()
                .autoSnapshotPolicyId(defaultAutoSnapshotPolicy.id())
                .diskId(defaultEcsDisk.id())
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      defaultAutoSnapshotPolicy:
        type: alicloud:ecs:AutoSnapshotPolicy
        name: default
        properties:
          autoSnapshotPolicyName: ${name}
          repeatWeekdays:
            - '1'
            - '2'
            - '3'
          retentionDays: 1
          timePoints:
            - '1'
            - '2'
            - '3'
      defaultEcsDisk:
        type: alicloud:ecs:EcsDisk
        name: default
        properties:
          zoneId: ${default.zones[0].id}
          size: '500'
      defaultEcsAutoSnapshotPolicyAttachment:
        type: alicloud:ecs:EcsAutoSnapshotPolicyAttachment
        name: default
        properties:
          autoSnapshotPolicyId: ${defaultAutoSnapshotPolicy.id}
          diskId: ${defaultEcsDisk.id}
    variables:
      default:
        fn::invoke:
          function: alicloud:getZones
          arguments:
            availableResourceCreation: VSwitch
    

    📚 Need more examples? VIEW MORE EXAMPLES

    Create EcsAutoSnapshotPolicyAttachment Resource

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

    Constructor syntax

    new EcsAutoSnapshotPolicyAttachment(name: string, args: EcsAutoSnapshotPolicyAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def EcsAutoSnapshotPolicyAttachment(resource_name: str,
                                        args: EcsAutoSnapshotPolicyAttachmentArgs,
                                        opts: Optional[ResourceOptions] = None)
    
    @overload
    def EcsAutoSnapshotPolicyAttachment(resource_name: str,
                                        opts: Optional[ResourceOptions] = None,
                                        auto_snapshot_policy_id: Optional[str] = None,
                                        disk_id: Optional[str] = None)
    func NewEcsAutoSnapshotPolicyAttachment(ctx *Context, name string, args EcsAutoSnapshotPolicyAttachmentArgs, opts ...ResourceOption) (*EcsAutoSnapshotPolicyAttachment, error)
    public EcsAutoSnapshotPolicyAttachment(string name, EcsAutoSnapshotPolicyAttachmentArgs args, CustomResourceOptions? opts = null)
    public EcsAutoSnapshotPolicyAttachment(String name, EcsAutoSnapshotPolicyAttachmentArgs args)
    public EcsAutoSnapshotPolicyAttachment(String name, EcsAutoSnapshotPolicyAttachmentArgs args, CustomResourceOptions options)
    
    type: alicloud:ecs:EcsAutoSnapshotPolicyAttachment
    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 EcsAutoSnapshotPolicyAttachmentArgs
    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 EcsAutoSnapshotPolicyAttachmentArgs
    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 EcsAutoSnapshotPolicyAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args EcsAutoSnapshotPolicyAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args EcsAutoSnapshotPolicyAttachmentArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var ecsAutoSnapshotPolicyAttachmentResource = new AliCloud.Ecs.EcsAutoSnapshotPolicyAttachment("ecsAutoSnapshotPolicyAttachmentResource", new()
    {
        AutoSnapshotPolicyId = "string",
        DiskId = "string",
    });
    
    example, err := ecs.NewEcsAutoSnapshotPolicyAttachment(ctx, "ecsAutoSnapshotPolicyAttachmentResource", &ecs.EcsAutoSnapshotPolicyAttachmentArgs{
    	AutoSnapshotPolicyId: pulumi.String("string"),
    	DiskId:               pulumi.String("string"),
    })
    
    var ecsAutoSnapshotPolicyAttachmentResource = new EcsAutoSnapshotPolicyAttachment("ecsAutoSnapshotPolicyAttachmentResource", EcsAutoSnapshotPolicyAttachmentArgs.builder()
        .autoSnapshotPolicyId("string")
        .diskId("string")
        .build());
    
    ecs_auto_snapshot_policy_attachment_resource = alicloud.ecs.EcsAutoSnapshotPolicyAttachment("ecsAutoSnapshotPolicyAttachmentResource",
        auto_snapshot_policy_id="string",
        disk_id="string")
    
    const ecsAutoSnapshotPolicyAttachmentResource = new alicloud.ecs.EcsAutoSnapshotPolicyAttachment("ecsAutoSnapshotPolicyAttachmentResource", {
        autoSnapshotPolicyId: "string",
        diskId: "string",
    });
    
    type: alicloud:ecs:EcsAutoSnapshotPolicyAttachment
    properties:
        autoSnapshotPolicyId: string
        diskId: string
    

    EcsAutoSnapshotPolicyAttachment 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 EcsAutoSnapshotPolicyAttachment resource accepts the following input properties:

    AutoSnapshotPolicyId string
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    DiskId string
    The ID of the disk.
    AutoSnapshotPolicyId string
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    DiskId string
    The ID of the disk.
    autoSnapshotPolicyId String
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    diskId String
    The ID of the disk.
    autoSnapshotPolicyId string
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    diskId string
    The ID of the disk.
    auto_snapshot_policy_id str
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    disk_id str
    The ID of the disk.
    autoSnapshotPolicyId String
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    diskId String
    The ID of the disk.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    RegionId string
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.
    Id string
    The provider-assigned unique ID for this managed resource.
    RegionId string
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.
    id String
    The provider-assigned unique ID for this managed resource.
    regionId String
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.
    id string
    The provider-assigned unique ID for this managed resource.
    regionId string
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.
    id str
    The provider-assigned unique ID for this managed resource.
    region_id str
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.
    id String
    The provider-assigned unique ID for this managed resource.
    regionId String
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.

    Look up Existing EcsAutoSnapshotPolicyAttachment Resource

    Get an existing EcsAutoSnapshotPolicyAttachment 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?: EcsAutoSnapshotPolicyAttachmentState, opts?: CustomResourceOptions): EcsAutoSnapshotPolicyAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            auto_snapshot_policy_id: Optional[str] = None,
            disk_id: Optional[str] = None,
            region_id: Optional[str] = None) -> EcsAutoSnapshotPolicyAttachment
    func GetEcsAutoSnapshotPolicyAttachment(ctx *Context, name string, id IDInput, state *EcsAutoSnapshotPolicyAttachmentState, opts ...ResourceOption) (*EcsAutoSnapshotPolicyAttachment, error)
    public static EcsAutoSnapshotPolicyAttachment Get(string name, Input<string> id, EcsAutoSnapshotPolicyAttachmentState? state, CustomResourceOptions? opts = null)
    public static EcsAutoSnapshotPolicyAttachment get(String name, Output<String> id, EcsAutoSnapshotPolicyAttachmentState state, CustomResourceOptions options)
    resources:  _:    type: alicloud:ecs:EcsAutoSnapshotPolicyAttachment    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:
    AutoSnapshotPolicyId string
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    DiskId string
    The ID of the disk.
    RegionId string
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.
    AutoSnapshotPolicyId string
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    DiskId string
    The ID of the disk.
    RegionId string
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.
    autoSnapshotPolicyId String
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    diskId String
    The ID of the disk.
    regionId String
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.
    autoSnapshotPolicyId string
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    diskId string
    The ID of the disk.
    regionId string
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.
    auto_snapshot_policy_id str
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    disk_id str
    The ID of the disk.
    region_id str
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.
    autoSnapshotPolicyId String
    The ID of the automatic snapshot policy that is applied to the cloud disk.
    diskId String
    The ID of the disk.
    regionId String
    (Available since v1.271.0) The ID of the region where the automatic snapshot policy and the cloud disk are located.

    Import

    ECS Auto Snapshot Policy Attachment can be imported using the id, e.g.

    $ pulumi import alicloud:ecs/ecsAutoSnapshotPolicyAttachment:EcsAutoSnapshotPolicyAttachment example <auto_snapshot_policy_id>:<disk_id>
    

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

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo
    Alibaba Cloud v3.95.0 published on Thursday, Feb 12, 2026 by Pulumi
      Meet Neo: Your AI Platform Teammate