/
databaseDb.go
121 lines (108 loc) · 3.7 KB
/
databaseDb.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
// *** 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 digitalocean
import (
"reflect"
"github.com/pkg/errors"
"github.com/pulumi/pulumi/sdk/v2/go/pulumi"
)
// Provides a DigitalOcean database resource. When creating a new database cluster, a default database with name `defaultdb` will be created. Then, this resource can be used to provide additional database inside the cluster.
//
// ## Example Usage
// ### Create a new PostgreSQL database
// ```go
// package main
//
// import (
// "github.com/pulumi/pulumi-digitalocean/sdk/v2/go/digitalocean"
// "github.com/pulumi/pulumi/sdk/v2/go/pulumi"
// )
//
// func main() {
// pulumi.Run(func(ctx *pulumi.Context) error {
// _, err := digitalocean.NewDatabaseCluster(ctx, "postgres_example", &digitalocean.DatabaseClusterArgs{
// Engine: pulumi.String("pg"),
// Version: pulumi.String("11"),
// Size: pulumi.String("db-s-1vcpu-1gb"),
// Region: pulumi.String("nyc1"),
// NodeCount: pulumi.Int(1),
// })
// if err != nil {
// return err
// }
// _, err = digitalocean.NewDatabaseDb(ctx, "database_example", &digitalocean.DatabaseDbArgs{
// ClusterId: postgres_example.ID(),
// })
// if err != nil {
// return err
// }
// return nil
// })
// }
// ```
type DatabaseDb struct {
pulumi.CustomResourceState
// The ID of the original source database cluster.
ClusterId pulumi.StringOutput `pulumi:"clusterId"`
// The name for the database.
Name pulumi.StringOutput `pulumi:"name"`
}
// NewDatabaseDb registers a new resource with the given unique name, arguments, and options.
func NewDatabaseDb(ctx *pulumi.Context,
name string, args *DatabaseDbArgs, opts ...pulumi.ResourceOption) (*DatabaseDb, error) {
if args == nil || args.ClusterId == nil {
return nil, errors.New("missing required argument 'ClusterId'")
}
if args == nil {
args = &DatabaseDbArgs{}
}
var resource DatabaseDb
err := ctx.RegisterResource("digitalocean:index:DatabaseDb", name, args, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// GetDatabaseDb gets an existing DatabaseDb 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 GetDatabaseDb(ctx *pulumi.Context,
name string, id pulumi.IDInput, state *DatabaseDbState, opts ...pulumi.ResourceOption) (*DatabaseDb, error) {
var resource DatabaseDb
err := ctx.ReadResource("digitalocean:index:DatabaseDb", name, id, state, &resource, opts...)
if err != nil {
return nil, err
}
return &resource, nil
}
// Input properties used for looking up and filtering DatabaseDb resources.
type databaseDbState struct {
// The ID of the original source database cluster.
ClusterId *string `pulumi:"clusterId"`
// The name for the database.
Name *string `pulumi:"name"`
}
type DatabaseDbState struct {
// The ID of the original source database cluster.
ClusterId pulumi.StringPtrInput
// The name for the database.
Name pulumi.StringPtrInput
}
func (DatabaseDbState) ElementType() reflect.Type {
return reflect.TypeOf((*databaseDbState)(nil)).Elem()
}
type databaseDbArgs struct {
// The ID of the original source database cluster.
ClusterId string `pulumi:"clusterId"`
// The name for the database.
Name *string `pulumi:"name"`
}
// The set of arguments for constructing a DatabaseDb resource.
type DatabaseDbArgs struct {
// The ID of the original source database cluster.
ClusterId pulumi.StringInput
// The name for the database.
Name pulumi.StringPtrInput
}
func (DatabaseDbArgs) ElementType() reflect.Type {
return reflect.TypeOf((*databaseDbArgs)(nil)).Elem()
}