1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. ens
  5. InstanceSecurityGroupAttachment
Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi

alicloud.ens.InstanceSecurityGroupAttachment

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.57.1 published on Wednesday, Jun 26, 2024 by Pulumi

    Provides a ENS Instance Security Group Attachment resource. Unbind instance and security group.

    For information about ENS Instance Security Group Attachment and how to use it, see What is Instance Security Group Attachment.

    NOTE: Available since v1.216.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 = new alicloud.ens.Instance("default", {
        systemDisk: {
            size: 20,
        },
        scheduleAreaLevel: "Region",
        imageId: "centos_6_08_64_20G_alibase_20171208",
        paymentType: "Subscription",
        instanceType: "ens.sn1.stiny",
        password: "12345678ABCabc",
        amount: 1,
        period: 1,
        internetMaxBandwidthOut: 10,
        publicIpIdentification: true,
        ensRegionId: "cn-chenzhou-telecom_unicom_cmcc",
        periodUnit: "Month",
    });
    const defaultSecurityGroup = new alicloud.ens.SecurityGroup("default", {
        description: "InstanceSecurityGroupAttachment_Description",
        securityGroupName: name,
    });
    const defaultInstanceSecurityGroupAttachment = new alicloud.ens.InstanceSecurityGroupAttachment("default", {
        instanceId: _default.id,
        securityGroupId: defaultSecurityGroup.id,
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default = alicloud.ens.Instance("default",
        system_disk=alicloud.ens.InstanceSystemDiskArgs(
            size=20,
        ),
        schedule_area_level="Region",
        image_id="centos_6_08_64_20G_alibase_20171208",
        payment_type="Subscription",
        instance_type="ens.sn1.stiny",
        password="12345678ABCabc",
        amount=1,
        period=1,
        internet_max_bandwidth_out=10,
        public_ip_identification=True,
        ens_region_id="cn-chenzhou-telecom_unicom_cmcc",
        period_unit="Month")
    default_security_group = alicloud.ens.SecurityGroup("default",
        description="InstanceSecurityGroupAttachment_Description",
        security_group_name=name)
    default_instance_security_group_attachment = alicloud.ens.InstanceSecurityGroupAttachment("default",
        instance_id=default.id,
        security_group_id=default_security_group.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ens"
    	"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
    		}
    		_, err := ens.NewInstance(ctx, "default", &ens.InstanceArgs{
    			SystemDisk: &ens.InstanceSystemDiskArgs{
    				Size: pulumi.Int(20),
    			},
    			ScheduleAreaLevel:       pulumi.String("Region"),
    			ImageId:                 pulumi.String("centos_6_08_64_20G_alibase_20171208"),
    			PaymentType:             pulumi.String("Subscription"),
    			InstanceType:            pulumi.String("ens.sn1.stiny"),
    			Password:                pulumi.String("12345678ABCabc"),
    			Amount:                  pulumi.Int(1),
    			Period:                  pulumi.Int(1),
    			InternetMaxBandwidthOut: pulumi.Int(10),
    			PublicIpIdentification:  pulumi.Bool(true),
    			EnsRegionId:             pulumi.String("cn-chenzhou-telecom_unicom_cmcc"),
    			PeriodUnit:              pulumi.String("Month"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultSecurityGroup, err := ens.NewSecurityGroup(ctx, "default", &ens.SecurityGroupArgs{
    			Description:       pulumi.String("InstanceSecurityGroupAttachment_Description"),
    			SecurityGroupName: pulumi.String(name),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = ens.NewInstanceSecurityGroupAttachment(ctx, "default", &ens.InstanceSecurityGroupAttachmentArgs{
    			InstanceId:      _default.ID(),
    			SecurityGroupId: defaultSecurityGroup.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 = new AliCloud.Ens.Instance("default", new()
        {
            SystemDisk = new AliCloud.Ens.Inputs.InstanceSystemDiskArgs
            {
                Size = 20,
            },
            ScheduleAreaLevel = "Region",
            ImageId = "centos_6_08_64_20G_alibase_20171208",
            PaymentType = "Subscription",
            InstanceType = "ens.sn1.stiny",
            Password = "12345678ABCabc",
            Amount = 1,
            Period = 1,
            InternetMaxBandwidthOut = 10,
            PublicIpIdentification = true,
            EnsRegionId = "cn-chenzhou-telecom_unicom_cmcc",
            PeriodUnit = "Month",
        });
    
        var defaultSecurityGroup = new AliCloud.Ens.SecurityGroup("default", new()
        {
            Description = "InstanceSecurityGroupAttachment_Description",
            SecurityGroupName = name,
        });
    
        var defaultInstanceSecurityGroupAttachment = new AliCloud.Ens.InstanceSecurityGroupAttachment("default", new()
        {
            InstanceId = @default.Id,
            SecurityGroupId = defaultSecurityGroup.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.ens.Instance;
    import com.pulumi.alicloud.ens.InstanceArgs;
    import com.pulumi.alicloud.ens.inputs.InstanceSystemDiskArgs;
    import com.pulumi.alicloud.ens.SecurityGroup;
    import com.pulumi.alicloud.ens.SecurityGroupArgs;
    import com.pulumi.alicloud.ens.InstanceSecurityGroupAttachment;
    import com.pulumi.alicloud.ens.InstanceSecurityGroupAttachmentArgs;
    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");
            var default_ = new Instance("default", InstanceArgs.builder()
                .systemDisk(InstanceSystemDiskArgs.builder()
                    .size("20")
                    .build())
                .scheduleAreaLevel("Region")
                .imageId("centos_6_08_64_20G_alibase_20171208")
                .paymentType("Subscription")
                .instanceType("ens.sn1.stiny")
                .password("12345678ABCabc")
                .amount("1")
                .period("1")
                .internetMaxBandwidthOut("10")
                .publicIpIdentification(true)
                .ensRegionId("cn-chenzhou-telecom_unicom_cmcc")
                .periodUnit("Month")
                .build());
    
            var defaultSecurityGroup = new SecurityGroup("defaultSecurityGroup", SecurityGroupArgs.builder()
                .description("InstanceSecurityGroupAttachment_Description")
                .securityGroupName(name)
                .build());
    
            var defaultInstanceSecurityGroupAttachment = new InstanceSecurityGroupAttachment("defaultInstanceSecurityGroupAttachment", InstanceSecurityGroupAttachmentArgs.builder()
                .instanceId(default_.id())
                .securityGroupId(defaultSecurityGroup.id())
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: terraform-example
    resources:
      default:
        type: alicloud:ens:Instance
        properties:
          systemDisk:
            size: '20'
          scheduleAreaLevel: Region
          imageId: centos_6_08_64_20G_alibase_20171208
          paymentType: Subscription
          instanceType: ens.sn1.stiny
          password: 12345678ABCabc
          amount: '1'
          period: '1'
          internetMaxBandwidthOut: '10'
          publicIpIdentification: true
          ensRegionId: cn-chenzhou-telecom_unicom_cmcc
          periodUnit: Month
      defaultSecurityGroup:
        type: alicloud:ens:SecurityGroup
        name: default
        properties:
          description: InstanceSecurityGroupAttachment_Description
          securityGroupName: ${name}
      defaultInstanceSecurityGroupAttachment:
        type: alicloud:ens:InstanceSecurityGroupAttachment
        name: default
        properties:
          instanceId: ${default.id}
          securityGroupId: ${defaultSecurityGroup.id}
    

    Create InstanceSecurityGroupAttachment Resource

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

    Constructor syntax

    new InstanceSecurityGroupAttachment(name: string, args: InstanceSecurityGroupAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def InstanceSecurityGroupAttachment(resource_name: str,
                                        args: InstanceSecurityGroupAttachmentArgs,
                                        opts: Optional[ResourceOptions] = None)
    
    @overload
    def InstanceSecurityGroupAttachment(resource_name: str,
                                        opts: Optional[ResourceOptions] = None,
                                        security_group_id: Optional[str] = None,
                                        instance_id: Optional[str] = None)
    func NewInstanceSecurityGroupAttachment(ctx *Context, name string, args InstanceSecurityGroupAttachmentArgs, opts ...ResourceOption) (*InstanceSecurityGroupAttachment, error)
    public InstanceSecurityGroupAttachment(string name, InstanceSecurityGroupAttachmentArgs args, CustomResourceOptions? opts = null)
    public InstanceSecurityGroupAttachment(String name, InstanceSecurityGroupAttachmentArgs args)
    public InstanceSecurityGroupAttachment(String name, InstanceSecurityGroupAttachmentArgs args, CustomResourceOptions options)
    
    type: alicloud:ens:InstanceSecurityGroupAttachment
    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 InstanceSecurityGroupAttachmentArgs
    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 InstanceSecurityGroupAttachmentArgs
    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 InstanceSecurityGroupAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args InstanceSecurityGroupAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args InstanceSecurityGroupAttachmentArgs
    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 instanceSecurityGroupAttachmentResource = new AliCloud.Ens.InstanceSecurityGroupAttachment("instanceSecurityGroupAttachmentResource", new()
    {
        SecurityGroupId = "string",
        InstanceId = "string",
    });
    
    example, err := ens.NewInstanceSecurityGroupAttachment(ctx, "instanceSecurityGroupAttachmentResource", &ens.InstanceSecurityGroupAttachmentArgs{
    	SecurityGroupId: pulumi.String("string"),
    	InstanceId:      pulumi.String("string"),
    })
    
    var instanceSecurityGroupAttachmentResource = new InstanceSecurityGroupAttachment("instanceSecurityGroupAttachmentResource", InstanceSecurityGroupAttachmentArgs.builder()
        .securityGroupId("string")
        .instanceId("string")
        .build());
    
    instance_security_group_attachment_resource = alicloud.ens.InstanceSecurityGroupAttachment("instanceSecurityGroupAttachmentResource",
        security_group_id="string",
        instance_id="string")
    
    const instanceSecurityGroupAttachmentResource = new alicloud.ens.InstanceSecurityGroupAttachment("instanceSecurityGroupAttachmentResource", {
        securityGroupId: "string",
        instanceId: "string",
    });
    
    type: alicloud:ens:InstanceSecurityGroupAttachment
    properties:
        instanceId: string
        securityGroupId: string
    

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

    SecurityGroupId string
    Security group ID.
    InstanceId string
    Instance ID.
    SecurityGroupId string
    Security group ID.
    InstanceId string
    Instance ID.
    securityGroupId String
    Security group ID.
    instanceId String
    Instance ID.
    securityGroupId string
    Security group ID.
    instanceId string
    Instance ID.
    security_group_id str
    Security group ID.
    instance_id str
    Instance ID.
    securityGroupId String
    Security group ID.
    instanceId String
    Instance ID.

    Outputs

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

    Get an existing InstanceSecurityGroupAttachment 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?: InstanceSecurityGroupAttachmentState, opts?: CustomResourceOptions): InstanceSecurityGroupAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            instance_id: Optional[str] = None,
            security_group_id: Optional[str] = None) -> InstanceSecurityGroupAttachment
    func GetInstanceSecurityGroupAttachment(ctx *Context, name string, id IDInput, state *InstanceSecurityGroupAttachmentState, opts ...ResourceOption) (*InstanceSecurityGroupAttachment, error)
    public static InstanceSecurityGroupAttachment Get(string name, Input<string> id, InstanceSecurityGroupAttachmentState? state, CustomResourceOptions? opts = null)
    public static InstanceSecurityGroupAttachment get(String name, Output<String> id, InstanceSecurityGroupAttachmentState 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:
    InstanceId string
    Instance ID.
    SecurityGroupId string
    Security group ID.
    InstanceId string
    Instance ID.
    SecurityGroupId string
    Security group ID.
    instanceId String
    Instance ID.
    securityGroupId String
    Security group ID.
    instanceId string
    Instance ID.
    securityGroupId string
    Security group ID.
    instance_id str
    Instance ID.
    security_group_id str
    Security group ID.
    instanceId String
    Instance ID.
    securityGroupId String
    Security group ID.

    Import

    ENS Instance Security Group Attachment can be imported using the id, e.g.

    $ pulumi import alicloud:ens/instanceSecurityGroupAttachment:InstanceSecurityGroupAttachment example <instance_id>:<security_group_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.57.1 published on Wednesday, Jun 26, 2024 by Pulumi