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