6
6
"fmt"
7
7
"regexp"
8
8
"strings"
9
- "time"
10
9
11
10
"github.com/crowdstrike/gofalcon/falcon/client"
12
11
"github.com/crowdstrike/gofalcon/falcon/client/cloud_aws_registration"
@@ -33,7 +32,6 @@ import (
33
32
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
34
33
"github.com/hashicorp/terraform-plugin-framework/types"
35
34
"github.com/hashicorp/terraform-plugin-log/tflog"
36
- "golang.org/x/exp/maps"
37
35
)
38
36
39
37
type cloudAWSAccountResource struct {
@@ -569,11 +567,6 @@ func (r *cloudAWSAccountResource) Create(
569
567
}
570
568
}
571
569
572
- // if IDP or realtime visibility are enabled wait until we get all values back
573
- if state .IDP .Enabled .ValueBool () || state .RealtimeVisibility .Enabled .ValueBool () {
574
- resp .Diagnostics .Append (r .pollMissingValues (ctx , & state )... )
575
- }
576
-
577
570
// Set refreshed state
578
571
diags = resp .State .Set (ctx , state )
579
572
resp .Diagnostics .Append (diags ... )
@@ -1451,89 +1444,3 @@ func (r *cloudAWSAccountResource) ValidateConfig(
1451
1444
return
1452
1445
}
1453
1446
}
1454
-
1455
- // pollMissingValues waits for missing backend values [eventbus_arn, eventbus_name, cloudtrail_bucket_name] to be set.
1456
- func (r * cloudAWSAccountResource ) pollMissingValues (
1457
- ctx context.Context ,
1458
- config * cloudAWSAccountModel ,
1459
- ) diag.Diagnostics {
1460
- var diags diag.Diagnostics
1461
- missingValues := make (map [string ]interface {})
1462
-
1463
- if config .EventbusArn .ValueString () == "" {
1464
- missingValues ["eventbus_arn" ] = nil
1465
- }
1466
-
1467
- if config .EventbusName .ValueString () == "" {
1468
- missingValues ["eventbus_name" ] = nil
1469
- }
1470
-
1471
- if config .CloudTrailBucketName .ValueString () == "" {
1472
- missingValues ["cloudtrail_bucket_name" ] = nil
1473
- }
1474
-
1475
- if len (missingValues ) == 0 {
1476
- return diags
1477
- }
1478
-
1479
- pollCtx , cancel := context .WithTimeout (ctx , 5 * time .Minute )
1480
- defer cancel ()
1481
-
1482
- ticker := time .NewTicker (10 * time .Second )
1483
- defer ticker .Stop ()
1484
-
1485
- for {
1486
- select {
1487
- case <- ticker .C :
1488
- account , diag := r .getCSPMAccount (pollCtx , config .AccountID .ValueString ())
1489
- if diag .HasError () {
1490
- return diag
1491
- }
1492
-
1493
- if _ , ok := missingValues ["eventbus_arn" ]; ok && account .AwsEventbusArn != "" {
1494
- config .EventbusArn = types .StringValue (account .AwsEventbusArn )
1495
- delete (missingValues , "eventbus_arn" )
1496
- }
1497
-
1498
- if _ , ok := missingValues ["eventbus_name" ]; ok && account .EventbusName != "" {
1499
- config .EventbusName = types .StringValue (account .EventbusName )
1500
- delete (missingValues , "eventbus_name" )
1501
- }
1502
-
1503
- if _ , ok := missingValues ["cloudtrail_bucket_name" ]; ok &&
1504
- account .AwsCloudtrailBucketName != "" {
1505
- config .CloudTrailBucketName = types .StringValue (account .AwsCloudtrailBucketName )
1506
- delete (missingValues , "cloudtrail_bucket_name" )
1507
- }
1508
-
1509
- if len (missingValues ) == 0 {
1510
- return diags
1511
- }
1512
-
1513
- fields := strings .Join (maps .Keys (missingValues ), ", " )
1514
- tflog .Debug (
1515
- pollCtx ,
1516
- fmt .Sprintf ("[%s] not yet available, polling again in 10s..." , fields ),
1517
- )
1518
-
1519
- case <- pollCtx .Done ():
1520
- if pollCtx .Err () != context .DeadlineExceeded {
1521
- return diags
1522
- }
1523
-
1524
- if len (missingValues ) == 0 {
1525
- return diags
1526
- }
1527
-
1528
- fields := strings .Join (maps .Keys (missingValues ), ", " )
1529
- diags .AddError (
1530
- "Timed out waiting for missing fields to populate" ,
1531
- fmt .Sprintf (
1532
- "Timed out on create waiting for missing fields [%s] to return from API." ,
1533
- fields ,
1534
- ),
1535
- )
1536
- return diags
1537
- }
1538
- }
1539
- }
0 commit comments