1. Packages
  2. AWS
  3. API Docs
  4. vpc
  5. getSecurityGroupRules
AWS v6.75.0 published on Wednesday, Apr 2, 2025 by Pulumi

aws.vpc.getSecurityGroupRules

Explore with Pulumi AI

This resource can be useful for getting back a set of security group rule IDs.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = aws.vpc.getSecurityGroupRules({
    filters: [{
        name: "group-id",
        values: [securityGroupId],
    }],
});
Copy
import pulumi
import pulumi_aws as aws

example = aws.vpc.get_security_group_rules(filters=[{
    "name": "group-id",
    "values": [security_group_id],
}])
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/vpc"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := vpc.GetSecurityGroupRules(ctx, &vpc.GetSecurityGroupRulesArgs{
Filters: []vpc.GetSecurityGroupRulesFilter{
{
Name: "group-id",
Values: interface{}{
securityGroupId,
},
},
},
}, nil);
if err != nil {
return err
}
return nil
})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = Aws.Vpc.GetSecurityGroupRules.Invoke(new()
    {
        Filters = new[]
        {
            new Aws.Vpc.Inputs.GetSecurityGroupRulesFilterInputArgs
            {
                Name = "group-id",
                Values = new[]
                {
                    securityGroupId,
                },
            },
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.vpc.VpcFunctions;
import com.pulumi.aws.vpc.inputs.GetSecurityGroupRulesArgs;
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 example = VpcFunctions.getSecurityGroupRules(GetSecurityGroupRulesArgs.builder()
            .filters(GetSecurityGroupRulesFilterArgs.builder()
                .name("group-id")
                .values(securityGroupId)
                .build())
            .build());

    }
}
Copy
variables:
  example:
    fn::invoke:
      function: aws:vpc:getSecurityGroupRules
      arguments:
        filters:
          - name: group-id
            values:
              - ${securityGroupId}
Copy

Using getSecurityGroupRules

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 getSecurityGroupRules(args: GetSecurityGroupRulesArgs, opts?: InvokeOptions): Promise<GetSecurityGroupRulesResult>
function getSecurityGroupRulesOutput(args: GetSecurityGroupRulesOutputArgs, opts?: InvokeOptions): Output<GetSecurityGroupRulesResult>
Copy
def get_security_group_rules(filters: Optional[Sequence[GetSecurityGroupRulesFilter]] = None,
                             tags: Optional[Mapping[str, str]] = None,
                             opts: Optional[InvokeOptions] = None) -> GetSecurityGroupRulesResult
def get_security_group_rules_output(filters: Optional[pulumi.Input[Sequence[pulumi.Input[GetSecurityGroupRulesFilterArgs]]]] = None,
                             tags: Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]] = None,
                             opts: Optional[InvokeOptions] = None) -> Output[GetSecurityGroupRulesResult]
Copy
func GetSecurityGroupRules(ctx *Context, args *GetSecurityGroupRulesArgs, opts ...InvokeOption) (*GetSecurityGroupRulesResult, error)
func GetSecurityGroupRulesOutput(ctx *Context, args *GetSecurityGroupRulesOutputArgs, opts ...InvokeOption) GetSecurityGroupRulesResultOutput
Copy

> Note: This function is named GetSecurityGroupRules in the Go SDK.

public static class GetSecurityGroupRules 
{
    public static Task<GetSecurityGroupRulesResult> InvokeAsync(GetSecurityGroupRulesArgs args, InvokeOptions? opts = null)
    public static Output<GetSecurityGroupRulesResult> Invoke(GetSecurityGroupRulesInvokeArgs args, InvokeOptions? opts = null)
}
Copy
public static CompletableFuture<GetSecurityGroupRulesResult> getSecurityGroupRules(GetSecurityGroupRulesArgs args, InvokeOptions options)
public static Output<GetSecurityGroupRulesResult> getSecurityGroupRules(GetSecurityGroupRulesArgs args, InvokeOptions options)
Copy
fn::invoke:
  function: aws:vpc/getSecurityGroupRules:getSecurityGroupRules
  arguments:
    # arguments dictionary
Copy

The following arguments are supported:

Filters List<GetSecurityGroupRulesFilter>
Custom filter block as described below.
Tags Dictionary<string, string>

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

More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

Filters []GetSecurityGroupRulesFilter
Custom filter block as described below.
Tags map[string]string

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

More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

filters List<GetSecurityGroupRulesFilter>
Custom filter block as described below.
tags Map<String,String>

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

More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

filters GetSecurityGroupRulesFilter[]
Custom filter block as described below.
tags {[key: string]: string}

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

More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

filters Sequence[GetSecurityGroupRulesFilter]
Custom filter block as described below.
tags Mapping[str, str]

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

More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

filters List<Property Map>
Custom filter block as described below.
tags Map<String>

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

More complex filters can be expressed using one or more filter sub-blocks, which take the following arguments:

getSecurityGroupRules Result

The following output properties are available:

Id string
Ids List<string>
List of all the security group rule IDs found.
Filters List<GetSecurityGroupRulesFilter>
Tags Dictionary<string, string>
Id string
Ids []string
List of all the security group rule IDs found.
Filters []GetSecurityGroupRulesFilter
Tags map[string]string
id String
ids List<String>
List of all the security group rule IDs found.
filters List<GetSecurityGroupRulesFilter>
tags Map<String,String>
id string
ids string[]
List of all the security group rule IDs found.
filters GetSecurityGroupRulesFilter[]
tags {[key: string]: string}
id str
ids Sequence[str]
List of all the security group rule IDs found.
filters Sequence[GetSecurityGroupRulesFilter]
tags Mapping[str, str]
id String
ids List<String>
List of all the security group rule IDs found.
filters List<Property Map>
tags Map<String>

Supporting Types

GetSecurityGroupRulesFilter

Name This property is required. string
Name of the field to filter by, as defined by the underlying AWS API.
Values This property is required. List<string>
Set of values that are accepted for the given field. Security group rule IDs will be selected if any one of the given values match.
Name This property is required. string
Name of the field to filter by, as defined by the underlying AWS API.
Values This property is required. []string
Set of values that are accepted for the given field. Security group rule IDs will be selected if any one of the given values match.
name This property is required. String
Name of the field to filter by, as defined by the underlying AWS API.
values This property is required. List<String>
Set of values that are accepted for the given field. Security group rule IDs will be selected if any one of the given values match.
name This property is required. string
Name of the field to filter by, as defined by the underlying AWS API.
values This property is required. string[]
Set of values that are accepted for the given field. Security group rule IDs will be selected if any one of the given values match.
name This property is required. str
Name of the field to filter by, as defined by the underlying AWS API.
values This property is required. Sequence[str]
Set of values that are accepted for the given field. Security group rule IDs will be selected if any one of the given values match.
name This property is required. String
Name of the field to filter by, as defined by the underlying AWS API.
values This property is required. List<String>
Set of values that are accepted for the given field. Security group rule IDs will be selected if any one of the given values match.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.