|
18 | 18 | package beyondcorp
|
19 | 19 |
|
20 | 20 | import (
|
| 21 | + "context" |
21 | 22 | "fmt"
|
22 | 23 | "log"
|
23 | 24 | "reflect"
|
@@ -46,6 +47,15 @@ func ResourceBeyondcorpAppGateway() *schema.Resource {
|
46 | 47 | Delete: schema.DefaultTimeout(20 * time.Minute),
|
47 | 48 | },
|
48 | 49 |
|
| 50 | + SchemaVersion: 1, |
| 51 | + |
| 52 | + StateUpgraders: []schema.StateUpgrader{ |
| 53 | + { |
| 54 | + Type: resourceBeyondcorpAppGatewayResourceV0().CoreConfigSchema().ImpliedType(), |
| 55 | + Upgrade: ResourceBeyondcorpAppGatewayUpgradeV0, |
| 56 | + Version: 0, |
| 57 | + }, |
| 58 | + }, |
49 | 59 | CustomizeDiff: customdiff.All(
|
50 | 60 | tpgresource.SetLabelsDiff,
|
51 | 61 | tpgresource.DefaultProviderProject,
|
@@ -506,3 +516,110 @@ func expandBeyondcorpAppGatewayEffectiveLabels(v interface{}, d tpgresource.Terr
|
506 | 516 | }
|
507 | 517 | return m, nil
|
508 | 518 | }
|
| 519 | + |
| 520 | +func resourceBeyondcorpAppGatewayResourceV0() *schema.Resource { |
| 521 | + return &schema.Resource{ |
| 522 | + Schema: map[string]*schema.Schema{ |
| 523 | + "name": { |
| 524 | + Type: schema.TypeString, |
| 525 | + Required: true, |
| 526 | + ForceNew: true, |
| 527 | + Description: `ID of the AppGateway.`, |
| 528 | + }, |
| 529 | + "display_name": { |
| 530 | + Type: schema.TypeString, |
| 531 | + Optional: true, |
| 532 | + ForceNew: true, |
| 533 | + Description: `An arbitrary user-provided name for the AppGateway.`, |
| 534 | + }, |
| 535 | + "host_type": { |
| 536 | + Type: schema.TypeString, |
| 537 | + Optional: true, |
| 538 | + ForceNew: true, |
| 539 | + ValidateFunc: verify.ValidateEnum([]string{"HOST_TYPE_UNSPECIFIED", "GCP_REGIONAL_MIG", ""}), |
| 540 | + Description: `The type of hosting used by the AppGateway. Default value: "HOST_TYPE_UNSPECIFIED" Possible values: ["HOST_TYPE_UNSPECIFIED", "GCP_REGIONAL_MIG"]`, |
| 541 | + Default: "HOST_TYPE_UNSPECIFIED", |
| 542 | + }, |
| 543 | + "labels": { |
| 544 | + Type: schema.TypeMap, |
| 545 | + Optional: true, |
| 546 | + ForceNew: true, |
| 547 | + Description: `Resource labels to represent user provided metadata. |
| 548 | +
|
| 549 | +
|
| 550 | +**Note**: This field is non-authoritative, and will only manage the labels present in your configuration. |
| 551 | +Please refer to the field 'effective_labels' for all of the labels present on the resource.`, |
| 552 | + Elem: &schema.Schema{Type: schema.TypeString}, |
| 553 | + }, |
| 554 | + "region": { |
| 555 | + Type: schema.TypeString, |
| 556 | + Optional: true, |
| 557 | + ForceNew: true, |
| 558 | + Description: `The region of the AppGateway.`, |
| 559 | + }, |
| 560 | + "type": { |
| 561 | + Type: schema.TypeString, |
| 562 | + Optional: true, |
| 563 | + ForceNew: true, |
| 564 | + ValidateFunc: verify.ValidateEnum([]string{"TYPE_UNSPECIFIED", "TCP_PROXY", ""}), |
| 565 | + Description: `The type of network connectivity used by the AppGateway. Default value: "TYPE_UNSPECIFIED" Possible values: ["TYPE_UNSPECIFIED", "TCP_PROXY"]`, |
| 566 | + Default: "TYPE_UNSPECIFIED", |
| 567 | + }, |
| 568 | + "allocated_connections": { |
| 569 | + Type: schema.TypeList, |
| 570 | + Computed: true, |
| 571 | + Description: `A list of connections allocated for the Gateway.`, |
| 572 | + Elem: &schema.Resource{ |
| 573 | + Schema: map[string]*schema.Schema{ |
| 574 | + "ingress_port": { |
| 575 | + Type: schema.TypeInt, |
| 576 | + Optional: true, |
| 577 | + Description: `The ingress port of an allocated connection.`, |
| 578 | + }, |
| 579 | + "psc_uri": { |
| 580 | + Type: schema.TypeString, |
| 581 | + Optional: true, |
| 582 | + Description: `The PSC uri of an allocated connection.`, |
| 583 | + }, |
| 584 | + }, |
| 585 | + }, |
| 586 | + }, |
| 587 | + "effective_labels": { |
| 588 | + Type: schema.TypeMap, |
| 589 | + Computed: true, |
| 590 | + ForceNew: true, |
| 591 | + Description: `All of labels (key/value pairs) present on the resource in GCP, including the labels configured through Terraform, other clients and services.`, |
| 592 | + Elem: &schema.Schema{Type: schema.TypeString}, |
| 593 | + }, |
| 594 | + "state": { |
| 595 | + Type: schema.TypeString, |
| 596 | + Computed: true, |
| 597 | + Description: `Represents the different states of a AppGateway.`, |
| 598 | + }, |
| 599 | + "terraform_labels": { |
| 600 | + Type: schema.TypeMap, |
| 601 | + Computed: true, |
| 602 | + ForceNew: true, |
| 603 | + Description: `The combination of labels configured directly on the resource |
| 604 | + and default labels configured on the provider.`, |
| 605 | + Elem: &schema.Schema{Type: schema.TypeString}, |
| 606 | + }, |
| 607 | + "uri": { |
| 608 | + Type: schema.TypeString, |
| 609 | + Computed: true, |
| 610 | + Description: `Server-defined URI for this resource.`, |
| 611 | + }, |
| 612 | + "project": { |
| 613 | + Type: schema.TypeString, |
| 614 | + Optional: true, |
| 615 | + Computed: true, |
| 616 | + ForceNew: true, |
| 617 | + }, |
| 618 | + }, |
| 619 | + UseJSONNumber: true, |
| 620 | + } |
| 621 | +} |
| 622 | + |
| 623 | +func ResourceBeyondcorpAppGatewayUpgradeV0(_ context.Context, rawState map[string]interface{}, meta interface{}) (map[string]interface{}, error) { |
| 624 | + return tpgresource.TerraformLabelsStateUpgrade(rawState) |
| 625 | +} |
0 commit comments