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

tencentcloud.getSecurityGroups

Explore with Pulumi AI

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({});
Copy
import pulumi
import pulumi_tencentcloud as tencentcloud

example = tencentcloud.get_security_groups()
Copy
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
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Tencentcloud = Pulumi.Tencentcloud;

return await Deployment.RunAsync(() => 
{
    var example = Tencentcloud.GetSecurityGroups.Invoke();

});
Copy
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();

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: tencentcloud:getSecurityGroups
      arguments: {}
Copy

Query security groups by filter

import * as pulumi from "@pulumi/pulumi";
import * as tencentcloud from "@pulumi/tencentcloud";

const example = tencentcloud.getSecurityGroups({
    tags: {
        createBy: "Terraform",
    },
});
Copy
import pulumi
import pulumi_tencentcloud as tencentcloud

example = tencentcloud.get_security_groups(tags={
    "createBy": "Terraform",
})
Copy
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
	})
}
Copy
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" },
        },
    });

});
Copy
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());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: tencentcloud:getSecurityGroups
      arguments:
        tags:
          createBy: Terraform
Copy

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>
Copy
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]
Copy
func GetSecurityGroups(ctx *Context, args *GetSecurityGroupsArgs, opts ...InvokeOption) (*GetSecurityGroupsResult, error)
func GetSecurityGroupsOutput(ctx *Context, args *GetSecurityGroupsOutputArgs, opts ...InvokeOption) GetSecurityGroupsResultOutput
Copy

> 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)
}
Copy
public static CompletableFuture<GetSecurityGroupsResult> getSecurityGroups(GetSecurityGroupsArgs args, InvokeOptions options)
public static Output<GetSecurityGroupsResult> getSecurityGroups(GetSecurityGroupsArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: tencentcloud:index/getSecurityGroups:getSecurityGroups
  arguments:
    # arguments dictionary
Copy

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 This property is required. double
Number of security group binding resources.
CreateTime This property is required. string
Creation time of security group.
Description This property is required. string
Description of the security group.
Egresses This property is required. 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 This property is required. 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 This property is required. string
Name of the security group to be queried. Conflict with security_group_id.
ProjectId This property is required. double
Project ID of the security group to be queried. Conflict with security_group_id.
SecurityGroupId This property is required. string
ID of the security group to be queried. Conflict with name and project_id.
Tags This property is required. Dictionary<string, string>
Tags of the security group to be queried. Conflict with security_group_id.
BeAssociateCount This property is required. float64
Number of security group binding resources.
CreateTime This property is required. string
Creation time of security group.
Description This property is required. string
Description of the security group.
Egresses This property is required. []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 This property is required. []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 This property is required. string
Name of the security group to be queried. Conflict with security_group_id.
ProjectId This property is required. float64
Project ID of the security group to be queried. Conflict with security_group_id.
SecurityGroupId This property is required. string
ID of the security group to be queried. Conflict with name and project_id.
Tags This property is required. map[string]string
Tags of the security group to be queried. Conflict with security_group_id.
beAssociateCount This property is required. Double
Number of security group binding resources.
createTime This property is required. String
Creation time of security group.
description This property is required. String
Description of the security group.
egresses This property is required. 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 This property is required. 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 This property is required. String
Name of the security group to be queried. Conflict with security_group_id.
projectId This property is required. Double
Project ID of the security group to be queried. Conflict with security_group_id.
securityGroupId This property is required. String
ID of the security group to be queried. Conflict with name and project_id.
tags This property is required. Map<String,String>
Tags of the security group to be queried. Conflict with security_group_id.
beAssociateCount This property is required. number
Number of security group binding resources.
createTime This property is required. string
Creation time of security group.
description This property is required. string
Description of the security group.
egresses This property is required. 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 This property is required. 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 This property is required. string
Name of the security group to be queried. Conflict with security_group_id.
projectId This property is required. number
Project ID of the security group to be queried. Conflict with security_group_id.
securityGroupId This property is required. string
ID of the security group to be queried. Conflict with name and project_id.
tags This property is required. {[key: string]: string}
Tags of the security group to be queried. Conflict with security_group_id.
be_associate_count This property is required. float
Number of security group binding resources.
create_time This property is required. str
Creation time of security group.
description This property is required. str
Description of the security group.
egresses This property is required. 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 This property is required. 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 This property is required. str
Name of the security group to be queried. Conflict with security_group_id.
project_id This property is required. float
Project ID of the security group to be queried. Conflict with security_group_id.
security_group_id This property is required. str
ID of the security group to be queried. Conflict with name and project_id.
tags This property is required. Mapping[str, str]
Tags of the security group to be queried. Conflict with security_group_id.
beAssociateCount This property is required. Number
Number of security group binding resources.
createTime This property is required. String
Creation time of security group.
description This property is required. String
Description of the security group.
egresses This property is required. 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 This property is required. 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 This property is required. String
Name of the security group to be queried. Conflict with security_group_id.
projectId This property is required. Number
Project ID of the security group to be queried. Conflict with security_group_id.
securityGroupId This property is required. String
ID of the security group to be queried. Conflict with name and project_id.
tags This property is required. 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.