Skip to content

Commit

Permalink
Merge pull request #524 from harness/CCM-12214
Browse files Browse the repository at this point in the history
Bug: [CCM-12214]: Setting the attributes only if the billing feature is enabled
  • Loading branch information
akash-nagarajan committed Apr 28, 2023
2 parents f289e83 + 524467c commit 4d4994d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .changelog/524.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
resource/harness_platform_connector_awscc: Fix bug in aws cloud cost connector resource
```
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
}
6 changes: 3 additions & 3 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,13 @@ 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",
"BILLING"
]
cross_account_access {
role_arn = "arn:aws:iam::123456789012:role/S3Access"
Expand Down

0 comments on commit 4d4994d

Please sign in to comment.