-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
Copy pathconfig.go
539 lines (480 loc) · 21.3 KB
/
config.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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
package conns
import (
"context"
"log"
"strings"
"github.com/aws/aws-sdk-go-v2/feature/ec2/imds"
"github.com/aws/aws-sdk-go-v2/service/route53domains"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/endpoints"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/apigateway"
"github.com/aws/aws-sdk-go/service/appconfig"
"github.com/aws/aws-sdk-go/service/applicationautoscaling"
"github.com/aws/aws-sdk-go/service/appsync"
"github.com/aws/aws-sdk-go/service/chime"
"github.com/aws/aws-sdk-go/service/cloudformation"
"github.com/aws/aws-sdk-go/service/cloudhsmv2"
"github.com/aws/aws-sdk-go/service/configservice"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/fms"
"github.com/aws/aws-sdk-go/service/globalaccelerator"
"github.com/aws/aws-sdk-go/service/kafka"
"github.com/aws/aws-sdk-go/service/kinesis"
"github.com/aws/aws-sdk-go/service/organizations"
"github.com/aws/aws-sdk-go/service/route53"
"github.com/aws/aws-sdk-go/service/route53recoverycontrolconfig"
"github.com/aws/aws-sdk-go/service/route53recoveryreadiness"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/securityhub"
"github.com/aws/aws-sdk-go/service/shield"
"github.com/aws/aws-sdk-go/service/ssoadmin"
"github.com/aws/aws-sdk-go/service/storagegateway"
"github.com/aws/aws-sdk-go/service/sts"
"github.com/aws/aws-sdk-go/service/wafv2"
awsbase "github.com/hashicorp/aws-sdk-go-base/v2"
awsbasev1 "github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2"
"github.com/hashicorp/aws-sdk-go-base/v2/awsv1shim/v2/tfawserr"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
tftags "github.com/hashicorp/terraform-provider-aws/internal/tags"
"github.com/hashicorp/terraform-provider-aws/names"
)
type Config struct {
AccessKey string
AllowedAccountIds []string
AssumeRole *awsbase.AssumeRole
AssumeRoleWithWebIdentity *awsbase.AssumeRoleWithWebIdentity
CustomCABundle string
DefaultTagsConfig *tftags.DefaultConfig
EC2MetadataServiceEnableState imds.ClientEnableState
EC2MetadataServiceEndpoint string
EC2MetadataServiceEndpointMode string
Endpoints map[string]string
ForbiddenAccountIds []string
HTTPProxy string
IgnoreTagsConfig *tftags.IgnoreConfig
Insecure bool
MaxRetries int
Profile string
Region string
S3UsePathStyle bool
SecretKey string
SharedConfigFiles []string
SharedCredentialsFiles []string
SkipCredsValidation bool
SkipGetEC2Platforms bool
SkipRegionValidation bool
SkipRequestingAccountId bool
STSRegion string
SuppressDebugLog bool
TerraformVersion string
Token string
UseDualStackEndpoint bool
UseFIPSEndpoint bool
}
// Client configures and returns a fully initialized AWSClient
func (c *Config) Client(ctx context.Context) (interface{}, diag.Diagnostics) {
awsbaseConfig := awsbase.Config{
AccessKey: c.AccessKey,
APNInfo: StdUserAgentProducts(c.TerraformVersion),
CallerDocumentationURL: "https://registry.terraform.io/providers/hashicorp/aws",
CallerName: "Terraform AWS Provider",
EC2MetadataServiceEnableState: c.EC2MetadataServiceEnableState,
IamEndpoint: c.Endpoints[names.IAM],
Insecure: c.Insecure,
HTTPProxy: c.HTTPProxy,
MaxRetries: c.MaxRetries,
Profile: c.Profile,
Region: c.Region,
SecretKey: c.SecretKey,
SkipCredsValidation: c.SkipCredsValidation,
SkipRequestingAccountId: c.SkipRequestingAccountId,
StsEndpoint: c.Endpoints[names.STS],
SuppressDebugLog: c.SuppressDebugLog,
Token: c.Token,
UseDualStackEndpoint: c.UseDualStackEndpoint,
UseFIPSEndpoint: c.UseFIPSEndpoint,
}
if c.AssumeRole != nil && c.AssumeRole.RoleARN != "" {
awsbaseConfig.AssumeRole = c.AssumeRole
}
if c.CustomCABundle != "" {
awsbaseConfig.CustomCABundle = c.CustomCABundle
}
if c.EC2MetadataServiceEndpoint != "" {
awsbaseConfig.EC2MetadataServiceEndpoint = c.EC2MetadataServiceEndpoint
awsbaseConfig.EC2MetadataServiceEndpointMode = c.EC2MetadataServiceEndpointMode
}
if len(c.SharedConfigFiles) != 0 {
awsbaseConfig.SharedConfigFiles = c.SharedConfigFiles
}
if len(c.SharedCredentialsFiles) != 0 {
awsbaseConfig.SharedCredentialsFiles = c.SharedCredentialsFiles
}
if c.STSRegion != "" {
awsbaseConfig.StsRegion = c.STSRegion
}
cfg, err := awsbase.GetAwsConfig(ctx, &awsbaseConfig)
if err != nil {
return nil, diag.Errorf("error configuring Terraform AWS Provider: %s", err)
}
if !c.SkipRegionValidation {
if err := awsbase.ValidateRegion(cfg.Region); err != nil {
return nil, diag.FromErr(err)
}
}
c.Region = cfg.Region
sess, err := awsbasev1.GetSession(&cfg, &awsbaseConfig)
if err != nil {
return nil, diag.Errorf("error creating AWS SDK v1 session: %s", err)
}
accountID, partition, err := awsbase.GetAwsAccountIDAndPartition(ctx, cfg, &awsbaseConfig)
if err != nil {
return nil, diag.Errorf("error retrieving account details: %s", err)
}
if accountID == "" {
log.Println("[WARN] AWS account ID not found for provider. See https://www.terraform.io/docs/providers/aws/index.html#skip_requesting_account_id for implications.")
}
if len(c.ForbiddenAccountIds) > 0 {
for _, forbiddenAccountID := range c.AllowedAccountIds {
if accountID == forbiddenAccountID {
return nil, diag.Errorf("AWS Account ID not allowed: %s", accountID)
}
}
}
if len(c.AllowedAccountIds) > 0 {
found := false
for _, allowedAccountID := range c.AllowedAccountIds {
if accountID == allowedAccountID {
found = true
break
}
}
if !found {
return nil, diag.Errorf("AWS Account ID not allowed: %s", accountID)
}
}
DNSSuffix := "amazonaws.com"
if p, ok := endpoints.PartitionForRegion(endpoints.DefaultPartitions(), c.Region); ok {
DNSSuffix = p.DNSSuffix()
}
client := c.clientConns(sess)
client.AccountID = accountID
client.DefaultTagsConfig = c.DefaultTagsConfig
client.DNSSuffix = DNSSuffix
client.IgnoreTagsConfig = c.IgnoreTagsConfig
client.Partition = partition
client.Region = c.Region
client.ReverseDNSPrefix = ReverseDNS(DNSSuffix)
client.Session = sess
client.TerraformVersion = c.TerraformVersion
client.Route53DomainsConn = route53domains.NewFromConfig(cfg, func(o *route53domains.Options) {
if endpoint := c.Endpoints[names.Route53Domains]; endpoint != "" {
o.EndpointResolver = route53domains.EndpointResolverFromURL(endpoint)
} else if partition == endpoints.AwsPartitionID {
// Route 53 Domains is only available in AWS Commercial us-east-1 Region.
o.Region = endpoints.UsEast1RegionID
}
})
// sts
stsConfig := &aws.Config{
Endpoint: aws.String(c.Endpoints[names.STS]),
}
if c.STSRegion != "" {
stsConfig.Region = aws.String(c.STSRegion)
}
client.STSConn = sts.New(sess.Copy(stsConfig))
// "Global" services that require customizations
globalAcceleratorConfig := &aws.Config{
Endpoint: aws.String(c.Endpoints[names.GlobalAccelerator]),
}
route53Config := &aws.Config{
Endpoint: aws.String(c.Endpoints[names.Route53]),
}
route53RecoveryControlConfigConfig := &aws.Config{
Endpoint: aws.String(c.Endpoints[names.Route53RecoveryControlConfig]),
}
route53RecoveryReadinessConfig := &aws.Config{
Endpoint: aws.String(c.Endpoints[names.Route53RecoveryReadiness]),
}
shieldConfig := &aws.Config{
Endpoint: aws.String(c.Endpoints[names.Shield]),
}
// Services that require multiple client configurations
s3Config := &aws.Config{
Endpoint: aws.String(c.Endpoints[names.S3]),
S3ForcePathStyle: aws.Bool(c.S3UsePathStyle),
}
client.S3Conn = s3.New(sess.Copy(s3Config))
s3Config.DisableRestProtocolURICleaning = aws.Bool(true)
client.S3ConnURICleaningDisabled = s3.New(sess.Copy(s3Config))
// Force "global" services to correct regions
switch partition {
case endpoints.AwsPartitionID:
globalAcceleratorConfig.Region = aws.String(endpoints.UsWest2RegionID)
route53Config.Region = aws.String(endpoints.UsEast1RegionID)
route53RecoveryControlConfigConfig.Region = aws.String(endpoints.UsWest2RegionID)
route53RecoveryReadinessConfig.Region = aws.String(endpoints.UsWest2RegionID)
shieldConfig.Region = aws.String(endpoints.UsEast1RegionID)
case endpoints.AwsCnPartitionID:
// The AWS Go SDK is missing endpoint information for Route 53 in the AWS China partition.
// This can likely be removed in the future.
if aws.StringValue(route53Config.Endpoint) == "" {
route53Config.Endpoint = aws.String("https://api.route53.cn")
}
route53Config.Region = aws.String(endpoints.CnNorthwest1RegionID)
case endpoints.AwsUsGovPartitionID:
route53Config.Region = aws.String(endpoints.UsGovWest1RegionID)
}
client.GlobalAcceleratorConn = globalaccelerator.New(sess.Copy(globalAcceleratorConfig))
client.Route53Conn = route53.New(sess.Copy(route53Config))
client.Route53RecoveryControlConfigConn = route53recoverycontrolconfig.New(sess.Copy(route53RecoveryControlConfigConfig))
client.Route53RecoveryReadinessConn = route53recoveryreadiness.New(sess.Copy(route53RecoveryReadinessConfig))
client.ShieldConn = shield.New(sess.Copy(shieldConfig))
client.APIGatewayConn.Handlers.Retry.PushBack(func(r *request.Request) {
// Many operations can return an error such as:
// ConflictException: Unable to complete operation due to concurrent modification. Please try again later.
// Handle them all globally for the service client.
if tfawserr.ErrMessageContains(r.Error, apigateway.ErrCodeConflictException, "try again later") {
r.Retryable = aws.Bool(true)
}
})
// Workaround for https://github.com/aws/aws-sdk-go/issues/1472
client.AppAutoScalingConn.Handlers.Retry.PushBack(func(r *request.Request) {
if !strings.HasPrefix(r.Operation.Name, "Describe") && !strings.HasPrefix(r.Operation.Name, "List") {
return
}
if tfawserr.ErrCodeEquals(r.Error, applicationautoscaling.ErrCodeFailedResourceAccessException) {
r.Retryable = aws.Bool(true)
}
})
// StartDeployment operations can return a ConflictException
// if ongoing deployments are in-progress, thus we handle them
// here for the service client.
client.AppConfigConn.Handlers.Retry.PushBack(func(r *request.Request) {
if r.Operation.Name == "StartDeployment" {
if tfawserr.ErrCodeEquals(r.Error, appconfig.ErrCodeConflictException) {
r.Retryable = aws.Bool(true)
}
}
})
client.AppSyncConn.Handlers.Retry.PushBack(func(r *request.Request) {
if r.Operation.Name == "CreateGraphqlApi" {
if tfawserr.ErrMessageContains(r.Error, appsync.ErrCodeConcurrentModificationException, "a GraphQL API creation is already in progress") {
r.Retryable = aws.Bool(true)
}
}
})
client.ChimeConn.Handlers.Retry.PushBack(func(r *request.Request) {
// When calling CreateVoiceConnector across multiple resources,
// the API can randomly return a BadRequestException without explanation
if r.Operation.Name == "CreateVoiceConnector" {
if tfawserr.ErrMessageContains(r.Error, chime.ErrCodeBadRequestException, "Service received a bad request") {
r.Retryable = aws.Bool(true)
}
}
})
client.CloudHSMV2Conn.Handlers.Retry.PushBack(func(r *request.Request) {
if tfawserr.ErrMessageContains(r.Error, cloudhsmv2.ErrCodeCloudHsmInternalFailureException, "request was rejected because of an AWS CloudHSM internal failure") {
r.Retryable = aws.Bool(true)
}
})
client.ConfigServiceConn.Handlers.Retry.PushBack(func(r *request.Request) {
// When calling Config Organization Rules API actions immediately
// after Organization creation, the API can randomly return the
// OrganizationAccessDeniedException error for a few minutes, even
// after succeeding a few requests.
switch r.Operation.Name {
case "DeleteOrganizationConfigRule", "DescribeOrganizationConfigRules", "DescribeOrganizationConfigRuleStatuses", "PutOrganizationConfigRule":
if !tfawserr.ErrMessageContains(r.Error, configservice.ErrCodeOrganizationAccessDeniedException, "This action can be only made by AWS Organization's master account.") {
return
}
// We only want to retry briefly as the default max retry count would
// excessively retry when the error could be legitimate.
// We currently depend on the DefaultRetryer exponential backoff here.
// ~10 retries gives a fair backoff of a few seconds.
if r.RetryCount < 9 {
r.Retryable = aws.Bool(true)
} else {
r.Retryable = aws.Bool(false)
}
case "DeleteOrganizationConformancePack", "DescribeOrganizationConformancePacks", "DescribeOrganizationConformancePackStatuses", "PutOrganizationConformancePack":
if !tfawserr.ErrCodeEquals(r.Error, configservice.ErrCodeOrganizationAccessDeniedException) {
if r.Operation.Name == "DeleteOrganizationConformancePack" && tfawserr.ErrCodeEquals(err, configservice.ErrCodeResourceInUseException) {
r.Retryable = aws.Bool(true)
}
return
}
// We only want to retry briefly as the default max retry count would
// excessively retry when the error could be legitimate.
// We currently depend on the DefaultRetryer exponential backoff here.
// ~10 retries gives a fair backoff of a few seconds.
if r.RetryCount < 9 {
r.Retryable = aws.Bool(true)
} else {
r.Retryable = aws.Bool(false)
}
}
})
client.CloudFormationConn.Handlers.Retry.PushBack(func(r *request.Request) {
if tfawserr.ErrMessageContains(r.Error, cloudformation.ErrCodeOperationInProgressException, "Another Operation on StackSet") {
r.Retryable = aws.Bool(true)
}
})
// See https://github.com/aws/aws-sdk-go/pull/1276
client.DynamoDBConn.Handlers.Retry.PushBack(func(r *request.Request) {
if r.Operation.Name != "PutItem" && r.Operation.Name != "UpdateItem" && r.Operation.Name != "DeleteItem" {
return
}
if tfawserr.ErrMessageContains(r.Error, dynamodb.ErrCodeLimitExceededException, "Subscriber limit exceeded:") {
r.Retryable = aws.Bool(true)
}
})
client.EC2Conn.Handlers.Retry.PushBack(func(r *request.Request) {
switch err := r.Error; r.Operation.Name {
case "AttachVpnGateway", "DetachVpnGateway":
if tfawserr.ErrMessageContains(err, "InvalidParameterValue", "This call cannot be completed because there are pending VPNs or Virtual Interfaces") {
r.Retryable = aws.Bool(true)
}
case "CreateClientVpnEndpoint":
if tfawserr.ErrMessageContains(err, "OperationNotPermitted", "Endpoint cannot be created while another endpoint is being created") {
r.Retryable = aws.Bool(true)
}
case "CreateClientVpnRoute", "DeleteClientVpnRoute":
if tfawserr.ErrMessageContains(err, "ConcurrentMutationLimitExceeded", "Cannot initiate another change for this endpoint at this time") {
r.Retryable = aws.Bool(true)
}
case "CreateVpnConnection":
if tfawserr.ErrMessageContains(err, "VpnConnectionLimitExceeded", "maximum number of mutating objects has been reached") {
r.Retryable = aws.Bool(true)
}
case "CreateVpnGateway":
if tfawserr.ErrMessageContains(err, "VpnGatewayLimitExceeded", "maximum number of mutating objects has been reached") {
r.Retryable = aws.Bool(true)
}
}
})
client.ECSConn.Handlers.Retry.PushBack(func(r *request.Request) {
// By design the "WaitUntilServicesStable" method will poll every 15 seconds until a successful state
// has been reached. This will exit with a return code of 255 (ResourceNotReady) after 40 failed checks.
// Thus, here we retry the operation a set number of times as
// described in https://github.com/hashicorp/terraform-provider-aws/pull/23747.
if r.Operation.Name == "WaitUntilServicesStable" {
if tfawserr.ErrCodeEquals(r.Error, "ResourceNotReady") {
// We only want to retry briefly as the default max retry count would
// excessively retry when the error could be legitimate.
// We currently depend on the DefaultRetryer exponential backoff here.
// ~10 retries gives a fair backoff of a few seconds.
if r.RetryCount < 9 {
r.Retryable = aws.Bool(true)
} else {
r.Retryable = aws.Bool(false)
}
}
}
})
client.FMSConn.Handlers.Retry.PushBack(func(r *request.Request) {
// Acceptance testing creates and deletes resources in quick succession.
// The FMS onboarding process into Organizations is opaque to consumers.
// Since we cannot reasonably check this status before receiving the error,
// set the operation as retryable.
switch r.Operation.Name {
case "AssociateAdminAccount":
if tfawserr.ErrMessageContains(r.Error, fms.ErrCodeInvalidOperationException, "Your AWS Organization is currently offboarding with AWS Firewall Manager. Please submit onboard request after offboarded.") {
r.Retryable = aws.Bool(true)
}
case "DisassociateAdminAccount":
if tfawserr.ErrMessageContains(r.Error, fms.ErrCodeInvalidOperationException, "Your AWS Organization is currently onboarding with AWS Firewall Manager and cannot be offboarded.") {
r.Retryable = aws.Bool(true)
}
// System problems can arise during FMS policy updates (maybe also creation),
// so we set the following operation as retryable.
// Reference: https://github.com/hashicorp/terraform-provider-aws/issues/23946
case "PutPolicy":
if tfawserr.ErrCodeEquals(r.Error, fms.ErrCodeInternalErrorException) {
r.Retryable = aws.Bool(true)
}
}
})
client.KafkaConn.Handlers.Retry.PushBack(func(r *request.Request) {
if tfawserr.ErrMessageContains(r.Error, kafka.ErrCodeTooManyRequestsException, "Too Many Requests") {
r.Retryable = aws.Bool(true)
}
})
client.KinesisConn.Handlers.Retry.PushBack(func(r *request.Request) {
if r.Operation.Name == "CreateStream" {
if tfawserr.ErrMessageContains(r.Error, kinesis.ErrCodeLimitExceededException, "simultaneously be in CREATING or DELETING") {
r.Retryable = aws.Bool(true)
}
}
if r.Operation.Name == "CreateStream" || r.Operation.Name == "DeleteStream" {
if tfawserr.ErrMessageContains(r.Error, kinesis.ErrCodeLimitExceededException, "Rate exceeded for stream") {
r.Retryable = aws.Bool(true)
}
}
})
client.OrganizationsConn.Handlers.Retry.PushBack(func(r *request.Request) {
// Retry on the following error:
// ConcurrentModificationException: AWS Organizations can't complete your request because it conflicts with another attempt to modify the same entity. Try again later.
if tfawserr.ErrMessageContains(r.Error, organizations.ErrCodeConcurrentModificationException, "Try again later") {
r.Retryable = aws.Bool(true)
}
})
client.S3Conn.Handlers.Retry.PushBack(func(r *request.Request) {
if tfawserr.ErrMessageContains(r.Error, "OperationAborted", "A conflicting conditional operation is currently in progress against this resource. Please try again.") {
r.Retryable = aws.Bool(true)
}
})
// Reference: https://github.com/hashicorp/terraform-provider-aws/issues/17996
client.SecurityHubConn.Handlers.Retry.PushBack(func(r *request.Request) {
switch r.Operation.Name {
case "EnableOrganizationAdminAccount":
if tfawserr.ErrCodeEquals(r.Error, securityhub.ErrCodeResourceConflictException) {
r.Retryable = aws.Bool(true)
}
}
})
// Reference: https://github.com/hashicorp/terraform-provider-aws/issues/19215
client.SSOAdminConn.Handlers.Retry.PushBack(func(r *request.Request) {
if r.Operation.Name == "AttachManagedPolicyToPermissionSet" || r.Operation.Name == "DetachManagedPolicyFromPermissionSet" {
if tfawserr.ErrCodeEquals(r.Error, ssoadmin.ErrCodeConflictException) {
r.Retryable = aws.Bool(true)
}
}
})
client.StorageGatewayConn.Handlers.Retry.PushBack(func(r *request.Request) {
// InvalidGatewayRequestException: The specified gateway proxy network connection is busy.
if tfawserr.ErrMessageContains(r.Error, storagegateway.ErrCodeInvalidGatewayRequestException, "The specified gateway proxy network connection is busy") {
r.Retryable = aws.Bool(true)
}
})
client.WAFV2Conn.Handlers.Retry.PushBack(func(r *request.Request) {
if tfawserr.ErrMessageContains(r.Error, wafv2.ErrCodeWAFInternalErrorException, "Retry your request") {
r.Retryable = aws.Bool(true)
}
if tfawserr.ErrMessageContains(r.Error, wafv2.ErrCodeWAFServiceLinkedRoleErrorException, "Retry") {
r.Retryable = aws.Bool(true)
}
if r.Operation.Name == "CreateIPSet" || r.Operation.Name == "CreateRegexPatternSet" ||
r.Operation.Name == "CreateRuleGroup" || r.Operation.Name == "CreateWebACL" {
// WAFv2 supports tag on create which can result in the below error codes according to the documentation
if tfawserr.ErrMessageContains(r.Error, wafv2.ErrCodeWAFTagOperationException, "Retry your request") {
r.Retryable = aws.Bool(true)
}
if tfawserr.ErrMessageContains(err, wafv2.ErrCodeWAFTagOperationInternalErrorException, "Retry your request") {
r.Retryable = aws.Bool(true)
}
}
})
if !c.SkipGetEC2Platforms {
supportedPlatforms, err := GetSupportedEC2Platforms(client.EC2Conn)
if err != nil {
// We intentionally fail *silently* because there's a chance
// user just doesn't have ec2:DescribeAccountAttributes permissions
log.Printf("[WARN] Unable to get supported EC2 platforms: %s", err)
} else {
client.SupportedPlatforms = supportedPlatforms
}
}
return client, nil
}