generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 41
/
azure_proxy.go
126 lines (120 loc) · 3.58 KB
/
azure_proxy.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package load_balancer
import (
"context"
"github.com/harness/terraform-provider-harness/helpers"
"github.com/harness/terraform-provider-harness/internal"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func ResourceAzureProxy() *schema.Resource {
resource := &schema.Resource{
Description: "Resource for creating an Azure autostopping proxy",
ReadContext: resourceLoadBalancerRead,
CreateContext: resourceAzureProxyCreateOrUpdate,
UpdateContext: resourceAzureProxyCreateOrUpdate,
DeleteContext: resourceLoadBalancerDelete,
Importer: helpers.MultiLevelResourceImporter,
Schema: map[string]*schema.Schema{
"identifier": {
Description: "Unique identifier of the resource",
Type: schema.TypeString,
Computed: true,
},
"name": {
Description: "Name of the proxy",
Type: schema.TypeString,
Required: true,
},
"host_name": {
Description: "Hostname for the proxy",
Type: schema.TypeString,
Required: true,
},
"cloud_connector_id": {
Description: "Id of the cloud connector",
Type: schema.TypeString,
Required: true,
},
"region": {
Description: "Region in which cloud resources are hosted",
Type: schema.TypeString,
Required: true,
},
"resource_group": {
Description: "Resource group in which cloud resources are hosted",
Type: schema.TypeString,
Required: true,
},
"subnet_id": {
Description: "Subnet in which cloud resources are hosted",
Type: schema.TypeString,
Required: true,
},
"security_groups": {
Description: "Security Group to define the security rules that determine the inbound and outbound traffic",
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
"vpc": {
Description: "VPC in which cloud resources are hosted",
Type: schema.TypeString,
Required: true,
},
"allocate_static_ip": {
Description: "Boolean value to indicate if proxy vm needs to have static IP",
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"machine_type": {
Description: "Type of instance to be used for proxy",
Type: schema.TypeString,
Required: true,
},
"api_key": {
Description: "Harness NG API key",
Sensitive: true,
Type: schema.TypeString,
Required: true,
},
"keypair": {
Description: "Name of SSH Key to be used for proxy VM",
Type: schema.TypeString,
Required: true,
},
"certificate_id": {
Description: "",
Type: schema.TypeString,
Optional: true,
},
"certificates": {
Type: schema.TypeList,
Optional: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"cert_secret_id": {
Type: schema.TypeString,
Required: true,
Description: "ID of certificate secret uploaded to vault",
},
"key_secret_id": {
Type: schema.TypeString,
Required: true,
Description: "ID of certificate key uploaded to vault",
},
},
},
},
},
}
return resource
}
func resourceAzureProxyCreateOrUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
c, ctx := meta.(*internal.Session).GetPlatformClientWithContext(ctx)
lb := buildLoadBalancer(d, c.AccountId, "azure", "autostopping_proxy")
return resourceLoadBalancerCreateOrUpdate(ctx, d, meta, lb)
}