1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. simpleapplicationserver
  5. CustomImage
Alibaba Cloud v3.53.0 published on Wednesday, Apr 17, 2024 by Pulumi

alicloud.simpleapplicationserver.CustomImage

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.53.0 published on Wednesday, Apr 17, 2024 by Pulumi

    Provides a Simple Application Server Custom Image resource.

    For information about Simple Application Server Custom Image and how to use it, see What is Custom Image.

    NOTE: Available since v1.143.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") || "tf_example";
    const defaultImages = alicloud.simpleapplicationserver.getImages({});
    const defaultServerPlans = alicloud.simpleapplicationserver.getServerPlans({});
    const defaultInstance = new alicloud.simpleapplicationserver.Instance("defaultInstance", {
        paymentType: "Subscription",
        planId: defaultServerPlans.then(defaultServerPlans => defaultServerPlans.plans?.[0]?.id),
        instanceName: name,
        imageId: defaultImages.then(defaultImages => defaultImages.images?.[0]?.id),
        period: 1,
        dataDiskSize: 100,
    });
    const defaultServerDisks = alicloud.simpleapplicationserver.getServerDisksOutput({
        instanceId: defaultInstance.id,
    });
    const defaultSnapshot = new alicloud.simpleapplicationserver.Snapshot("defaultSnapshot", {
        diskId: defaultServerDisks.apply(defaultServerDisks => defaultServerDisks.ids?.[0]),
        snapshotName: name,
    });
    const defaultCustomImage = new alicloud.simpleapplicationserver.CustomImage("defaultCustomImage", {
        customImageName: name,
        instanceId: defaultInstance.id,
        systemSnapshotId: defaultSnapshot.id,
        status: "Share",
        description: name,
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "tf_example"
    default_images = alicloud.simpleapplicationserver.get_images()
    default_server_plans = alicloud.simpleapplicationserver.get_server_plans()
    default_instance = alicloud.simpleapplicationserver.Instance("defaultInstance",
        payment_type="Subscription",
        plan_id=default_server_plans.plans[0].id,
        instance_name=name,
        image_id=default_images.images[0].id,
        period=1,
        data_disk_size=100)
    default_server_disks = alicloud.simpleapplicationserver.get_server_disks_output(instance_id=default_instance.id)
    default_snapshot = alicloud.simpleapplicationserver.Snapshot("defaultSnapshot",
        disk_id=default_server_disks.ids[0],
        snapshot_name=name)
    default_custom_image = alicloud.simpleapplicationserver.CustomImage("defaultCustomImage",
        custom_image_name=name,
        instance_id=default_instance.id,
        system_snapshot_id=default_snapshot.id,
        status="Share",
        description=name)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/simpleapplicationserver"
    	"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 := "tf_example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		defaultImages, err := simpleapplicationserver.GetImages(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		defaultServerPlans, err := simpleapplicationserver.GetServerPlans(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		defaultInstance, err := simpleapplicationserver.NewInstance(ctx, "defaultInstance", &simpleapplicationserver.InstanceArgs{
    			PaymentType:  pulumi.String("Subscription"),
    			PlanId:       pulumi.String(defaultServerPlans.Plans[0].Id),
    			InstanceName: pulumi.String(name),
    			ImageId:      pulumi.String(defaultImages.Images[0].Id),
    			Period:       pulumi.Int(1),
    			DataDiskSize: pulumi.Int(100),
    		})
    		if err != nil {
    			return err
    		}
    		defaultServerDisks := simpleapplicationserver.GetServerDisksOutput(ctx, simpleapplicationserver.GetServerDisksOutputArgs{
    			InstanceId: defaultInstance.ID(),
    		}, nil)
    		defaultSnapshot, err := simpleapplicationserver.NewSnapshot(ctx, "defaultSnapshot", &simpleapplicationserver.SnapshotArgs{
    			DiskId: defaultServerDisks.ApplyT(func(defaultServerDisks simpleapplicationserver.GetServerDisksResult) (*string, error) {
    				return &defaultServerDisks.Ids[0], nil
    			}).(pulumi.StringPtrOutput),
    			SnapshotName: pulumi.String(name),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = simpleapplicationserver.NewCustomImage(ctx, "defaultCustomImage", &simpleapplicationserver.CustomImageArgs{
    			CustomImageName:  pulumi.String(name),
    			InstanceId:       defaultInstance.ID(),
    			SystemSnapshotId: defaultSnapshot.ID(),
    			Status:           pulumi.String("Share"),
    			Description:      pulumi.String(name),
    		})
    		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") ?? "tf_example";
        var defaultImages = AliCloud.SimpleApplicationServer.GetImages.Invoke();
    
        var defaultServerPlans = AliCloud.SimpleApplicationServer.GetServerPlans.Invoke();
    
        var defaultInstance = new AliCloud.SimpleApplicationServer.Instance("defaultInstance", new()
        {
            PaymentType = "Subscription",
            PlanId = defaultServerPlans.Apply(getServerPlansResult => getServerPlansResult.Plans[0]?.Id),
            InstanceName = name,
            ImageId = defaultImages.Apply(getImagesResult => getImagesResult.Images[0]?.Id),
            Period = 1,
            DataDiskSize = 100,
        });
    
        var defaultServerDisks = AliCloud.SimpleApplicationServer.GetServerDisks.Invoke(new()
        {
            InstanceId = defaultInstance.Id,
        });
    
        var defaultSnapshot = new AliCloud.SimpleApplicationServer.Snapshot("defaultSnapshot", new()
        {
            DiskId = defaultServerDisks.Apply(getServerDisksResult => getServerDisksResult.Ids[0]),
            SnapshotName = name,
        });
    
        var defaultCustomImage = new AliCloud.SimpleApplicationServer.CustomImage("defaultCustomImage", new()
        {
            CustomImageName = name,
            InstanceId = defaultInstance.Id,
            SystemSnapshotId = defaultSnapshot.Id,
            Status = "Share",
            Description = name,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.simpleapplicationserver.SimpleapplicationserverFunctions;
    import com.pulumi.alicloud.simpleapplicationserver.inputs.GetImagesArgs;
    import com.pulumi.alicloud.simpleapplicationserver.inputs.GetServerPlansArgs;
    import com.pulumi.alicloud.simpleapplicationserver.Instance;
    import com.pulumi.alicloud.simpleapplicationserver.InstanceArgs;
    import com.pulumi.alicloud.simpleapplicationserver.inputs.GetServerDisksArgs;
    import com.pulumi.alicloud.simpleapplicationserver.Snapshot;
    import com.pulumi.alicloud.simpleapplicationserver.SnapshotArgs;
    import com.pulumi.alicloud.simpleapplicationserver.CustomImage;
    import com.pulumi.alicloud.simpleapplicationserver.CustomImageArgs;
    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("tf_example");
            final var defaultImages = SimpleapplicationserverFunctions.getImages();
    
            final var defaultServerPlans = SimpleapplicationserverFunctions.getServerPlans();
    
            var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()        
                .paymentType("Subscription")
                .planId(defaultServerPlans.applyValue(getServerPlansResult -> getServerPlansResult.plans()[0].id()))
                .instanceName(name)
                .imageId(defaultImages.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
                .period(1)
                .dataDiskSize(100)
                .build());
    
            final var defaultServerDisks = SimpleapplicationserverFunctions.getServerDisks(GetServerDisksArgs.builder()
                .instanceId(defaultInstance.id())
                .build());
    
            var defaultSnapshot = new Snapshot("defaultSnapshot", SnapshotArgs.builder()        
                .diskId(defaultServerDisks.applyValue(getServerDisksResult -> getServerDisksResult).applyValue(defaultServerDisks -> defaultServerDisks.applyValue(getServerDisksResult -> getServerDisksResult.ids()[0])))
                .snapshotName(name)
                .build());
    
            var defaultCustomImage = new CustomImage("defaultCustomImage", CustomImageArgs.builder()        
                .customImageName(name)
                .instanceId(defaultInstance.id())
                .systemSnapshotId(defaultSnapshot.id())
                .status("Share")
                .description(name)
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: tf_example
    resources:
      defaultInstance:
        type: alicloud:simpleapplicationserver:Instance
        properties:
          paymentType: Subscription
          planId: ${defaultServerPlans.plans[0].id}
          instanceName: ${name}
          imageId: ${defaultImages.images[0].id}
          period: 1
          dataDiskSize: 100
      defaultSnapshot:
        type: alicloud:simpleapplicationserver:Snapshot
        properties:
          diskId: ${defaultServerDisks.ids[0]}
          snapshotName: ${name}
      defaultCustomImage:
        type: alicloud:simpleapplicationserver:CustomImage
        properties:
          customImageName: ${name}
          instanceId: ${defaultInstance.id}
          systemSnapshotId: ${defaultSnapshot.id}
          status: Share
          description: ${name}
    variables:
      defaultImages:
        fn::invoke:
          Function: alicloud:simpleapplicationserver:getImages
          Arguments: {}
      defaultServerPlans:
        fn::invoke:
          Function: alicloud:simpleapplicationserver:getServerPlans
          Arguments: {}
      defaultServerDisks:
        fn::invoke:
          Function: alicloud:simpleapplicationserver:getServerDisks
          Arguments:
            instanceId: ${defaultInstance.id}
    

    Create CustomImage Resource

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

    Constructor syntax

    new CustomImage(name: string, args: CustomImageArgs, opts?: CustomResourceOptions);
    @overload
    def CustomImage(resource_name: str,
                    args: CustomImageArgs,
                    opts: Optional[ResourceOptions] = None)
    
    @overload
    def CustomImage(resource_name: str,
                    opts: Optional[ResourceOptions] = None,
                    custom_image_name: Optional[str] = None,
                    instance_id: Optional[str] = None,
                    system_snapshot_id: Optional[str] = None,
                    description: Optional[str] = None,
                    status: Optional[str] = None)
    func NewCustomImage(ctx *Context, name string, args CustomImageArgs, opts ...ResourceOption) (*CustomImage, error)
    public CustomImage(string name, CustomImageArgs args, CustomResourceOptions? opts = null)
    public CustomImage(String name, CustomImageArgs args)
    public CustomImage(String name, CustomImageArgs args, CustomResourceOptions options)
    
    type: alicloud:simpleapplicationserver:CustomImage
    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 CustomImageArgs
    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 CustomImageArgs
    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 CustomImageArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args CustomImageArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args CustomImageArgs
    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 customImageResource = new AliCloud.SimpleApplicationServer.CustomImage("customImageResource", new()
    {
        CustomImageName = "string",
        InstanceId = "string",
        SystemSnapshotId = "string",
        Description = "string",
        Status = "string",
    });
    
    example, err := simpleapplicationserver.NewCustomImage(ctx, "customImageResource", &simpleapplicationserver.CustomImageArgs{
    	CustomImageName:  pulumi.String("string"),
    	InstanceId:       pulumi.String("string"),
    	SystemSnapshotId: pulumi.String("string"),
    	Description:      pulumi.String("string"),
    	Status:           pulumi.String("string"),
    })
    
    var customImageResource = new CustomImage("customImageResource", CustomImageArgs.builder()        
        .customImageName("string")
        .instanceId("string")
        .systemSnapshotId("string")
        .description("string")
        .status("string")
        .build());
    
    custom_image_resource = alicloud.simpleapplicationserver.CustomImage("customImageResource",
        custom_image_name="string",
        instance_id="string",
        system_snapshot_id="string",
        description="string",
        status="string")
    
    const customImageResource = new alicloud.simpleapplicationserver.CustomImage("customImageResource", {
        customImageName: "string",
        instanceId: "string",
        systemSnapshotId: "string",
        description: "string",
        status: "string",
    });
    
    type: alicloud:simpleapplicationserver:CustomImage
    properties:
        customImageName: string
        description: string
        instanceId: string
        status: string
        systemSnapshotId: string
    

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

    CustomImageName string
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    InstanceId string
    The ID of the instance.
    SystemSnapshotId string
    The ID of the system snapshot.
    Description string
    The description of the Custom Image.
    Status string

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    CustomImageName string
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    InstanceId string
    The ID of the instance.
    SystemSnapshotId string
    The ID of the system snapshot.
    Description string
    The description of the Custom Image.
    Status string

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    customImageName String
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    instanceId String
    The ID of the instance.
    systemSnapshotId String
    The ID of the system snapshot.
    description String
    The description of the Custom Image.
    status String

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    customImageName string
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    instanceId string
    The ID of the instance.
    systemSnapshotId string
    The ID of the system snapshot.
    description string
    The description of the Custom Image.
    status string

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    custom_image_name str
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    instance_id str
    The ID of the instance.
    system_snapshot_id str
    The ID of the system snapshot.
    description str
    The description of the Custom Image.
    status str

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    customImageName String
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    instanceId String
    The ID of the instance.
    systemSnapshotId String
    The ID of the system snapshot.
    description String
    The description of the Custom Image.
    status String

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the CustomImage 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 CustomImage Resource

    Get an existing CustomImage 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?: CustomImageState, opts?: CustomResourceOptions): CustomImage
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            custom_image_name: Optional[str] = None,
            description: Optional[str] = None,
            instance_id: Optional[str] = None,
            status: Optional[str] = None,
            system_snapshot_id: Optional[str] = None) -> CustomImage
    func GetCustomImage(ctx *Context, name string, id IDInput, state *CustomImageState, opts ...ResourceOption) (*CustomImage, error)
    public static CustomImage Get(string name, Input<string> id, CustomImageState? state, CustomResourceOptions? opts = null)
    public static CustomImage get(String name, Output<String> id, CustomImageState 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:
    CustomImageName string
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    Description string
    The description of the Custom Image.
    InstanceId string
    The ID of the instance.
    Status string

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    SystemSnapshotId string
    The ID of the system snapshot.
    CustomImageName string
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    Description string
    The description of the Custom Image.
    InstanceId string
    The ID of the instance.
    Status string

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    SystemSnapshotId string
    The ID of the system snapshot.
    customImageName String
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    description String
    The description of the Custom Image.
    instanceId String
    The ID of the instance.
    status String

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    systemSnapshotId String
    The ID of the system snapshot.
    customImageName string
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    description string
    The description of the Custom Image.
    instanceId string
    The ID of the instance.
    status string

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    systemSnapshotId string
    The ID of the system snapshot.
    custom_image_name str
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    description str
    The description of the Custom Image.
    instance_id str
    The ID of the instance.
    status str

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    system_snapshot_id str
    The ID of the system snapshot.
    customImageName String
    The name of the resource. The name must be 2 to 128 characters in length. It must start with a letter or a number. It can contain letters, digits, colons (:), underscores (_) and hyphens (-).
    description String
    The description of the Custom Image.
    instanceId String
    The ID of the instance.
    status String

    The Shared status of the Custom Image. Valid values: Share, UnShare.

    NOTE: The status will be automatically change to UnShare when the resource is deleted, please operate with caution.

    systemSnapshotId String
    The ID of the system snapshot.

    Import

    Simple Application Server Custom Image can be imported using the id, e.g.

    $ pulumi import alicloud:simpleapplicationserver/customImage:CustomImage example <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.53.0 published on Wednesday, Apr 17, 2024 by Pulumi