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 40
/
task_definitions.go
871 lines (857 loc) · 33.8 KB
/
task_definitions.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
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
package ecs
import (
"context"
"encoding/json"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ecs"
"github.com/aws/aws-sdk-go-v2/service/ecs/types"
"github.com/cloudquery/cq-provider-aws/client"
"github.com/cloudquery/cq-provider-sdk/provider/diag"
"github.com/cloudquery/cq-provider-sdk/provider/schema"
"golang.org/x/sync/errgroup"
"golang.org/x/sync/semaphore"
)
type TaskDefinitionWrapper struct {
*types.TaskDefinition
Tags []types.Tag
}
const MAX_GOROUTINES = 10
func EcsTaskDefinitions() *schema.Table {
return &schema.Table{
Name: "aws_ecs_task_definitions",
Description: "The details of a task definition which describes the container and volume definitions of an Amazon Elastic Container Service task",
Resolver: listEcsTaskDefinitions,
Multiplex: client.ServiceAccountRegionMultiplexer("ecs"),
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: "tags",
Description: "The metadata that you apply to the service to help you categorize and organize them",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionTags,
},
{
Name: "compatibilities",
Description: "The task launch types the task definition validated against during task definition registration",
Type: schema.TypeStringArray,
},
{
Name: "cpu",
Description: "The number of cpu units used by the task",
Type: schema.TypeString,
},
{
Name: "deregistered_at",
Description: "The Unix timestamp for when the task definition was deregistered.",
Type: schema.TypeTimestamp,
},
{
Name: "ephemeral_storage_size",
Description: "The total amount, in GiB, of ephemeral storage to set for the task.",
Type: schema.TypeInt,
Resolver: schema.PathResolver("EphemeralStorage.SizeInGiB"),
},
{
Name: "execution_role_arn",
Description: "The Amazon Resource Name (ARN) of the task execution role that grants the Amazon ECS container agent permission to make AWS API calls on your behalf",
Type: schema.TypeString,
},
{
Name: "family",
Description: "The name of a family that this task definition is registered to",
Type: schema.TypeString,
},
{
Name: "inference_accelerators",
Description: "The Elastic Inference accelerator associated with the task.",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionsInferenceAccelerators,
},
{
Name: "ipc_mode",
Description: "The IPC resource namespace to use for the containers in the task",
Type: schema.TypeString,
},
{
Name: "memory",
Description: "The amount (in MiB) of memory used by the task",
Type: schema.TypeString,
},
{
Name: "network_mode",
Description: "The Docker networking mode to use for the containers in the task",
Type: schema.TypeString,
},
{
Name: "pid_mode",
Description: "The process namespace to use for the containers in the task",
Type: schema.TypeString,
},
{
Name: "placement_constraints",
Description: "An array of placement constraint objects to use for tasks",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionsPlacementConstraints,
},
{
Name: "proxy_configuration_container_name",
Description: "The name of the container that will serve as the App Mesh proxy.",
Type: schema.TypeString,
Resolver: schema.PathResolver("ProxyConfiguration.ContainerName"),
},
{
Name: "proxy_configuration_properties",
Description: "The set of network configuration parameters to provide the Container Network Interface (CNI) plugin, specified as key-value pairs. * IgnoredUID - (Required) The user ID (UID) of the proxy container as defined by the user parameter in a container definition",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionsProxyConfigurationProperties,
},
{
Name: "proxy_configuration_type",
Description: "The proxy type",
Type: schema.TypeString,
Resolver: schema.PathResolver("ProxyConfiguration.Type"),
},
{
Name: "registered_at",
Description: "The Unix timestamp for when the task definition was registered.",
Type: schema.TypeTimestamp,
},
{
Name: "registered_by",
Description: "The principal that registered the task definition.",
Type: schema.TypeString,
},
{
Name: "requires_attributes",
Description: "The container instance attributes required by your task",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionsRequiresAttributes,
},
{
Name: "requires_compatibilities",
Description: "The task launch types the task definition was validated against",
Type: schema.TypeStringArray,
},
{
Name: "revision",
Description: "The revision of the task in a particular family",
Type: schema.TypeInt,
},
{
Name: "runtime_platform_cpu_architecture",
Description: "The CPU architecture.",
Type: schema.TypeString,
Resolver: schema.PathResolver("RuntimePlatform.CpuArchitecture"),
},
{
Name: "runtime_platform_os_family",
Description: "The operating system.",
Type: schema.TypeString,
Resolver: schema.PathResolver("RuntimePlatform.OperatingSystemFamily"),
},
{
Name: "status",
Description: "The status of the task definition.",
Type: schema.TypeString,
},
{
Name: "arn",
Description: "The full Amazon Resource Name (ARN) of the task definition.",
Type: schema.TypeString,
Resolver: schema.PathResolver("TaskDefinitionArn"),
},
{
Name: "task_role_arn",
Description: "The short name or full Amazon Resource Name (ARN) of the AWS Identity and Access Management (IAM) role that grants containers in the task permission to call AWS APIs on your behalf",
Type: schema.TypeString,
},
},
Relations: []*schema.Table{
{
Name: "aws_ecs_task_definition_container_definitions",
Description: "Container definitions are used in task definitions to describe the different containers that are launched as part of a task.",
Resolver: fetchEcsTaskDefinitionContainerDefinitions,
IgnoreInTests: true,
Columns: []schema.Column{
{
Name: "task_definition_cq_id",
Description: "Unique CloudQuery ID of aws_ecs_task_definitions table (FK)",
Type: schema.TypeUUID,
Resolver: schema.ParentIdResolver,
},
{
Name: "command",
Description: "The command that is passed to the container",
Type: schema.TypeStringArray,
},
{
Name: "cpu",
Description: "The number of cpu units reserved for the container",
Type: schema.TypeInt,
},
{
Name: "depends_on",
Description: "The dependencies defined for container startup and shutdown",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsDependsOn,
},
{
Name: "disable_networking",
Description: "When this parameter is true, networking is disabled within the container",
Type: schema.TypeBool,
},
{
Name: "dns_search_domains",
Description: "A list of DNS search domains that are presented to the container",
Type: schema.TypeStringArray,
},
{
Name: "dns_servers",
Description: "A list of DNS servers that are presented to the container",
Type: schema.TypeStringArray,
},
{
Name: "docker_labels",
Description: "A key/value map of labels to add to the container",
Type: schema.TypeJSON,
},
{
Name: "docker_security_options",
Description: "A list of strings to provide custom labels for SELinux and AppArmor multi-level security systems",
Type: schema.TypeStringArray,
},
{
Name: "entry_point",
Description: "Early versions of the Amazon ECS container agent do not properly handle entryPoint parameters",
Type: schema.TypeStringArray,
},
{
Name: "environment",
Description: "The environment variables to pass to a container",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsEnvironment,
},
{
Name: "environment_files",
Description: "A list of files containing the environment variables to pass to a container. This parameter maps to the --env-file option to docker run (https://docs.docker.com/engine/reference/run/#security-configuration)",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsEnvironmentFiles,
},
{
Name: "essential",
Description: "If the essential parameter of a container is marked as true, and that container fails or stops for any reason, all other containers that are part of the task are stopped",
Type: schema.TypeBool,
},
{
Name: "extra_hosts",
Description: "A list of hostnames and IP address mappings to append to the /etc/hosts file on the container",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsExtraHosts,
},
{
Name: "firelens_configuration_type",
Description: "The log router to use",
Type: schema.TypeString,
Resolver: schema.PathResolver("FirelensConfiguration.Type"),
},
{
Name: "firelens_configuration_options",
Description: "The options to use when configuring the log router",
Type: schema.TypeJSON,
Resolver: schema.PathResolver("FirelensConfiguration.Options"),
},
{
Name: "health_check_command",
Description: "A string array representing the command that the container runs to determine if it is healthy",
Type: schema.TypeStringArray,
Resolver: schema.PathResolver("HealthCheck.Command"),
},
{
Name: "health_check_interval",
Description: "The time period in seconds between each health check execution",
Type: schema.TypeInt,
Resolver: schema.PathResolver("HealthCheck.Interval"),
},
{
Name: "health_check_retries",
Description: "The number of times to retry a failed health check before the container is considered unhealthy",
Type: schema.TypeInt,
Resolver: schema.PathResolver("HealthCheck.Retries"),
},
{
Name: "health_check_start_period",
Description: "The optional grace period within which to provide containers time to bootstrap before failed health checks count towards the maximum number of retries",
Type: schema.TypeInt,
Resolver: schema.PathResolver("HealthCheck.StartPeriod"),
},
{
Name: "health_check_timeout",
Description: "The time period in seconds to wait for a health check to succeed before it is considered a failure",
Type: schema.TypeInt,
Resolver: schema.PathResolver("HealthCheck.Timeout"),
},
{
Name: "hostname",
Description: "The hostname to use for your container",
Type: schema.TypeString,
},
{
Name: "image",
Description: "The image used to start a container",
Type: schema.TypeString,
},
{
Name: "interactive",
Description: "When this parameter is true, this allows you to deploy containerized applications that require stdin or a tty to be allocated",
Type: schema.TypeBool,
},
{
Name: "links",
Description: "The links parameter allows containers to communicate with each other without the need for port mappings",
Type: schema.TypeStringArray,
},
{
Name: "linux_parameters_capabilities_add",
Description: "The Linux capabilities for the container that have been added to the default configuration provided by Docker",
Type: schema.TypeStringArray,
Resolver: schema.PathResolver("LinuxParameters.Capabilities.Add"),
},
{
Name: "linux_parameters_capabilities_drop",
Description: "The Linux capabilities for the container that have been removed from the default configuration provided by Docker",
Type: schema.TypeStringArray,
Resolver: schema.PathResolver("LinuxParameters.Capabilities.Drop"),
},
{
Name: "linux_parameters_devices",
Description: "Any host devices to expose to the container",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsLinuxParametersDevices,
},
{
Name: "linux_parameters_init_process_enabled",
Description: "Run an init process inside the container that forwards signals and reaps processes",
Type: schema.TypeBool,
Resolver: schema.PathResolver("LinuxParameters.InitProcessEnabled"),
},
{
Name: "linux_parameters_max_swap",
Description: "The total amount of swap memory (in MiB) a container can use",
Type: schema.TypeInt,
Resolver: schema.PathResolver("LinuxParameters.MaxSwap"),
},
{
Name: "linux_parameters_shared_memory_size",
Description: "The value for the size (in MiB) of the /dev/shm volume",
Type: schema.TypeInt,
Resolver: schema.PathResolver("LinuxParameters.SharedMemorySize"),
},
{
Name: "linux_parameters_swappiness",
Description: "This allows you to tune a container's memory swappiness behavior",
Type: schema.TypeInt,
Resolver: schema.PathResolver("LinuxParameters.Swappiness"),
},
{
Name: "linux_parameters_tmpfs",
Description: "The container path, mount options, and size (in MiB) of the tmpfs mount",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsLinuxParametersTmpfs,
},
{
Name: "log_configuration_log_driver",
Description: "The log driver to use for the container",
Type: schema.TypeString,
Resolver: schema.PathResolver("LogConfiguration.LogDriver"),
},
{
Name: "log_configuration_options",
Description: "The configuration options to send to the log driver",
Type: schema.TypeJSON,
Resolver: schema.PathResolver("LogConfiguration.Options"),
},
{
Name: "log_configuration_secret_options",
Description: "The secrets to pass to the log configuration",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsLogConfigurationSecretOptions,
},
{
Name: "memory",
Description: "The amount (in MiB) of memory to present to the container",
Type: schema.TypeInt,
},
{
Name: "memory_reservation",
Description: "The soft limit (in MiB) of memory to reserve for the container",
Type: schema.TypeInt,
},
{
Name: "mount_points",
Description: "The mount points for data volumes in your container",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsMountPoints,
},
{
Name: "name",
Description: "The name of a container",
Type: schema.TypeString,
},
{
Name: "port_mappings",
Description: "The list of port mappings for the container",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsPortMappings,
},
{
Name: "privileged",
Description: "When this parameter is true, the container is given elevated privileges on the host container instance (similar to the root user)",
Type: schema.TypeBool,
},
{
Name: "pseudo_terminal",
Description: "When this parameter is true, a TTY is allocated",
Type: schema.TypeBool,
},
{
Name: "readonly_root_filesystem",
Description: "When this parameter is true, the container is given read-only access to its root file system",
Type: schema.TypeBool,
},
{
Name: "repository_credentials_parameter",
Description: "The Amazon Resource Name (ARN) of the secret containing the private repository credentials",
Type: schema.TypeString,
Resolver: schema.PathResolver("RepositoryCredentials.CredentialsParameter"),
},
{
Name: "resource_requirements",
Description: "The type and amount of a resource to assign to a container",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsResourceRequirements,
},
{
Name: "secrets",
Description: "The secrets to pass to the container",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsSecrets,
},
{
Name: "start_timeout",
Description: "Time duration (in seconds) to wait before giving up on resolving dependencies for a container",
Type: schema.TypeInt,
},
{
Name: "stop_timeout",
Description: "Time duration (in seconds) to wait before the container is forcefully killed if it doesn't exit normally on its own",
Type: schema.TypeInt,
},
{
Name: "system_controls",
Description: "A list of namespaced kernel parameters to set in the container",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsSystemControls,
},
{
Name: "ulimits",
Description: "A list of ulimits to set in the container",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsUlimits,
},
{
Name: "user",
Description: "The user to use inside the container",
Type: schema.TypeString,
},
{
Name: "volumes_from",
Description: "Data volumes to mount from another container",
Type: schema.TypeJSON,
Resolver: resolveEcsTaskDefinitionContainerDefinitionsVolumesFrom,
},
{
Name: "working_directory",
Description: "The working directory in which to run commands inside the container",
Type: schema.TypeString,
},
},
},
{
Name: "aws_ecs_task_definition_volumes",
Description: "A data volume used in a task definition",
Resolver: fetchEcsTaskDefinitionVolumes,
IgnoreInTests: true,
Columns: []schema.Column{
{
Name: "task_definition_cq_id",
Description: "Unique CloudQuery ID of aws_ecs_task_definitions table (FK)",
Type: schema.TypeUUID,
Resolver: schema.ParentIdResolver,
},
{
Name: "docker_autoprovision",
Description: "If this value is true, the Docker volume is created if it does not already exist",
Type: schema.TypeBool,
Resolver: schema.PathResolver("DockerVolumeConfiguration.Autoprovision"),
},
{
Name: "docker_driver",
Description: "The Docker volume driver to use",
Type: schema.TypeString,
Resolver: schema.PathResolver("DockerVolumeConfiguration.Driver"),
},
{
Name: "docker_driver_opts",
Description: "A map of Docker driver-specific options passed through",
Type: schema.TypeJSON,
Resolver: schema.PathResolver("DockerVolumeConfiguration.DriverOpts"),
},
{
Name: "docker_labels",
Description: "Custom metadata to add to your Docker volume",
Type: schema.TypeJSON,
Resolver: schema.PathResolver("DockerVolumeConfiguration.Labels"),
},
{
Name: "docker_scope",
Description: "The scope for the Docker volume that determines its lifecycle",
Type: schema.TypeString,
Resolver: schema.PathResolver("DockerVolumeConfiguration.Scope"),
},
{
Name: "efs_file_system_id",
Description: "The Amazon EFS file system ID to use.",
Type: schema.TypeString,
Resolver: schema.PathResolver("EfsVolumeConfiguration.FileSystemId"),
},
{
Name: "efs_authorization_config_access_point_id",
Description: "The Amazon EFS access point ID to use",
Type: schema.TypeString,
Resolver: schema.PathResolver("EfsVolumeConfiguration.AuthorizationConfig.AccessPointId"),
},
{
Name: "efs_authorization_config_iam",
Description: "Whether or not to use the Amazon ECS task IAM role defined in a task definition when mounting the Amazon EFS file system",
Type: schema.TypeString,
Resolver: schema.PathResolver("EfsVolumeConfiguration.AuthorizationConfig.Iam"),
},
{
Name: "efs_root_directory",
Description: "The directory within the Amazon EFS file system to mount as the root directory inside the host",
Type: schema.TypeString,
Resolver: schema.PathResolver("EfsVolumeConfiguration.RootDirectory"),
},
{
Name: "efs_volume_configuration_transit_encryption",
Description: "Whether or not to enable encryption for Amazon EFS data in transit between the Amazon ECS host and the Amazon EFS server",
Type: schema.TypeString,
Resolver: schema.PathResolver("EfsVolumeConfiguration.TransitEncryption"),
},
{
Name: "efs_transit_encryption_port",
Description: "The port to use when sending encrypted data between the Amazon ECS host and the Amazon EFS server",
Type: schema.TypeInt,
Resolver: schema.PathResolver("EfsVolumeConfiguration.TransitEncryptionPort"),
},
{
Name: "fsx_wfs_authorization_config_credentials_parameter",
Description: "The authorization credential option to use",
Type: schema.TypeString,
Resolver: schema.PathResolver("FsxWindowsFileServerVolumeConfiguration.AuthorizationConfig.CredentialsParameter"),
},
{
Name: "fsx_wfs_authorization_config_domain",
Description: "A fully qualified domain name hosted by an AWS Directory Service (https://docs.aws.amazon.com/directoryservice/latest/admin-guide/directory_microsoft_ad.html) Managed Microsoft AD (Active Directory) or self-hosted AD on Amazon EC2.",
Type: schema.TypeString,
Resolver: schema.PathResolver("FsxWindowsFileServerVolumeConfiguration.AuthorizationConfig.Domain"),
},
{
Name: "fsx_wfs_file_system_id",
Description: "The Amazon FSx for Windows File Server file system ID to use.",
Type: schema.TypeString,
Resolver: schema.PathResolver("FsxWindowsFileServerVolumeConfiguration.FileSystemId"),
},
{
Name: "fsx_wfs_root_directory",
Description: "The directory within the Amazon FSx for Windows File Server file system to mount as the root directory inside the host.",
Type: schema.TypeString,
Resolver: schema.PathResolver("FsxWindowsFileServerVolumeConfiguration.RootDirectory"),
},
{
Name: "host_source_path",
Description: "When the host parameter is used, specify a sourcePath to declare the path on the host container instance that is presented to the container",
Type: schema.TypeString,
Resolver: schema.PathResolver("Host.SourcePath"),
},
{
Name: "name",
Description: "The name of the volume",
Type: schema.TypeString,
},
},
},
},
}
}
func fetchEcsTaskDefinition(ctx context.Context, res chan<- interface{}, svc client.EcsClient, region, taskArn string) error {
describeTaskDefinitionOutput, err := svc.DescribeTaskDefinition(ctx, &ecs.DescribeTaskDefinitionInput{
TaskDefinition: aws.String(taskArn),
Include: []types.TaskDefinitionField{types.TaskDefinitionFieldTags},
}, func(o *ecs.Options) {
o.Region = region
})
if err != nil {
return diag.WrapError(err)
}
if describeTaskDefinitionOutput.TaskDefinition == nil {
return nil
}
res <- TaskDefinitionWrapper{
TaskDefinition: describeTaskDefinitionOutput.TaskDefinition,
Tags: describeTaskDefinitionOutput.Tags,
}
return nil
}
// ====================================================================================================================
// Table Resolver Functions
// ====================================================================================================================
func listEcsTaskDefinitions(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
var config ecs.ListTaskDefinitionsInput
var sem = semaphore.NewWeighted(int64(MAX_GOROUTINES))
region := meta.(*client.Client).Region
svc := meta.(*client.Client).Services().ECS
for {
listClustersOutput, err := svc.ListTaskDefinitions(ctx, &config, func(o *ecs.Options) {
o.Region = region
})
if err != nil {
return diag.WrapError(err)
}
if len(listClustersOutput.TaskDefinitionArns) == 0 {
return nil
}
errs, ctx := errgroup.WithContext(ctx)
for _, t := range listClustersOutput.TaskDefinitionArns {
if err := sem.Acquire(ctx, 1); err != nil {
return diag.WrapError(err)
}
func(arn string) {
errs.Go(func() error {
defer sem.Release(1)
return fetchEcsTaskDefinition(ctx, res, svc, region, arn)
})
}(t)
}
err = errs.Wait()
if err != nil {
return diag.WrapError(err)
}
if listClustersOutput.NextToken == nil {
break
}
config.NextToken = listClustersOutput.NextToken
}
return nil
}
func resolveEcsTaskDefinitionsInferenceAccelerators(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(TaskDefinitionWrapper)
j := map[string]interface{}{}
for _, a := range r.InferenceAccelerators {
j[*a.DeviceName] = *a.DeviceType
}
return diag.WrapError(resource.Set(c.Name, j))
}
func resolveEcsTaskDefinitionsPlacementConstraints(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(TaskDefinitionWrapper)
j := map[string]interface{}{}
for _, p := range r.PlacementConstraints {
j[*p.Expression] = p.Type
}
return diag.WrapError(resource.Set(c.Name, j))
}
func resolveEcsTaskDefinitionsProxyConfigurationProperties(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(TaskDefinitionWrapper)
j := map[string]interface{}{}
if r.ProxyConfiguration == nil {
return nil
}
for _, p := range r.ProxyConfiguration.Properties {
j[*p.Name] = *p.Value
}
return diag.WrapError(resource.Set(c.Name, j))
}
func resolveEcsTaskDefinitionsRequiresAttributes(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(TaskDefinitionWrapper)
data, err := json.Marshal(r.RequiresAttributes)
if err != nil {
return diag.WrapError(err)
}
return diag.WrapError(resource.Set(c.Name, data))
}
func fetchEcsTaskDefinitionContainerDefinitions(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
r := parent.Item.(TaskDefinitionWrapper)
res <- r.ContainerDefinitions
return nil
}
func resolveEcsTaskDefinitionContainerDefinitionsDependsOn(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
j := map[string]interface{}{}
for _, p := range r.DependsOn {
j[*p.ContainerName] = p.Condition
}
return diag.WrapError(resource.Set(c.Name, j))
}
func resolveEcsTaskDefinitionContainerDefinitionsEnvironment(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
j := map[string]interface{}{}
for _, p := range r.Environment {
j[*p.Name] = p.Value
}
return diag.WrapError(resource.Set(c.Name, j))
}
func resolveEcsTaskDefinitionContainerDefinitionsEnvironmentFiles(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
j := map[string]interface{}{}
for _, p := range r.EnvironmentFiles {
j[string(p.Type)] = p.Value
}
return diag.WrapError(resource.Set(c.Name, j))
}
func resolveEcsTaskDefinitionContainerDefinitionsExtraHosts(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
j := map[string]interface{}{}
for _, h := range r.ExtraHosts {
j[*h.Hostname] = h.IpAddress
}
return diag.WrapError(resource.Set(c.Name, j))
}
func resolveEcsTaskDefinitionContainerDefinitionsLinuxParametersDevices(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
if r.LinuxParameters == nil {
return nil
}
data, err := json.Marshal(r.LinuxParameters.Devices)
if err != nil {
return diag.WrapError(err)
}
return diag.WrapError(resource.Set(c.Name, data))
}
func resolveEcsTaskDefinitionContainerDefinitionsLinuxParametersTmpfs(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
if r.LinuxParameters == nil {
return nil
}
data, err := json.Marshal(r.LinuxParameters.Tmpfs)
if err != nil {
return diag.WrapError(err)
}
return diag.WrapError(resource.Set(c.Name, data))
}
func resolveEcsTaskDefinitionContainerDefinitionsLogConfigurationSecretOptions(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
j := map[string]interface{}{}
if r.LogConfiguration == nil {
return nil
}
for _, s := range r.LogConfiguration.SecretOptions {
j[*s.Name] = *s.ValueFrom
}
return diag.WrapError(resource.Set(c.Name, j))
}
func resolveEcsTaskDefinitionContainerDefinitionsMountPoints(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
data, err := json.Marshal(r.MountPoints)
if err != nil {
return diag.WrapError(err)
}
return diag.WrapError(resource.Set(c.Name, data))
}
func resolveEcsTaskDefinitionContainerDefinitionsPortMappings(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
data, err := json.Marshal(r.PortMappings)
if err != nil {
return diag.WrapError(err)
}
return diag.WrapError(resource.Set(c.Name, data))
}
func resolveEcsTaskDefinitionContainerDefinitionsResourceRequirements(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
j := map[string]interface{}{}
if r.LogConfiguration == nil {
return nil
}
for _, s := range r.ResourceRequirements {
j[string(s.Type)] = *s.Value
}
return diag.WrapError(resource.Set(c.Name, j))
}
func resolveEcsTaskDefinitionContainerDefinitionsSecrets(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
j := map[string]interface{}{}
if r.LogConfiguration == nil {
return nil
}
for _, s := range r.Secrets {
j[*s.Name] = *s.ValueFrom
}
return diag.WrapError(resource.Set(c.Name, j))
}
func resolveEcsTaskDefinitionContainerDefinitionsSystemControls(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
j := map[string]interface{}{}
if r.LogConfiguration == nil {
return nil
}
for _, s := range r.SystemControls {
j[*s.Namespace] = *s.Value
}
return diag.WrapError(resource.Set(c.Name, j))
}
func resolveEcsTaskDefinitionContainerDefinitionsUlimits(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
data, err := json.Marshal(r.Ulimits)
if err != nil {
return diag.WrapError(err)
}
return diag.WrapError(resource.Set(c.Name, data))
}
func resolveEcsTaskDefinitionContainerDefinitionsVolumesFrom(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(types.ContainerDefinition)
j := map[string]interface{}{}
if r.LogConfiguration == nil {
return nil
}
for _, s := range r.VolumesFrom {
j[*s.SourceContainer] = *s.ReadOnly
}
return diag.WrapError(resource.Set(c.Name, j))
}
func fetchEcsTaskDefinitionVolumes(ctx context.Context, meta schema.ClientMeta, parent *schema.Resource, res chan<- interface{}) error {
r := parent.Item.(TaskDefinitionWrapper)
res <- r.Volumes
return nil
}
func resolveEcsTaskDefinitionTags(ctx context.Context, meta schema.ClientMeta, resource *schema.Resource, c schema.Column) error {
r := resource.Item.(TaskDefinitionWrapper)
j := map[string]interface{}{}
for _, a := range r.Tags {
j[*a.Key] = *a.Value
}
return diag.WrapError(resource.Set(c.Name, j))
}