AWS Classic

Pulumi Official
Package maintained by Pulumi
v5.4.0 published on Wednesday, May 4, 2022 by Pulumi

getSecurityGroups

Use this data source to get IDs and VPC membership of Security Groups that are created outside of this provider.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var test = Output.Create(Aws.Ec2.GetSecurityGroups.InvokeAsync(new Aws.Ec2.GetSecurityGroupsArgs
        {
            Tags = 
            {
                { "Application", "k8s" },
                { "Environment", "dev" },
            },
        }));
    }

}
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ec2.GetSecurityGroups(ctx, &ec2.GetSecurityGroupsArgs{
			Tags: map[string]interface{}{
				"Application": "k8s",
				"Environment": "dev",
			},
		}, nil)
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import java.util.*;
import java.io.*;
import java.nio.*;
import com.pulumi.*;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var test = Output.of(Ec2Functions.getSecurityGroups(GetSecurityGroupsArgs.builder()
            .tags(Map.ofEntries(
                Map.entry("Application", "k8s"),
                Map.entry("Environment", "dev")
            ))
            .build()));

        }
}
import pulumi
import pulumi_aws as aws

test = aws.ec2.get_security_groups(tags={
    "Application": "k8s",
    "Environment": "dev",
})
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const test = pulumi.output(aws.ec2.getSecurityGroups({
    tags: {
        Application: "k8s",
        Environment: "dev",
    },
}));
variables:
  test:
    Fn::Invoke:
      Function: aws:ec2:getSecurityGroups
      Arguments:
        tags:
          Application: k8s
          Environment: dev

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(filters: Optional[Sequence[GetSecurityGroupsFilter]] = None,
                        tags: Optional[Mapping[str, str]] = None,
                        opts: Optional[InvokeOptions] = None) -> GetSecurityGroupsResult
def get_security_groups_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetSecurityGroupsFilterArgs]]]] = 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)
// Output-based functions aren't available in Java yet
Fn::Invoke:
  Function: aws:ec2/getSecurityGroups:getSecurityGroups
  Arguments:
    # Arguments dictionary

The following arguments are supported:

Filters List<Pulumi.Aws.Ec2.Inputs.GetSecurityGroupsFilter>

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-security-groups in the AWS CLI reference][1].

Tags Dictionary<string, string>

A map of tags, each pair of which must exactly match for desired security groups.

Filters []GetSecurityGroupsFilter

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-security-groups in the AWS CLI reference][1].

Tags map[string]string

A map of tags, each pair of which must exactly match for desired security groups.

filters ListSecurityGroupsFilter>

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-security-groups in the AWS CLI reference][1].

tags Map

A map of tags, each pair of which must exactly match for desired security groups.

filters GetSecurityGroupsFilter[]

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-security-groups in the AWS CLI reference][1].

tags {[key: string]: string}

A map of tags, each pair of which must exactly match for desired security groups.

filters Sequence[GetSecurityGroupsFilter]

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-security-groups in the AWS CLI reference][1].

tags Mapping[str, str]

A map of tags, each pair of which must exactly match for desired security groups.

filters List

One or more name/value pairs to use as filters. There are several valid keys, for a full reference, check out [describe-security-groups in the AWS CLI reference][1].

tags Map

A map of tags, each pair of which must exactly match for desired security groups.

getSecurityGroups Result

The following output properties are available:

Arns List<string>

ARNs of the matched security groups.

Id string

The provider-assigned unique ID for this managed resource.

Ids List<string>

IDs of the matches security groups.

Tags Dictionary<string, string>
VpcIds List<string>

The VPC IDs of the matched security groups. The data source's tag or filter will span VPCs unless the vpc-id filter is also used.

Filters List<Pulumi.Aws.Ec2.Outputs.GetSecurityGroupsFilter>
Arns []string

ARNs of the matched security groups.

Id string

The provider-assigned unique ID for this managed resource.

Ids []string

IDs of the matches security groups.

Tags map[string]string
VpcIds []string

The VPC IDs of the matched security groups. The data source's tag or filter will span VPCs unless the vpc-id filter is also used.

Filters []GetSecurityGroupsFilter
arns List

ARNs of the matched security groups.

id String

The provider-assigned unique ID for this managed resource.

ids List

IDs of the matches security groups.

tags Map
vpcIds List

The VPC IDs of the matched security groups. The data source's tag or filter will span VPCs unless the vpc-id filter is also used.

filters ListSecurityGroupsFilter>
arns string[]

ARNs of the matched security groups.

id string

The provider-assigned unique ID for this managed resource.

ids string[]

IDs of the matches security groups.

tags {[key: string]: string}
vpcIds string[]

The VPC IDs of the matched security groups. The data source's tag or filter will span VPCs unless the vpc-id filter is also used.

filters GetSecurityGroupsFilter[]
arns Sequence[str]

ARNs of the matched security groups.

id str

The provider-assigned unique ID for this managed resource.

ids Sequence[str]

IDs of the matches security groups.

tags Mapping[str, str]
vpc_ids Sequence[str]

The VPC IDs of the matched security groups. The data source's tag or filter will span VPCs unless the vpc-id filter is also used.

filters Sequence[GetSecurityGroupsFilter]
arns List

ARNs of the matched security groups.

id String

The provider-assigned unique ID for this managed resource.

ids List

IDs of the matches security groups.

tags Map
vpcIds List

The VPC IDs of the matched security groups. The data source's tag or filter will span VPCs unless the vpc-id filter is also used.

filters List

Supporting Types

GetSecurityGroupsFilter

Name string
Values List<string>
Name string
Values []string
name String
values List
name string
values string[]
name str
values Sequence[str]
name String
values List

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes

This Pulumi package is based on the aws Terraform Provider.