diff --git a/docs/data-sources/fw_policy_v2.md b/docs/data-sources/fw_policy_v2.md index 470c2eba3..186e26e92 100644 --- a/docs/data-sources/fw_policy_v2.md +++ b/docs/data-sources/fw_policy_v2.md @@ -31,7 +31,11 @@ data "openstack_fw_policy_v2" "policy" { * `policy_id` - (Optional) The ID of the firewall policy. -* `tenant_id` - (Optional) The owner of the firewall policy. +* `tenant_id` - (Optional) - This argument conflicts and is interchangeable + with `project_id`. The owner of the firewall policy. + +* `project_id` - (Optional) - This argument conflicts and is interchangeable + with `tenant_id`. The owner of the firewall policy. * `shared` - (Optional) Whether this policy is shared across all projects. @@ -45,6 +49,7 @@ The following attributes are exported: * `name` - See Argument Reference above. * `policy_id` - See Argument Reference above. * `tenant_id` - See Argument Reference above. +* `project_id` - See Argument Reference above. * `shared` - The sharing status of the firewall policy. * `audited` - The audit status of the firewall policy. * `rules` - The array of one or more firewall rules that comprise the policy. diff --git a/docs/resources/fw_policy_v2.md b/docs/resources/fw_policy_v2.md index 76ac133fb..1e0973991 100644 --- a/docs/resources/fw_policy_v2.md +++ b/docs/resources/fw_policy_v2.md @@ -59,9 +59,15 @@ The following arguments are supported: * `description` - (Optional) A description for the firewall policy. Changing this updates the `description` of an existing firewall policy. -* `tenant_id` - (Optional) The owner of the firewall policy. Required if admin - wants to create a firewall policy for another tenant. Changing this - creates a new firewall policy. +* `tenant_id` - (Optional) - This argument conflicts and is interchangeable + with `project_id`. The owner of the firewall policy. Required if admin wants + to create a firewall policy for another tenant. Changing this creates a new + firewall policy. + +* `project_id` - (Optional) - This argument conflicts and is interchangeable + with `tenant_id`. The owner of the firewall policy. Required if admin wants + to create a firewall policy for another project. Changing this creates a new + firewall policy. * `rules` - (Optional) An array of one or more firewall rules that comprise the policy. Changing this results in adding/removing rules from the @@ -86,6 +92,7 @@ The following attributes are exported: * `region` - See Argument Reference above. * `name` - See Argument Reference above. * `tenant_id` - See Argument Reference above. +* `project_id` - See Argument Reference above. * `description` - See Argument Reference above. * `rules` - See Argument Reference above. * `audited` - See Argument Reference above. diff --git a/openstack/data_source_openstack_fw_policy_v2.go b/openstack/data_source_openstack_fw_policy_v2.go index ba4383e7a..46d2f6930 100644 --- a/openstack/data_source_openstack_fw_policy_v2.go +++ b/openstack/data_source_openstack_fw_policy_v2.go @@ -33,10 +33,17 @@ func dataSourceFWPolicyV2() *schema.Resource { }, "tenant_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, + Type: schema.TypeString, + Computed: true, + Optional: true, + ConflictsWith: []string{"project_id"}, + }, + + "project_id": { + Type: schema.TypeString, + Optional: true, + Computed: true, + ConflictsWith: []string{"tenant_id"}, }, "description": { @@ -90,6 +97,10 @@ func dataSourceFWPolicyV2Read(ctx context.Context, d *schema.ResourceData, meta listOpts.TenantID = v.(string) } + if v, ok := d.GetOk("project_id"); ok { + listOpts.ProjectID = v.(string) + } + if v, ok := d.GetOk("shared"); ok { shared := v.(bool) listOpts.Shared = &shared @@ -126,6 +137,7 @@ func dataSourceFWPolicyV2Read(ctx context.Context, d *schema.ResourceData, meta d.Set("name", policy.Name) d.Set("tenant_id", policy.TenantID) + d.Set("project_id", policy.ProjectID) d.Set("description", policy.Description) d.Set("shared", policy.Shared) d.Set("audited", policy.Audited) diff --git a/openstack/resource_openstack_fw_policy_v2.go b/openstack/resource_openstack_fw_policy_v2.go index 4f733ade6..83397adb9 100644 --- a/openstack/resource_openstack_fw_policy_v2.go +++ b/openstack/resource_openstack_fw_policy_v2.go @@ -46,10 +46,19 @@ func resourceFWPolicyV2() *schema.Resource { }, "tenant_id": { - Type: schema.TypeString, - Optional: true, - ForceNew: true, - Computed: true, + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Computed: true, + ConflictsWith: []string{"project_id"}, + }, + + "project_id": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Computed: true, + ConflictsWith: []string{"tenant_id"}, }, "audited": { @@ -82,6 +91,7 @@ func resourceFWPolicyV2Create(ctx context.Context, d *schema.ResourceData, meta Name: d.Get("name").(string), Description: d.Get("description").(string), TenantID: d.Get("tenant_id").(string), + ProjectID: d.Get("project_id").(string), FirewallRules: expandToStringSlice(d.Get("rules").([]interface{})), } @@ -126,6 +136,7 @@ func resourceFWPolicyV2Read(_ context.Context, d *schema.ResourceData, meta inte d.Set("name", policy.Name) d.Set("description", policy.Description) d.Set("tenant_id", policy.TenantID) + d.Set("project_id", policy.ProjectID) d.Set("rules", policy.Rules) d.Set("audited", policy.Audited) d.Set("shared", policy.Shared)