1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. ecs
  5. EcsAutoSnapshotPolicyAttachment
Alibaba Cloud v3.57.0 published on Saturday, Jun 15, 2024 by Pulumi

alicloud.ecs.EcsAutoSnapshotPolicyAttachment

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.57.0 published on Saturday, Jun 15, 2024 by Pulumi

    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,
    });
    
    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)
    
    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: -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.Map{
    				"Name": pulumi.Any("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
    	})
    }
    
    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,
        });
    
    });
    
    Coming soon!
    
    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
    

    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.

    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

    The EcsAutoSnapshotPolicyAttachment resource accepts the following input properties:

    AutoSnapshotPolicyId string
    The auto snapshot policy id.
    DiskId string
    The disk id.
    AutoSnapshotPolicyId string
    The auto snapshot policy id.
    DiskId string
    The disk id.
    autoSnapshotPolicyId String
    The auto snapshot policy id.
    diskId String
    The disk id.
    autoSnapshotPolicyId string
    The auto snapshot policy id.
    diskId string
    The disk id.
    auto_snapshot_policy_id str
    The auto snapshot policy id.
    disk_id str
    The disk id.
    autoSnapshotPolicyId String
    The auto snapshot policy id.
    diskId 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)
    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:
    AutoSnapshotPolicyId string
    The auto snapshot policy id.
    DiskId string
    The disk id.
    AutoSnapshotPolicyId string
    The auto snapshot policy id.
    DiskId string
    The disk id.
    autoSnapshotPolicyId String
    The auto snapshot policy id.
    diskId String
    The disk id.
    autoSnapshotPolicyId string
    The auto snapshot policy id.
    diskId string
    The disk id.
    auto_snapshot_policy_id str
    The auto snapshot policy id.
    disk_id str
    The disk id.
    autoSnapshotPolicyId String
    The auto snapshot policy id.
    diskId 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
    

    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.57.0 published on Saturday, Jun 15, 2024 by Pulumi