1. Packages
  2. Tencentcloud Provider
  3. API Docs
  4. EniSgAttachment
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

tencentcloud.EniSgAttachment

Explore with Pulumi AI

tencentcloud logo
tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack

    Provides a resource to create a eni_sg_attachment

    Note: If this resource is used to bind security groups to eni, it cannot be linked to tentcloud_eni binding security group for simultaneous use.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as tencentcloud from "@pulumi/tencentcloud";
    
    const zones = tencentcloud.getAvailabilityZonesByProduct({
        product: "vpc",
    });
    const vpc = new tencentcloud.Vpc("vpc", {cidrBlock: "10.0.0.0/16"});
    const subnet = new tencentcloud.Subnet("subnet", {
        availabilityZone: zones.then(zones => zones.zones?.[0]?.name),
        vpcId: vpc.vpcId,
        cidrBlock: "10.0.0.0/16",
        isMulticast: false,
    });
    const example1 = new tencentcloud.SecurityGroup("example1", {
        description: "sg desc.",
        projectId: 0,
        tags: {
            example: "test",
        },
    });
    const example2 = new tencentcloud.SecurityGroup("example2", {
        description: "sg desc.",
        projectId: 0,
        tags: {
            example: "test",
        },
    });
    const example = new tencentcloud.Eni("example", {
        vpcId: vpc.vpcId,
        subnetId: subnet.subnetId,
        description: "eni desc.",
        ipv4Count: 1,
    });
    const eniSgAttachment = new tencentcloud.EniSgAttachment("eniSgAttachment", {
        networkInterfaceIds: [example.eniId],
        securityGroupIds: [
            example1.securityGroupId,
            example2.securityGroupId,
        ],
    });
    
    import pulumi
    import pulumi_tencentcloud as tencentcloud
    
    zones = tencentcloud.get_availability_zones_by_product(product="vpc")
    vpc = tencentcloud.Vpc("vpc", cidr_block="10.0.0.0/16")
    subnet = tencentcloud.Subnet("subnet",
        availability_zone=zones.zones[0].name,
        vpc_id=vpc.vpc_id,
        cidr_block="10.0.0.0/16",
        is_multicast=False)
    example1 = tencentcloud.SecurityGroup("example1",
        description="sg desc.",
        project_id=0,
        tags={
            "example": "test",
        })
    example2 = tencentcloud.SecurityGroup("example2",
        description="sg desc.",
        project_id=0,
        tags={
            "example": "test",
        })
    example = tencentcloud.Eni("example",
        vpc_id=vpc.vpc_id,
        subnet_id=subnet.subnet_id,
        description="eni desc.",
        ipv4_count=1)
    eni_sg_attachment = tencentcloud.EniSgAttachment("eniSgAttachment",
        network_interface_ids=[example.eni_id],
        security_group_ids=[
            example1.security_group_id,
            example2.security_group_id,
        ])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/tencentcloud/tencentcloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		zones, err := tencentcloud.GetAvailabilityZonesByProduct(ctx, &tencentcloud.GetAvailabilityZonesByProductArgs{
    			Product: "vpc",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		vpc, err := tencentcloud.NewVpc(ctx, "vpc", &tencentcloud.VpcArgs{
    			CidrBlock: pulumi.String("10.0.0.0/16"),
    		})
    		if err != nil {
    			return err
    		}
    		subnet, err := tencentcloud.NewSubnet(ctx, "subnet", &tencentcloud.SubnetArgs{
    			AvailabilityZone: pulumi.String(zones.Zones[0].Name),
    			VpcId:            vpc.VpcId,
    			CidrBlock:        pulumi.String("10.0.0.0/16"),
    			IsMulticast:      pulumi.Bool(false),
    		})
    		if err != nil {
    			return err
    		}
    		example1, err := tencentcloud.NewSecurityGroup(ctx, "example1", &tencentcloud.SecurityGroupArgs{
    			Description: pulumi.String("sg desc."),
    			ProjectId:   pulumi.Float64(0),
    			Tags: pulumi.StringMap{
    				"example": pulumi.String("test"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		example2, err := tencentcloud.NewSecurityGroup(ctx, "example2", &tencentcloud.SecurityGroupArgs{
    			Description: pulumi.String("sg desc."),
    			ProjectId:   pulumi.Float64(0),
    			Tags: pulumi.StringMap{
    				"example": pulumi.String("test"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		example, err := tencentcloud.NewEni(ctx, "example", &tencentcloud.EniArgs{
    			VpcId:       vpc.VpcId,
    			SubnetId:    subnet.SubnetId,
    			Description: pulumi.String("eni desc."),
    			Ipv4Count:   pulumi.Float64(1),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = tencentcloud.NewEniSgAttachment(ctx, "eniSgAttachment", &tencentcloud.EniSgAttachmentArgs{
    			NetworkInterfaceIds: pulumi.StringArray{
    				example.EniId,
    			},
    			SecurityGroupIds: pulumi.StringArray{
    				example1.SecurityGroupId,
    				example2.SecurityGroupId,
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Tencentcloud = Pulumi.Tencentcloud;
    
    return await Deployment.RunAsync(() => 
    {
        var zones = Tencentcloud.GetAvailabilityZonesByProduct.Invoke(new()
        {
            Product = "vpc",
        });
    
        var vpc = new Tencentcloud.Vpc("vpc", new()
        {
            CidrBlock = "10.0.0.0/16",
        });
    
        var subnet = new Tencentcloud.Subnet("subnet", new()
        {
            AvailabilityZone = zones.Apply(getAvailabilityZonesByProductResult => getAvailabilityZonesByProductResult.Zones[0]?.Name),
            VpcId = vpc.VpcId,
            CidrBlock = "10.0.0.0/16",
            IsMulticast = false,
        });
    
        var example1 = new Tencentcloud.SecurityGroup("example1", new()
        {
            Description = "sg desc.",
            ProjectId = 0,
            Tags = 
            {
                { "example", "test" },
            },
        });
    
        var example2 = new Tencentcloud.SecurityGroup("example2", new()
        {
            Description = "sg desc.",
            ProjectId = 0,
            Tags = 
            {
                { "example", "test" },
            },
        });
    
        var example = new Tencentcloud.Eni("example", new()
        {
            VpcId = vpc.VpcId,
            SubnetId = subnet.SubnetId,
            Description = "eni desc.",
            Ipv4Count = 1,
        });
    
        var eniSgAttachment = new Tencentcloud.EniSgAttachment("eniSgAttachment", new()
        {
            NetworkInterfaceIds = new[]
            {
                example.EniId,
            },
            SecurityGroupIds = new[]
            {
                example1.SecurityGroupId,
                example2.SecurityGroupId,
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.tencentcloud.TencentcloudFunctions;
    import com.pulumi.tencentcloud.inputs.GetAvailabilityZonesByProductArgs;
    import com.pulumi.tencentcloud.Vpc;
    import com.pulumi.tencentcloud.VpcArgs;
    import com.pulumi.tencentcloud.Subnet;
    import com.pulumi.tencentcloud.SubnetArgs;
    import com.pulumi.tencentcloud.SecurityGroup;
    import com.pulumi.tencentcloud.SecurityGroupArgs;
    import com.pulumi.tencentcloud.Eni;
    import com.pulumi.tencentcloud.EniArgs;
    import com.pulumi.tencentcloud.EniSgAttachment;
    import com.pulumi.tencentcloud.EniSgAttachmentArgs;
    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 zones = TencentcloudFunctions.getAvailabilityZonesByProduct(GetAvailabilityZonesByProductArgs.builder()
                .product("vpc")
                .build());
    
            var vpc = new Vpc("vpc", VpcArgs.builder()
                .cidrBlock("10.0.0.0/16")
                .build());
    
            var subnet = new Subnet("subnet", SubnetArgs.builder()
                .availabilityZone(zones.applyValue(getAvailabilityZonesByProductResult -> getAvailabilityZonesByProductResult.zones()[0].name()))
                .vpcId(vpc.vpcId())
                .cidrBlock("10.0.0.0/16")
                .isMulticast(false)
                .build());
    
            var example1 = new SecurityGroup("example1", SecurityGroupArgs.builder()
                .description("sg desc.")
                .projectId(0)
                .tags(Map.of("example", "test"))
                .build());
    
            var example2 = new SecurityGroup("example2", SecurityGroupArgs.builder()
                .description("sg desc.")
                .projectId(0)
                .tags(Map.of("example", "test"))
                .build());
    
            var example = new Eni("example", EniArgs.builder()
                .vpcId(vpc.vpcId())
                .subnetId(subnet.subnetId())
                .description("eni desc.")
                .ipv4Count(1)
                .build());
    
            var eniSgAttachment = new EniSgAttachment("eniSgAttachment", EniSgAttachmentArgs.builder()
                .networkInterfaceIds(example.eniId())
                .securityGroupIds(            
                    example1.securityGroupId(),
                    example2.securityGroupId())
                .build());
    
        }
    }
    
    resources:
      vpc:
        type: tencentcloud:Vpc
        properties:
          cidrBlock: 10.0.0.0/16
      subnet:
        type: tencentcloud:Subnet
        properties:
          availabilityZone: ${zones.zones[0].name}
          vpcId: ${vpc.vpcId}
          cidrBlock: 10.0.0.0/16
          isMulticast: false
      example1:
        type: tencentcloud:SecurityGroup
        properties:
          description: sg desc.
          projectId: 0
          tags:
            example: test
      example2:
        type: tencentcloud:SecurityGroup
        properties:
          description: sg desc.
          projectId: 0
          tags:
            example: test
      example:
        type: tencentcloud:Eni
        properties:
          vpcId: ${vpc.vpcId}
          subnetId: ${subnet.subnetId}
          description: eni desc.
          ipv4Count: 1
      eniSgAttachment:
        type: tencentcloud:EniSgAttachment
        properties:
          networkInterfaceIds:
            - ${example.eniId}
          securityGroupIds:
            - ${example1.securityGroupId}
            - ${example2.securityGroupId}
    variables:
      zones:
        fn::invoke:
          function: tencentcloud:getAvailabilityZonesByProduct
          arguments:
            product: vpc
    

    Create EniSgAttachment Resource

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

    Constructor syntax

    new EniSgAttachment(name: string, args: EniSgAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def EniSgAttachment(resource_name: str,
                        args: EniSgAttachmentArgs,
                        opts: Optional[ResourceOptions] = None)
    
    @overload
    def EniSgAttachment(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        network_interface_ids: Optional[Sequence[str]] = None,
                        security_group_ids: Optional[Sequence[str]] = None,
                        eni_sg_attachment_id: Optional[str] = None)
    func NewEniSgAttachment(ctx *Context, name string, args EniSgAttachmentArgs, opts ...ResourceOption) (*EniSgAttachment, error)
    public EniSgAttachment(string name, EniSgAttachmentArgs args, CustomResourceOptions? opts = null)
    public EniSgAttachment(String name, EniSgAttachmentArgs args)
    public EniSgAttachment(String name, EniSgAttachmentArgs args, CustomResourceOptions options)
    
    type: tencentcloud:EniSgAttachment
    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 EniSgAttachmentArgs
    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 EniSgAttachmentArgs
    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 EniSgAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args EniSgAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args EniSgAttachmentArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

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

    NetworkInterfaceIds List<string>
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    SecurityGroupIds List<string>
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.
    EniSgAttachmentId string
    ID of the resource.
    NetworkInterfaceIds []string
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    SecurityGroupIds []string
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.
    EniSgAttachmentId string
    ID of the resource.
    networkInterfaceIds List<String>
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    securityGroupIds List<String>
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.
    eniSgAttachmentId String
    ID of the resource.
    networkInterfaceIds string[]
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    securityGroupIds string[]
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.
    eniSgAttachmentId string
    ID of the resource.
    network_interface_ids Sequence[str]
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    security_group_ids Sequence[str]
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.
    eni_sg_attachment_id str
    ID of the resource.
    networkInterfaceIds List<String>
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    securityGroupIds List<String>
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.
    eniSgAttachmentId String
    ID of the resource.

    Outputs

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

    Get an existing EniSgAttachment 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?: EniSgAttachmentState, opts?: CustomResourceOptions): EniSgAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            eni_sg_attachment_id: Optional[str] = None,
            network_interface_ids: Optional[Sequence[str]] = None,
            security_group_ids: Optional[Sequence[str]] = None) -> EniSgAttachment
    func GetEniSgAttachment(ctx *Context, name string, id IDInput, state *EniSgAttachmentState, opts ...ResourceOption) (*EniSgAttachment, error)
    public static EniSgAttachment Get(string name, Input<string> id, EniSgAttachmentState? state, CustomResourceOptions? opts = null)
    public static EniSgAttachment get(String name, Output<String> id, EniSgAttachmentState state, CustomResourceOptions options)
    resources:  _:    type: tencentcloud:EniSgAttachment    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:
    EniSgAttachmentId string
    ID of the resource.
    NetworkInterfaceIds List<string>
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    SecurityGroupIds List<string>
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.
    EniSgAttachmentId string
    ID of the resource.
    NetworkInterfaceIds []string
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    SecurityGroupIds []string
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.
    eniSgAttachmentId String
    ID of the resource.
    networkInterfaceIds List<String>
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    securityGroupIds List<String>
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.
    eniSgAttachmentId string
    ID of the resource.
    networkInterfaceIds string[]
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    securityGroupIds string[]
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.
    eni_sg_attachment_id str
    ID of the resource.
    network_interface_ids Sequence[str]
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    security_group_ids Sequence[str]
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.
    eniSgAttachmentId String
    ID of the resource.
    networkInterfaceIds List<String>
    ENI instance ID. Such as:eni-pxir56ns. It Only support set one eni instance now.
    securityGroupIds List<String>
    Security group instance ID, for example:sg-33ocnj9n, can be obtained through DescribeSecurityGroups. There is a limit of 100 instances per request.

    Import

    vpc eni_sg_attachment can be imported using the id, e.g.

    $ pulumi import tencentcloud:index/eniSgAttachment:EniSgAttachment eni_sg_attachment eni_sg_attachment_id
    

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

    Package Details

    Repository
    tencentcloud tencentcloudstack/terraform-provider-tencentcloud
    License
    Notes
    This Pulumi package is based on the tencentcloud Terraform Provider.
    tencentcloud logo
    tencentcloud 1.81.189 published on Wednesday, Apr 30, 2025 by tencentcloudstack