Class GetSecurityGroup
Inheritance
System.Object
GetSecurityGroup
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Aws.Ec2
Assembly: Pulumi.Aws.dll
Syntax
public static class GetSecurityGroup
Methods
View SourceInvokeAsync(GetSecurityGroupArgs, InvokeOptions)
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.
{{% examples %}}
Example Usage
{{% example %}}
The following example shows how one might accept a Security Group id as a variable and use this data source to obtain the data necessary to create a subnet.
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),
});
}
}
{{% /example %}} {{% /examples %}}
Declaration
public static Task<GetSecurityGroupResult> InvokeAsync(GetSecurityGroupArgs args = null, InvokeOptions options = null)
Parameters
| Type | Name | Description |
|---|---|---|
| GetSecurityGroupArgs | args | |
| InvokeOptions | options |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<GetSecurityGroupResult> |