-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add access reusable policies support
- Loading branch information
Eduardo Gomes
committed
May 6, 2024
1 parent
815f78e
commit 80fe48e
Showing
9 changed files
with
233 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```release-note:enhancement | ||
resource/cloudflare_access_policies: added support for reusable policies | ||
``` | ||
|
||
```release-note:enhancement | ||
resource/cloudflare_access_application: added support for 'policies' argument | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -694,6 +694,31 @@ func TestAccCloudflareAccessApplication_WithDefinedTags(t *testing.T) { | |
}) | ||
} | ||
|
||
func TestAccCloudflareAccessApplication_WithReusablePolicies(t *testing.T) { | ||
rnd := generateRandomResourceName() | ||
name := fmt.Sprintf("cloudflare_access_application.%s", rnd) | ||
accountID := os.Getenv("CLOUDFLARE_ACCOUNT_ID") | ||
resource.Test(t, resource.TestCase{ | ||
PreCheck: func() { | ||
testAccPreCheck(t) | ||
testAccPreCheckAccount(t) | ||
}, | ||
ProviderFactories: providerFactories, | ||
CheckDestroy: testAccCheckCloudflareAccessApplicationDestroy, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCloudflareAccessApplicationConfigWithReusablePolicies(rnd, domain, accountID), | ||
Check: resource.ComposeTestCheckFunc( | ||
resource.TestCheckResourceAttr(name, "name", rnd), | ||
resource.TestCheckResourceAttr(name, "domain", fmt.Sprintf("%s.%s", rnd, domain)), | ||
resource.TestCheckResourceAttr(name, "type", "self_hosted"), | ||
resource.TestCheckResourceAttr(name, "policies.#", "2"), | ||
), | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func TestAccCloudflareAccessApplication_WithAppLauncherCustomization(t *testing.T) { | ||
rnd := generateRandomResourceName() | ||
name := fmt.Sprintf("cloudflare_access_application.%s", rnd) | ||
|
@@ -1311,7 +1336,40 @@ resource "cloudflare_access_application" "%[1]s" { | |
domain = "%[1]s.%[3]s" | ||
type = "self_hosted" | ||
session_duration = "24h" | ||
tags = [cloudflare_access_tag.%[1]s.id] | ||
tags = [cloudflare_access_tag.%[1]s.id] | ||
} | ||
`, rnd, zoneID, domain, accountID) | ||
} | ||
|
||
func testAccCloudflareAccessApplicationConfigWithReusablePolicies(rnd, domain string, accountID string) string { | ||
return fmt.Sprintf(` | ||
resource "cloudflare_access_policy" "%[1]s_p1" { | ||
account_id = "%[3]s" | ||
name = "%[1]s" | ||
decision = "allow" | ||
include { | ||
email = ["[email protected]"] | ||
} | ||
} | ||
resource "cloudflare_access_policy" "%[1]s_p2" { | ||
account_id = "%[3]s" | ||
name = "%[1]s" | ||
decision = "non_identity" | ||
include { | ||
ip = ["127.0.0.1/32"] | ||
} | ||
} | ||
resource "cloudflare_access_application" "%[1]s" { | ||
account_id = "%[3]s" | ||
name = "%[1]s" | ||
domain = "%[1]s.%[2]s" | ||
type = "self_hosted" | ||
policies = [ | ||
cloudflare_access_policy.%[1]s_p1.id, | ||
cloudflare_access_policy.%[1]s_p2.id | ||
] | ||
} | ||
`, rnd, domain, accountID) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.