Skip to content

Commit

Permalink
Check to see if billing feature enabled before setting the attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
akash-nagarajan committed Apr 27, 2023
1 parent 9fc8e95 commit 255782a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
15 changes: 13 additions & 2 deletions internal/service/platform/connector/aws_cc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
7 changes: 3 additions & 4 deletions internal/service/platform/connector/aws_cc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 255782a

Please sign in to comment.