1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. ecs
  5. getSecurityGroups
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.ecs.getSecurityGroups

Explore with Pulumi AI

Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

This data source provides a list of Security Groups in an Alibaba Cloud account according to the specified filters.

Example Usage

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

// Filter security groups and print the results into a file
const secGroupsDs = alicloud.ecs.getSecurityGroups({
    nameRegex: "^web-",
    outputFile: "web_access.json",
});
// In conjunction with a VPC
const primaryVpcDs = new alicloud.vpc.Network("primary_vpc_ds", {});
const primarySecGroupsDs = alicloud.ecs.getSecurityGroupsOutput({
    vpcId: primaryVpcDs.id,
});
export const firstGroupId = primarySecGroupsDs.apply(primarySecGroupsDs => primarySecGroupsDs.groups?.[0]?.id);
Copy
import pulumi
import pulumi_alicloud as alicloud

# Filter security groups and print the results into a file
sec_groups_ds = alicloud.ecs.get_security_groups(name_regex="^web-",
    output_file="web_access.json")
# In conjunction with a VPC
primary_vpc_ds = alicloud.vpc.Network("primary_vpc_ds")
primary_sec_groups_ds = alicloud.ecs.get_security_groups_output(vpc_id=primary_vpc_ds.id)
pulumi.export("firstGroupId", primary_sec_groups_ds.groups[0].id)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Filter security groups and print the results into a file
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			NameRegex:  pulumi.StringRef("^web-"),
			OutputFile: pulumi.StringRef("web_access.json"),
		}, nil)
		if err != nil {
			return err
		}
		// In conjunction with a VPC
		primaryVpcDs, err := vpc.NewNetwork(ctx, "primary_vpc_ds", nil)
		if err != nil {
			return err
		}
		primarySecGroupsDs := ecs.GetSecurityGroupsOutput(ctx, ecs.GetSecurityGroupsOutputArgs{
			VpcId: primaryVpcDs.ID(),
		}, nil)
		ctx.Export("firstGroupId", primarySecGroupsDs.ApplyT(func(primarySecGroupsDs ecs.GetSecurityGroupsResult) (*string, error) {
			return &primarySecGroupsDs.Groups[0].Id, nil
		}).(pulumi.StringPtrOutput))
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    // Filter security groups and print the results into a file
    var secGroupsDs = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        NameRegex = "^web-",
        OutputFile = "web_access.json",
    });

    // In conjunction with a VPC
    var primaryVpcDs = new AliCloud.Vpc.Network("primary_vpc_ds");

    var primarySecGroupsDs = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        VpcId = primaryVpcDs.Id,
    });

    return new Dictionary<string, object?>
    {
        ["firstGroupId"] = primarySecGroupsDs.Apply(getSecurityGroupsResult => getSecurityGroupsResult.Groups[0]?.Id),
    };
});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.inputs.GetSecurityGroupsArgs;
import com.pulumi.alicloud.vpc.Network;
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) {
        // Filter security groups and print the results into a file
        final var secGroupsDs = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .nameRegex("^web-")
            .outputFile("web_access.json")
            .build());

        // In conjunction with a VPC
        var primaryVpcDs = new Network("primaryVpcDs");

        final var primarySecGroupsDs = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .vpcId(primaryVpcDs.id())
            .build());

        ctx.export("firstGroupId", primarySecGroupsDs.applyValue(getSecurityGroupsResult -> getSecurityGroupsResult).applyValue(primarySecGroupsDs -> primarySecGroupsDs.applyValue(getSecurityGroupsResult -> getSecurityGroupsResult.groups()[0].id())));
    }
}
Copy
resources:
  # In conjunction with a VPC
  primaryVpcDs:
    type: alicloud:vpc:Network
    name: primary_vpc_ds
variables:
  # Filter security groups and print the results into a file
  secGroupsDs:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        nameRegex: ^web-
        outputFile: web_access.json
  primarySecGroupsDs:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        vpcId: ${primaryVpcDs.id}
outputs:
  firstGroupId: ${primarySecGroupsDs.groups[0].id}
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(enable_details: Optional[bool] = None,
                        ids: Optional[Sequence[str]] = None,
                        name_regex: Optional[str] = None,
                        output_file: Optional[str] = None,
                        page_number: Optional[int] = None,
                        page_size: Optional[int] = None,
                        resource_group_id: Optional[str] = None,
                        tags: Optional[Mapping[str, str]] = None,
                        vpc_id: Optional[str] = None,
                        opts: Optional[InvokeOptions] = None) -> GetSecurityGroupsResult
def get_security_groups_output(enable_details: Optional[pulumi.Input[bool]] = None,
                        ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
                        name_regex: Optional[pulumi.Input[str]] = None,
                        output_file: Optional[pulumi.Input[str]] = None,
                        page_number: Optional[pulumi.Input[int]] = None,
                        page_size: Optional[pulumi.Input[int]] = None,
                        resource_group_id: Optional[pulumi.Input[str]] = None,
                        tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                        vpc_id: Optional[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: alicloud:ecs/getSecurityGroups:getSecurityGroups
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

EnableDetails bool
Ids List<string>
A list of Security Group IDs.
NameRegex Changes to this property will trigger replacement. string
A regex string to filter the resulting security groups by their names.
OutputFile string
File name where to save data source results (after running pulumi preview).
PageNumber int
PageSize int
ResourceGroupId Changes to this property will trigger replacement. string
The Id of resource group which the security_group belongs.
Tags Dictionary<string, string>
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2
title="Optional"> <span id="vpcid_csharp">

VpcId Changes to this property will trigger replacement. string

Used to retrieve security groups that belong to the specified VPC ID.

EnableDetails bool
Ids []string
A list of Security Group IDs.
NameRegex Changes to this property will trigger replacement. string
A regex string to filter the resulting security groups by their names.
OutputFile string
File name where to save data source results (after running pulumi preview).
PageNumber int
PageSize int
ResourceGroupId Changes to this property will trigger replacement. string
The Id of resource group which the security_group belongs.
Tags map[string]string
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2
title="Optional"> <span id="vpcid_go">

VpcId Changes to this property will trigger replacement. string

Used to retrieve security groups that belong to the specified VPC ID.

enableDetails Boolean
ids List<String>
A list of Security Group IDs.
nameRegex Changes to this property will trigger replacement. String
A regex string to filter the resulting security groups by their names.
outputFile String
File name where to save data source results (after running pulumi preview).
pageNumber Integer
pageSize Integer
resourceGroupId Changes to this property will trigger replacement. String
The Id of resource group which the security_group belongs.
tags Map<String,String>
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2
title="Optional"> <span id="vpcid_java">

vpcId Changes to this property will trigger replacement. String

Used to retrieve security groups that belong to the specified VPC ID.

enableDetails boolean
ids string[]
A list of Security Group IDs.
nameRegex Changes to this property will trigger replacement. string
A regex string to filter the resulting security groups by their names.
outputFile string
File name where to save data source results (after running pulumi preview).
pageNumber number
pageSize number
resourceGroupId Changes to this property will trigger replacement. string
The Id of resource group which the security_group belongs.
tags {[key: string]: string}
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2
title="Optional"> <span id="vpcid_nodejs">

vpcId Changes to this property will trigger replacement. string

Used to retrieve security groups that belong to the specified VPC ID.

enable_details bool
ids Sequence[str]
A list of Security Group IDs.
name_regex Changes to this property will trigger replacement. str
A regex string to filter the resulting security groups by their names.
output_file str
File name where to save data source results (after running pulumi preview).
page_number int
page_size int
resource_group_id Changes to this property will trigger replacement. str
The Id of resource group which the security_group belongs.
tags Mapping[str, str]
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2
title="Optional"> <span id="vpc_id_python">

vpc_id Changes to this property will trigger replacement. str

Used to retrieve security groups that belong to the specified VPC ID.

enableDetails Boolean
ids List<String>
A list of Security Group IDs.
nameRegex Changes to this property will trigger replacement. String
A regex string to filter the resulting security groups by their names.
outputFile String
File name where to save data source results (after running pulumi preview).
pageNumber Number
pageSize Number
resourceGroupId Changes to this property will trigger replacement. String
The Id of resource group which the security_group belongs.
tags Map<String>
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2
title="Optional"> <span id="vpcid_yaml">

vpcId Changes to this property will trigger replacement. String

Used to retrieve security groups that belong to the specified VPC ID.

getSecurityGroups Result

The following output properties are available:

Groups List<Pulumi.AliCloud.Ecs.Outputs.GetSecurityGroupsGroup>
A list of Security Groups. Each element contains the following attributes:
Id string
The provider-assigned unique ID for this managed resource.
Ids List<string>
A list of Security Group IDs.
Names List<string>
A list of Security Group names.
TotalCount int
EnableDetails bool
NameRegex string
OutputFile string
PageNumber int
PageSize int
ResourceGroupId string
The Id of resource group which the security_group belongs.
Tags Dictionary<string, string>
A map of tags assigned to the ECS instance.
VpcId string
The ID of the VPC that owns the security group.
Groups []GetSecurityGroupsGroup
A list of Security Groups. Each element contains the following attributes:
Id string
The provider-assigned unique ID for this managed resource.
Ids []string
A list of Security Group IDs.
Names []string
A list of Security Group names.
TotalCount int
EnableDetails bool
NameRegex string
OutputFile string
PageNumber int
PageSize int
ResourceGroupId string
The Id of resource group which the security_group belongs.
Tags map[string]string
A map of tags assigned to the ECS instance.
VpcId string
The ID of the VPC that owns the security group.
groups List<GetSecurityGroupsGroup>
A list of Security Groups. Each element contains the following attributes:
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
A list of Security Group IDs.
names List<String>
A list of Security Group names.
totalCount Integer
enableDetails Boolean
nameRegex String
outputFile String
pageNumber Integer
pageSize Integer
resourceGroupId String
The Id of resource group which the security_group belongs.
tags Map<String,String>
A map of tags assigned to the ECS instance.
vpcId String
The ID of the VPC that owns the security group.
groups GetSecurityGroupsGroup[]
A list of Security Groups. Each element contains the following attributes:
id string
The provider-assigned unique ID for this managed resource.
ids string[]
A list of Security Group IDs.
names string[]
A list of Security Group names.
totalCount number
enableDetails boolean
nameRegex string
outputFile string
pageNumber number
pageSize number
resourceGroupId string
The Id of resource group which the security_group belongs.
tags {[key: string]: string}
A map of tags assigned to the ECS instance.
vpcId string
The ID of the VPC that owns the security group.
groups Sequence[GetSecurityGroupsGroup]
A list of Security Groups. Each element contains the following attributes:
id str
The provider-assigned unique ID for this managed resource.
ids Sequence[str]
A list of Security Group IDs.
names Sequence[str]
A list of Security Group names.
total_count int
enable_details bool
name_regex str
output_file str
page_number int
page_size int
resource_group_id str
The Id of resource group which the security_group belongs.
tags Mapping[str, str]
A map of tags assigned to the ECS instance.
vpc_id str
The ID of the VPC that owns the security group.
groups List<Property Map>
A list of Security Groups. Each element contains the following attributes:
id String
The provider-assigned unique ID for this managed resource.
ids List<String>
A list of Security Group IDs.
names List<String>
A list of Security Group names.
totalCount Number
enableDetails Boolean
nameRegex String
outputFile String
pageNumber Number
pageSize Number
resourceGroupId String
The Id of resource group which the security_group belongs.
tags Map<String>
A map of tags assigned to the ECS instance.
vpcId String
The ID of the VPC that owns the security group.

Supporting Types

GetSecurityGroupsGroup

CreationTime This property is required. string
Creation time of the security group.
Description This property is required. string
The description of the security group.
Id This property is required. string
The ID of the security group.
InnerAccess This property is required. bool
Whether to allow inner network access.
Name This property is required. string
The name of the security group.
ResourceGroupId This property is required. string
The Id of resource group which the security_group belongs.
SecurityGroupType This property is required. string
The type of the security group.
VpcId This property is required. string
Used to retrieve security groups that belong to the specified VPC ID.
Tags Dictionary<string, string>
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2
CreationTime This property is required. string
Creation time of the security group.
Description This property is required. string
The description of the security group.
Id This property is required. string
The ID of the security group.
InnerAccess This property is required. bool
Whether to allow inner network access.
Name This property is required. string
The name of the security group.
ResourceGroupId This property is required. string
The Id of resource group which the security_group belongs.
SecurityGroupType This property is required. string
The type of the security group.
VpcId This property is required. string
Used to retrieve security groups that belong to the specified VPC ID.
Tags map[string]string
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2
creationTime This property is required. String
Creation time of the security group.
description This property is required. String
The description of the security group.
id This property is required. String
The ID of the security group.
innerAccess This property is required. Boolean
Whether to allow inner network access.
name This property is required. String
The name of the security group.
resourceGroupId This property is required. String
The Id of resource group which the security_group belongs.
securityGroupType This property is required. String
The type of the security group.
vpcId This property is required. String
Used to retrieve security groups that belong to the specified VPC ID.
tags Map<String,String>
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2
creationTime This property is required. string
Creation time of the security group.
description This property is required. string
The description of the security group.
id This property is required. string
The ID of the security group.
innerAccess This property is required. boolean
Whether to allow inner network access.
name This property is required. string
The name of the security group.
resourceGroupId This property is required. string
The Id of resource group which the security_group belongs.
securityGroupType This property is required. string
The type of the security group.
vpcId This property is required. string
Used to retrieve security groups that belong to the specified VPC ID.
tags {[key: string]: string}
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2
creation_time This property is required. str
Creation time of the security group.
description This property is required. str
The description of the security group.
id This property is required. str
The ID of the security group.
inner_access This property is required. bool
Whether to allow inner network access.
name This property is required. str
The name of the security group.
resource_group_id This property is required. str
The Id of resource group which the security_group belongs.
security_group_type This property is required. str
The type of the security group.
vpc_id This property is required. str
Used to retrieve security groups that belong to the specified VPC ID.
tags Mapping[str, str]
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2
creationTime This property is required. String
Creation time of the security group.
description This property is required. String
The description of the security group.
id This property is required. String
The ID of the security group.
innerAccess This property is required. Boolean
Whether to allow inner network access.
name This property is required. String
The name of the security group.
resourceGroupId This property is required. String
The Id of resource group which the security_group belongs.
securityGroupType This property is required. String
The type of the security group.
vpcId This property is required. String
Used to retrieve security groups that belong to the specified VPC ID.
tags Map<String>
A map of tags assigned to the ECS instances. It must be in the format:

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

const taggedSecurityGroups = alicloud.ecs.getSecurityGroups({ tags: { tagKey1: "tagValue1", tagKey2: "tagValue2", }, });

import pulumi
import pulumi_alicloud as alicloud

tagged_security_groups = alicloud.ecs.get_security_groups(tags={
    "tagKey1": "tagValue1",
    "tagKey2": "tagValue2",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var taggedSecurityGroups = AliCloud.Ecs.GetSecurityGroups.Invoke(new()
    {
        Tags = 
        {
            { "tagKey1", "tagValue1" },
            { "tagKey2", "tagValue2" },
        },
    });

});
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecs.GetSecurityGroups(ctx, &ecs.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"tagKey1": "tagValue1",
				"tagKey2": "tagValue2",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.ecs.EcsFunctions;
import com.pulumi.alicloud.ecs.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 taggedSecurityGroups = EcsFunctions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("tagKey1", "tagValue1"),
                Map.entry("tagKey2", "tagValue2")
            ))
            .build());

    }
}
variables:
  taggedSecurityGroups:
    fn::invoke:
      function: alicloud:ecs:getSecurityGroups
      arguments:
        tags:
          tagKey1: tagValue1
          tagKey2: tagValue2

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi