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

tencentcloud.getSecurityGroups

Explore with Pulumi AI

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

    Use this data source to query detailed information of security groups.

    Example Usage

    Query all security groups

    import * as pulumi from "@pulumi/pulumi";
    import * as tencentcloud from "@pulumi/tencentcloud";
    
    const example = tencentcloud.getSecurityGroups({});
    
    import pulumi
    import pulumi_tencentcloud as tencentcloud
    
    example = tencentcloud.get_security_groups()
    
    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 {
    		_, err := tencentcloud.GetSecurityGroups(ctx, &tencentcloud.GetSecurityGroupsArgs{}, nil)
    		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 example = Tencentcloud.GetSecurityGroups.Invoke();
    
    });
    
    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.GetSecurityGroupsArgs;
    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 = TencentcloudFunctions.getSecurityGroups();
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: tencentcloud:getSecurityGroups
          arguments: {}
    

    Query security groups by filter

    import * as pulumi from "@pulumi/pulumi";
    import * as tencentcloud from "@pulumi/tencentcloud";
    
    const example = tencentcloud.getSecurityGroups({
        tags: {
            createBy: "Terraform",
        },
    });
    
    import pulumi
    import pulumi_tencentcloud as tencentcloud
    
    example = tencentcloud.get_security_groups(tags={
        "createBy": "Terraform",
    })
    
    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 {
    		_, err := tencentcloud.GetSecurityGroups(ctx, &tencentcloud.GetSecurityGroupsArgs{
    			Tags: map[string]interface{}{
    				"createBy": "Terraform",
    			},
    		}, nil)
    		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 example = Tencentcloud.GetSecurityGroups.Invoke(new()
        {
            Tags = 
            {
                { "createBy", "Terraform" },
            },
        });
    
    });
    
    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.GetSecurityGroupsArgs;
    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 = TencentcloudFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
                .tags(Map.of("createBy", "Terraform"))
                .build());
    
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: tencentcloud:getSecurityGroups
          arguments:
            tags:
              createBy: Terraform
    

    Using getSecurityGroups

    Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.

    function getSecurityGroups(args: GetSecurityGroupsArgs, opts?: InvokeOptions): Promise<GetSecurityGroupsResult>
    function getSecurityGroupsOutput(args: GetSecurityGroupsOutputArgs, opts?: InvokeOptions): Output<GetSecurityGroupsResult>
    def get_security_groups(id: Optional[str] = None,
                            name: Optional[str] = None,
                            project_id: Optional[float] = None,
                            result_output_file: Optional[str] = None,
                            security_group_id: Optional[str] = None,
                            tags: Optional[Mapping[str, str]] = None,
                            opts: Optional[InvokeOptions] = None) -> GetSecurityGroupsResult
    def get_security_groups_output(id: Optional[pulumi.Input[str]] = None,
                            name: Optional[pulumi.Input[str]] = None,
                            project_id: Optional[pulumi.Input[float]] = None,
                            result_output_file: Optional[pulumi.Input[str]] = None,
                            security_group_id: Optional[pulumi.Input[str]] = None,
                            tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                            opts: Optional[InvokeOptions] = None) -> Output[GetSecurityGroupsResult]
    func GetSecurityGroups(ctx *Context, args *GetSecurityGroupsArgs, opts ...InvokeOption) (*GetSecurityGroupsResult, error)
    func GetSecurityGroupsOutput(ctx *Context, args *GetSecurityGroupsOutputArgs, opts ...InvokeOption) GetSecurityGroupsResultOutput

    > Note: This function is named GetSecurityGroups in the Go SDK.

    public static class GetSecurityGroups 
    {
        public static Task<GetSecurityGroupsResult> InvokeAsync(GetSecurityGroupsArgs args, InvokeOptions? opts = null)
        public static Output<GetSecurityGroupsResult> Invoke(GetSecurityGroupsInvokeArgs args, InvokeOptions? opts = null)
    }
    public static CompletableFuture<GetSecurityGroupsResult> getSecurityGroups(GetSecurityGroupsArgs args, InvokeOptions options)
    public static Output<GetSecurityGroupsResult> getSecurityGroups(GetSecurityGroupsArgs args, InvokeOptions options)
    
    fn::invoke:
      function: tencentcloud:index/getSecurityGroups:getSecurityGroups
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Id string
    Name string
    Name of the security group to be queried. Conflict with security_group_id.
    ProjectId double
    Project ID of the security group to be queried. Conflict with security_group_id.
    ResultOutputFile string
    Used to save results.
    SecurityGroupId string
    ID of the security group to be queried. Conflict with name and project_id.
    Tags Dictionary<string, string>
    Tags of the security group to be queried. Conflict with security_group_id.
    Id string
    Name string
    Name of the security group to be queried. Conflict with security_group_id.
    ProjectId float64
    Project ID of the security group to be queried. Conflict with security_group_id.
    ResultOutputFile string
    Used to save results.
    SecurityGroupId string
    ID of the security group to be queried. Conflict with name and project_id.
    Tags map[string]string
    Tags of the security group to be queried. Conflict with security_group_id.
    id String
    name String
    Name of the security group to be queried. Conflict with security_group_id.
    projectId Double
    Project ID of the security group to be queried. Conflict with security_group_id.
    resultOutputFile String
    Used to save results.
    securityGroupId String
    ID of the security group to be queried. Conflict with name and project_id.
    tags Map<String,String>
    Tags of the security group to be queried. Conflict with security_group_id.
    id string
    name string
    Name of the security group to be queried. Conflict with security_group_id.
    projectId number
    Project ID of the security group to be queried. Conflict with security_group_id.
    resultOutputFile string
    Used to save results.
    securityGroupId string
    ID of the security group to be queried. Conflict with name and project_id.
    tags {[key: string]: string}
    Tags of the security group to be queried. Conflict with security_group_id.
    id str
    name str
    Name of the security group to be queried. Conflict with security_group_id.
    project_id float
    Project ID of the security group to be queried. Conflict with security_group_id.
    result_output_file str
    Used to save results.
    security_group_id str
    ID of the security group to be queried. Conflict with name and project_id.
    tags Mapping[str, str]
    Tags of the security group to be queried. Conflict with security_group_id.
    id String
    name String
    Name of the security group to be queried. Conflict with security_group_id.
    projectId Number
    Project ID of the security group to be queried. Conflict with security_group_id.
    resultOutputFile String
    Used to save results.
    securityGroupId String
    ID of the security group to be queried. Conflict with name and project_id.
    tags Map<String>
    Tags of the security group to be queried. Conflict with security_group_id.

    getSecurityGroups Result

    The following output properties are available:

    Id string
    SecurityGroups List<GetSecurityGroupsSecurityGroup>
    Information list of security group.
    Name string
    Name of the security group.
    ProjectId double
    Project ID of the security group.
    ResultOutputFile string
    SecurityGroupId string
    ID of the security group.
    Tags Dictionary<string, string>
    Tags of the security group.
    Id string
    SecurityGroups []GetSecurityGroupsSecurityGroup
    Information list of security group.
    Name string
    Name of the security group.
    ProjectId float64
    Project ID of the security group.
    ResultOutputFile string
    SecurityGroupId string
    ID of the security group.
    Tags map[string]string
    Tags of the security group.
    id String
    securityGroups List<GetSecurityGroupsSecurityGroup>
    Information list of security group.
    name String
    Name of the security group.
    projectId Double
    Project ID of the security group.
    resultOutputFile String
    securityGroupId String
    ID of the security group.
    tags Map<String,String>
    Tags of the security group.
    id string
    securityGroups GetSecurityGroupsSecurityGroup[]
    Information list of security group.
    name string
    Name of the security group.
    projectId number
    Project ID of the security group.
    resultOutputFile string
    securityGroupId string
    ID of the security group.
    tags {[key: string]: string}
    Tags of the security group.
    id str
    security_groups Sequence[GetSecurityGroupsSecurityGroup]
    Information list of security group.
    name str
    Name of the security group.
    project_id float
    Project ID of the security group.
    result_output_file str
    security_group_id str
    ID of the security group.
    tags Mapping[str, str]
    Tags of the security group.
    id String
    securityGroups List<Property Map>
    Information list of security group.
    name String
    Name of the security group.
    projectId Number
    Project ID of the security group.
    resultOutputFile String
    securityGroupId String
    ID of the security group.
    tags Map<String>
    Tags of the security group.

    Supporting Types

    GetSecurityGroupsSecurityGroup

    BeAssociateCount double
    Number of security group binding resources.
    CreateTime string
    Creation time of security group.
    Description string
    Description of the security group.
    Egresses List<string>
    Egress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    Ingresses List<string>
    Ingress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    Name string
    Name of the security group to be queried. Conflict with security_group_id.
    ProjectId double
    Project ID of the security group to be queried. Conflict with security_group_id.
    SecurityGroupId string
    ID of the security group to be queried. Conflict with name and project_id.
    Tags Dictionary<string, string>
    Tags of the security group to be queried. Conflict with security_group_id.
    BeAssociateCount float64
    Number of security group binding resources.
    CreateTime string
    Creation time of security group.
    Description string
    Description of the security group.
    Egresses []string
    Egress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    Ingresses []string
    Ingress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    Name string
    Name of the security group to be queried. Conflict with security_group_id.
    ProjectId float64
    Project ID of the security group to be queried. Conflict with security_group_id.
    SecurityGroupId string
    ID of the security group to be queried. Conflict with name and project_id.
    Tags map[string]string
    Tags of the security group to be queried. Conflict with security_group_id.
    beAssociateCount Double
    Number of security group binding resources.
    createTime String
    Creation time of security group.
    description String
    Description of the security group.
    egresses List<String>
    Egress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    ingresses List<String>
    Ingress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    name String
    Name of the security group to be queried. Conflict with security_group_id.
    projectId Double
    Project ID of the security group to be queried. Conflict with security_group_id.
    securityGroupId String
    ID of the security group to be queried. Conflict with name and project_id.
    tags Map<String,String>
    Tags of the security group to be queried. Conflict with security_group_id.
    beAssociateCount number
    Number of security group binding resources.
    createTime string
    Creation time of security group.
    description string
    Description of the security group.
    egresses string[]
    Egress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    ingresses string[]
    Ingress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    name string
    Name of the security group to be queried. Conflict with security_group_id.
    projectId number
    Project ID of the security group to be queried. Conflict with security_group_id.
    securityGroupId string
    ID of the security group to be queried. Conflict with name and project_id.
    tags {[key: string]: string}
    Tags of the security group to be queried. Conflict with security_group_id.
    be_associate_count float
    Number of security group binding resources.
    create_time str
    Creation time of security group.
    description str
    Description of the security group.
    egresses Sequence[str]
    Egress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    ingresses Sequence[str]
    Ingress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    name str
    Name of the security group to be queried. Conflict with security_group_id.
    project_id float
    Project ID of the security group to be queried. Conflict with security_group_id.
    security_group_id str
    ID of the security group to be queried. Conflict with name and project_id.
    tags Mapping[str, str]
    Tags of the security group to be queried. Conflict with security_group_id.
    beAssociateCount Number
    Number of security group binding resources.
    createTime String
    Creation time of security group.
    description String
    Description of the security group.
    egresses List<String>
    Egress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    ingresses List<String>
    Ingress rules set. For items like [action]#[cidr_ip]#[port]#[protocol], it means a regular rule; for items like sg-XXXX, it means a nested security group.
    name String
    Name of the security group to be queried. Conflict with security_group_id.
    projectId Number
    Project ID of the security group to be queried. Conflict with security_group_id.
    securityGroupId String
    ID of the security group to be queried. Conflict with name and project_id.
    tags Map<String>
    Tags of the security group to be queried. Conflict with security_group_id.

    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