GetSecurityGroup

aws.ec2.SecurityGroup provides details about a specific Security Group.

This resource can prove useful when a module accepts a Security Group id as an input variable and needs to, for example, determine the id of the VPC that the security group belongs to.

Example Usage

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
    public MyStack()
    {
        var config = new Config();
        var securityGroupId = config.RequireObject<dynamic>("securityGroupId");
        var selected = Output.Create(Aws.Ec2.GetSecurityGroup.InvokeAsync(new Aws.Ec2.GetSecurityGroupArgs
        {
            Id = securityGroupId,
        }));
        var subnet = new Aws.Ec2.Subnet("subnet", new Aws.Ec2.SubnetArgs
        {
            CidrBlock = "10.0.1.0/24",
            VpcId = selected.Apply(selected => selected.VpcId),
        });
    }

}
package main

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

func main() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        opt0 := securityGroupId
        selected, err := ec2.LookupSecurityGroup(ctx, &ec2.LookupSecurityGroupArgs{
            Id: &opt0,
        }, nil)
        if err != nil {
            return err
        }
        _, err = ec2.NewSubnet(ctx, "subnet", &ec2.SubnetArgs{
            CidrBlock: pulumi.String("10.0.1.0/24"),
            VpcId:     pulumi.String(selected.VpcId),
        })
        if err != nil {
            return err
        }
        return nil
    })
}
import pulumi
import pulumi_aws as aws

config = pulumi.Config()
security_group_id = config.require_object("securityGroupId")
selected = aws.ec2.get_security_group(id=security_group_id)
subnet = aws.ec2.Subnet("subnet",
    cidr_block="10.0.1.0/24",
    vpc_id=selected.vpc_id)
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const config = new pulumi.Config();
const securityGroupId = config.require("securityGroupId");

const selected = pulumi.output(aws.ec2.getSecurityGroup({
    id: securityGroupId,
}, { async: true }));
const subnet = new aws.ec2.Subnet("subnet", {
    cidrBlock: "10.0.1.0/24",
    vpcId: selected.vpcId!,
});

Using GetSecurityGroup

function getSecurityGroup(args: GetSecurityGroupArgs, opts?: InvokeOptions): Promise<GetSecurityGroupResult>
function  get_security_group(filters=None, id=None, name=None, tags=None, vpc_id=None, opts=None)
func LookupSecurityGroup(ctx *Context, args *LookupSecurityGroupArgs, opts ...InvokeOption) (*LookupSecurityGroupResult, error)

Note: This function is named LookupSecurityGroup in the Go SDK.

public static class GetSecurityGroup {
    public static Task<GetSecurityGroupResult> InvokeAsync(GetSecurityGroupArgs args, InvokeOptions? opts = null)
}

The following arguments are supported:

Filters List<GetSecurityGroupFilterArgs>

Custom filter block as described below.

Id string

The id of the specific security group to retrieve.

Name string

The name of the field to filter by, as defined by the underlying AWS API.

Tags Dictionary<string, string>

A map of tags, each pair of which must exactly match a pair on the desired security group.

VpcId string

The id of the VPC that the desired security group belongs to.

Filters []GetSecurityGroupFilter

Custom filter block as described below.

Id string

The id of the specific security group to retrieve.

Name string

The name of the field to filter by, as defined by the underlying AWS API.

Tags map[string]string

A map of tags, each pair of which must exactly match a pair on the desired security group.

VpcId string

The id of the VPC that the desired security group belongs to.

filters GetSecurityGroupFilter[]

Custom filter block as described below.

id string

The id of the specific security group to retrieve.

name string

The name of the field to filter by, as defined by the underlying AWS API.

tags {[key: string]: string}

A map of tags, each pair of which must exactly match a pair on the desired security group.

vpcId string

The id of the VPC that the desired security group belongs to.

filters List[GetSecurityGroupFilter]

Custom filter block as described below.

id str

The id of the specific security group to retrieve.

name str

The name of the field to filter by, as defined by the underlying AWS API.

tags Dict[str, str]

A map of tags, each pair of which must exactly match a pair on the desired security group.

vpc_id str

The id of the VPC that the desired security group belongs to.

GetSecurityGroup Result

The following output properties are available:

Arn string

The computed ARN of the security group.

Description string

The description of the security group.

Id string
Name string
Tags Dictionary<string, string>
VpcId string
Filters List<GetSecurityGroupFilter>
Arn string

The computed ARN of the security group.

Description string

The description of the security group.

Id string
Name string
Tags map[string]string
VpcId string
Filters []GetSecurityGroupFilter
arn string

The computed ARN of the security group.

description string

The description of the security group.

id string
name string
tags {[key: string]: string}
vpcId string
filters GetSecurityGroupFilter[]
arn str

The computed ARN of the security group.

description str

The description of the security group.

id str
name str
tags Dict[str, str]
vpc_id str
filters List[GetSecurityGroupFilter]

Supporting Types

GetSecurityGroupFilter

See the input and output API doc for this type.

See the input and output API doc for this type.

See the input and output API doc for this type.

Name string

The name of the field to filter by, as defined by the underlying AWS API.

Values List<string>

Set of values that are accepted for the given field. A Security Group will be selected if any one of the given values matches.

Name string

The name of the field to filter by, as defined by the underlying AWS API.

Values []string

Set of values that are accepted for the given field. A Security Group will be selected if any one of the given values matches.

name string

The name of the field to filter by, as defined by the underlying AWS API.

values string[]

Set of values that are accepted for the given field. A Security Group will be selected if any one of the given values matches.

name str

The name of the field to filter by, as defined by the underlying AWS API.

values List[str]

Set of values that are accepted for the given field. A Security Group will be selected if any one of the given values matches.

Package Details

Repository
https://github.com/pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.