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

Support MSP_BIZ rate plan #3185

Closed
wants to merge 9 commits into from
2 changes: 1 addition & 1 deletion docs/resources/zone.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ resource "cloudflare_zone" "example" {

- `jump_start` (Boolean) Whether to scan for DNS records on creation. Ignored after zone is created.
- `paused` (Boolean) Whether this zone is paused (traffic bypasses Cloudflare). Defaults to `false`.
- `plan` (String) The name of the commercial plan to apply to the zone. Available values: `free`, `lite`, `pro`, `pro_plus`, `business`, `enterprise`, `partners_free`, `partners_pro`, `partners_business`, `partners_enterprise`.
- `plan` (String) The name of the commercial plan to apply to the zone. Available values: `free`, `lite`, `pro`, `pro_plus`, `business`, `enterprise`, `partners_free`, `partners_pro`, `partners_business`, `partners_enterprise`, `msp_biz`.
- `type` (String) A full zone implies that DNS is hosted with Cloudflare. A partial zone is typically a partner-hosted zone or a CNAME setup. Available values: `full`, `partial`, `secondary`. Defaults to `full`.

### Read-Only
Expand Down
13 changes: 13 additions & 0 deletions internal/sdkv2provider/resource_cloudflare_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const (
planIDPartnerPro = "partners_pro"
planIDPartnerBusiness = "partners_business"
planIDPartnerEnterprise = "partners_enterprise"

planIDMspBiz = "msp_biz"
)

type subscriptionData struct {
Expand Down Expand Up @@ -87,6 +89,11 @@ var ratePlans = map[string]subscriptionData{
ID: planIDPartnerEnterprise,
Description: "Enterprise Website",
},
planIDMspBiz: {
Name: "MSP_BIZ",
ID: planIDMspBiz,
Description: "Business Website",
},
}

func resourceCloudflareZone() *schema.Resource {
Expand Down Expand Up @@ -178,6 +185,9 @@ func resourceCloudflareZoneRead(ctx context.Context, d *schema.ResourceData, met
var plan string
if zone.Status == "pending" && zone.PlanPending.LegacyID != "" {
plan = zone.PlanPending.LegacyID
} else if zone.Plan.ID == "1ac039f6c29b691475c3d74fe588d1ae" {
// Check if the plan is MSP_BIZ as it's legacy id is not equal to it's name in subscription
plan = "msp_biz"
} else {
plan = zone.Plan.LegacyID
}
Expand Down Expand Up @@ -226,6 +236,9 @@ func resourceCloudflareZoneUpdate(ctx context.Context, d *schema.ResourceData, m
// from `zone.PlanPending` instead to account for paid plans.
if zone.Status == "pending" && zone.PlanPending.Name != "" {
d.Set("plan", zone.PlanPending.LegacyID)
} else if zone.Plan.ID == "1ac039f6c29b691475c3d74fe588d1ae" {
// Check if the plan is MSP_BIZ as it's legacy id is not equal to it's name in subscription
d.Set("plan", "msp_biz")
}

if change := d.HasChange("plan"); change {
Expand Down
2 changes: 2 additions & 0 deletions internal/sdkv2provider/schema_cloudflare_zone.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ func resourceCloudflareZoneSchema() map[string]*schema.Schema {
planIDPartnerPro,
planIDPartnerBusiness,
planIDPartnerEnterprise,
planIDMspBiz,
}, false),
Description: fmt.Sprintf("The name of the commercial plan to apply to the zone. %s", renderAvailableDocumentationValuesStringSlice([]string{
planIDFree,
Expand All @@ -68,6 +69,7 @@ func resourceCloudflareZoneSchema() map[string]*schema.Schema {
planIDPartnerPro,
planIDPartnerBusiness,
planIDPartnerEnterprise,
planIDMspBiz,
})),
},
"meta": {
Expand Down
Loading