GetPrefixList
aws.getPrefixList provides details about a specific prefix list (PL)
in the current region.
This can be used both to validate a prefix list given in a variable and to obtain the CIDR blocks (IP address ranges) for the associated AWS service. The latter may be useful e.g. for adding network ACL rules.
Example Usage
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var privateS3VpcEndpoint = new Aws.Ec2.VpcEndpoint("privateS3VpcEndpoint", new Aws.Ec2.VpcEndpointArgs
{
ServiceName = "com.amazonaws.us-west-2.s3",
VpcId = aws_vpc.Foo.Id,
});
var privateS3PrefixList = privateS3VpcEndpoint.PrefixListId.Apply(prefixListId => Aws.GetPrefixList.InvokeAsync(new Aws.GetPrefixListArgs
{
PrefixListId = prefixListId,
}));
var bar = new Aws.Ec2.NetworkAcl("bar", new Aws.Ec2.NetworkAclArgs
{
VpcId = aws_vpc.Foo.Id,
});
var privateS3NetworkAclRule = new Aws.Ec2.NetworkAclRule("privateS3NetworkAclRule", new Aws.Ec2.NetworkAclRuleArgs
{
CidrBlock = privateS3PrefixList.Apply(privateS3PrefixList => privateS3PrefixList.CidrBlocks[0]),
Egress = false,
FromPort = 443,
NetworkAclId = bar.Id,
Protocol = "tcp",
RuleAction = "allow",
RuleNumber = 200,
ToPort = 443,
});
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws"
"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 {
privateS3VpcEndpoint, err := ec2.NewVpcEndpoint(ctx, "privateS3VpcEndpoint", &ec2.VpcEndpointArgs{
ServiceName: pulumi.String("com.amazonaws.us-west-2.s3"),
VpcId: pulumi.String(aws_vpc.Foo.Id),
})
if err != nil {
return err
}
bar, err := ec2.NewNetworkAcl(ctx, "bar", &ec2.NetworkAclArgs{
VpcId: pulumi.String(aws_vpc.Foo.Id),
})
if err != nil {
return err
}
_, err = ec2.NewNetworkAclRule(ctx, "privateS3NetworkAclRule", &ec2.NetworkAclRuleArgs{
CidrBlock: privateS3PrefixList.ApplyT(func(privateS3PrefixList aws.GetPrefixListResult) (string, error) {
return privateS3PrefixList.CidrBlocks[0], nil
}).(pulumi.StringOutput),
Egress: pulumi.Bool(false),
FromPort: pulumi.Int(443),
NetworkAclId: bar.ID(),
Protocol: pulumi.String("tcp"),
RuleAction: pulumi.String("allow"),
RuleNumber: pulumi.Int(200),
ToPort: pulumi.Int(443),
})
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
private_s3_vpc_endpoint = aws.ec2.VpcEndpoint("privateS3VpcEndpoint",
service_name="com.amazonaws.us-west-2.s3",
vpc_id=aws_vpc["foo"]["id"])
private_s3_prefix_list = private_s3_vpc_endpoint.prefix_list_id.apply(lambda prefix_list_id: aws.get_prefix_list(prefix_list_id=prefix_list_id))
bar = aws.ec2.NetworkAcl("bar", vpc_id=aws_vpc["foo"]["id"])
private_s3_network_acl_rule = aws.ec2.NetworkAclRule("privateS3NetworkAclRule",
cidr_block=private_s3_prefix_list.cidr_blocks[0],
egress=False,
from_port=443,
network_acl_id=bar.id,
protocol="tcp",
rule_action="allow",
rule_number=200,
to_port=443)import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const privateS3VpcEndpoint = new aws.ec2.VpcEndpoint("private_s3", {
serviceName: "com.amazonaws.us-west-2.s3",
vpcId: aws_vpc_foo.id,
});
const privateS3PrefixList = privateS3VpcEndpoint.prefixListId.apply(prefixListId => aws.getPrefixList({
prefixListId: prefixListId,
}, { async: true }));
const bar = new aws.ec2.NetworkAcl("bar", {
vpcId: aws_vpc_foo.id,
});
const privateS3NetworkAclRule = new aws.ec2.NetworkAclRule("private_s3", {
cidrBlock: privateS3PrefixList.apply(privateS3PrefixList => privateS3PrefixList.cidrBlocks[0]),
egress: false,
fromPort: 443,
networkAclId: bar.id,
protocol: "tcp",
ruleAction: "allow",
ruleNumber: 200,
toPort: 443,
});Filter
using Pulumi;
using Aws = Pulumi.Aws;
class MyStack : Stack
{
public MyStack()
{
var test = Output.Create(Aws.GetPrefixList.InvokeAsync(new Aws.GetPrefixListArgs
{
Filters =
{
new Aws.Inputs.GetPrefixListFilterArgs
{
Name = "prefix-list-id",
Values =
{
"pl-68a54001",
},
},
},
}));
}
}
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v2/go/aws"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := aws.GetPrefixList(ctx, &aws.GetPrefixListArgs{
Filters: []aws.GetPrefixListFilter{
aws.GetPrefixListFilter{
Name: "prefix-list-id",
Values: []string{
"pl-68a54001",
},
},
},
}, nil)
if err != nil {
return err
}
return nil
})
}import pulumi
import pulumi_aws as aws
test = aws.get_prefix_list(filters=[{
"name": "prefix-list-id",
"values": ["pl-68a54001"],
}])import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const test = pulumi.output(aws.getPrefixList({
filters: [{
name: "prefix-list-id",
values: ["pl-68a54001"],
}],
}, { async: true }));Using GetPrefixList
function getPrefixList(args: GetPrefixListArgs, opts?: InvokeOptions): Promise<GetPrefixListResult>function get_prefix_list(filters=None, name=None, prefix_list_id=None, opts=None)func GetPrefixList(ctx *Context, args *GetPrefixListArgs, opts ...InvokeOption) (*GetPrefixListResult, error)public static class GetPrefixList {
public static Task<GetPrefixListResult> InvokeAsync(GetPrefixListArgs args, InvokeOptions? opts = null)
}The following arguments are supported:
- Filters
List<Get
Prefix List Filter Args> Configuration block(s) for filtering. Detailed below.
- Name string
The name of the filter field. Valid values can be found in the EC2 DescribePrefixLists API Reference.
- Prefix
List stringId The ID of the prefix list to select.
- Filters
[]Get
Prefix List Filter Configuration block(s) for filtering. Detailed below.
- Name string
The name of the filter field. Valid values can be found in the EC2 DescribePrefixLists API Reference.
- Prefix
List stringId The ID of the prefix list to select.
- filters
Get
Prefix List Filter[] Configuration block(s) for filtering. Detailed below.
- name string
The name of the filter field. Valid values can be found in the EC2 DescribePrefixLists API Reference.
- prefix
List stringId The ID of the prefix list to select.
- filters
List[Get
Prefix List Filter] Configuration block(s) for filtering. Detailed below.
- name str
The name of the filter field. Valid values can be found in the EC2 DescribePrefixLists API Reference.
- prefix_
list_ strid The ID of the prefix list to select.
GetPrefixList Result
The following output properties are available:
- Cidr
Blocks List<string> The list of CIDR blocks for the AWS service associated with the prefix list.
- Id string
The provider-assigned unique ID for this managed resource.
- Name string
The name of the selected prefix list.
- Filters
List<Get
Prefix List Filter> - Prefix
List stringId
- Cidr
Blocks []string The list of CIDR blocks for the AWS service associated with the prefix list.
- Id string
The provider-assigned unique ID for this managed resource.
- Name string
The name of the selected prefix list.
- Filters
[]Get
Prefix List Filter - Prefix
List stringId
- cidr
Blocks string[] The list of CIDR blocks for the AWS service associated with the prefix list.
- id string
The provider-assigned unique ID for this managed resource.
- name string
The name of the selected prefix list.
- filters
Get
Prefix List Filter[] - prefix
List stringId
- cidr_
blocks List[str] The list of CIDR blocks for the AWS service associated with the prefix list.
- id str
The provider-assigned unique ID for this managed resource.
- name str
The name of the selected prefix list.
- filters
List[Get
Prefix List Filter] - prefix_
list_ strid
Supporting Types
GetPrefixListFilter
- Name string
The name of the filter field. Valid values can be found in the EC2 DescribePrefixLists API Reference.
- Values List<string>
Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
- Name string
The name of the filter field. Valid values can be found in the EC2 DescribePrefixLists API Reference.
- Values []string
Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
- name string
The name of the filter field. Valid values can be found in the EC2 DescribePrefixLists API Reference.
- values string[]
Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
- name str
The name of the filter field. Valid values can be found in the EC2 DescribePrefixLists API Reference.
- values List[str]
Set of values that are accepted for the given filter field. Results will be selected if any given value matches.
Package Details
- Repository
- https://github.com/pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
awsTerraform Provider.