Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Migrate google_compute_firewall_policy_association resource from DCL to MMv1" #12614

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 0 additions & 83 deletions mmv1/products/compute/FirewallPolicyAssociation.yaml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,53 +62,3 @@ resource "google_compute_firewall_policy_association" "default" {
}
`, context)
}

func TestAccComputeFirewallPolicyAssociation_organization(t *testing.T) {
t.Parallel()

context := map[string]interface{}{
"random_suffix": acctest.RandString(t, 10),
"org_name": fmt.Sprintf("organizations/%s", envvar.GetTestOrgFromEnv(t)),
}

acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
ExternalProviders: map[string]resource.ExternalProvider{
"time": {},
},
Steps: []resource.TestStep{
{
Config: testAccComputeFirewallPolicyAssociation_organization(context),
},
{
ResourceName: "google_compute_firewall_policy_association.default",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"firewall_policy"},
},
},
})
}

func testAccComputeFirewallPolicyAssociation_organization(context map[string]interface{}) string {
return acctest.Nprintf(`
resource "google_folder" "folder" {
display_name = "tf-test-my-folder-%{random_suffix}"
parent = "%{org_name}"
deletion_protection = false
}

resource "google_compute_firewall_policy" "policy" {
parent = "%{org_name}"
short_name = "tf-test-my-policy-%{random_suffix}"
description = "Example Resource"
}

resource "google_compute_firewall_policy_association" "default" {
firewall_policy = google_compute_firewall_policy.policy.id
attachment_target = google_folder.folder.name
name = "tf-test-my-association-%{random_suffix}"
}
`, context)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** Type: DCL ***
#
# ----------------------------------------------------------------------------
#
# This file is managed by Magic Modules (https:#github.com/GoogleCloudPlatform/magic-modules)
# and is based on the DCL (https:#github.com/GoogleCloudPlatform/declarative-resource-client-library).
# Changes will need to be made to the DCL or Magic Modules instead of here.
#
# We are not currently able to accept contributions to this file. If changes
# are required, please file an issue at https:#github.com/hashicorp/terraform-provider-google/issues/new/choose
#
# ----------------------------------------------------------------------------
subcategory: "Compute Engine"
description: |-
Applies a hierarchical firewall policy to a target resource
---

# google_compute_firewall_policy_association

Allows associating hierarchical firewall policies with the target where they are applied. This allows creating policies and rules in a different location than they are applied.

For more information on applying hierarchical firewall policies see the [official documentation](https://cloud.google.com/vpc/docs/firewall-policies#managing_hierarchical_firewall_policy_resources)

## Example Usage

```hcl
resource "google_compute_firewall_policy" "default" {
parent = "organizations/12345"
short_name = "my-policy"
description = "Example Resource"
}

resource "google_compute_firewall_policy_association" "default" {
firewall_policy = google_compute_firewall_policy.default.id
attachment_target = google_folder.folder.name
name = "my-association"
}
```


## Argument Reference

The following arguments are supported:

* `attachment_target` -
(Required)
The target that the firewall policy is attached to.

* `firewall_policy` -
(Required)
The firewall policy ID of the association.

* `name` -
(Required)
The name for an association.



- - -



## Attributes Reference

In addition to the arguments listed above, the following computed attributes are exported:

* `id` - an identifier for the resource with format `locations/global/firewallPolicies/{{firewall_policy}}/associations/{{name}}`

* `short_name` -
The short name of the firewall policy of the association.

## Timeouts

This resource provides the following
[Timeouts](https://developer.hashicorp.com/terraform/plugin/sdkv2/resources/retries-and-customizable-timeouts) configuration options: configuration options:

- `create` - Default is 20 minutes.
- `delete` - Default is 20 minutes.

## Import

FirewallPolicyAssociation can be imported using any of these accepted formats:

* `locations/global/firewallPolicies/{{firewall_policy}}/associations/{{name}}`
* `{{firewall_policy}}/{{name}}`

In Terraform v1.5.0 and later, use an [`import` block](https://developer.hashicorp.com/terraform/language/import) to import FirewallPolicyAssociation using one of the formats above. For example:

```tf
import {
id = "locations/global/firewallPolicies/{{firewall_policy}}/associations/{{name}}"
to = google_compute_firewall_policy_association.default
}
```

When using the [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import), FirewallPolicyAssociation can be imported using one of the formats above. For example:

```
$ terraform import google_compute_firewall_policy_association.default locations/global/firewallPolicies/{{firewall_policy}}/associations/{{name}}
$ terraform import google_compute_firewall_policy_association.default {{firewall_policy}}/{{name}}
```



Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- type: CUSTOMIZE_DIFF
details:
functions:
- tpgresource.DefaultProviderProject
4 changes: 4 additions & 0 deletions tpgtools/overrides/compute/firewall_policy_association.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- type: CUSTOMIZE_DIFF
details:
functions:
- tpgresource.DefaultProviderProject
Loading