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
LookupSecurityGroupin the Go SDK.
public static class GetSecurityGroup {
public static Task<GetSecurityGroupResult> InvokeAsync(GetSecurityGroupArgs args, InvokeOptions? opts = null)
}The following arguments are supported:
- Filters
List<Get
Security Group Filter Args> 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.
- Dictionary<string, string>
A map of tags, each pair of which must exactly match a pair on the desired security group.
- Vpc
Id string The id of the VPC that the desired security group belongs to.
- Filters
[]Get
Security Group Filter 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.
- map[string]string
A map of tags, each pair of which must exactly match a pair on the desired security group.
- Vpc
Id string The id of the VPC that the desired security group belongs to.
- filters
Get
Security Group Filter[] 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.
- {[key: string]: string}
A map of tags, each pair of which must exactly match a pair on the desired security group.
- vpc
Id string The id of the VPC that the desired security group belongs to.
- filters
List[Get
Security Group Filter] 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.
- 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:
Supporting Types
GetSecurityGroupFilter
- 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
awsTerraform Provider.