-
Notifications
You must be signed in to change notification settings - Fork 5
/
account.go
216 lines (203 loc) · 11 KB
/
account.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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
package polardb
import (
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// Provides a PolarDB account resource and used to manage databases.
//
// > **NOTE:** Available in v1.67.0+.
//
// ## Example Usage
//
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-alicloud/sdk/v2/go/alicloud"
// "github.com/pulumi/pulumi-alicloud/sdk/v2/go/alicloud/polardb"
// "github.com/pulumi/pulumi-alicloud/sdk/v2/go/alicloud/vpc"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi/config"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// cfg := config.New(ctx, "")
// creation := "PolarDB"
// if param := cfg.Get("creation"); param != "" {
// creation = param
// }
// name := "polardbaccountmysql"
// if param := cfg.Get("name"); param != "" {
// name = param
// }
// opt0 := creation
// defaultZones, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
// AvailableResourceCreation: &opt0,
// }, nil)
// if err != nil {
// return err
// }
// defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
// CidrBlock: pulumi.String("172.16.0.0/16"),
// })
// if err != nil {
// return err
// }
// defaultSwitch, err := vpc.NewSwitch(ctx, "defaultSwitch", &vpc.SwitchArgs{
// VpcId: defaultNetwork.ID(),
// CidrBlock: pulumi.String("172.16.0.0/24"),
// AvailabilityZone: pulumi.String(defaultZones.Zones[0].Id),
// })
// if err != nil {
// return err
// }
// cluster, err := polardb.NewCluster(ctx, "cluster", &polardb.ClusterArgs{
// DbType: pulumi.String("MySQL"),
// DbVersion: pulumi.String("8.0"),
// DbNodeClass: pulumi.String("polar.mysql.x4.large"),
// PayType: pulumi.String("PostPaid"),
// VswitchId: defaultSwitch.ID(),
// Description: pulumi.String(name),
// })
// if err != nil {
// return err
// }
// _, err = polardb.NewAccount(ctx, "account", &polardb.AccountArgs{
// DbClusterId: cluster.ID(),
// AccountName: pulumi.String("tftestnormal"),
// AccountPassword: pulumi.String("Test12345"),
// AccountDescription: pulumi.String(name),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
type Account struct {
pulumi.CustomResourceState
// Account description. It cannot begin with https://. It must start with a Chinese character or English letter. It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length may be 2-256 characters.
AccountDescription pulumi.StringPtrOutput `pulumi:"accountDescription"`
// Operation account requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letter and have no more than 16 characters.
AccountName pulumi.StringOutput `pulumi:"accountName"`
// Operation password. It may consist of letters, digits, or underlines, with a length of 6 to 32 characters.
AccountPassword pulumi.StringOutput `pulumi:"accountPassword"`
// Account type, Valid values are `Normal`, `Super`, Default to `Normal`.
AccountType pulumi.StringPtrOutput `pulumi:"accountType"`
// The Id of cluster in which account belongs.
DbClusterId pulumi.StringOutput `pulumi:"dbClusterId"`
// An KMS encrypts password used to a db account. If the `accountPassword` is filled in, this field will be ignored.
KmsEncryptedPassword pulumi.StringPtrOutput `pulumi:"kmsEncryptedPassword"`
// An KMS encryption context used to decrypt `kmsEncryptedPassword` before creating or updating a db account with `kmsEncryptedPassword`. See [Encryption Context](https://www.alibabacloud.com/help/doc-detail/42975.htm). It is valid when `kmsEncryptedPassword` is set.
KmsEncryptionContext pulumi.MapOutput `pulumi:"kmsEncryptionContext"`
}
// NewAccount registers a new resource with the given unique name, arguments, and options.
func NewAccount(ctx *pulumi.Context,
name string, args *AccountArgs, opts ...pulumi.ResourceOption) (*Account, error) {
if args == nil || args.AccountName == nil {
return nil, errors.New("missing required argument 'AccountName'")
}
if args == nil || args.AccountPassword == nil {
return nil, errors.New("missing required argument 'AccountPassword'")
}
if args == nil || args.DbClusterId == nil {
return nil, errors.New("missing required argument 'DbClusterId'")
}
if args == nil {
args = &AccountArgs{}
}
var resource Account
err := ctx.RegisterResource("alicloud:polardb/account:Account", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetAccount gets an existing Account resource's state with the given name, ID, and optional
// state properties that are used to uniquely qualify the lookup (nil if not required).
func GetAccount(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *AccountState, opts ...pulumi.ResourceOption) (*Account, error) {
var resource Account
err := ctx.ReadResource("alicloud:polardb/account:Account", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering Account resources.
type accountState struct {
// Account description. It cannot begin with https://. It must start with a Chinese character or English letter. It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length may be 2-256 characters.
AccountDescription *string `pulumi:"accountDescription"`
// Operation account requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letter and have no more than 16 characters.
AccountName *string `pulumi:"accountName"`
// Operation password. It may consist of letters, digits, or underlines, with a length of 6 to 32 characters.
AccountPassword *string `pulumi:"accountPassword"`
// Account type, Valid values are `Normal`, `Super`, Default to `Normal`.
AccountType *string `pulumi:"accountType"`
// The Id of cluster in which account belongs.
DbClusterId *string `pulumi:"dbClusterId"`
// An KMS encrypts password used to a db account. If the `accountPassword` is filled in, this field will be ignored.
KmsEncryptedPassword *string `pulumi:"kmsEncryptedPassword"`
// An KMS encryption context used to decrypt `kmsEncryptedPassword` before creating or updating a db account with `kmsEncryptedPassword`. See [Encryption Context](https://www.alibabacloud.com/help/doc-detail/42975.htm). It is valid when `kmsEncryptedPassword` is set.
KmsEncryptionContext map[string]interface{} `pulumi:"kmsEncryptionContext"`
}
type AccountState struct {
// Account description. It cannot begin with https://. It must start with a Chinese character or English letter. It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length may be 2-256 characters.
AccountDescription pulumi.StringPtrInput
// Operation account requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letter and have no more than 16 characters.
AccountName pulumi.StringPtrInput
// Operation password. It may consist of letters, digits, or underlines, with a length of 6 to 32 characters.
AccountPassword pulumi.StringPtrInput
// Account type, Valid values are `Normal`, `Super`, Default to `Normal`.
AccountType pulumi.StringPtrInput
// The Id of cluster in which account belongs.
DbClusterId pulumi.StringPtrInput
// An KMS encrypts password used to a db account. If the `accountPassword` is filled in, this field will be ignored.
KmsEncryptedPassword pulumi.StringPtrInput
// An KMS encryption context used to decrypt `kmsEncryptedPassword` before creating or updating a db account with `kmsEncryptedPassword`. See [Encryption Context](https://www.alibabacloud.com/help/doc-detail/42975.htm). It is valid when `kmsEncryptedPassword` is set.
KmsEncryptionContext pulumi.MapInput
}
func (AccountState) ElementType() reflect.Type {
return reflect.TypeOf((*accountState)(nil)).Elem()
}
type accountArgs struct {
// Account description. It cannot begin with https://. It must start with a Chinese character or English letter. It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length may be 2-256 characters.
AccountDescription *string `pulumi:"accountDescription"`
// Operation account requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letter and have no more than 16 characters.
AccountName string `pulumi:"accountName"`
// Operation password. It may consist of letters, digits, or underlines, with a length of 6 to 32 characters.
AccountPassword string `pulumi:"accountPassword"`
// Account type, Valid values are `Normal`, `Super`, Default to `Normal`.
AccountType *string `pulumi:"accountType"`
// The Id of cluster in which account belongs.
DbClusterId string `pulumi:"dbClusterId"`
// An KMS encrypts password used to a db account. If the `accountPassword` is filled in, this field will be ignored.
KmsEncryptedPassword *string `pulumi:"kmsEncryptedPassword"`
// An KMS encryption context used to decrypt `kmsEncryptedPassword` before creating or updating a db account with `kmsEncryptedPassword`. See [Encryption Context](https://www.alibabacloud.com/help/doc-detail/42975.htm). It is valid when `kmsEncryptedPassword` is set.
KmsEncryptionContext map[string]interface{} `pulumi:"kmsEncryptionContext"`
}
// The set of arguments for constructing a Account resource.
type AccountArgs struct {
// Account description. It cannot begin with https://. It must start with a Chinese character or English letter. It can include Chinese and English characters, underlines (_), hyphens (-), and numbers. The length may be 2-256 characters.
AccountDescription pulumi.StringPtrInput
// Operation account requiring a uniqueness check. It may consist of lower case letters, numbers, and underlines, and must start with a letter and have no more than 16 characters.
AccountName pulumi.StringInput
// Operation password. It may consist of letters, digits, or underlines, with a length of 6 to 32 characters.
AccountPassword pulumi.StringInput
// Account type, Valid values are `Normal`, `Super`, Default to `Normal`.
AccountType pulumi.StringPtrInput
// The Id of cluster in which account belongs.
DbClusterId pulumi.StringInput
// An KMS encrypts password used to a db account. If the `accountPassword` is filled in, this field will be ignored.
KmsEncryptedPassword pulumi.StringPtrInput
// An KMS encryption context used to decrypt `kmsEncryptedPassword` before creating or updating a db account with `kmsEncryptedPassword`. See [Encryption Context](https://www.alibabacloud.com/help/doc-detail/42975.htm). It is valid when `kmsEncryptedPassword` is set.
KmsEncryptionContext pulumi.MapInput
}
func (AccountArgs) ElementType() reflect.Type {
return reflect.TypeOf((*accountArgs)(nil)).Elem()
}