get Security Group
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
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.
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ec2.Ec2Functions;
import com.pulumi.aws.ec2.inputs.GetSecurityGroupArgs;
import com.pulumi.aws.ec2.Subnet;
import com.pulumi.aws.ec2.SubnetArgs;
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 config = ctx.config();
final var securityGroupId = config.get("securityGroupId");
final var selected = Ec2Functions.getSecurityGroup(GetSecurityGroupArgs.builder()
.id(securityGroupId)
.build());
var subnet = new Subnet("subnet", SubnetArgs.builder()
.vpcId(selected.applyValue(getSecurityGroupResult -> getSecurityGroupResult.vpcId()))
.cidrBlock("10.0.1.0/24")
.build());
}
}
Return
A collection of values returned by getSecurityGroup.
Parameters
A collection of arguments for invoking getSecurityGroup.
Return
A collection of values returned by getSecurityGroup.
Parameters
Custom filter block as described below.
Id of the specific security group to retrieve.
Name of the field to filter by, as defined by the underlying AWS API.
Map of tags, each pair of which must exactly match a pair on the desired security group.
Id of the VPC that the desired security group belongs to. More complex filters can be expressed using one or more filter
sub-blocks, which take the following arguments:
See also
Return
A collection of values returned by getSecurityGroup.
Parameters
Builder for com.pulumi.aws.ec2.kotlin.inputs.GetSecurityGroupPlainArgs.