Skip to content

Commit 3e32c9e

Browse files
committed
fix reference to gcp/aws for account mappings
1 parent a1eb19e commit 3e32c9e

File tree

2 files changed

+9
-12
lines changed

2 files changed

+9
-12
lines changed

lacework/account_mapping_helper.go

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package lacework
22

33
import (
4-
"fmt"
5-
64
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
75
)
86

@@ -19,14 +17,13 @@ var awsMappingType string = "aws_accounts"
1917
var gcpMappingType string = "gcp_projects"
2018

2119
func getResourceOrgAccountMappings(d *schema.ResourceData, mappingsType string) *accountMappingsFile {
22-
fmt.Println("MAPPINGS TYPE: ", mappingsType)
2320
accountMapFile := new(accountMappingsFile)
2421
accMapsInt := d.Get("org_account_mappings").([]interface{})
2522
if len(accMapsInt) != 0 && accMapsInt[0] != nil {
2623
accountMappings := accMapsInt[0].(map[string]interface{})
2724

2825
accountMapFile = &accountMappingsFile{
29-
DefaultLaceworkAccount: accountMappings["default_lacework_account_aws"].(string),
26+
DefaultLaceworkAccount: accountMappings["default_lacework_account"].(string),
3027
Mappings: map[string]interface{}{},
3128
}
3229

@@ -56,8 +53,8 @@ func flattenOrgAccountMappings(mappingFile *accountMappingsFile, mappingsType st
5653
}
5754

5855
mappings := map[string]interface{}{
59-
"default_lacework_account_aws": mappingFile.DefaultLaceworkAccount,
60-
"mapping": flattenMappings(mappingFile.Mappings, mappingsType),
56+
"default_lacework_account": mappingFile.DefaultLaceworkAccount,
57+
"mapping": flattenMappings(mappingFile.Mappings, mappingsType),
6158
}
6259

6360
orgAccMappings = append(orgAccMappings, mappings)
@@ -85,7 +82,7 @@ func flattenMappings(mappings map[string]interface{}, mappingsType string) *sche
8582
return awsRes
8683
}
8784

88-
func flattenOrgGcpAccountMappings(mappingFile *accountMappingsFile, mappingsType string) []map[string]interface{} {
85+
func flattenOrgGcpAccountMappings(mappingFile *accountMappingsFile) []map[string]interface{} {
8986
orgAccMappings := make([]map[string]interface{}, 0, 1)
9087

9188
if mappingFile.Empty() {
@@ -94,18 +91,18 @@ func flattenOrgGcpAccountMappings(mappingFile *accountMappingsFile, mappingsType
9491

9592
mappings := map[string]interface{}{
9693
"default_lacework_account_aws": mappingFile.DefaultLaceworkAccount,
97-
"mapping": flattenGcpMappings(mappingFile.Mappings, mappingsType),
94+
"mapping": flattenGcpMappings(mappingFile.Mappings),
9895
}
9996

10097
orgAccMappings = append(orgAccMappings, mappings)
10198
return orgAccMappings
10299
}
103100

104-
func flattenGcpMappings(mappings map[string]interface{}, mappingsType string) *schema.Set {
101+
func flattenGcpMappings(mappings map[string]interface{}) *schema.Set {
105102
var (
106103
gcpOrgAccountMappingsSchema = gcpAgentlessScanningIntegrationSchema["org_account_mappings"].Elem.(*schema.Resource)
107104
gcpMappingSchema = gcpOrgAccountMappingsSchema.Schema["mapping"].Elem.(*schema.Resource)
108-
gcpAccountsSchema = gcpMappingSchema.Schema[mappingsType].Elem.(*schema.Schema)
105+
gcpAccountsSchema = gcpMappingSchema.Schema["mapping"].Elem.(*schema.Schema)
109106
gcpRes = schema.NewSet(schema.HashResource(gcpMappingSchema), []interface{}{})
110107
)
111108

lacework/resource_lacework_integration_gcp_agentless_scanning.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ var gcpAgentlessScanningIntegrationSchema = map[string]*schema.Schema{
217217
Description: "Mapping of GCP projects to Lacework accounts within a Lacework organization.",
218218
Elem: &schema.Resource{
219219
Schema: map[string]*schema.Schema{
220-
"default_lacework_account_aws": {
220+
"default_lacework_account": {
221221
Type: schema.TypeString,
222222
Required: true,
223223
Description: "The default Lacework account name where any non-mapped GCP project will appear",
@@ -404,7 +404,7 @@ func resourceLaceworkIntegrationGcpAgentlessScanningRead(d *schema.ResourceData,
404404

405405
}
406406

407-
err = d.Set("org_account_mappings", flattenOrgGcpAccountMappings(accountMapFile, gcpMappingType))
407+
err = d.Set("org_account_mappings", flattenOrgGcpAccountMappings(accountMapFile))
408408
if err != nil {
409409
return fmt.Errorf("Error flattening organization account mapping: %s", err)
410410
}

0 commit comments

Comments
 (0)