1. Packages
  2. Ucloud Provider
  3. API Docs
  4. getSecurityGroups
ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud

ucloud.getSecurityGroups

Explore with Pulumi AI

ucloud logo
ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud

    This data source provides a list of Security Group resources according to their Security Group ID, name and resource id.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as ucloud from "@pulumi/ucloud";
    
    const example = ucloud.getSecurityGroups({});
    export const first = example.then(example => example.securityGroups?.[0]?.id);
    
    import pulumi
    import pulumi_ucloud as ucloud
    
    example = ucloud.get_security_groups()
    pulumi.export("first", example.security_groups[0].id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-terraform-provider/sdks/go/ucloud/ucloud"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		example, err := ucloud.GetSecurityGroups(ctx, &ucloud.GetSecurityGroupsArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		ctx.Export("first", example.SecurityGroups[0].Id)
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Ucloud = Pulumi.Ucloud;
    
    return await Deployment.RunAsync(() => 
    {
        var example = Ucloud.GetSecurityGroups.Invoke();
    
        return new Dictionary<string, object?>
        {
            ["first"] = example.Apply(getSecurityGroupsResult => getSecurityGroupsResult.SecurityGroups[0]?.Id),
        };
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.ucloud.UcloudFunctions;
    import com.pulumi.ucloud.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 = UcloudFunctions.getSecurityGroups();
    
            ctx.export("first", example.applyValue(getSecurityGroupsResult -> getSecurityGroupsResult.securityGroups()[0].id()));
        }
    }
    
    variables:
      example:
        fn::invoke:
          function: ucloud:getSecurityGroups
          arguments: {}
    outputs:
      first: ${example.securityGroups[0].id}
    

    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,
                            ids: Optional[Sequence[str]] = None,
                            name_regex: Optional[str] = None,
                            output_file: Optional[str] = None,
                            type: Optional[str] = None,
                            opts: Optional[InvokeOptions] = None) -> GetSecurityGroupsResult
    def get_security_groups_output(id: Optional[pulumi.Input[str]] = None,
                            ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                            name_regex: Optional[pulumi.Input[str]] = None,
                            output_file: Optional[pulumi.Input[str]] = None,
                            type: Optional[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: ucloud:index/getSecurityGroups:getSecurityGroups
      arguments:
        # arguments dictionary

    The following arguments are supported:

    Id string
    The ID of Security Group.
    Ids List<string>
    A list of Security Group IDs, all the Security Group resources belong to this region will be retrieved if the ID is [].
    NameRegex string
    A regex string to filter resulting Security Group resources by name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    Type string
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.
    Id string
    The ID of Security Group.
    Ids []string
    A list of Security Group IDs, all the Security Group resources belong to this region will be retrieved if the ID is [].
    NameRegex string
    A regex string to filter resulting Security Group resources by name.
    OutputFile string
    File name where to save data source results (after running pulumi preview).
    Type string
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.
    id String
    The ID of Security Group.
    ids List<String>
    A list of Security Group IDs, all the Security Group resources belong to this region will be retrieved if the ID is [].
    nameRegex String
    A regex string to filter resulting Security Group resources by name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    type String
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.
    id string
    The ID of Security Group.
    ids string[]
    A list of Security Group IDs, all the Security Group resources belong to this region will be retrieved if the ID is [].
    nameRegex string
    A regex string to filter resulting Security Group resources by name.
    outputFile string
    File name where to save data source results (after running pulumi preview).
    type string
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.
    id str
    The ID of Security Group.
    ids Sequence[str]
    A list of Security Group IDs, all the Security Group resources belong to this region will be retrieved if the ID is [].
    name_regex str
    A regex string to filter resulting Security Group resources by name.
    output_file str
    File name where to save data source results (after running pulumi preview).
    type str
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.
    id String
    The ID of Security Group.
    ids List<String>
    A list of Security Group IDs, all the Security Group resources belong to this region will be retrieved if the ID is [].
    nameRegex String
    A regex string to filter resulting Security Group resources by name.
    outputFile String
    File name where to save data source results (after running pulumi preview).
    type String
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.

    getSecurityGroups Result

    The following output properties are available:

    Id string
    The ID of Security Group.
    Ids List<string>
    SecurityGroups List<GetSecurityGroupsSecurityGroup>
    It is a nested type which documented below.
    TotalCount double
    Total number of Security Group resources that satisfy the condition.
    NameRegex string
    OutputFile string
    Type string
    The type of Security Group.
    Id string
    The ID of Security Group.
    Ids []string
    SecurityGroups []GetSecurityGroupsSecurityGroup
    It is a nested type which documented below.
    TotalCount float64
    Total number of Security Group resources that satisfy the condition.
    NameRegex string
    OutputFile string
    Type string
    The type of Security Group.
    id String
    The ID of Security Group.
    ids List<String>
    securityGroups List<GetSecurityGroupsSecurityGroup>
    It is a nested type which documented below.
    totalCount Double
    Total number of Security Group resources that satisfy the condition.
    nameRegex String
    outputFile String
    type String
    The type of Security Group.
    id string
    The ID of Security Group.
    ids string[]
    securityGroups GetSecurityGroupsSecurityGroup[]
    It is a nested type which documented below.
    totalCount number
    Total number of Security Group resources that satisfy the condition.
    nameRegex string
    outputFile string
    type string
    The type of Security Group.
    id str
    The ID of Security Group.
    ids Sequence[str]
    security_groups Sequence[GetSecurityGroupsSecurityGroup]
    It is a nested type which documented below.
    total_count float
    Total number of Security Group resources that satisfy the condition.
    name_regex str
    output_file str
    type str
    The type of Security Group.
    id String
    The ID of Security Group.
    ids List<String>
    securityGroups List<Property Map>
    It is a nested type which documented below.
    totalCount Number
    Total number of Security Group resources that satisfy the condition.
    nameRegex String
    outputFile String
    type String
    The type of Security Group.

    Supporting Types

    GetSecurityGroupsSecurityGroup

    CreateTime string
    The time of creation for the security group, formatted in RFC3339 time string.
    Id string
    The ID of Security Group.
    Name string
    The name of Security Group.
    Remark string
    The remarks of the security group.
    Rules List<GetSecurityGroupsSecurityGroupRule>
    It is a nested type which documented below.
    Tag string
    A tag assigned to the security group.
    Type string
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.
    CreateTime string
    The time of creation for the security group, formatted in RFC3339 time string.
    Id string
    The ID of Security Group.
    Name string
    The name of Security Group.
    Remark string
    The remarks of the security group.
    Rules []GetSecurityGroupsSecurityGroupRule
    It is a nested type which documented below.
    Tag string
    A tag assigned to the security group.
    Type string
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.
    createTime String
    The time of creation for the security group, formatted in RFC3339 time string.
    id String
    The ID of Security Group.
    name String
    The name of Security Group.
    remark String
    The remarks of the security group.
    rules List<GetSecurityGroupsSecurityGroupRule>
    It is a nested type which documented below.
    tag String
    A tag assigned to the security group.
    type String
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.
    createTime string
    The time of creation for the security group, formatted in RFC3339 time string.
    id string
    The ID of Security Group.
    name string
    The name of Security Group.
    remark string
    The remarks of the security group.
    rules GetSecurityGroupsSecurityGroupRule[]
    It is a nested type which documented below.
    tag string
    A tag assigned to the security group.
    type string
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.
    create_time str
    The time of creation for the security group, formatted in RFC3339 time string.
    id str
    The ID of Security Group.
    name str
    The name of Security Group.
    remark str
    The remarks of the security group.
    rules Sequence[GetSecurityGroupsSecurityGroupRule]
    It is a nested type which documented below.
    tag str
    A tag assigned to the security group.
    type str
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.
    createTime String
    The time of creation for the security group, formatted in RFC3339 time string.
    id String
    The ID of Security Group.
    name String
    The name of Security Group.
    remark String
    The remarks of the security group.
    rules List<Property Map>
    It is a nested type which documented below.
    tag String
    A tag assigned to the security group.
    type String
    The type of Security Group. Possible values are: recommend_web as the default Web security group that UCloud recommend to users, default opened port include 80, 443, 22, 3389, recommend_non_web as the default non Web security group that UCloud recommend to users, default opened port include 22, 3389, user_defined as the security groups defined by users. You may refer to security group.

    GetSecurityGroupsSecurityGroupRule

    CidrBlock string
    The cidr block of source.
    Policy string
    Authorization policy. Can be either accept or drop.
    PortRange string
    The range of port numbers, range: 1-65535. (eg: port or port1-port2).
    Priority string
    Rule priority. Can be high, medium, low.
    Protocol string
    The protocol. Can be tcp, udp, icmp, gre.
    CidrBlock string
    The cidr block of source.
    Policy string
    Authorization policy. Can be either accept or drop.
    PortRange string
    The range of port numbers, range: 1-65535. (eg: port or port1-port2).
    Priority string
    Rule priority. Can be high, medium, low.
    Protocol string
    The protocol. Can be tcp, udp, icmp, gre.
    cidrBlock String
    The cidr block of source.
    policy String
    Authorization policy. Can be either accept or drop.
    portRange String
    The range of port numbers, range: 1-65535. (eg: port or port1-port2).
    priority String
    Rule priority. Can be high, medium, low.
    protocol String
    The protocol. Can be tcp, udp, icmp, gre.
    cidrBlock string
    The cidr block of source.
    policy string
    Authorization policy. Can be either accept or drop.
    portRange string
    The range of port numbers, range: 1-65535. (eg: port or port1-port2).
    priority string
    Rule priority. Can be high, medium, low.
    protocol string
    The protocol. Can be tcp, udp, icmp, gre.
    cidr_block str
    The cidr block of source.
    policy str
    Authorization policy. Can be either accept or drop.
    port_range str
    The range of port numbers, range: 1-65535. (eg: port or port1-port2).
    priority str
    Rule priority. Can be high, medium, low.
    protocol str
    The protocol. Can be tcp, udp, icmp, gre.
    cidrBlock String
    The cidr block of source.
    policy String
    Authorization policy. Can be either accept or drop.
    portRange String
    The range of port numbers, range: 1-65535. (eg: port or port1-port2).
    priority String
    Rule priority. Can be high, medium, low.
    protocol String
    The protocol. Can be tcp, udp, icmp, gre.

    Package Details

    Repository
    ucloud ucloud/terraform-provider-ucloud
    License
    Notes
    This Pulumi package is based on the ucloud Terraform Provider.
    ucloud logo
    ucloud 1.39.1 published on Monday, Apr 14, 2025 by ucloud