Skip to content

Commit b506b50

Browse files
update logic to support empty cloudprovider and cloudprovider_id
1 parent 5167999 commit b506b50

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

sysdig/data_source_sysdig_secure_onboarding.go

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,6 @@ func dataSourceSysdigSecureCloudIngestionAssets() *schema.Resource {
369369
Type: schema.TypeMap,
370370
Computed: true,
371371
},
372-
"sns_routing_key": {
373-
Type: schema.TypeString,
374-
Computed: true,
375-
},
376-
"sns_metadata": {
377-
Type: schema.TypeMap,
378-
Computed: true,
379-
},
380372
},
381373
}
382374
}
@@ -396,12 +388,17 @@ func dataSourceSysdigSecureCloudIngestionAssetsRead(ctx context.Context, d *sche
396388
assetsAws, _ := assets["aws"].(map[string]interface{})
397389
assetsGcp, _ := assets["gcp"].(map[string]interface{})
398390

391+
var ingestionURL string
392+
if assetsAws["snsMetadata"] != nil {
393+
ingestionURL = assetsAws["snsMetadata"].(map[string]interface{})["ingestionURL"].(string)
394+
}
395+
399396
d.SetId("cloudIngestionAssets")
400397
err = d.Set("aws", map[string]interface{}{
401398
"eventBusARN": assetsAws["eventBusARN"],
402399
"eventBusARNGov": assetsAws["eventBusARNGov"],
403400
"sns_routing_key": assetsAws["snsRoutingKey"],
404-
"sns_metadata": assetsAws["snsMetadata"],
401+
"sns_routing_url": ingestionURL,
405402
})
406403
if err != nil {
407404
return diag.FromErr(err)

sysdig/data_source_sysdig_secure_onboarding_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@ func TestAccCloudIngestionAssetsDataSource(t *testing.T) {
176176
},
177177
Steps: []resource.TestStep{
178178
{
179-
Config: `data "sysdig_secure_cloud_ingestion_assets" "assets" {
180-
cloud_provider = "invalid"
181-
cloud_provider_id = "123"
182-
}`,
179+
Config: `data "sysdig_secure_cloud_ingestion_assets" "assets" {
180+
cloud_provider = "invalid"
181+
cloud_provider_id = "123"
182+
}`,
183183
ExpectError: regexp.MustCompile(`.*expected cloud_provider to be one of.*`),
184184
},
185185
{
@@ -201,8 +201,8 @@ func TestAccCloudIngestionAssetsDataSource(t *testing.T) {
201201
cloud_provider_id = "012345678901"
202202
}`,
203203
Check: resource.ComposeTestCheckFunc(
204-
resource.TestCheckResourceAttrSet("data.sysdig_secure_cloud_ingestion_assets.assets", "sns_routing_key"),
205-
// not asserting the gov exported fields because not every backend environment is gov supported and thus will have empty values
204+
resource.TestCheckResourceAttrSet("data.sysdig_secure_cloud_ingestion_assets.assets", "aws.sns_routing_key"),
205+
resource.TestCheckResourceAttrSet("data.sysdig_secure_cloud_ingestion_assets.assets", "aws.sns_routing_url"),
206206
),
207207
},
208208
},

0 commit comments

Comments
 (0)