-
Notifications
You must be signed in to change notification settings - Fork 19
/
resolver.go
303 lines (235 loc) · 10.6 KB
/
resolver.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
package localstack
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/service/cloudformation"
"github.com/aws/aws-sdk-go-v2/service/cloudwatch"
"github.com/aws/aws-sdk-go-v2/service/cloudwatchevents"
"github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs"
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/aws/aws-sdk-go-v2/service/dynamodbstreams"
"github.com/aws/aws-sdk-go-v2/service/ec2"
"github.com/aws/aws-sdk-go-v2/service/elasticsearchservice"
"github.com/aws/aws-sdk-go-v2/service/firehose"
"github.com/aws/aws-sdk-go-v2/service/iam"
"github.com/aws/aws-sdk-go-v2/service/kinesis"
"github.com/aws/aws-sdk-go-v2/service/lambda"
"github.com/aws/aws-sdk-go-v2/service/redshift"
"github.com/aws/aws-sdk-go-v2/service/route53"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/aws-sdk-go-v2/service/secretsmanager"
"github.com/aws/aws-sdk-go-v2/service/ses"
"github.com/aws/aws-sdk-go-v2/service/sfn"
"github.com/aws/aws-sdk-go-v2/service/sns"
"github.com/aws/aws-sdk-go-v2/service/sqs"
"github.com/aws/aws-sdk-go-v2/service/ssm"
"github.com/aws/aws-sdk-go-v2/service/sts"
"github.com/aws/smithy-go"
smithyauth "github.com/aws/smithy-go/auth"
smithyendpoints "github.com/aws/smithy-go/endpoints"
smithyhttp "github.com/aws/smithy-go/transport/http"
"net/http"
"net/url"
)
// NewCloudformationResolverV2 resolves the services ResolverV2 endpoint
func NewCloudformationResolverV2(i *Instance) *CloudformationResolverV2 {
return &CloudformationResolverV2{i: i}
}
type CloudformationResolverV2 struct{ i *Instance }
func (c *CloudformationResolverV2) ResolveEndpoint(_ context.Context, _ cloudformation.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(CloudFormation))
}
// NewCloudwatchResolverV2 resolves the services ResolverV2 endpoint
func NewCloudwatchResolverV2(i *Instance) *CloudwatchResolverV2 {
return &CloudwatchResolverV2{i: i}
}
type CloudwatchResolverV2 struct{ i *Instance }
func (c *CloudwatchResolverV2) ResolveEndpoint(_ context.Context, _ cloudwatch.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(CloudWatch))
}
// NewCloudwatchLogsResolverV2 resolves the services ResolverV2 endpoint
func NewCloudwatchLogsResolverV2(i *Instance) *CloudwatchLogsResolverV2 {
return &CloudwatchLogsResolverV2{i: i}
}
type CloudwatchLogsResolverV2 struct{ i *Instance }
func (c *CloudwatchLogsResolverV2) ResolveEndpoint(_ context.Context, _ cloudwatchlogs.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(CloudWatchLogs))
}
// NewCloudwatchEventsResolverV2 resolves the services ResolverV2 endpoint
func NewCloudwatchEventsResolverV2(i *Instance) *CloudwatchEventsResolverV2 {
return &CloudwatchEventsResolverV2{i: i}
}
type CloudwatchEventsResolverV2 struct{ i *Instance }
func (c *CloudwatchEventsResolverV2) ResolveEndpoint(_ context.Context, _ cloudwatchevents.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(CloudWatchEvents))
}
// NewDynamoDbResolverV2 resolves the services ResolverV2 endpoint
func NewDynamoDbResolverV2(i *Instance) *DynamoDbResolver {
return &DynamoDbResolver{i: i}
}
type DynamoDbResolver struct{ i *Instance }
func (c *DynamoDbResolver) ResolveEndpoint(_ context.Context, _ dynamodb.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(DynamoDB))
}
// NewDynamoDbStreamsResolverV2 resolves the services ResolverV2 endpoint
func NewDynamoDbStreamsResolverV2(i *Instance) *DynamoDbStreamsResolverV2 {
return &DynamoDbStreamsResolverV2{i: i}
}
type DynamoDbStreamsResolverV2 struct{ i *Instance }
func (c *DynamoDbStreamsResolverV2) ResolveEndpoint(_ context.Context, _ dynamodbstreams.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(DynamoDBStreams))
}
// NewEc2ResolverV2 resolves the services ResolverV2 endpoint
func NewEc2ResolverV2(i *Instance) *Ec2ResolverV2 {
return &Ec2ResolverV2{i: i}
}
type Ec2ResolverV2 struct{ i *Instance }
func (c *Ec2ResolverV2) ResolveEndpoint(_ context.Context, _ ec2.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(EC2))
}
// NewElasticSearchResolverV2 resolves the services ResolverV2 endpoint
func NewElasticSearchResolverV2(i *Instance) *ElasticSearchResolverV2 {
return &ElasticSearchResolverV2{i: i}
}
type ElasticSearchResolverV2 struct{ i *Instance }
func (c *ElasticSearchResolverV2) ResolveEndpoint(_ context.Context, _ elasticsearchservice.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(ES))
}
// NewFirehoseResolverV2 resolves the services ResolverV2 endpoint
func NewFirehoseResolverV2(i *Instance) *FirehoseResolverV2 {
return &FirehoseResolverV2{i: i}
}
type FirehoseResolverV2 struct{ i *Instance }
func (c *FirehoseResolverV2) ResolveEndpoint(_ context.Context, _ firehose.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(Firehose))
}
// NewIamResolverV2 resolves the services ResolverV2 endpoint
func NewIamResolverV2(i *Instance) *IamResolverV2 {
return &IamResolverV2{i: i}
}
type IamResolverV2 struct{ i *Instance }
func (c *IamResolverV2) ResolveEndpoint(_ context.Context, _ iam.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(IAM))
}
// NewKinesisResolverV2 resolves the services ResolverV2 endpoint
func NewKinesisResolverV2(i *Instance) *KinesisResolverV2 {
return &KinesisResolverV2{i: i}
}
type KinesisResolverV2 struct{ i *Instance }
func (c *KinesisResolverV2) ResolveEndpoint(_ context.Context, _ kinesis.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(Kinesis))
}
// NewLambdaResolverV2 resolves the services ResolverV2 endpoint
func NewLambdaResolverV2(i *Instance) *LambdaResolverV2 {
return &LambdaResolverV2{i: i}
}
type LambdaResolverV2 struct{ i *Instance }
func (c *LambdaResolverV2) ResolveEndpoint(_ context.Context, _ lambda.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(Lambda))
}
// NewRedshiftResolverV2 resolves the services ResolverV2 endpoint
func NewRedshiftResolverV2(i *Instance) *RedshiftResolverV2 {
return &RedshiftResolverV2{i: i}
}
type RedshiftResolverV2 struct{ i *Instance }
func (c *RedshiftResolverV2) ResolveEndpoint(_ context.Context, _ redshift.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(Redshift))
}
// NewRoute53ResolverV2 resolves the services ResolverV2 endpoint
func NewRoute53ResolverV2(i *Instance) *Route53ResolverV2 {
return &Route53ResolverV2{i: i}
}
type Route53ResolverV2 struct{ i *Instance }
func (c *Route53ResolverV2) ResolveEndpoint(_ context.Context, _ route53.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(Route53))
}
// NewS3ResolverV2 resolves the services ResolverV2 endpoint
func NewS3ResolverV2(i *Instance) *S3ResolverV2 {
return &S3ResolverV2{i: i}
}
type S3ResolverV2 struct{ i *Instance }
func (c *S3ResolverV2) ResolveEndpoint(_ context.Context, _ s3.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(S3))
}
// NewSecretsManagerResolverV2 resolves the services ResolverV2 endpoint
func NewSecretsManagerResolverV2(i *Instance) *SecretsManagerResolverV2 {
return &SecretsManagerResolverV2{i: i}
}
type SecretsManagerResolverV2 struct{ i *Instance }
func (c *SecretsManagerResolverV2) ResolveEndpoint(_ context.Context, _ secretsmanager.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(SecretsManager))
}
// NewSesResolverV2 resolves the services ResolverV2 endpoint
func NewSesResolverV2(i *Instance) *SesResolverV2 {
return &SesResolverV2{i: i}
}
type SesResolverV2 struct{ i *Instance }
func (c *SesResolverV2) ResolveEndpoint(_ context.Context, _ ses.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(SES))
}
// NewSnsResolverV2 resolves the services ResolverV2 endpoint
func NewSnsResolverV2(i *Instance) *SnsResolverV2 {
return &SnsResolverV2{i: i}
}
type SnsResolverV2 struct{ i *Instance }
func (c *SnsResolverV2) ResolveEndpoint(_ context.Context, _ sns.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(SNS))
}
// NewSqsResolverV2 resolves the services ResolverV2 endpoint
func NewSqsResolverV2(i *Instance) *SqsResolverV2 {
return &SqsResolverV2{i: i}
}
type SqsResolverV2 struct{ i *Instance }
func (c *SqsResolverV2) ResolveEndpoint(_ context.Context, _ sqs.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(SQS))
}
// NewSsmResolverV2 resolves the services ResolverV2 endpoint
func NewSsmResolverV2(i *Instance) *SsmResolverV2 {
return &SsmResolverV2{i: i}
}
type SsmResolverV2 struct{ i *Instance }
func (c *SsmResolverV2) ResolveEndpoint(_ context.Context, _ ssm.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(SSM))
}
// NewStsResolverV2 resolves the services ResolverV2 endpoint
func NewStsResolverV2(i *Instance) *StsResolverV2 {
return &StsResolverV2{i: i}
}
type StsResolverV2 struct{ i *Instance }
func (c *StsResolverV2) ResolveEndpoint(_ context.Context, _ sts.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(STS))
}
// NewStepFunctionsResolverV2 resolves the services ResolverV2 endpoint
func NewStepFunctionsResolverV2(i *Instance) *StepFunctionsResolverV2 {
return &StepFunctionsResolverV2{i: i}
}
type StepFunctionsResolverV2 struct{ i *Instance }
func (c *StepFunctionsResolverV2) ResolveEndpoint(_ context.Context, _ sfn.EndpointParameters) (smithyendpoints.Endpoint, error) {
return resolveEndpoint(c.i.EndpointV2(StepFunctions))
}
func resolveEndpoint(endpoint string) (smithyendpoints.Endpoint, error) {
uri, err := url.ParseRequestURI(endpoint)
if err != nil {
return smithyendpoints.Endpoint{}, fmt.Errorf("failed to parse uri: %s", endpoint)
}
return smithyendpoints.Endpoint{
URI: *uri,
Headers: http.Header{},
Properties: func() smithy.Properties {
var out smithy.Properties
smithyauth.SetAuthOptions(&out, []*smithyauth.Option{
{
SchemeID: "aws.auth#sigv4",
SignerProperties: func() smithy.Properties {
var sp smithy.Properties
smithyhttp.SetSigV4SigningName(&sp, "dynamodb")
smithyhttp.SetSigV4ASigningName(&sp, "dynamodb")
smithyhttp.SetSigV4SigningRegion(&sp, "us-east-1")
return sp
}(),
},
})
return out
}(),
}, nil
}