From 255782a0c40907c4f8fe0be1827d8e21b25f72bf Mon Sep 17 00:00:00 2001 From: akash-nagarajan Date: Thu, 27 Apr 2023 13:10:40 +0530 Subject: [PATCH] Check to see if billing feature enabled before setting the attributes --- internal/service/platform/connector/aws_cc.go | 15 +++++++++++++-- .../service/platform/connector/aws_cc_test.go | 7 +++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/internal/service/platform/connector/aws_cc.go b/internal/service/platform/connector/aws_cc.go index 9f2c94fd9..f393f1c1f 100644 --- a/internal/service/platform/connector/aws_cc.go +++ b/internal/service/platform/connector/aws_cc.go @@ -162,8 +162,10 @@ func buildConnectorAwsCC(d *schema.ResourceData) *nextgen.ConnectorInfo { func readConnectorAwsCC(d *schema.ResourceData, connector *nextgen.ConnectorInfo) error { d.Set("account_id", connector.AwsCC.AwsAccountId) - d.Set("report_name", connector.AwsCC.CurAttributes.ReportName) - d.Set("s3_bucket", connector.AwsCC.CurAttributes.S3BucketName) + if isFeatureEnabled("BILLING", connector.AwsCC.FeaturesEnabled) { + d.Set("report_name", connector.AwsCC.CurAttributes.ReportName) + d.Set("s3_bucket", connector.AwsCC.CurAttributes.S3BucketName) + } // d.Set("s3_prefix", connector.AwsCC.CurAttributes.S3Prefix) // d.Set("region", connector.AwsCC.CurAttributes.Region) d.Set("features_enabled", connector.AwsCC.FeaturesEnabled) @@ -176,3 +178,12 @@ func readConnectorAwsCC(d *schema.ResourceData, connector *nextgen.ConnectorInfo return nil } + +func isFeatureEnabled(value string, list []string) bool { + for _, v := range list { + if strings.EqualFold(value, v) { + return true + } + } + return false +} diff --git a/internal/service/platform/connector/aws_cc_test.go b/internal/service/platform/connector/aws_cc_test.go index a617010e2..bbfa20d2a 100644 --- a/internal/service/platform/connector/aws_cc_test.go +++ b/internal/service/platform/connector/aws_cc_test.go @@ -10,7 +10,7 @@ import ( ) func TestAccResourceConnectorAwsCC(t *testing.T) { - t.Skip("Skipping until account id issue is fixed https://harness.atlassian.net/browse/PL-20793") + //t.Skip("Skipping until account id issue is fixed https://harness.atlassian.net/browse/PL-20793") id := fmt.Sprintf("%s_%s", t.Name(), utils.RandStringBytes(5)) name := id @@ -64,13 +64,12 @@ func testAccResourceConnectorAwsCC(id string, name string) string { description = "test" tags = ["foo:bar"] - account_id = "000000000001" + account_id = "123456789012" report_name = "test_report" s3_bucket = "s3bucket" features_enabled = [ "OPTIMIZATION", - "VISIBILITY", - "BILLING", + "VISIBILITY" ] cross_account_access { role_arn = "arn:aws:iam::123456789012:role/S3Access"