Skip to content

Commit 592d890

Browse files
authored
PLT-1519: Added resource limit support (#567)
* initial draft * PLT-1519:Added support for resource limits. * build fix * fix2 * add unit test * reviewable fix * fix
1 parent dc4b5e5 commit 592d890

File tree

11 files changed

+626
-3
lines changed

11 files changed

+626
-3
lines changed

docs/resources/resource_limit.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
page_title: "spectrocloud_resource_limit Resource - terraform-provider-spectrocloud"
3+
subcategory: ""
4+
description: |-
5+
6+
---
7+
8+
# spectrocloud_resource_limit (Resource)
9+
10+
11+
12+
You can learn more about managing resource limit in Palette by reviewing the [Default Resource Limit](https://docs.spectrocloud.com/tenant-settings/palette-resource-limits/?utm_source=palette&utm_medium=product2docs) guide.
13+
14+
~> The resource_limit resource enforces a resource limit in Palette. By default, a resource limit is configured in Palette with default values. Users can update the resource limit settings as per their requirements. When a spectrocloud_resource_limit resource is destroyed, the resource limits will revert to the Palette default settings.
15+
16+
## Example Usage
17+
18+
An example of managing an password policy in Palette.
19+
20+
```hcl
21+
resource "spectrocloud_resource_limit" "resource_limit" {
22+
alert = 101
23+
api_keys = 201
24+
appliance = 6001
25+
appliance_token = 201
26+
application_deployment = 200
27+
application_profile = 200
28+
certificate = 20
29+
cloud_account = 355
30+
cluster = 300
31+
cluster_group = 50
32+
cluster_profile = 2500
33+
filter = 200
34+
location = 100
35+
macro = 6000
36+
private_gateway = 100
37+
project = 200
38+
registry = 200
39+
role = 100
40+
ssh_key = 300
41+
team = 100
42+
user = 300
43+
workspace = 60
44+
}
45+
46+
## import existing resource limit
47+
#import {
48+
# to = spectrocloud_resource_limit.resource_limit
49+
# id = "5eea74e919f5e0d43fd3f316" // tenant-uid
50+
#}
51+
```
52+
53+
<!-- schema generated by tfplugindocs -->
54+
## Schema
55+
56+
### Optional
57+
58+
- `alert` (Number) The maximum number of alerts that can be created. Must be between 1 and 10,000.
59+
- `api_keys` (Number) The maximum number of API keys that can be generated. Must be between 1 and 10,000.
60+
- `appliance` (Number) The maximum number of appliances that can be managed. Must be between 1 and 50,000.
61+
- `appliance_token` (Number) The maximum number of appliance tokens that can be issued. Must be between 1 and 10,000.
62+
- `application_deployment` (Number) The maximum number of application deployments allowed. Must be between 1 and 10,000.
63+
- `application_profile` (Number) The maximum number of application profiles that can be configured. Must be between 1 and 10,000.
64+
- `certificate` (Number) The maximum number of certificates that can be managed. Must be between 1 and 10,000.
65+
- `cloud_account` (Number) The maximum number of cloud accounts that can be added. Must be between 1 and 10,000.
66+
- `cluster` (Number) The maximum number of clusters that can be created. Must be between 1 and 50,000.
67+
- `cluster_group` (Number) The maximum number of cluster groups that can be created. Must be between 1 and 10,000.
68+
- `cluster_profile` (Number) The maximum number of cluster profiles that can be configured. Must be between 1 and 10,000.
69+
- `filter` (Number) The maximum number of filters that can be defined. Must be between 1 and 10,000.
70+
- `location` (Number) The maximum number of locations that can be configured. Must be between 1 and 10,000.
71+
- `macro` (Number) The maximum number of macros that can be created. Must be between 1 and 10,000.
72+
- `private_gateway` (Number) The maximum number of private gateways that can be managed. Must be between 1 and 10,000.
73+
- `project` (Number) The maximum number of projects that can be created. Must be between 1 and 10,000.
74+
- `registry` (Number) The maximum number of registries that can be configured. Must be between 1 and 10,000.
75+
- `role` (Number) The maximum number of roles that can be assigned. Must be between 1 and 10,000.
76+
- `ssh_key` (Number) The maximum number of SSH keys that can be managed. Must be between 1 and 10,000.
77+
- `team` (Number) The maximum number of teams that can be created. Must be between 1 and 10,000.
78+
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
79+
- `user` (Number) The maximum number of users that can be added. Must be between 1 and 10,000.
80+
- `workspace` (Number) The maximum number of workspaces that can be created. Must be between 1 and 10,000.
81+
82+
### Read-Only
83+
84+
- `id` (String) The ID of this resource.
85+
86+
<a id="nestedblock--timeouts"></a>
87+
### Nested Schema for `timeouts`
88+
89+
Optional:
90+
91+
- `create` (String)
92+
- `delete` (String)
93+
- `update` (String)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
terraform {
2+
required_providers {
3+
spectrocloud = {
4+
version = ">= 0.1"
5+
source = "spectrocloud/spectrocloud"
6+
}
7+
}
8+
}
9+
10+
provider "spectrocloud" {
11+
host = var.sc_host
12+
api_key = var.sc_api_key
13+
project_name = var.sc_project_name
14+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
resource "spectrocloud_resource_limit" "resource_limit" {
2+
alert = 101
3+
api_keys = 201
4+
appliance = 6001
5+
appliance_token = 201
6+
application_deployment = 200
7+
application_profile = 200
8+
certificate = 20
9+
cloud_account = 355
10+
cluster = 300
11+
cluster_group = 50
12+
cluster_profile = 2500
13+
filter = 200
14+
location = 100
15+
macro = 6000
16+
private_gateway = 100
17+
project = 200
18+
registry = 200
19+
role = 100
20+
ssh_key = 300
21+
team = 100
22+
user = 300
23+
workspace = 60
24+
}
25+
26+
## import existing resource limit
27+
#import {
28+
# to = spectrocloud_resource_limit.resource_limit
29+
# id = "5eea74e919f5e0d43fd3f316" // tenant-uid
30+
#}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Spectro Cloud credentials
2+
sc_host = "{Enter Spectro Cloud API Host}" #e.g: api.spectrocloud.com (for SaaS)
3+
sc_api_key = "{Enter Spectro Cloud API Key}"
4+
sc_project_name = "{Enter Spectro Cloud Project Name}" #e.g: Default
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
variable "sc_host" {
2+
description = "Spectro Cloud Endpoint"
3+
default = "api.spectrocloud.com"
4+
}
5+
6+
variable "sc_api_key" {
7+
description = "Spectro Cloud API key"
8+
}
9+
10+
variable "sc_project_name" {
11+
description = "Spectro Cloud Project (e.g: Default)"
12+
default = "Default"
13+
}
14+
15+
variable "ssh_key_value" {
16+
description = "ssh key value"
17+
default = "ssh-rsa ...... == [email protected]"
18+
}

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require (
1111
github.com/hashicorp/terraform-plugin-docs v0.16.0
1212
github.com/hashicorp/terraform-plugin-sdk/v2 v2.30.0
1313
github.com/robfig/cron v1.2.0
14-
github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368
14+
github.com/spectrocloud/gomi v1.14.1-0.20241226051628-5517f1108187
1515
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d
1616
github.com/spectrocloud/palette-sdk-go v0.0.0-20250129091228-61bad491e5e8
1717
github.com/stretchr/testify v1.10.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9
597597
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
598598
github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0=
599599
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
600-
github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368 h1:eY0BOyEbGuNZcLtILVQrh7D7oEu+UezpLkuCzlK6Ae4=
601-
github.com/spectrocloud/gomi v1.14.1-0.20240214074114-c19394812368/go.mod h1:LlZ9We4kDaELYi7Is0SVmnySuDhwphJLS6ZT4wXxFIk=
600+
github.com/spectrocloud/gomi v1.14.1-0.20241226051628-5517f1108187 h1:P1VH0jiSo/KND6pYxDPM+wy4bPthH9uxdPu0We8kQFk=
601+
github.com/spectrocloud/gomi v1.14.1-0.20241226051628-5517f1108187/go.mod h1:HUKoN5t9KjBY7R2F4gj9rIBnpN8jRPEFWqe1ul+SKCA=
602602
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d h1:OMRbHxMJ1a+G1BYzvUYuMM0wLkYJPdnEOFx16faQ/UY=
603603
github.com/spectrocloud/hapi v1.14.1-0.20240214071352-81f589b1d86d/go.mod h1:MktpRPnSXDTHsQrFSD+daJFQ1zMLSR+1gWOL31jVvWE=
604604
github.com/spectrocloud/palette-sdk-go v0.0.0-20250129091228-61bad491e5e8 h1:VjJvMdivBh0TLPKJhtbZa1OYcGmbvoVIAHNN8v1cnvc=

spectrocloud/provider.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ func New(_ string) func() *schema.Provider {
138138
"spectrocloud_user": resourceUser(),
139139
"spectrocloud_role": resourceRole(),
140140
"spectrocloud_password_policy": resourcePasswordPolicy(),
141+
"spectrocloud_resource_limit": resourceResourceLimit(),
141142
},
142143
DataSourcesMap: map[string]*schema.Resource{
143144
"spectrocloud_permission": dataSourcePermission(),

0 commit comments

Comments
 (0)