/
flowLog.ts
316 lines (307 loc) · 11.1 KB
/
flowLog.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
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
// *** 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";
/**
* Provides a VPC/Subnet/ENI Flow Log to capture IP traffic for a specific network
* interface, subnet, or VPC. Logs are sent to a CloudWatch Log Group or a S3 Bucket.
*
* ## Example Usage
*
* ### CloudWatch Logging
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const exampleLogGroup = new aws.cloudwatch.LogGroup("example", {});
* const exampleRole = new aws.iam.Role("example", {
* assumeRolePolicy: `{
* "Version": "2012-10-17",
* "Statement": [
* {
* "Sid": "",
* "Effect": "Allow",
* "Principal": {
* "Service": "vpc-flow-logs.amazonaws.com"
* },
* "Action": "sts:AssumeRole"
* }
* ]
* }
* `,
* });
* const exampleFlowLog = new aws.ec2.FlowLog("example", {
* iamRoleArn: exampleRole.arn,
* logDestination: exampleLogGroup.arn,
* trafficType: "ALL",
* vpcId: aws_vpc_example.id,
* });
* const exampleRolePolicy = new aws.iam.RolePolicy("example", {
* policy: `{
* "Version": "2012-10-17",
* "Statement": [
* {
* "Action": [
* "logs:CreateLogGroup",
* "logs:CreateLogStream",
* "logs:PutLogEvents",
* "logs:DescribeLogGroups",
* "logs:DescribeLogStreams"
* ],
* "Effect": "Allow",
* "Resource": "*"
* }
* ]
* }
* `,
* role: exampleRole.id,
* });
* ```
*
* ### S3 Logging
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const exampleBucket = new aws.s3.Bucket("example", {});
* const exampleFlowLog = new aws.ec2.FlowLog("example", {
* logDestination: exampleBucket.arn,
* logDestinationType: "s3",
* trafficType: "ALL",
* vpcId: aws_vpc_example.id,
* });
* ```
*/
export class FlowLog extends pulumi.CustomResource {
/**
* Get an existing FlowLog 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.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
public static get(name: string, id: pulumi.Input<pulumi.ID>, state?: FlowLogState, opts?: pulumi.CustomResourceOptions): FlowLog {
return new FlowLog(name, <any>state, { ...opts, id: id });
}
/** @internal */
public static readonly __pulumiType = 'aws:ec2/flowLog:FlowLog';
/**
* Returns true if the given object is an instance of FlowLog. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
public static isInstance(obj: any): obj is FlowLog {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === FlowLog.__pulumiType;
}
/**
* Elastic Network Interface ID to attach to
*/
public readonly eniId!: pulumi.Output<string | undefined>;
/**
* The ARN for the IAM role that's used to post flow logs to a CloudWatch Logs log group
*/
public readonly iamRoleArn!: pulumi.Output<string | undefined>;
/**
* The ARN of the logging destination.
*/
public readonly logDestination!: pulumi.Output<string>;
/**
* The type of the logging destination. Valid values: `cloud-watch-logs`, `s3`. Default: `cloud-watch-logs`.
*/
public readonly logDestinationType!: pulumi.Output<string | undefined>;
/**
* The fields to include in the flow log record, in the order in which they should appear.
*/
public readonly logFormat!: pulumi.Output<string>;
/**
* *Deprecated:* Use `logDestination` instead. The name of the CloudWatch log group.
*
* @deprecated use 'log_destination' argument instead
*/
public readonly logGroupName!: pulumi.Output<string>;
/**
* The maximum interval of time
* during which a flow of packets is captured and aggregated into a flow
* log record. Valid Values: `60` seconds (1 minute) or `600` seconds (10
* minutes). Default: `600`.
*/
public readonly maxAggregationInterval!: pulumi.Output<number | undefined>;
/**
* Subnet ID to attach to
*/
public readonly subnetId!: pulumi.Output<string | undefined>;
/**
* Key-value map of resource tags
*/
public readonly tags!: pulumi.Output<{[key: string]: any} | undefined>;
/**
* The type of traffic to capture. Valid values: `ACCEPT`,`REJECT`, `ALL`.
*/
public readonly trafficType!: pulumi.Output<string>;
/**
* VPC ID to attach to
*/
public readonly vpcId!: pulumi.Output<string | undefined>;
/**
* Create a FlowLog 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: FlowLogArgs, opts?: pulumi.CustomResourceOptions)
constructor(name: string, argsOrState?: FlowLogArgs | FlowLogState, opts?: pulumi.CustomResourceOptions) {
let inputs: pulumi.Inputs = {};
if (opts && opts.id) {
const state = argsOrState as FlowLogState | undefined;
inputs["eniId"] = state ? state.eniId : undefined;
inputs["iamRoleArn"] = state ? state.iamRoleArn : undefined;
inputs["logDestination"] = state ? state.logDestination : undefined;
inputs["logDestinationType"] = state ? state.logDestinationType : undefined;
inputs["logFormat"] = state ? state.logFormat : undefined;
inputs["logGroupName"] = state ? state.logGroupName : undefined;
inputs["maxAggregationInterval"] = state ? state.maxAggregationInterval : undefined;
inputs["subnetId"] = state ? state.subnetId : undefined;
inputs["tags"] = state ? state.tags : undefined;
inputs["trafficType"] = state ? state.trafficType : undefined;
inputs["vpcId"] = state ? state.vpcId : undefined;
} else {
const args = argsOrState as FlowLogArgs | undefined;
if (!args || args.trafficType === undefined) {
throw new Error("Missing required property 'trafficType'");
}
inputs["eniId"] = args ? args.eniId : undefined;
inputs["iamRoleArn"] = args ? args.iamRoleArn : undefined;
inputs["logDestination"] = args ? args.logDestination : undefined;
inputs["logDestinationType"] = args ? args.logDestinationType : undefined;
inputs["logFormat"] = args ? args.logFormat : undefined;
inputs["logGroupName"] = args ? args.logGroupName : undefined;
inputs["maxAggregationInterval"] = args ? args.maxAggregationInterval : undefined;
inputs["subnetId"] = args ? args.subnetId : undefined;
inputs["tags"] = args ? args.tags : undefined;
inputs["trafficType"] = args ? args.trafficType : undefined;
inputs["vpcId"] = args ? args.vpcId : undefined;
}
if (!opts) {
opts = {}
}
if (!opts.version) {
opts.version = utilities.getVersion();
}
super(FlowLog.__pulumiType, name, inputs, opts);
}
}
/**
* Input properties used for looking up and filtering FlowLog resources.
*/
export interface FlowLogState {
/**
* Elastic Network Interface ID to attach to
*/
readonly eniId?: pulumi.Input<string>;
/**
* The ARN for the IAM role that's used to post flow logs to a CloudWatch Logs log group
*/
readonly iamRoleArn?: pulumi.Input<string>;
/**
* The ARN of the logging destination.
*/
readonly logDestination?: pulumi.Input<string>;
/**
* The type of the logging destination. Valid values: `cloud-watch-logs`, `s3`. Default: `cloud-watch-logs`.
*/
readonly logDestinationType?: pulumi.Input<string>;
/**
* The fields to include in the flow log record, in the order in which they should appear.
*/
readonly logFormat?: pulumi.Input<string>;
/**
* *Deprecated:* Use `logDestination` instead. The name of the CloudWatch log group.
*
* @deprecated use 'log_destination' argument instead
*/
readonly logGroupName?: pulumi.Input<string>;
/**
* The maximum interval of time
* during which a flow of packets is captured and aggregated into a flow
* log record. Valid Values: `60` seconds (1 minute) or `600` seconds (10
* minutes). Default: `600`.
*/
readonly maxAggregationInterval?: pulumi.Input<number>;
/**
* Subnet ID to attach to
*/
readonly subnetId?: pulumi.Input<string>;
/**
* Key-value map of resource tags
*/
readonly tags?: pulumi.Input<{[key: string]: any}>;
/**
* The type of traffic to capture. Valid values: `ACCEPT`,`REJECT`, `ALL`.
*/
readonly trafficType?: pulumi.Input<string>;
/**
* VPC ID to attach to
*/
readonly vpcId?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a FlowLog resource.
*/
export interface FlowLogArgs {
/**
* Elastic Network Interface ID to attach to
*/
readonly eniId?: pulumi.Input<string>;
/**
* The ARN for the IAM role that's used to post flow logs to a CloudWatch Logs log group
*/
readonly iamRoleArn?: pulumi.Input<string>;
/**
* The ARN of the logging destination.
*/
readonly logDestination?: pulumi.Input<string>;
/**
* The type of the logging destination. Valid values: `cloud-watch-logs`, `s3`. Default: `cloud-watch-logs`.
*/
readonly logDestinationType?: pulumi.Input<string>;
/**
* The fields to include in the flow log record, in the order in which they should appear.
*/
readonly logFormat?: pulumi.Input<string>;
/**
* *Deprecated:* Use `logDestination` instead. The name of the CloudWatch log group.
*
* @deprecated use 'log_destination' argument instead
*/
readonly logGroupName?: pulumi.Input<string>;
/**
* The maximum interval of time
* during which a flow of packets is captured and aggregated into a flow
* log record. Valid Values: `60` seconds (1 minute) or `600` seconds (10
* minutes). Default: `600`.
*/
readonly maxAggregationInterval?: pulumi.Input<number>;
/**
* Subnet ID to attach to
*/
readonly subnetId?: pulumi.Input<string>;
/**
* Key-value map of resource tags
*/
readonly tags?: pulumi.Input<{[key: string]: any}>;
/**
* The type of traffic to capture. Valid values: `ACCEPT`,`REJECT`, `ALL`.
*/
readonly trafficType: pulumi.Input<string>;
/**
* VPC ID to attach to
*/
readonly vpcId?: pulumi.Input<string>;
}