/
folderSink.ts
203 lines (196 loc) · 8.52 KB
/
folderSink.ts
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
// *** 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! ***
import * as pulumi from "@pulumi/pulumi";
import * as utilities from "../utilities";
/**
* Manages a folder-level logging sink. For more information see
* [the official documentation](https://cloud.google.com/logging/docs/) and
* [Exporting Logs in the API](https://cloud.google.com/logging/docs/api/tasks/exporting-logs).
*
* Note that you must have the "Logs Configuration Writer" IAM role (`roles/logging.configWriter`)
* granted to the credentials used with terraform.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const my_folder = new gcp.organizations.Folder("my-folder", {
* displayName: "My folder",
* parent: "organizations/123456",
* });
* const log_bucket = new gcp.storage.Bucket("log-bucket", {});
* const my_sink = new gcp.logging.FolderSink("my-sink", {
* destination: pulumi.interpolate`storage.googleapis.com/${log_bucket.name}`,
* // Log all WARN or higher severity messages relating to instances
* filter: "resource.type = gce_instance AND severity >= WARN",
* folder: my_folder.name,
* });
* const log_writer = new gcp.projects.IAMBinding("log-writer", {
* members: [my_sink.writerIdentity],
* role: "roles/storage.objectCreator",
* });
* ```
*/
export class FolderSink extends pulumi.CustomResource {
/**
* Get an existing FolderSink resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
*/
public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: FolderSinkState, opts?: pulumi.CustomResourceOptions): FolderSink {
return new FolderSink(name, <any>state, { ...opts, id: id });
}
/**
* The destination of the sink (or, in other words, where logs are written to). Can be a
* Cloud Storage bucket, a PubSub topic, or a BigQuery dataset. Examples:
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* ```
* The writer associated with the sink must have access to write to the above resource.
*/
public readonly destination!: pulumi.Output<string>;
/**
* The filter to apply when exporting logs. Only log entries that match the filter are exported.
* See [Advanced Log Filters](https://cloud.google.com/logging/docs/view/advanced_filters) for information on how to
* write a filter.
*/
public readonly filter!: pulumi.Output<string | undefined>;
/**
* The folder to be exported to the sink. Note that either [FOLDER_ID] or "folders/[FOLDER_ID]" is
* accepted.
*/
public readonly folder!: pulumi.Output<string>;
/**
* Whether or not to include children folders in the sink export. If true, logs
* associated with child projects are also exported; otherwise only logs relating to the provided folder are included.
*/
public readonly includeChildren!: pulumi.Output<boolean | undefined>;
/**
* The name of the logging sink.
*/
public readonly name!: pulumi.Output<string>;
/**
* The identity associated with this sink. This identity must be granted write access to the
* configured `destination`.
*/
public /*out*/ readonly writerIdentity!: pulumi.Output<string>;
/**
* Create a FolderSink resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: FolderSinkArgs, opts?: pulumi.CustomResourceOptions)
constructor(name: string, argsOrState?: FolderSinkArgs | FolderSinkState, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
if (opts && opts.id) {
const state = argsOrState as FolderSinkState | undefined;
inputs["destination"] = state ? state.destination : undefined;
inputs["filter"] = state ? state.filter : undefined;
inputs["folder"] = state ? state.folder : undefined;
inputs["includeChildren"] = state ? state.includeChildren : undefined;
inputs["name"] = state ? state.name : undefined;
inputs["writerIdentity"] = state ? state.writerIdentity : undefined;
} else {
const args = argsOrState as FolderSinkArgs | undefined;
if (!args || args.destination === undefined) {
throw new Error("Missing required property 'destination'");
}
if (!args || args.folder === undefined) {
throw new Error("Missing required property 'folder'");
}
inputs["destination"] = args ? args.destination : undefined;
inputs["filter"] = args ? args.filter : undefined;
inputs["folder"] = args ? args.folder : undefined;
inputs["includeChildren"] = args ? args.includeChildren : undefined;
inputs["name"] = args ? args.name : undefined;
inputs["writerIdentity"] = undefined /*out*/;
}
if (!opts) {
opts = {}
}
if (!opts.version) {
opts.version = utilities.getVersion();
}
super("gcp:logging/folderSink:FolderSink", name, inputs, opts);
}
}
/**
* Input properties used for looking up and filtering FolderSink resources.
*/
export interface FolderSinkState {
/**
* The destination of the sink (or, in other words, where logs are written to). Can be a
* Cloud Storage bucket, a PubSub topic, or a BigQuery dataset. Examples:
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* ```
* The writer associated with the sink must have access to write to the above resource.
*/
readonly destination?: pulumi.Input<string>;
/**
* The filter to apply when exporting logs. Only log entries that match the filter are exported.
* See [Advanced Log Filters](https://cloud.google.com/logging/docs/view/advanced_filters) for information on how to
* write a filter.
*/
readonly filter?: pulumi.Input<string>;
/**
* The folder to be exported to the sink. Note that either [FOLDER_ID] or "folders/[FOLDER_ID]" is
* accepted.
*/
readonly folder?: pulumi.Input<string>;
/**
* Whether or not to include children folders in the sink export. If true, logs
* associated with child projects are also exported; otherwise only logs relating to the provided folder are included.
*/
readonly includeChildren?: pulumi.Input<boolean>;
/**
* The name of the logging sink.
*/
readonly name?: pulumi.Input<string>;
/**
* The identity associated with this sink. This identity must be granted write access to the
* configured `destination`.
*/
readonly writerIdentity?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a FolderSink resource.
*/
export interface FolderSinkArgs {
/**
* The destination of the sink (or, in other words, where logs are written to). Can be a
* Cloud Storage bucket, a PubSub topic, or a BigQuery dataset. Examples:
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* ```
* The writer associated with the sink must have access to write to the above resource.
*/
readonly destination: pulumi.Input<string>;
/**
* The filter to apply when exporting logs. Only log entries that match the filter are exported.
* See [Advanced Log Filters](https://cloud.google.com/logging/docs/view/advanced_filters) for information on how to
* write a filter.
*/
readonly filter?: pulumi.Input<string>;
/**
* The folder to be exported to the sink. Note that either [FOLDER_ID] or "folders/[FOLDER_ID]" is
* accepted.
*/
readonly folder: pulumi.Input<string>;
/**
* Whether or not to include children folders in the sink export. If true, logs
* associated with child projects are also exported; otherwise only logs relating to the provided folder are included.
*/
readonly includeChildren?: pulumi.Input<boolean>;
/**
* The name of the logging sink.
*/
readonly name?: pulumi.Input<string>;
}