-
Notifications
You must be signed in to change notification settings - Fork 7
660 add rate limit configuration resource #1176
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
Draft
jonathanfuller-pingidentity
wants to merge
10
commits into
main
Choose a base branch
from
660-add-rate-limit-configuration-resource
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1bc56f6
Add rate limit config resource
jonathanfuller-pingidentity ab7855b
Add tests
jonathanfuller-pingidentity 38d2afb
Minor description and test changes
jonathanfuller-pingidentity e48d194
Docs
jonathanfuller-pingidentity 3e63014
Fix compilation due to SDK breaking change
jonathanfuller-pingidentity bd80c83
Temporary SDK version update
jonathanfuller-pingidentity 31de82a
Changelog
jonathanfuller-pingidentity 68a96e5
Add explicit default
jonathanfuller-pingidentity e21b3d8
Read type from plan
jonathanfuller-pingidentity 16c35fc
Use enum everywhere
jonathanfuller-pingidentity File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,3 @@ | ||
| ```release-note:new-resource | ||
| pingone_rate_limit_configuration | ||
| ``` |
This file contains hidden or 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,51 @@ | ||
| --- | ||
| page_title: "pingone_rate_limit_configuration Resource - terraform-provider-pingone" | ||
| subcategory: "Platform" | ||
| description: |- | ||
| Resource to create and manage rate limit configurations in PingOne. Rate limit configurations allow you to exclude specific IP addresses or CIDR ranges from rate limiting. | ||
| --- | ||
|
|
||
| # pingone_rate_limit_configuration (Resource) | ||
|
|
||
| Resource to create and manage rate limit configurations in PingOne. Rate limit configurations allow you to exclude specific IP addresses or CIDR ranges from rate limiting. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```terraform | ||
| resource "pingone_environment" "my_environment" { | ||
| # ... | ||
| } | ||
|
|
||
| resource "pingone_rate_limit_configuration" "my_rate_limit_configuration" { | ||
| environment_id = pingone_environment.my_environment.id | ||
|
|
||
| type = "WHITELIST" | ||
| value = "192.0.2.0/24" | ||
| } | ||
| ``` | ||
|
|
||
| <!-- schema generated by tfplugindocs --> | ||
| ## Schema | ||
|
|
||
| ### Required | ||
|
|
||
| - `environment_id` (String) The ID of the environment to create the rate limit configuration in. Must be a valid PingOne resource ID. This field is immutable and will trigger a replace plan if changed. | ||
| - `value` (String) The IP address (IPv4 or IPv6), or a CIDR range, for the IP address or addresses to be excluded from rate limiting. | ||
|
|
||
| ### Optional | ||
|
|
||
| - `type` (String) The type of rate limit configuration. Currently, the only type supported is `WHITELIST`, indicating that the IP address in `value` is to be excluded from rate limiting. | ||
|
|
||
| ### Read-Only | ||
|
|
||
| - `created_at` (String) A string that specifies the time the resource was created. | ||
| - `id` (String) The ID of this resource. | ||
| - `updated_at` (String) A string that specifies the time the resource was last updated. | ||
|
|
||
| ## Import | ||
|
|
||
| Import is supported using the following syntax, where attributes in `<>` brackets are replaced with the relevant ID. For example, `<environment_id>` should be replaced with the ID of the environment to import from. | ||
|
|
||
| ```shell | ||
| terraform import pingone_rate_limit_configuration.example <environment_id>/<rate_limit_configuration_id> | ||
| ``` |
This file contains hidden or 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 @@ | ||
| terraform import pingone_rate_limit_configuration.example <environment_id>/<rate_limit_configuration_id> |
10 changes: 10 additions & 0 deletions
10
examples/resources/pingone_rate_limit_configuration/resource.tf
This file contains hidden or 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,10 @@ | ||
| resource "pingone_environment" "my_environment" { | ||
| # ... | ||
| } | ||
|
|
||
| resource "pingone_rate_limit_configuration" "my_rate_limit_configuration" { | ||
| environment_id = pingone_environment.my_environment.id | ||
|
|
||
| type = "WHITELIST" | ||
| value = "192.0.2.0/24" | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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,88 @@ | ||
| // Copyright © 2025 Ping Identity Corporation | ||
|
|
||
| package base | ||
|
|
||
| import ( | ||
| "context" | ||
| "fmt" | ||
| "testing" | ||
|
|
||
| "github.com/hashicorp/terraform-plugin-testing/helper/resource" | ||
| "github.com/hashicorp/terraform-plugin-testing/terraform" | ||
| "github.com/patrickcping/pingone-go-sdk-v2/management" | ||
| "github.com/pingidentity/terraform-provider-pingone/internal/acctest" | ||
| "github.com/pingidentity/terraform-provider-pingone/internal/acctest/legacysdk" | ||
| ) | ||
|
|
||
| func RateLimitConfiguration_CheckDestroy(s *terraform.State) error { | ||
| var ctx = context.Background() | ||
|
|
||
| p1Client, err := legacysdk.TestClient(ctx) | ||
|
|
||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| apiClient := p1Client.API.ManagementAPIClient | ||
|
|
||
| for _, rs := range s.RootModule().Resources { | ||
| if rs.Type != "pingone_rate_limit_configuration" { | ||
| continue | ||
| } | ||
|
|
||
| shouldContinue, err := legacysdk.CheckParentEnvironmentDestroy(ctx, apiClient, rs.Primary.Attributes["environment_id"]) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if shouldContinue { | ||
| continue | ||
| } | ||
|
|
||
| _, r, err := apiClient.RateLimitingApi.ReadOneRateLimitConfiguration(ctx, rs.Primary.Attributes["environment_id"], rs.Primary.ID).Execute() | ||
|
|
||
| shouldContinue, err = acctest.CheckForResourceDestroy(r, err) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if shouldContinue { | ||
| continue | ||
| } | ||
|
|
||
| return fmt.Errorf("PingOne Rate Limit Configuration %s still exists", rs.Primary.ID) | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func RateLimitConfiguration_GetIDs(resourceName string, environmentID, resourceID *string) resource.TestCheckFunc { | ||
| return func(s *terraform.State) error { | ||
|
|
||
| rs, ok := s.RootModule().Resources[resourceName] | ||
| if !ok { | ||
| return fmt.Errorf("Resource Not found: %s", resourceName) | ||
| } | ||
|
|
||
| if resourceID != nil { | ||
| *resourceID = rs.Primary.ID | ||
| } | ||
|
|
||
| if environmentID != nil { | ||
| *environmentID = rs.Primary.Attributes["environment_id"] | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
| } | ||
|
|
||
| func RateLimitConfiguration_RemovalDrift_PreConfig(ctx context.Context, apiClient *management.APIClient, t *testing.T, environmentID, rateLimitConfigurationID string) { | ||
| if environmentID == "" || rateLimitConfigurationID == "" { | ||
| t.Fatalf("One of environment ID or rate limit configuration ID cannot be determined. Environment ID: %s, Rate Limit Configuration ID: %s", environmentID, rateLimitConfigurationID) | ||
| } | ||
|
|
||
| _, err := apiClient.RateLimitingApi.DeleteRateLimitConfiguration(ctx, environmentID, rateLimitConfigurationID).Execute() | ||
| if err != nil { | ||
| t.Fatalf("Failed to delete rate limit configuration: %v", err) | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.