This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
/
clusters.go
348 lines (344 loc) · 13.3 KB
/
clusters.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
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
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
package emr
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/emr"
"github.com/cloudquery/cq-provider-aws/client"
"github.com/cloudquery/cq-provider-sdk/provider/diag"
"github.com/cloudquery/cq-provider-sdk/provider/schema"
)
func EmrClusters() *schema.Table {
return &schema.Table{
Name: "aws_emr_clusters",
Description: "The detailed description of the cluster.",
Resolver: fetchEmrClusters,
Multiplex: client.ServiceAccountRegionMultiplexer("elasticmapreduce"),
IgnoreError: client.IgnoreCommonErrors,
DeleteFilter: client.DeleteAccountRegionFilter,
Options: schema.TableCreationOptions{PrimaryKeys: []string{"arn"}},
IgnoreInTests: true,
Columns: []schema.Column{
{
Name: "account_id",
Description: "The AWS Account ID of the resource.",
Type: schema.TypeString,
Resolver: client.ResolveAWSAccount,
},
{
Name: "region",
Description: "The AWS Region of the resource.",
Type: schema.TypeString,
Resolver: client.ResolveAWSRegion,
},
{
Name: "applications",
Description: "The applications installed on this cluster.",
Type: schema.TypeJSON,
Resolver: schema.PathResolver("Applications"),
},
{
Name: "auto_scaling_role",
Description: "An IAM role for automatic scaling policies",
Type: schema.TypeString,
},
{
Name: "auto_terminate",
Description: "Specifies whether the cluster should terminate after completing all steps.",
Type: schema.TypeBool,
},
{
Name: "arn",
Description: "The Amazon Resource Name of the cluster.",
Type: schema.TypeString,
Resolver: schema.PathResolver("ClusterArn"),
},
{
Name: "configurations",
Description: "The list of Configurations supplied to the EMR cluster.",
Type: schema.TypeJSON,
Resolver: schema.PathResolver("Configurations"),
},
{
Name: "custom_ami_id",
Description: "The ID of a custom Amazon EBS-backed Linux AMI if the cluster uses a custom AMI.",
Type: schema.TypeString,
IgnoreInTests: true,
},
{
Name: "ebs_root_volume_size",
Description: "The size, in GiB, of the Amazon EBS root device volume of the Linux AMI that is used for each EC2 instance",
Type: schema.TypeInt,
},
{
Name: "ec2_instance_attribute_additional_master_security_groups",
Description: "A list of additional Amazon EC2 security group IDs for the master node.",
Type: schema.TypeStringArray,
Resolver: schema.PathResolver("Ec2InstanceAttributes.AdditionalMasterSecurityGroups"),
},
{
Name: "ec2_instance_attribute_additional_slave_security_groups",
Description: "A list of additional Amazon EC2 security group IDs for the core and task nodes.",
Type: schema.TypeStringArray,
Resolver: schema.PathResolver("Ec2InstanceAttributes.AdditionalSlaveSecurityGroups"),
},
{
Name: "ec2_instance_attribute_availability_zone",
Description: "The Availability Zone in which the cluster will run.",
Type: schema.TypeString,
Resolver: schema.PathResolver("Ec2InstanceAttributes.Ec2AvailabilityZone"),
},
{
Name: "ec2_instance_attribute_key_name",
Description: "The name of the Amazon EC2 key pair to use when connecting with SSH into the master node as a user named \"hadoop\".",
Type: schema.TypeString,
Resolver: schema.PathResolver("Ec2InstanceAttributes.Ec2KeyName"),
},
{
Name: "ec2_instance_attribute_subnet_id",
Description: "Set this parameter to the identifier of the Amazon VPC subnet where you want the cluster to launch",
Type: schema.TypeString,
Resolver: schema.PathResolver("Ec2InstanceAttributes.Ec2SubnetId"),
},
{
Name: "ec2_instance_attribute_emr_managed_master_security_group",
Description: "The identifier of the Amazon EC2 security group for the master node.",
Type: schema.TypeString,
Resolver: schema.PathResolver("Ec2InstanceAttributes.EmrManagedMasterSecurityGroup"),
},
{
Name: "ec2_instance_attribute_emr_managed_slave_security_group",
Description: "The identifier of the Amazon EC2 security group for the core and task nodes.",
Type: schema.TypeString,
Resolver: schema.PathResolver("Ec2InstanceAttributes.EmrManagedSlaveSecurityGroup"),
},
{
Name: "ec2_instance_attribute_iam_instance_profile",
Description: "The IAM role that was specified when the cluster was launched",
Type: schema.TypeString,
Resolver: schema.PathResolver("Ec2InstanceAttributes.IamInstanceProfile"),
},
{
Name: "ec2_instance_attribute_requested_availability_zones",
Description: "Specifies one or more Availability Zones in which to launch EC2 cluster instances when the EC2-Classic network configuration is supported.",
Type: schema.TypeStringArray,
Resolver: schema.PathResolver("Ec2InstanceAttributes.RequestedEc2AvailabilityZones"),
},
{
Name: "ec2_instance_attribute_requested_subnet_ids",
Description: "Specifies the unique identifier of one or more Amazon EC2 subnets in which to launch EC2 cluster instances.",
Type: schema.TypeStringArray,
Resolver: schema.PathResolver("Ec2InstanceAttributes.RequestedEc2SubnetIds"),
},
{
Name: "ec2_instance_attribute_service_access_security_group",
Description: "The identifier of the Amazon EC2 security group for the Amazon EMR service to access clusters in VPC private subnets.",
Type: schema.TypeString,
Resolver: schema.PathResolver("Ec2InstanceAttributes.ServiceAccessSecurityGroup"),
},
{
Name: "id",
Description: "The unique identifier for the cluster.",
Type: schema.TypeString,
},
{
Name: "instance_collection_type",
Description: "The instance group configuration of the cluster.",
Type: schema.TypeString,
},
{
Name: "kerberos_kdc_admin_password",
Description: "The password used within the cluster for the kadmin service on the cluster-dedicated KDC, which maintains Kerberos principals, password policies, and keytabs for the cluster. ",
Type: schema.TypeString,
Resolver: schema.PathResolver("KerberosAttributes.KdcAdminPassword"),
IgnoreInTests: true,
},
{
Name: "kerberos_realm",
Description: "The name of the Kerberos realm to which all nodes in a cluster belong",
Type: schema.TypeString,
Resolver: schema.PathResolver("KerberosAttributes.Realm"),
IgnoreInTests: true,
},
{
Name: "kerberos_ad_domain_join_password",
Description: "The Active Directory password for ADDomainJoinUser.",
Type: schema.TypeString,
Resolver: schema.PathResolver("KerberosAttributes.ADDomainJoinPassword"),
IgnoreInTests: true,
},
{
Name: "kerberos_ad_domain_join_user",
Description: "Required only when establishing a cross-realm trust with an Active Directory domain",
Type: schema.TypeString,
Resolver: schema.PathResolver("KerberosAttributes.ADDomainJoinUser"),
IgnoreInTests: true,
},
{
Name: "kerberos_cross_realm_trust_principal_password",
Description: "Required only when establishing a cross-realm trust with a KDC in a different realm",
Type: schema.TypeString,
Resolver: schema.PathResolver("KerberosAttributes.CrossRealmTrustPrincipalPassword"),
IgnoreInTests: true,
},
{
Name: "log_encryption_kms_key_id",
Description: "The AWS KMS customer master key (CMK) used for encrypting log files",
Type: schema.TypeString,
IgnoreInTests: true,
},
{
Name: "log_uri",
Description: "The path to the Amazon S3 location where logs for this cluster are stored.",
Type: schema.TypeString,
},
{
Name: "master_public_dns_name",
Description: "The DNS name of the master node",
Type: schema.TypeString,
},
{
Name: "name",
Description: "The name of the cluster.",
Type: schema.TypeString,
},
{
Name: "normalized_instance_hours",
Description: "An approximation of the cost of the cluster, represented in m1.small/hours",
Type: schema.TypeInt,
},
{
Name: "outpost_arn",
Description: "The Amazon Resource Name (ARN) of the Outpost where the cluster is launched.",
Type: schema.TypeString,
IgnoreInTests: true,
},
{
Name: "placement_groups",
Description: "Placement group configured for an Amazon EMR cluster.",
Type: schema.TypeJSON,
Resolver: schema.PathResolver("PlacementGroups"),
},
{
Name: "release_label",
Description: "The Amazon EMR release label, which determines the version of open-source application packages installed on the cluster",
Type: schema.TypeString,
},
{
Name: "repo_upgrade_on_boot",
Description: "Specifies the type of updates that are applied from the Amazon Linux AMI package repositories when an instance boots using the AMI.",
Type: schema.TypeString,
},
{
Name: "requested_ami_version",
Description: "The AMI version requested for this cluster.",
Type: schema.TypeString,
IgnoreInTests: true,
},
{
Name: "running_ami_version",
Description: "The AMI version running on this cluster.",
Type: schema.TypeString,
IgnoreInTests: true,
},
{
Name: "scale_down_behavior",
Description: "The way that individual Amazon EC2 instances terminate when an automatic scale-in activity occurs or an instance group is resized.",
Type: schema.TypeString,
},
{
Name: "security_configuration",
Description: "The name of the security configuration applied to the cluster.",
Type: schema.TypeString,
IgnoreInTests: true,
},
{
Name: "service_role",
Description: "The IAM role that will be assumed by the Amazon EMR service to access AWS resources on your behalf.",
Type: schema.TypeString,
},
{
Name: "state",
Description: "The current state of the cluster.",
Type: schema.TypeString,
Resolver: schema.PathResolver("Status.State"),
},
{
Name: "state_change_reason_code",
Description: "The programmatic code for the state change reason.",
Type: schema.TypeString,
Resolver: schema.PathResolver("Status.StateChangeReason.Code"),
},
{
Name: "state_change_reason_message",
Description: "The descriptive message for the state change reason.",
Type: schema.TypeString,
Resolver: schema.PathResolver("Status.StateChangeReason.Message"),
},
{
Name: "creation_date_time",
Description: "The creation date and time of the cluster.",
Type: schema.TypeTimestamp,
Resolver: schema.PathResolver("Status.Timeline.CreationDateTime"),
},
{
Name: "end_date_time",
Description: "The date and time when the cluster was terminated.",
Type: schema.TypeTimestamp,
Resolver: schema.PathResolver("Status.Timeline.EndDateTime"),
},
{
Name: "ready_date_time",
Description: "The date and time when the cluster was ready to run steps.",
Type: schema.TypeTimestamp,
Resolver: schema.PathResolver("Status.Timeline.ReadyDateTime"),
},
{
Name: "step_concurrency_level",
Description: "Specifies the number of steps that can be executed concurrently.",
Type: schema.TypeInt,
},
{
Name: "tags",
Description: "A list of tags associated with a cluster.",
Type: schema.TypeJSON,
Resolver: client.ResolveTags,
},
{
Name: "termination_protected",
Description: "Indicates whether Amazon EMR will lock the cluster to prevent the EC2 instances from being terminated by an API call or user intervention, or in the event of a cluster error.",
Type: schema.TypeBool,
},
{
Name: "visible_to_all_users",
Description: "Indicates whether the cluster is visible to all IAM users of the AWS account associated with the cluster",
Type: schema.TypeBool,
},
},
}
}
// ====================================================================================================================
// Table Resolver Functions
// ====================================================================================================================
func fetchEmrClusters(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
var config emr.ListClustersInput
c := meta.(*client.Client)
svc := c.Services().EMR
for {
response, err := svc.ListClusters(ctx, &config)
if err != nil {
return diag.WrapError(err)
}
for _, c := range response.Clusters {
out, err := svc.DescribeCluster(ctx, &emr.DescribeClusterInput{ClusterId: c.Id})
if err != nil {
return diag.WrapError(err)
}
res <- out.Cluster
}
if aws.ToString(response.Marker) == "" {
break
}
config.Marker = response.Marker
}
return nil
}