1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. ecs
  5. EcsAutoSnapshotPolicyAttachment
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.ecs.EcsAutoSnapshotPolicyAttachment

Explore with Pulumi AI

Provides a ECS Auto Snapshot Policy Attachment resource.

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

NOTE: Available in v1.122.0+.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const example = alicloud.getZones({
    availableResourceCreation: "VSwitch",
});
const exampleKey = new alicloud.kms.Key("example", {
    description: "terraform-example",
    pendingWindowInDays: 7,
    status: "Enabled",
});
const exampleAutoSnapshotPolicy = new alicloud.ecs.AutoSnapshotPolicy("example", {
    name: "terraform-example",
    repeatWeekdays: [
        "1",
        "2",
        "3",
    ],
    retentionDays: -1,
    timePoints: [
        "1",
        "22",
        "23",
    ],
});
const exampleEcsDisk = new alicloud.ecs.EcsDisk("example", {
    zoneId: example.then(example => example.zones?.[0]?.id),
    diskName: "terraform-example",
    description: "Hello ecs disk.",
    category: "cloud_efficiency",
    size: 30,
    encrypted: true,
    kmsKeyId: exampleKey.id,
    tags: {
        Name: "terraform-example",
    },
});
const exampleEcsAutoSnapshotPolicyAttachment = new alicloud.ecs.EcsAutoSnapshotPolicyAttachment("example", {
    autoSnapshotPolicyId: exampleAutoSnapshotPolicy.id,
    diskId: exampleEcsDisk.id,
});
Copy
import pulumi
import pulumi_alicloud as alicloud

example = alicloud.get_zones(available_resource_creation="VSwitch")
example_key = alicloud.kms.Key("example",
    description="terraform-example",
    pending_window_in_days=7,
    status="Enabled")
example_auto_snapshot_policy = alicloud.ecs.AutoSnapshotPolicy("example",
    name="terraform-example",
    repeat_weekdays=[
        "1",
        "2",
        "3",
    ],
    retention_days=-1,
    time_points=[
        "1",
        "22",
        "23",
    ])
example_ecs_disk = alicloud.ecs.EcsDisk("example",
    zone_id=example.zones[0].id,
    disk_name="terraform-example",
    description="Hello ecs disk.",
    category="cloud_efficiency",
    size=30,
    encrypted=True,
    kms_key_id=example_key.id,
    tags={
        "Name": "terraform-example",
    })
example_ecs_auto_snapshot_policy_attachment = alicloud.ecs.EcsAutoSnapshotPolicyAttachment("example",
    auto_snapshot_policy_id=example_auto_snapshot_policy.id,
    disk_id=example_ecs_disk.id)
Copy
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-alicloud/sdk/v3/go/alicloud/kms"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		example, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
			AvailableResourceCreation: pulumi.StringRef("VSwitch"),
		}, nil)
		if err != nil {
			return err
		}
		exampleKey, err := kms.NewKey(ctx, "example", &kms.KeyArgs{
			Description:         pulumi.String("terraform-example"),
			PendingWindowInDays: pulumi.Int(7),
			Status:              pulumi.String("Enabled"),
		})
		if err != nil {
			return err
		}
		exampleAutoSnapshotPolicy, err := ecs.NewAutoSnapshotPolicy(ctx, "example", &ecs.AutoSnapshotPolicyArgs{
			Name: pulumi.String("terraform-example"),
			RepeatWeekdays: pulumi.StringArray{
				pulumi.String("1"),
				pulumi.String("2"),
				pulumi.String("3"),
			},
			RetentionDays: pulumi.Int(-1),
			TimePoints: pulumi.StringArray{
				pulumi.String("1"),
				pulumi.String("22"),
				pulumi.String("23"),
			},
		})
		if err != nil {
			return err
		}
		exampleEcsDisk, err := ecs.NewEcsDisk(ctx, "example", &ecs.EcsDiskArgs{
			ZoneId:      pulumi.String(example.Zones[0].Id),
			DiskName:    pulumi.String("terraform-example"),
			Description: pulumi.String("Hello ecs disk."),
			Category:    pulumi.String("cloud_efficiency"),
			Size:        pulumi.Int(30),
			Encrypted:   pulumi.Bool(true),
			KmsKeyId:    exampleKey.ID(),
			Tags: pulumi.StringMap{
				"Name": pulumi.String("terraform-example"),
			},
		})
		if err != nil {
			return err
		}
		_, err = ecs.NewEcsAutoSnapshotPolicyAttachment(ctx, "example", &ecs.EcsAutoSnapshotPolicyAttachmentArgs{
			AutoSnapshotPolicyId: exampleAutoSnapshotPolicy.ID(),
			DiskId:               exampleEcsDisk.ID(),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var example = AliCloud.GetZones.Invoke(new()
    {
        AvailableResourceCreation = "VSwitch",
    });

    var exampleKey = new AliCloud.Kms.Key("example", new()
    {
        Description = "terraform-example",
        PendingWindowInDays = 7,
        Status = "Enabled",
    });

    var exampleAutoSnapshotPolicy = new AliCloud.Ecs.AutoSnapshotPolicy("example", new()
    {
        Name = "terraform-example",
        RepeatWeekdays = new[]
        {
            "1",
            "2",
            "3",
        },
        RetentionDays = -1,
        TimePoints = new[]
        {
            "1",
            "22",
            "23",
        },
    });

    var exampleEcsDisk = new AliCloud.Ecs.EcsDisk("example", new()
    {
        ZoneId = example.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
        DiskName = "terraform-example",
        Description = "Hello ecs disk.",
        Category = "cloud_efficiency",
        Size = 30,
        Encrypted = true,
        KmsKeyId = exampleKey.Id,
        Tags = 
        {
            { "Name", "terraform-example" },
        },
    });

    var exampleEcsAutoSnapshotPolicyAttachment = new AliCloud.Ecs.EcsAutoSnapshotPolicyAttachment("example", new()
    {
        AutoSnapshotPolicyId = exampleAutoSnapshotPolicy.Id,
        DiskId = exampleEcsDisk.Id,
    });

});
Copy
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.kms.Key;
import com.pulumi.alicloud.kms.KeyArgs;
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 example = AlicloudFunctions.getZones(GetZonesArgs.builder()
            .availableResourceCreation("VSwitch")
            .build());

        var exampleKey = new Key("exampleKey", KeyArgs.builder()
            .description("terraform-example")
            .pendingWindowInDays("7")
            .status("Enabled")
            .build());

        var exampleAutoSnapshotPolicy = new AutoSnapshotPolicy("exampleAutoSnapshotPolicy", AutoSnapshotPolicyArgs.builder()
            .name("terraform-example")
            .repeatWeekdays(            
                "1",
                "2",
                "3")
            .retentionDays(-1)
            .timePoints(            
                "1",
                "22",
                "23")
            .build());

        var exampleEcsDisk = new EcsDisk("exampleEcsDisk", EcsDiskArgs.builder()
            .zoneId(example.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
            .diskName("terraform-example")
            .description("Hello ecs disk.")
            .category("cloud_efficiency")
            .size("30")
            .encrypted(true)
            .kmsKeyId(exampleKey.id())
            .tags(Map.of("Name", "terraform-example"))
            .build());

        var exampleEcsAutoSnapshotPolicyAttachment = new EcsAutoSnapshotPolicyAttachment("exampleEcsAutoSnapshotPolicyAttachment", EcsAutoSnapshotPolicyAttachmentArgs.builder()
            .autoSnapshotPolicyId(exampleAutoSnapshotPolicy.id())
            .diskId(exampleEcsDisk.id())
            .build());

    }
}
Copy
resources:
  exampleKey:
    type: alicloud:kms:Key
    name: example
    properties:
      description: terraform-example
      pendingWindowInDays: '7'
      status: Enabled
  exampleAutoSnapshotPolicy:
    type: alicloud:ecs:AutoSnapshotPolicy
    name: example
    properties:
      name: terraform-example
      repeatWeekdays:
        - '1'
        - '2'
        - '3'
      retentionDays: -1
      timePoints:
        - '1'
        - '22'
        - '23'
  exampleEcsDisk:
    type: alicloud:ecs:EcsDisk
    name: example
    properties:
      zoneId: ${example.zones[0].id}
      diskName: terraform-example
      description: Hello ecs disk.
      category: cloud_efficiency
      size: '30'
      encrypted: true
      kmsKeyId: ${exampleKey.id}
      tags:
        Name: terraform-example
  exampleEcsAutoSnapshotPolicyAttachment:
    type: alicloud:ecs:EcsAutoSnapshotPolicyAttachment
    name: example
    properties:
      autoSnapshotPolicyId: ${exampleAutoSnapshotPolicy.id}
      diskId: ${exampleEcsDisk.id}
variables:
  example:
    fn::invoke:
      function: alicloud:getZones
      arguments:
        availableResourceCreation: VSwitch
Copy

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 This property is required. string
The unique name of the resource.
args This property is required. EcsAutoSnapshotPolicyAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. 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 This property is required. string
The unique name of the resource.
args This property is required. EcsAutoSnapshotPolicyAttachmentArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. EcsAutoSnapshotPolicyAttachmentArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. 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",
});
Copy
example, err := ecs.NewEcsAutoSnapshotPolicyAttachment(ctx, "ecsAutoSnapshotPolicyAttachmentResource", &ecs.EcsAutoSnapshotPolicyAttachmentArgs{
	AutoSnapshotPolicyId: pulumi.String("string"),
	DiskId:               pulumi.String("string"),
})
Copy
var ecsAutoSnapshotPolicyAttachmentResource = new EcsAutoSnapshotPolicyAttachment("ecsAutoSnapshotPolicyAttachmentResource", EcsAutoSnapshotPolicyAttachmentArgs.builder()
    .autoSnapshotPolicyId("string")
    .diskId("string")
    .build());
Copy
ecs_auto_snapshot_policy_attachment_resource = alicloud.ecs.EcsAutoSnapshotPolicyAttachment("ecsAutoSnapshotPolicyAttachmentResource",
    auto_snapshot_policy_id="string",
    disk_id="string")
Copy
const ecsAutoSnapshotPolicyAttachmentResource = new alicloud.ecs.EcsAutoSnapshotPolicyAttachment("ecsAutoSnapshotPolicyAttachmentResource", {
    autoSnapshotPolicyId: "string",
    diskId: "string",
});
Copy
type: alicloud:ecs:EcsAutoSnapshotPolicyAttachment
properties:
    autoSnapshotPolicyId: string
    diskId: string
Copy

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
This property is required.
Changes to this property will trigger replacement.
string
The auto snapshot policy id.
DiskId
This property is required.
Changes to this property will trigger replacement.
string
The disk id.
AutoSnapshotPolicyId
This property is required.
Changes to this property will trigger replacement.
string
The auto snapshot policy id.
DiskId
This property is required.
Changes to this property will trigger replacement.
string
The disk id.
autoSnapshotPolicyId
This property is required.
Changes to this property will trigger replacement.
String
The auto snapshot policy id.
diskId
This property is required.
Changes to this property will trigger replacement.
String
The disk id.
autoSnapshotPolicyId
This property is required.
Changes to this property will trigger replacement.
string
The auto snapshot policy id.
diskId
This property is required.
Changes to this property will trigger replacement.
string
The disk id.
auto_snapshot_policy_id
This property is required.
Changes to this property will trigger replacement.
str
The auto snapshot policy id.
disk_id
This property is required.
Changes to this property will trigger replacement.
str
The disk id.
autoSnapshotPolicyId
This property is required.
Changes to this property will trigger replacement.
String
The auto snapshot policy id.
diskId
This property is required.
Changes to this property will trigger replacement.
String
The disk id.

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.
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 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) -> 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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 This property is required.
The unique name of the resulting resource.
id This property is required.
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 Changes to this property will trigger replacement. string
The auto snapshot policy id.
DiskId Changes to this property will trigger replacement. string
The disk id.
AutoSnapshotPolicyId Changes to this property will trigger replacement. string
The auto snapshot policy id.
DiskId Changes to this property will trigger replacement. string
The disk id.
autoSnapshotPolicyId Changes to this property will trigger replacement. String
The auto snapshot policy id.
diskId Changes to this property will trigger replacement. String
The disk id.
autoSnapshotPolicyId Changes to this property will trigger replacement. string
The auto snapshot policy id.
diskId Changes to this property will trigger replacement. string
The disk id.
auto_snapshot_policy_id Changes to this property will trigger replacement. str
The auto snapshot policy id.
disk_id Changes to this property will trigger replacement. str
The disk id.
autoSnapshotPolicyId Changes to this property will trigger replacement. String
The auto snapshot policy id.
diskId Changes to this property will trigger replacement. String
The disk id.

Import

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

$ pulumi import alicloud:ecs/ecsAutoSnapshotPolicyAttachment:EcsAutoSnapshotPolicyAttachment example s-abcd12345:d-abcd12345
Copy

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.