github.com/pulumi/pulumi-aws/sdk/v6@v6.32.0/go/aws/ec2/getPrefixList.go (about)

     1  // Code generated by the Pulumi Terraform Bridge (tfgen) Tool DO NOT EDIT.
     2  // *** WARNING: Do not edit by hand unless you're certain you know what you are doing! ***
     3  
     4  package ec2
     5  
     6  import (
     7  	"context"
     8  	"reflect"
     9  
    10  	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/internal"
    11  	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    12  )
    13  
    14  // `ec2.getPrefixList` provides details about a specific AWS prefix list (PL)
    15  // in the current region.
    16  //
    17  // This can be used both to validate a prefix list given in a variable
    18  // and to obtain the CIDR blocks (IP address ranges) for the associated
    19  // AWS service. The latter may be useful e.g., for adding network ACL
    20  // rules.
    21  //
    22  // The ec2.ManagedPrefixList data source is normally more appropriate to use given it can return customer-managed prefix list info, as well as additional attributes.
    23  //
    24  // ## Example Usage
    25  //
    26  // <!--Start PulumiCodeChooser -->
    27  // ```go
    28  // package main
    29  //
    30  // import (
    31  //
    32  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    33  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    34  //
    35  // )
    36  //
    37  //	func main() {
    38  //		pulumi.Run(func(ctx *pulumi.Context) error {
    39  //			privateS3VpcEndpoint, err := ec2.NewVpcEndpoint(ctx, "private_s3", &ec2.VpcEndpointArgs{
    40  //				VpcId:       pulumi.Any(foo.Id),
    41  //				ServiceName: pulumi.String("com.amazonaws.us-west-2.s3"),
    42  //			})
    43  //			if err != nil {
    44  //				return err
    45  //			}
    46  //			privateS3 := ec2.GetPrefixListOutput(ctx, ec2.GetPrefixListOutputArgs{
    47  //				PrefixListId: privateS3VpcEndpoint.PrefixListId,
    48  //			}, nil)
    49  //			bar, err := ec2.NewNetworkAcl(ctx, "bar", &ec2.NetworkAclArgs{
    50  //				VpcId: pulumi.Any(foo.Id),
    51  //			})
    52  //			if err != nil {
    53  //				return err
    54  //			}
    55  //			_, err = ec2.NewNetworkAclRule(ctx, "private_s3", &ec2.NetworkAclRuleArgs{
    56  //				NetworkAclId: bar.ID(),
    57  //				RuleNumber:   pulumi.Int(200),
    58  //				Egress:       pulumi.Bool(false),
    59  //				Protocol:     pulumi.String("tcp"),
    60  //				RuleAction:   pulumi.String("allow"),
    61  //				CidrBlock: privateS3.ApplyT(func(privateS3 ec2.GetPrefixListResult) (*string, error) {
    62  //					return &privateS3.CidrBlocks[0], nil
    63  //				}).(pulumi.StringPtrOutput),
    64  //				FromPort: pulumi.Int(443),
    65  //				ToPort:   pulumi.Int(443),
    66  //			})
    67  //			if err != nil {
    68  //				return err
    69  //			}
    70  //			return nil
    71  //		})
    72  //	}
    73  //
    74  // ```
    75  // <!--End PulumiCodeChooser -->
    76  //
    77  // ### Filter
    78  //
    79  // <!--Start PulumiCodeChooser -->
    80  // ```go
    81  // package main
    82  //
    83  // import (
    84  //
    85  //	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ec2"
    86  //	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    87  //
    88  // )
    89  //
    90  //	func main() {
    91  //		pulumi.Run(func(ctx *pulumi.Context) error {
    92  //			_, err := ec2.GetPrefixList(ctx, &ec2.GetPrefixListArgs{
    93  //				Filters: []ec2.GetPrefixListFilter{
    94  //					{
    95  //						Name: "prefix-list-id",
    96  //						Values: []string{
    97  //							"pl-68a54001",
    98  //						},
    99  //					},
   100  //				},
   101  //			}, nil)
   102  //			if err != nil {
   103  //				return err
   104  //			}
   105  //			return nil
   106  //		})
   107  //	}
   108  //
   109  // ```
   110  // <!--End PulumiCodeChooser -->
   111  func GetPrefixList(ctx *pulumi.Context, args *GetPrefixListArgs, opts ...pulumi.InvokeOption) (*GetPrefixListResult, error) {
   112  	opts = internal.PkgInvokeDefaultOpts(opts)
   113  	var rv GetPrefixListResult
   114  	err := ctx.Invoke("aws:ec2/getPrefixList:getPrefixList", args, &rv, opts...)
   115  	if err != nil {
   116  		return nil, err
   117  	}
   118  	return &rv, nil
   119  }
   120  
   121  // A collection of arguments for invoking getPrefixList.
   122  type GetPrefixListArgs struct {
   123  	// Configuration block(s) for filtering. Detailed below.
   124  	Filters []GetPrefixListFilter `pulumi:"filters"`
   125  	// Name of the prefix list to select.
   126  	Name *string `pulumi:"name"`
   127  	// ID of the prefix list to select.
   128  	PrefixListId *string `pulumi:"prefixListId"`
   129  }
   130  
   131  // A collection of values returned by getPrefixList.
   132  type GetPrefixListResult struct {
   133  	// List of CIDR blocks for the AWS service associated with the prefix list.
   134  	CidrBlocks []string              `pulumi:"cidrBlocks"`
   135  	Filters    []GetPrefixListFilter `pulumi:"filters"`
   136  	// The provider-assigned unique ID for this managed resource.
   137  	Id string `pulumi:"id"`
   138  	// Name of the selected prefix list.
   139  	Name         string  `pulumi:"name"`
   140  	PrefixListId *string `pulumi:"prefixListId"`
   141  }
   142  
   143  func GetPrefixListOutput(ctx *pulumi.Context, args GetPrefixListOutputArgs, opts ...pulumi.InvokeOption) GetPrefixListResultOutput {
   144  	return pulumi.ToOutputWithContext(context.Background(), args).
   145  		ApplyT(func(v interface{}) (GetPrefixListResult, error) {
   146  			args := v.(GetPrefixListArgs)
   147  			r, err := GetPrefixList(ctx, &args, opts...)
   148  			var s GetPrefixListResult
   149  			if r != nil {
   150  				s = *r
   151  			}
   152  			return s, err
   153  		}).(GetPrefixListResultOutput)
   154  }
   155  
   156  // A collection of arguments for invoking getPrefixList.
   157  type GetPrefixListOutputArgs struct {
   158  	// Configuration block(s) for filtering. Detailed below.
   159  	Filters GetPrefixListFilterArrayInput `pulumi:"filters"`
   160  	// Name of the prefix list to select.
   161  	Name pulumi.StringPtrInput `pulumi:"name"`
   162  	// ID of the prefix list to select.
   163  	PrefixListId pulumi.StringPtrInput `pulumi:"prefixListId"`
   164  }
   165  
   166  func (GetPrefixListOutputArgs) ElementType() reflect.Type {
   167  	return reflect.TypeOf((*GetPrefixListArgs)(nil)).Elem()
   168  }
   169  
   170  // A collection of values returned by getPrefixList.
   171  type GetPrefixListResultOutput struct{ *pulumi.OutputState }
   172  
   173  func (GetPrefixListResultOutput) ElementType() reflect.Type {
   174  	return reflect.TypeOf((*GetPrefixListResult)(nil)).Elem()
   175  }
   176  
   177  func (o GetPrefixListResultOutput) ToGetPrefixListResultOutput() GetPrefixListResultOutput {
   178  	return o
   179  }
   180  
   181  func (o GetPrefixListResultOutput) ToGetPrefixListResultOutputWithContext(ctx context.Context) GetPrefixListResultOutput {
   182  	return o
   183  }
   184  
   185  // List of CIDR blocks for the AWS service associated with the prefix list.
   186  func (o GetPrefixListResultOutput) CidrBlocks() pulumi.StringArrayOutput {
   187  	return o.ApplyT(func(v GetPrefixListResult) []string { return v.CidrBlocks }).(pulumi.StringArrayOutput)
   188  }
   189  
   190  func (o GetPrefixListResultOutput) Filters() GetPrefixListFilterArrayOutput {
   191  	return o.ApplyT(func(v GetPrefixListResult) []GetPrefixListFilter { return v.Filters }).(GetPrefixListFilterArrayOutput)
   192  }
   193  
   194  // The provider-assigned unique ID for this managed resource.
   195  func (o GetPrefixListResultOutput) Id() pulumi.StringOutput {
   196  	return o.ApplyT(func(v GetPrefixListResult) string { return v.Id }).(pulumi.StringOutput)
   197  }
   198  
   199  // Name of the selected prefix list.
   200  func (o GetPrefixListResultOutput) Name() pulumi.StringOutput {
   201  	return o.ApplyT(func(v GetPrefixListResult) string { return v.Name }).(pulumi.StringOutput)
   202  }
   203  
   204  func (o GetPrefixListResultOutput) PrefixListId() pulumi.StringPtrOutput {
   205  	return o.ApplyT(func(v GetPrefixListResult) *string { return v.PrefixListId }).(pulumi.StringPtrOutput)
   206  }
   207  
   208  func init() {
   209  	pulumi.RegisterOutputType(GetPrefixListResultOutput{})
   210  }