Skip to content

Commit

Permalink
Merge pull request #1457 from ksamoray/default_security_profile_fix
Browse files Browse the repository at this point in the history
Handle default_security_profile attribute in project read func
  • Loading branch information
ksamoray authored Nov 12, 2024
2 parents d6cdf56 + 9ea081c commit 59391db
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions nsxt/resource_nsxt_policy_project.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,27 @@ func patchVpcSecurityProfile(d *schema.ResourceData, connector client.Connector,
return client.Patch(defaultOrgID, projectID, "default", obj)
}

func setVpcSecurityProfileInSchema(d *schema.ResourceData, connector client.Connector, projectID string) error {
client := projects.NewVpcSecurityProfilesClient(connector)
obj, err := client.Get(defaultOrgID, projectID, "default")
if err != nil {
return err
}

enabled := false
if obj.NorthSouthFirewall != nil && obj.NorthSouthFirewall.Enabled != nil {
enabled = *obj.NorthSouthFirewall.Enabled
}

nsfw := map[string]interface{}{"enabled": &enabled}
nsfws := []interface{}{nsfw}
dsp := map[string]interface{}{"north_south_firewall": nsfws}
dsps := []interface{}{dsp}

d.Set("default_security_profile", dsps)
return nil
}

func resourceNsxtPolicyProjectCreate(d *schema.ResourceData, m interface{}) error {

// Initialize resource Id and verify this ID is not yet used
Expand Down Expand Up @@ -259,6 +280,10 @@ func resourceNsxtPolicyProjectRead(d *schema.ResourceData, m interface{}) error
}
d.Set("site_info", siteInfosList)
d.Set("tier0_gateway_paths", obj.Tier0s)
err = setVpcSecurityProfileInSchema(d, connector, id)
if err != nil {
return err
}
if util.NsxVersionHigherOrEqual("4.2.0") {
d.Set("activate_default_dfw_rules", obj.ActivateDefaultDfwRules)
}
Expand Down

0 comments on commit 59391db

Please sign in to comment.