diff --git a/go.mod b/go.mod index 9445a2fd4..3c9055077 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,6 @@ require ( github.com/aws/aws-sdk-go-v2/service/s3 v1.11.1 github.com/aws/smithy-go v1.6.0 github.com/awslabs/goformation/v4 v4.19.1 - github.com/davecgh/go-spew v1.1.1 // indirect github.com/ghodss/yaml v1.0.0 github.com/go-errors/errors v1.0.1 github.com/google/uuid v1.2.0 diff --git a/go.sum b/go.sum index 95593bdeb..43049a347 100644 --- a/go.sum +++ b/go.sum @@ -1858,8 +1858,6 @@ golang.org/x/tools v0.0.0-20201124115921-2c860bdd6e78/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.4 h1:cVngSRcfgyZCzys3KYOpCFa+4dqX/Oub9tAq00ttGVs= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/out.json b/out.json deleted file mode 100644 index ebcd73fa9..000000000 --- a/out.json +++ /dev/null @@ -1,800 +0,0 @@ -{ - "aws_ecs_task_definition": [ - { - "id": "aws_ecs_task_definition.demo-ecs-jsoncode-task-definition", - "name": "demo-ecs-jsoncode-task-definition", - "module_name": "root", - "source": "terraform-aws-provider/jsoncode_in_task_definition.tf", - "plan_root": "terraform-aws-provider", - "line": 1, - "type": "aws_ecs_task_definition", - "config": { - "container_definitions": "${jsonencode(\n[\n {\n \"cpu\": 10,\n \"command\": [\"sleep\", \"10\"],\n \"entryPoint\": [\"/\"],\n \"environment\": [\n {\"name\": \"VARNAME\", \"value\": \"VARVAL\"}\n ],\n \"essential\": true,\n \"image\": \"jenkins\",\n \"memory\": 128,\n \"name\": \"jenkins\",\n \"portMappings\": [\n {\n \"containerPort\": 80,\n \"hostPort\": 8080\n }\n ],\n \"resourceRequirements\":[\n {\n \"type\":\"InferenceAccelerator\",\n \"value\":\"device_1\"\n }\n ]\n }\n]\n )}", - "cpu": "512", - "execution_role_arn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole", - "family": "ecs-task-definition-demo", - "memory": "1024", - "network_mode": "awsvpc", - "requires_compatibilities": [ - "FARGATE" - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "jenkins", - "image": "jenkins" - } - ] - }, - { - "id": "aws_ecs_task_definition.demo-ecs-task-definition", - "name": "demo-ecs-task-definition", - "module_name": "root", - "source": "terraform-aws-provider/main.tf", - "plan_root": "terraform-aws-provider", - "line": 1, - "type": "aws_ecs_task_definition", - "config": { - "container_definitions": "[\n {\n \"cpu\": 10,\n \"command\": [\"sleep\", \"10\"],\n \"entryPoint\": [\"/\"],\n \"environment\": [\n {\"name\": \"VARNAME\", \"value\": \"VARVAL\"}\n ],\n \"essential\": true,\n \"image\": \"jenkins\",\n \"memory\": 128,\n \"name\": \"jenkins\",\n \"portMappings\": [\n {\n \"containerPort\": 80,\n \"hostPort\": 8080\n }\n ],\n \"resourceRequirements\":[\n {\n \"type\":\"InferenceAccelerator\",\n \"value\":\"device_1\"\n }\n ]\n }\n]\n", - "cpu": "512", - "execution_role_arn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole", - "family": "ecs-task-definition-demo", - "memory": "1024", - "network_mode": "awsvpc", - "requires_compatibilities": [ - "FARGATE" - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "jenkins", - "image": "jenkins" - } - ] - }, - { - "id": "aws_ecs_task_definition.service", - "name": "service", - "module_name": "root", - "source": "terraform-aws-provider/file_in_task_definition.tf", - "plan_root": "terraform-aws-provider", - "line": 1, - "type": "aws_ecs_task_definition", - "config": { - "container_definitions": "${file(\"pkg/iac-providers/terraform/v12/testdata/terraform-container-extraction/terraform-aws-provider/task-definitions/service.json\")}", - "family": "service", - "proxy_configuration": [ - { - "container_name": "applicationContainerName", - "properties": { - "AppPorts": "8080", - "EgressIgnoredIPs": "169.254.170.2,169.254.169.254", - "IgnoredUID": "1337", - "ProxyEgressPort": 15001, - "ProxyIngressPort": 15000 - }, - "type": "APPMESH" - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "jenkins", - "image": "jenkins" - } - ] - } - ], - "azurerm_container_group": [ - { - "id": "azurerm_container_group.example", - "name": "example", - "module_name": "root", - "source": "terraform-azure-provider/main.tf", - "plan_root": "terraform-azure-provider", - "line": 1, - "type": "azurerm_container_group", - "config": { - "container": [ - { - "cpu": "0.5", - "image": "microsoft/aci-helloworld:latest", - "memory": "1.5", - "name": "hello-world", - "ports": [ - { - "port": 443, - "protocol": "TCP" - } - ] - }, - { - "cpu": "0.5", - "image": "microsoft/aci-tutorial-sidecar", - "memory": "1.5", - "name": "sidecar" - } - ], - "dns_name_label": "aci-label", - "ip_address_type": "public", - "location": "${azurerm_resource_group.example.location}", - "name": "example-continst", - "os_type": "Linux", - "resource_group_name": "${azurerm_resource_group.example.name}", - "tags": { - "environment": "testing" - } - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "hello-world", - "image": "microsoft/aci-helloworld:latest" - }, - { - "name": "sidecar", - "image": "microsoft/aci-tutorial-sidecar" - } - ] - } - ], - "kubernetes_cron_job": [ - { - "id": "kubernetes_cron_job.demo", - "name": "demo", - "module_name": "root", - "source": "terraform-k8s-provider/cron_job.tf", - "plan_root": "terraform-k8s-provider", - "line": 1, - "type": "kubernetes_cron_job", - "config": { - "metadata": [ - { - "name": "demo" - } - ], - "spec": [ - { - "concurrency_policy": "Replace", - "failed_jobs_history_limit": 5, - "job_template": [ - { - "metadata": [ - {} - ], - "spec": [ - { - "backoff_limit": 2, - "template": [ - { - "metadata": [ - {} - ], - "spec": [ - { - "container": [ - { - "command": [ - "/bin/sh", - "-c", - "date; echo Hello from the Kubernetes cluster" - ], - "image": "busybox", - "name": "hello" - } - ] - } - ] - } - ], - "ttl_seconds_after_finished": 10 - } - ] - } - ], - "schedule": "1 0 * * *", - "starting_deadline_seconds": 10, - "successful_jobs_history_limit": 10 - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "hello", - "image": "busybox" - } - ] - } - ], - "kubernetes_deployment": [ - { - "id": "kubernetes_deployment.example", - "name": "example", - "module_name": "root", - "source": "terraform-k8s-provider/deployment.tf", - "plan_root": "terraform-k8s-provider", - "line": 37, - "type": "kubernetes_deployment", - "config": { - "metadata": [ - { - "labels": { - "test": "MyExampleApp" - }, - "name": "terraform-example", - "namespace": "${kubernetes_namespace.test.metadata.0.name}" - } - ], - "spec": [ - { - "replicas": 1, - "selector": [ - { - "match_labels": { - "test": "MyExampleApp" - } - } - ], - "template": [ - { - "metadata": [ - { - "labels": { - "test": "MyExampleApp" - } - } - ], - "spec": [ - { - "automount_service_account_token": false, - "container": [ - { - "image": "nginx:1.7.8", - "name": "example1" - }, - { - "image": "nginx:1.7.8", - "name": "example2" - }, - { - "image": "nginx:1.7.8", - "name": "example3" - } - ], - "service_account_name": "default" - } - ] - } - ] - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "example1", - "image": "nginx:1.7.8" - }, - { - "name": "example2", - "image": "nginx:1.7.8" - }, - { - "name": "example3", - "image": "nginx:1.7.8" - } - ] - } - ], - "kubernetes_job": [ - { - "id": "kubernetes_job.demo", - "name": "demo", - "module_name": "root", - "source": "terraform-k8s-provider/job.tf", - "plan_root": "terraform-k8s-provider", - "line": 1, - "type": "kubernetes_job", - "config": { - "metadata": [ - { - "name": "demo" - } - ], - "spec": [ - { - "backoff_limit": 4, - "template": [ - { - "metadata": [ - {} - ], - "spec": [ - { - "container": [ - { - "command": [ - "perl", - "-Mbignum=bpi", - "-wle", - "print bpi(2000)" - ], - "image": "perl", - "name": "pi" - } - ], - "restart_policy": "Never" - } - ] - } - ] - } - ], - "wait_for_completion": true - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "pi", - "image": "perl" - } - ] - } - ], - "kubernetes_namespace": [ - { - "id": "kubernetes_namespace.test", - "name": "test", - "module_name": "root", - "source": "terraform-k8s-provider/deployment.tf", - "plan_root": "terraform-k8s-provider", - "line": 13, - "type": "kubernetes_namespace", - "config": { - "metadata": [ - { - "name": "nginx" - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "" - } - ], - "kubernetes_pod": [ - { - "id": "kubernetes_pod.test", - "name": "test", - "module_name": "root", - "source": "terraform-k8s-provider/pod.tf", - "plan_root": "terraform-k8s-provider", - "line": 1, - "type": "kubernetes_pod", - "config": { - "metadata": [ - { - "name": "terraform-example" - } - ], - "spec": [ - { - "container": [ - { - "image": "nginx:1.7.9", - "name": "example", - "resources": [ - { - "limits": { - "cpu": "0.5", - "memory": "512Mi", - "nvidia/gpu": "1" - }, - "requests": { - "cpu": "250m", - "memory": "50Mi", - "nvidia/gpu": "1" - } - } - ] - } - ] - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "example", - "image": "nginx:1.7.9" - } - ] - } - ], - "kubernetes_replication_controller": [ - { - "id": "kubernetes_replication_controller.example", - "name": "example", - "module_name": "root", - "source": "terraform-k8s-provider/rc.tf", - "plan_root": "terraform-k8s-provider", - "line": 1, - "type": "kubernetes_replication_controller", - "config": { - "metadata": [ - { - "labels": { - "test": "MyExampleApp" - }, - "name": "terraform-example" - } - ], - "spec": [ - { - "selector": { - "test": "MyExampleApp" - }, - "template": [ - { - "metadata": [ - { - "annotations": { - "key1": "value1" - }, - "labels": { - "test": "MyExampleApp" - } - } - ], - "spec": [ - { - "container": [ - { - "image": "nginx:1.7.8", - "liveness_probe": [ - { - "http_get": [ - { - "http_header": [ - { - "name": "X-Custom-Header", - "value": "Awesome" - } - ], - "path": "/nginx_status", - "port": 8080 - } - ], - "initial_delay_seconds": 3, - "period_seconds": 3 - } - ], - "name": "example", - "resources": [ - { - "limits": { - "cpu": "0.5", - "memory": "512Mi" - }, - "requests": { - "cpu": "250m", - "memory": "50Mi" - } - } - ] - } - ] - } - ] - } - ] - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "example", - "image": "nginx:1.7.8" - } - ] - } - ], - "kubernetes_service": [ - { - "id": "kubernetes_service.test", - "name": "test", - "module_name": "root", - "source": "terraform-k8s-provider/deployment.tf", - "plan_root": "terraform-k8s-provider", - "line": 19, - "type": "kubernetes_service", - "config": { - "metadata": [ - { - "name": "nginx", - "namespace": "${kubernetes_namespace.test.metadata.0.name}" - } - ], - "spec": [ - { - "port": [ - { - "node_port": 30201, - "port": 80, - "target_port": 80 - } - ], - "selector": { - "app": "${kubernetes_deployment.example.spec.0.template.0.metadata.0.labels.test}" - }, - "type": "NodePort" - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "" - } - ], - "kubernetes_stateful_set": [ - { - "id": "kubernetes_stateful_set.prometheus", - "name": "prometheus", - "module_name": "root", - "source": "terraform-k8s-provider/stateful_set.tf", - "plan_root": "terraform-k8s-provider", - "line": 1, - "type": "kubernetes_stateful_set", - "config": { - "metadata": [ - { - "annotations": { - "SomeAnnotation": "foobar" - }, - "labels": { - "addonmanager.kubernetes.io/mode": "Reconcile", - "k8s-app": "prometheus", - "kubernetes.io/cluster-service": "true", - "version": "v2.2.1" - }, - "name": "prometheus" - } - ], - "spec": [ - { - "pod_management_policy": "Parallel", - "replicas": 1, - "revision_history_limit": 5, - "selector": [ - { - "match_labels": { - "k8s-app": "prometheus" - } - } - ], - "service_name": "prometheus", - "template": [ - { - "metadata": [ - { - "annotations": {}, - "labels": { - "k8s-app": "prometheus" - } - } - ], - "spec": [ - { - "container": [ - { - "args": [ - "--volume-dir=/etc/config", - "--webhook-url=http://localhost:9090/-/reload" - ], - "image": "jimmidyson/configmap-reload:v0.1", - "image_pull_policy": "IfNotPresent", - "name": "prometheus-server-configmap-reload", - "resources": [ - { - "limits": { - "cpu": "10m", - "memory": "10Mi" - }, - "requests": { - "cpu": "10m", - "memory": "10Mi" - } - } - ], - "volume_mount": [ - { - "mount_path": "/etc/config", - "name": "config-volume", - "read_only": true - } - ] - }, - { - "args": [ - "--config.file=/etc/config/prometheus.yml", - "--storage.tsdb.path=/data", - "--web.console.libraries=/etc/prometheus/console_libraries", - "--web.console.templates=/etc/prometheus/consoles", - "--web.enable-lifecycle" - ], - "image": "prom/prometheus:v2.2.1", - "image_pull_policy": "IfNotPresent", - "liveness_probe": [ - { - "http_get": [ - { - "path": "/-/healthy", - "port": 9090, - "scheme": "HTTPS" - } - ], - "initial_delay_seconds": 30, - "timeout_seconds": 30 - } - ], - "name": "prometheus-server", - "port": [ - { - "container_port": 9090 - } - ], - "readiness_probe": [ - { - "http_get": [ - { - "path": "/-/ready", - "port": 9090 - } - ], - "initial_delay_seconds": 30, - "timeout_seconds": 30 - } - ], - "resources": [ - { - "limits": { - "cpu": "200m", - "memory": "1000Mi" - }, - "requests": { - "cpu": "200m", - "memory": "1000Mi" - } - } - ], - "volume_mount": [ - { - "mount_path": "/etc/config", - "name": "config-volume" - }, - { - "mount_path": "/data", - "name": "prometheus-data", - "sub_path": "" - } - ] - } - ], - "init_container": [ - { - "command": [ - "chown", - "-R", - "65534:65534", - "/data" - ], - "image": "busybox:latest", - "image_pull_policy": "IfNotPresent", - "name": "init-chown-data", - "volume_mount": [ - { - "mount_path": "/data", - "name": "prometheus-data", - "sub_path": "" - } - ] - } - ], - "service_account_name": "prometheus", - "termination_grace_period_seconds": 300, - "volume": [ - { - "config_map": [ - { - "name": "prometheus-config" - } - ], - "name": "config-volume" - } - ] - } - ] - } - ], - "update_strategy": [ - { - "rolling_update": [ - { - "partition": 1 - } - ], - "type": "RollingUpdate" - } - ], - "volume_claim_template": [ - { - "metadata": [ - { - "name": "prometheus-data" - } - ], - "spec": [ - { - "access_modes": [ - "ReadWriteOnce" - ], - "resources": [ - { - "requests": { - "storage": "16Gi" - } - } - ], - "storage_class_name": "standard" - } - ] - } - ] - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "prometheus-server-configmap-reload", - "image": "jimmidyson/configmap-reload:v0.1" - }, - { - "name": "prometheus-server", - "image": "prom/prometheus:v2.2.1" - } - ], - "init_container_images": [ - { - "name": "init-chown-data", - "image": "busybox:latest" - } - ] - } - ] -} diff --git a/pkg/iac-providers/terraform/commons/extract-container-images.go b/pkg/iac-providers/terraform/commons/extract-container-images.go index d014641f8..dfe540e57 100644 --- a/pkg/iac-providers/terraform/commons/extract-container-images.go +++ b/pkg/iac-providers/terraform/commons/extract-container-images.go @@ -63,40 +63,29 @@ func fetchContainersFromAzureResource(resource jsonObj) []output.ContainerNameAn results := []output.ContainerNameAndImage{} if v, ok := resource[container]; ok { if containers, vok := v.([]jsonObj); vok { - for _, container := range containers { - tempContainer := output.ContainerNameAndImage{} - if image, iok := container[image]; iok { - tempContainer.Image = image.(string) - } - if name, nok := container[name]; nok { - tempContainer.Name = name.(string) - } - if tempContainer.Name == "" && tempContainer.Image == "" { - continue - } - results = append(results, tempContainer) - } + results = getContainers(containers) } } return results } //fetchConatinersFromAwsResource extracts all the containers from aws ecs resource -func fetchContainersFromAwsResource(resource jsonObj, absRootDir string) []output.ContainerNameAndImage { +func fetchContainersFromAwsResource(resource jsonObj, hclBody *hclsyntax.Body, resourcePath string) []output.ContainerNameAndImage { results := []output.ContainerNameAndImage{} if v, ok := resource[containerDefinitions]; ok { def := v.(string) if strings.HasPrefix(def, jsonCodeSuffix) { - def = strings.TrimPrefix(def, jsonCodeSuffix) - def = strings.TrimSuffix(def, ")}") + return getContainersFromhclBody(hclBody) } else if strings.HasPrefix(def, fileSuffix) { - file := strings.TrimPrefix(def, fileSuffix) - file = strings.TrimSuffix(file, `")}`) - dir := filepath.Dir(absRootDir) - file = filepath.Join(dir, file) - fileData, err := ioutil.ReadFile(file) + fileLocation := strings.TrimPrefix(def, fileSuffix) + fileLocation = strings.TrimSuffix(fileLocation, `")}`) + dir := filepath.Dir(resourcePath) + if !filepath.IsAbs(fileLocation) { + fileLocation = filepath.Join(dir, fileLocation) + } + fileData, err := ioutil.ReadFile(fileLocation) if err != nil { - zap.S().Errorf("error reading file: %s : %v", file, err) + zap.S().Errorf("error reading file: %s : %v", fileLocation, err) return results } def = string(fileData) @@ -107,21 +96,61 @@ func fetchContainersFromAwsResource(resource jsonObj, absRootDir string) []outpu zap.S().Errorf("error unmarshaling string: %s : %v", def, err) return results } - for _, container := range containers { - tempContainer := output.ContainerNameAndImage{} - if image, iok := container[image]; iok { - tempContainer.Image = image.(string) - } - if name, nok := container[name]; nok { - tempContainer.Name = name.(string) - } - if tempContainer.Name == "" && tempContainer.Image == "" { - continue + results = getContainers(containers) + } + return results +} + +//getContainersFromhclBody parses the attribute and creates container object +func getContainersFromhclBody(hclBody *hclsyntax.Body) (results []output.ContainerNameAndImage) { + for _, v := range hclBody.Attributes { + if v.Name == containerDefinitions { + switch v.Expr.(type) { + case *hclsyntax.FunctionCallExpr: + if funcExp, ok := v.Expr.(*hclsyntax.FunctionCallExpr); ok { + for _, arg := range funcExp.Args { + re, _ := arg.Value(nil) + it := re.ElementIterator() + for it.Next() { + _, val := it.Element() + containerMap := val.AsValueMap() + tempContainer := output.ContainerNameAndImage{} + if image, iok := containerMap[image]; iok { + tempContainer.Image = image.AsString() + } + if name, nok := containerMap[name]; nok { + tempContainer.Name = name.AsString() + } + if tempContainer.Name == "" && tempContainer.Image == "" { + continue + } + results = append(results, tempContainer) + } + } + } } - results = append(results, tempContainer) + break } } - return results + return +} + +// getContainers reads and creates container config +func getContainers(containers []jsonObj) (results []output.ContainerNameAndImage) { + for _, container := range containers { + tempContainer := output.ContainerNameAndImage{} + if image, iok := container[image]; iok { + tempContainer.Image = image.(string) + } + if name, nok := container[name]; nok { + tempContainer.Name = name.(string) + } + if tempContainer.Name == "" && tempContainer.Image == "" { + continue + } + results = append(results, tempContainer) + } + return } //extractContainerImagesFromk8sResources extracts containers from k8s resource diff --git a/pkg/iac-providers/terraform/commons/load-dir.go b/pkg/iac-providers/terraform/commons/load-dir.go index 0f4e36628..77d208c57 100644 --- a/pkg/iac-providers/terraform/commons/load-dir.go +++ b/pkg/iac-providers/terraform/commons/load-dir.go @@ -337,10 +337,6 @@ func (t TerraformDirectoryLoader) loadDirNonRecursive() (output.AllResourceConfi allResourcesConfig[resourceConfig.Type] = append(allResourcesConfig[resourceConfig.Type], resourceConfig) } } - - zap.S().Infof(managedResource.Provider.ForDisplay()) - zap.S().Infof(managedResource.Provider.Namespace) - zap.S().Infof(managedResource.Provider.Type) } // add all current's children to the queue diff --git a/pkg/iac-providers/terraform/commons/resource.go b/pkg/iac-providers/terraform/commons/resource.go index 02c5b4a93..7aaea3307 100644 --- a/pkg/iac-providers/terraform/commons/resource.go +++ b/pkg/iac-providers/terraform/commons/resource.go @@ -82,7 +82,7 @@ func findContainers(managedResource *hclConfigs.Resource, jsonBody jsonObj, hclB } else if isAzureConatinerResource(managedResource) { containers = fetchContainersFromAzureResource(jsonBody) } else if isAwsConatinerResource(managedResource) { - containers = fetchContainersFromAwsResource(jsonBody, managedResource.DeclRange.Filename) + containers = fetchContainersFromAwsResource(jsonBody, hclBody, managedResource.DeclRange.Filename) } return } diff --git a/pkg/iac-providers/terraform/v12/testdata/terraform-container-extraction/terraform-aws-provider/jsoncode_in_task_definition.tf b/pkg/iac-providers/terraform/v12/testdata/terraform-container-extraction/terraform-aws-provider/jsoncode_in_task_definition.tf index 53df87116..7606c3afc 100644 --- a/pkg/iac-providers/terraform/v12/testdata/terraform-container-extraction/terraform-aws-provider/jsoncode_in_task_definition.tf +++ b/pkg/iac-providers/terraform/v12/testdata/terraform-container-extraction/terraform-aws-provider/jsoncode_in_task_definition.tf @@ -5,33 +5,33 @@ resource "aws_ecs_task_definition" "demo-ecs-jsoncode-task-definition" { memory = "1024" cpu = "512" execution_role_arn = "arn:aws:iam::123456789012:role/ecsTaskExecutionRole" - container_definitions = jsonencode( -[ + container_definitions = jsonencode([ { - "cpu": 10, - "command": ["sleep", "10"], - "entryPoint": ["/"], - "environment": [ - {"name": "VARNAME", "value": "VARVAL"} - ], - "essential": true, - "image": "jenkins", - "memory": 128, - "name": "jenkins", - "portMappings": [ - { - "containerPort": 80, - "hostPort": 8080 - } - ], - "resourceRequirements":[ - { - "type":"InferenceAccelerator", - "value":"device_1" - } - ] + name = "first" + image = "service-first" + cpu = 10 + memory = 512 + essential = true + portMappings = [ + { + containerPort = 80 + hostPort = 80 + } + ] + }, + { + name = "second" + image = "service-second" + cpu = 10 + memory = 256 + essential = true + portMappings = [ + { + containerPort = 443 + hostPort = 443 + } + ] } -] - ) + ]) } \ No newline at end of file diff --git a/pkg/iac-providers/terraform/v12/testdata/tfjson/output-with-containers.json b/pkg/iac-providers/terraform/v12/testdata/tfjson/output-with-containers.json index dfc3a2a0a..7a01e88ea 100644 --- a/pkg/iac-providers/terraform/v12/testdata/tfjson/output-with-containers.json +++ b/pkg/iac-providers/terraform/v12/testdata/tfjson/output-with-containers.json @@ -1,800 +1,804 @@ { - "aws_ecs_task_definition": [ - { - "id": "aws_ecs_task_definition.service", - "name": "service", - "module_name": "root", - "source": "terraform-aws-provider/file_in_task_definition.tf", - "plan_root": "terraform-aws-provider", - "line": 1, - "type": "aws_ecs_task_definition", - "config": { - "container_definitions": "${file(\"task-definitions/service.json\")}", - "family": "service", - "proxy_configuration": [ - { - "container_name": "applicationContainerName", - "properties": { - "AppPorts": "8080", - "EgressIgnoredIPs": "169.254.170.2,169.254.169.254", - "IgnoredUID": "1337", - "ProxyEgressPort": 15001, - "ProxyIngressPort": 15000 - }, - "type": "APPMESH" - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ + "aws_ecs_task_definition": [ + { + "id": "aws_ecs_task_definition.service", + "name": "service", + "module_name": "root", + "source": "terraform-aws-provider/file_in_task_definition.tf", + "plan_root": "terraform-aws-provider", + "line": 1, + "type": "aws_ecs_task_definition", + "config": { + "container_definitions": "${file(\"task-definitions/service.json\")}", + "family": "service", + "proxy_configuration": [ { - "name": "jenkins", - "image": "jenkins" + "container_name": "applicationContainerName", + "properties": { + "AppPorts": "8080", + "EgressIgnoredIPs": "169.254.170.2,169.254.169.254", + "IgnoredUID": "1337", + "ProxyEgressPort": 15001, + "ProxyIngressPort": 15000 + }, + "type": "APPMESH" } ] }, - { - "id": "aws_ecs_task_definition.demo-ecs-jsoncode-task-definition", - "name": "demo-ecs-jsoncode-task-definition", - "module_name": "root", - "source": "terraform-aws-provider/jsoncode_in_task_definition.tf", - "plan_root": "terraform-aws-provider", - "line": 1, - "type": "aws_ecs_task_definition", - "config": { - "container_definitions": "${jsonencode(\n[\n {\n \"cpu\": 10,\n \"command\": [\"sleep\", \"10\"],\n \"entryPoint\": [\"/\"],\n \"environment\": [\n {\"name\": \"VARNAME\", \"value\": \"VARVAL\"}\n ],\n \"essential\": true,\n \"image\": \"jenkins\",\n \"memory\": 128,\n \"name\": \"jenkins\",\n \"portMappings\": [\n {\n \"containerPort\": 80,\n \"hostPort\": 8080\n }\n ],\n \"resourceRequirements\":[\n {\n \"type\":\"InferenceAccelerator\",\n \"value\":\"device_1\"\n }\n ]\n }\n]\n )}", - "cpu": "512", - "execution_role_arn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole", - "family": "ecs-task-definition-demo", - "memory": "1024", - "network_mode": "awsvpc", - "requires_compatibilities": [ - "FARGATE" - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "jenkins", - "image": "jenkins" - } + "skip_rules": null, + "max_severity": "", + "min_severity": "", + "container_images": [ + { + "name": "jenkins", + "image": "jenkins" + } + ] + }, + { + "id": "aws_ecs_task_definition.demo-ecs-jsoncode-task-definition", + "name": "demo-ecs-jsoncode-task-definition", + "module_name": "root", + "source": "terraform-aws-provider/jsoncode_in_task_definition.tf", + "plan_root": "terraform-aws-provider", + "line": 1, + "type": "aws_ecs_task_definition", + "config": { + "container_definitions": "${jsonencode([\n {\n name = \"first\"\n image = \"service-first\"\n cpu = 10\n memory = 512\n essential = true\n portMappings = [\n {\n containerPort = 80\n hostPort = 80\n }\n ]\n },\n {\n name = \"second\"\n image = \"service-second\"\n cpu = 10\n memory = 256\n essential = true\n portMappings = [\n {\n containerPort = 443\n hostPort = 443\n }\n ]\n }\n ])}", + "cpu": "512", + "execution_role_arn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole", + "family": "ecs-task-definition-demo", + "memory": "1024", + "network_mode": "awsvpc", + "requires_compatibilities": [ + "FARGATE" ] }, - { - "id": "aws_ecs_task_definition.demo-ecs-task-definition", - "name": "demo-ecs-task-definition", - "module_name": "root", - "source": "terraform-aws-provider/main.tf", - "plan_root": "terraform-aws-provider", - "line": 1, - "type": "aws_ecs_task_definition", - "config": { - "container_definitions": "[\n {\n \"cpu\": 10,\n \"command\": [\"sleep\", \"10\"],\n \"entryPoint\": [\"/\"],\n \"environment\": [\n {\"name\": \"VARNAME\", \"value\": \"VARVAL\"}\n ],\n \"essential\": true,\n \"image\": \"jenkins\",\n \"memory\": 128,\n \"name\": \"jenkins\",\n \"portMappings\": [\n {\n \"containerPort\": 80,\n \"hostPort\": 8080\n }\n ],\n \"resourceRequirements\":[\n {\n \"type\":\"InferenceAccelerator\",\n \"value\":\"device_1\"\n }\n ]\n }\n]\n", - "cpu": "512", - "execution_role_arn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole", - "family": "ecs-task-definition-demo", - "memory": "1024", - "network_mode": "awsvpc", - "requires_compatibilities": [ - "FARGATE" - ] + "skip_rules": null, + "max_severity": "", + "min_severity": "", + "container_images": [ + { + "name": "first", + "image": "service-first" }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "jenkins", - "image": "jenkins" - } + { + "name": "second", + "image": "service-second" + } + ] + }, + { + "id": "aws_ecs_task_definition.demo-ecs-task-definition", + "name": "demo-ecs-task-definition", + "module_name": "root", + "source": "terraform-aws-provider/main.tf", + "plan_root": "terraform-aws-provider", + "line": 1, + "type": "aws_ecs_task_definition", + "config": { + "container_definitions": "[\n {\n \"cpu\": 10,\n \"command\": [\"sleep\", \"10\"],\n \"entryPoint\": [\"/\"],\n \"environment\": [\n {\"name\": \"VARNAME\", \"value\": \"VARVAL\"}\n ],\n \"essential\": true,\n \"image\": \"jenkins\",\n \"memory\": 128,\n \"name\": \"jenkins\",\n \"portMappings\": [\n {\n \"containerPort\": 80,\n \"hostPort\": 8080\n }\n ],\n \"resourceRequirements\":[\n {\n \"type\":\"InferenceAccelerator\",\n \"value\":\"device_1\"\n }\n ]\n }\n]\n", + "cpu": "512", + "execution_role_arn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole", + "family": "ecs-task-definition-demo", + "memory": "1024", + "network_mode": "awsvpc", + "requires_compatibilities": [ + "FARGATE" ] - } - ], - "azurerm_container_group": [ - { - "id": "azurerm_container_group.example", - "name": "example", - "module_name": "root", - "source": "terraform-azure-provider/main.tf", - "plan_root": "terraform-azure-provider", - "line": 1, - "type": "azurerm_container_group", - "config": { - "container": [ - { - "cpu": "0.5", - "image": "microsoft/aci-helloworld:latest", - "memory": "1.5", - "name": "hello-world", - "ports": [ - { - "port": 443, - "protocol": "TCP" - } - ] - }, - { - "cpu": "0.5", - "image": "microsoft/aci-tutorial-sidecar", - "memory": "1.5", - "name": "sidecar" - } - ], - "dns_name_label": "aci-label", - "ip_address_type": "public", - "location": "${azurerm_resource_group.example.location}", - "name": "example-continst", - "os_type": "Linux", - "resource_group_name": "${azurerm_resource_group.example.name}", - "tags": { - "environment": "testing" - } - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ + }, + "skip_rules": null, + "max_severity": "", + "min_severity": "", + "container_images": [ + { + "name": "jenkins", + "image": "jenkins" + } + ] + } + ], + "azurerm_container_group": [ + { + "id": "azurerm_container_group.example", + "name": "example", + "module_name": "root", + "source": "terraform-azure-provider/main.tf", + "plan_root": "terraform-azure-provider", + "line": 1, + "type": "azurerm_container_group", + "config": { + "container": [ { + "cpu": "0.5", + "image": "microsoft/aci-helloworld:latest", + "memory": "1.5", "name": "hello-world", - "image": "microsoft/aci-helloworld:latest" + "ports": [ + { + "port": 443, + "protocol": "TCP" + } + ] }, { - "name": "sidecar", - "image": "microsoft/aci-tutorial-sidecar" + "cpu": "0.5", + "image": "microsoft/aci-tutorial-sidecar", + "memory": "1.5", + "name": "sidecar" } - ] - } - ], - "kubernetes_cron_job": [ - { - "id": "kubernetes_cron_job.demo", - "name": "demo", - "module_name": "root", - "source": "terraform-k8s-provider/cron_job.tf", - "plan_root": "terraform-k8s-provider", - "line": 1, - "type": "kubernetes_cron_job", - "config": { - "metadata": [ - { - "name": "demo" - } - ], - "spec": [ - { - "concurrency_policy": "Replace", - "failed_jobs_history_limit": 5, - "job_template": [ - { - "metadata": [ - {} - ], - "spec": [ - { - "backoff_limit": 2, - "template": [ - { - "metadata": [ - {} - ], - "spec": [ - { - "container": [ - { - "command": [ - "/bin/sh", - "-c", - "date; echo Hello from the Kubernetes cluster" - ], - "image": "busybox", - "name": "hello" - } - ] - } - ] - } - ], - "ttl_seconds_after_finished": 10 - } - ] - } - ], - "schedule": "1 0 * * *", - "starting_deadline_seconds": 10, - "successful_jobs_history_limit": 10 - } - ] + ], + "dns_name_label": "aci-label", + "ip_address_type": "public", + "location": "${azurerm_resource_group.example.location}", + "name": "example-continst", + "os_type": "Linux", + "resource_group_name": "${azurerm_resource_group.example.name}", + "tags": { + "environment": "testing" + } + }, + "skip_rules": null, + "max_severity": "", + "min_severity": "", + "container_images": [ + { + "name": "hello-world", + "image": "microsoft/aci-helloworld:latest" }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ + { + "name": "sidecar", + "image": "microsoft/aci-tutorial-sidecar" + } + ] + } + ], + "kubernetes_cron_job": [ + { + "id": "kubernetes_cron_job.demo", + "name": "demo", + "module_name": "root", + "source": "terraform-k8s-provider/cron_job.tf", + "plan_root": "terraform-k8s-provider", + "line": 1, + "type": "kubernetes_cron_job", + "config": { + "metadata": [ { - "name": "hello", - "image": "busybox" + "name": "demo" } - ] - } - ], - "kubernetes_deployment": [ - { - "id": "kubernetes_deployment.example", - "name": "example", - "module_name": "root", - "source": "terraform-k8s-provider/deployment.tf", - "plan_root": "terraform-k8s-provider", - "line": 37, - "type": "kubernetes_deployment", - "config": { - "metadata": [ - { - "labels": { - "test": "MyExampleApp" - }, - "name": "terraform-example", - "namespace": "${kubernetes_namespace.test.metadata.0.name}" - } - ], - "spec": [ - { - "replicas": 1, - "selector": [ - { - "match_labels": { - "test": "MyExampleApp" + ], + "spec": [ + { + "concurrency_policy": "Replace", + "failed_jobs_history_limit": 5, + "job_template": [ + { + "metadata": [ + {} + ], + "spec": [ + { + "backoff_limit": 2, + "template": [ + { + "metadata": [ + {} + ], + "spec": [ + { + "container": [ + { + "command": [ + "/bin/sh", + "-c", + "date; echo Hello from the Kubernetes cluster" + ], + "image": "busybox", + "name": "hello" + } + ] + } + ] + } + ], + "ttl_seconds_after_finished": 10 } + ] + } + ], + "schedule": "1 0 * * *", + "starting_deadline_seconds": 10, + "successful_jobs_history_limit": 10 + } + ] + }, + "skip_rules": null, + "max_severity": "", + "min_severity": "", + "container_images": [ + { + "name": "hello", + "image": "busybox" + } + ] + } + ], + "kubernetes_deployment": [ + { + "id": "kubernetes_deployment.example", + "name": "example", + "module_name": "root", + "source": "terraform-k8s-provider/deployment.tf", + "plan_root": "terraform-k8s-provider", + "line": 37, + "type": "kubernetes_deployment", + "config": { + "metadata": [ + { + "labels": { + "test": "MyExampleApp" + }, + "name": "terraform-example", + "namespace": "${kubernetes_namespace.test.metadata.0.name}" + } + ], + "spec": [ + { + "replicas": 1, + "selector": [ + { + "match_labels": { + "test": "MyExampleApp" } - ], - "template": [ - { - "metadata": [ - { - "labels": { - "test": "MyExampleApp" - } + } + ], + "template": [ + { + "metadata": [ + { + "labels": { + "test": "MyExampleApp" } - ], - "spec": [ - { - "automount_service_account_token": false, - "container": [ - { - "image": "nginx:1.7.8", - "name": "example1" - }, - { - "image": "nginx:1.7.8", - "name": "example2" - }, - { - "image": "nginx:1.7.8", - "name": "example3" - } - ], - "service_account_name": "default" - } - ] - } - ] - } - ] + } + ], + "spec": [ + { + "automount_service_account_token": false, + "container": [ + { + "image": "nginx:1.7.8", + "name": "example1" + }, + { + "image": "nginx:1.7.8", + "name": "example2" + }, + { + "image": "nginx:1.7.8", + "name": "example3" + } + ], + "service_account_name": "default" + } + ] + } + ] + } + ] + }, + "skip_rules": null, + "max_severity": "", + "min_severity": "", + "container_images": [ + { + "name": "example1", + "image": "nginx:1.7.8" + }, + { + "name": "example2", + "image": "nginx:1.7.8" }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ + { + "name": "example3", + "image": "nginx:1.7.8" + } + ] + } + ], + "kubernetes_job": [ + { + "id": "kubernetes_job.demo", + "name": "demo", + "module_name": "root", + "source": "terraform-k8s-provider/job.tf", + "plan_root": "terraform-k8s-provider", + "line": 1, + "type": "kubernetes_job", + "config": { + "metadata": [ { - "name": "example1", - "image": "nginx:1.7.8" - }, + "name": "demo" + } + ], + "spec": [ { - "name": "example2", - "image": "nginx:1.7.8" - }, + "backoff_limit": 4, + "template": [ + { + "metadata": [ + {} + ], + "spec": [ + { + "container": [ + { + "command": [ + "perl", + "-Mbignum=bpi", + "-wle", + "print bpi(2000)" + ], + "image": "perl", + "name": "pi" + } + ], + "restart_policy": "Never" + } + ] + } + ] + } + ], + "wait_for_completion": true + }, + "skip_rules": null, + "max_severity": "", + "min_severity": "", + "container_images": [ + { + "name": "pi", + "image": "perl" + } + ] + } + ], + "kubernetes_namespace": [ + { + "id": "kubernetes_namespace.test", + "name": "test", + "module_name": "root", + "source": "terraform-k8s-provider/deployment.tf", + "plan_root": "terraform-k8s-provider", + "line": 13, + "type": "kubernetes_namespace", + "config": { + "metadata": [ { - "name": "example3", - "image": "nginx:1.7.8" + "name": "nginx" } ] - } - ], - "kubernetes_job": [ - { - "id": "kubernetes_job.demo", - "name": "demo", - "module_name": "root", - "source": "terraform-k8s-provider/job.tf", - "plan_root": "terraform-k8s-provider", - "line": 1, - "type": "kubernetes_job", - "config": { - "metadata": [ - { - "name": "demo" - } - ], - "spec": [ - { - "backoff_limit": 4, - "template": [ - { - "metadata": [ - {} - ], - "spec": [ - { - "container": [ - { - "command": [ - "perl", - "-Mbignum=bpi", - "-wle", - "print bpi(2000)" - ], - "image": "perl", - "name": "pi" - } - ], - "restart_policy": "Never" - } - ] - } - ] - } - ], - "wait_for_completion": true - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ + }, + "skip_rules": null, + "max_severity": "", + "min_severity": "" + } + ], + "kubernetes_pod": [ + { + "id": "kubernetes_pod.test", + "name": "test", + "module_name": "root", + "source": "terraform-k8s-provider/pod.tf", + "plan_root": "terraform-k8s-provider", + "line": 1, + "type": "kubernetes_pod", + "config": { + "metadata": [ { - "name": "pi", - "image": "perl" + "name": "terraform-example" } - ] - } - ], - "kubernetes_namespace": [ - { - "id": "kubernetes_namespace.test", - "name": "test", - "module_name": "root", - "source": "terraform-k8s-provider/deployment.tf", - "plan_root": "terraform-k8s-provider", - "line": 13, - "type": "kubernetes_namespace", - "config": { - "metadata": [ - { - "name": "nginx" - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "" - } - ], - "kubernetes_pod": [ - { - "id": "kubernetes_pod.test", - "name": "test", - "module_name": "root", - "source": "terraform-k8s-provider/pod.tf", - "plan_root": "terraform-k8s-provider", - "line": 1, - "type": "kubernetes_pod", - "config": { - "metadata": [ - { - "name": "terraform-example" - } - ], - "spec": [ - { - "container": [ - { - "image": "nginx:1.7.9", - "name": "example", - "resources": [ - { - "limits": { - "cpu": "0.5", - "memory": "512Mi", - "nvidia/gpu": "1" - }, - "requests": { - "cpu": "250m", - "memory": "50Mi", - "nvidia/gpu": "1" - } - } - ] - } - ] - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ + ], + "spec": [ { - "name": "example", - "image": "nginx:1.7.9" + "container": [ + { + "image": "nginx:1.7.9", + "name": "example", + "resources": [ + { + "limits": { + "cpu": "0.5", + "memory": "512Mi", + "nvidia/gpu": "1" + }, + "requests": { + "cpu": "250m", + "memory": "50Mi", + "nvidia/gpu": "1" + } + } + ] + } + ] } ] - } - ], - "kubernetes_replication_controller": [ - { - "id": "kubernetes_replication_controller.example", - "name": "example", - "module_name": "root", - "source": "terraform-k8s-provider/rc.tf", - "plan_root": "terraform-k8s-provider", - "line": 1, - "type": "kubernetes_replication_controller", - "config": { - "metadata": [ - { - "labels": { - "test": "MyExampleApp" - }, - "name": "terraform-example" - } - ], - "spec": [ - { - "selector": { - "test": "MyExampleApp" - }, - "template": [ - { - "metadata": [ - { - "annotations": { - "key1": "value1" - }, - "labels": { - "test": "MyExampleApp" - } + }, + "skip_rules": null, + "max_severity": "", + "min_severity": "", + "container_images": [ + { + "name": "example", + "image": "nginx:1.7.9" + } + ] + } + ], + "kubernetes_replication_controller": [ + { + "id": "kubernetes_replication_controller.example", + "name": "example", + "module_name": "root", + "source": "terraform-k8s-provider/rc.tf", + "plan_root": "terraform-k8s-provider", + "line": 1, + "type": "kubernetes_replication_controller", + "config": { + "metadata": [ + { + "labels": { + "test": "MyExampleApp" + }, + "name": "terraform-example" + } + ], + "spec": [ + { + "selector": { + "test": "MyExampleApp" + }, + "template": [ + { + "metadata": [ + { + "annotations": { + "key1": "value1" + }, + "labels": { + "test": "MyExampleApp" } - ], - "spec": [ - { - "container": [ - { - "image": "nginx:1.7.8", - "liveness_probe": [ - { - "http_get": [ - { - "http_header": [ - { - "name": "X-Custom-Header", - "value": "Awesome" - } - ], - "path": "/nginx_status", - "port": 8080 - } - ], - "initial_delay_seconds": 3, - "period_seconds": 3 - } - ], - "name": "example", - "resources": [ - { - "limits": { - "cpu": "0.5", - "memory": "512Mi" - }, - "requests": { - "cpu": "250m", - "memory": "50Mi" + } + ], + "spec": [ + { + "container": [ + { + "image": "nginx:1.7.8", + "liveness_probe": [ + { + "http_get": [ + { + "http_header": [ + { + "name": "X-Custom-Header", + "value": "Awesome" + } + ], + "path": "/nginx_status", + "port": 8080 } + ], + "initial_delay_seconds": 3, + "period_seconds": 3 + } + ], + "name": "example", + "resources": [ + { + "limits": { + "cpu": "0.5", + "memory": "512Mi" + }, + "requests": { + "cpu": "250m", + "memory": "50Mi" } - ] - } - ] - } - ] - } - ] - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ + } + ] + } + ] + } + ] + } + ] + } + ] + }, + "skip_rules": null, + "max_severity": "", + "min_severity": "", + "container_images": [ + { + "name": "example", + "image": "nginx:1.7.8" + } + ] + } + ], + "kubernetes_service": [ + { + "id": "kubernetes_service.test", + "name": "test", + "module_name": "root", + "source": "terraform-k8s-provider/deployment.tf", + "plan_root": "terraform-k8s-provider", + "line": 19, + "type": "kubernetes_service", + "config": { + "metadata": [ { - "name": "example", - "image": "nginx:1.7.8" + "name": "nginx", + "namespace": "${kubernetes_namespace.test.metadata.0.name}" + } + ], + "spec": [ + { + "port": [ + { + "node_port": 30201, + "port": 80, + "target_port": 80 + } + ], + "selector": { + "app": "${kubernetes_deployment.example.spec.0.template.0.metadata.0.labels.test}" + }, + "type": "NodePort" } ] - } - ], - "kubernetes_service": [ - { - "id": "kubernetes_service.test", - "name": "test", - "module_name": "root", - "source": "terraform-k8s-provider/deployment.tf", - "plan_root": "terraform-k8s-provider", - "line": 19, - "type": "kubernetes_service", - "config": { - "metadata": [ - { - "name": "nginx", - "namespace": "${kubernetes_namespace.test.metadata.0.name}" - } - ], - "spec": [ - { - "port": [ - { - "node_port": 30201, - "port": 80, - "target_port": 80 - } - ], - "selector": { - "app": "${kubernetes_deployment.example.spec.0.template.0.metadata.0.labels.test}" - }, - "type": "NodePort" - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "" - } - ], - "kubernetes_stateful_set": [ - { - "id": "kubernetes_stateful_set.prometheus", - "name": "prometheus", - "module_name": "root", - "source": "terraform-k8s-provider/stateful_set.tf", - "plan_root": "terraform-k8s-provider", - "line": 1, - "type": "kubernetes_stateful_set", - "config": { - "metadata": [ - { - "annotations": { - "SomeAnnotation": "foobar" - }, - "labels": { - "addonmanager.kubernetes.io/mode": "Reconcile", - "k8s-app": "prometheus", - "kubernetes.io/cluster-service": "true", - "version": "v2.2.1" - }, - "name": "prometheus" - } - ], - "spec": [ - { - "pod_management_policy": "Parallel", - "replicas": 1, - "revision_history_limit": 5, - "selector": [ - { - "match_labels": { - "k8s-app": "prometheus" - } + }, + "skip_rules": null, + "max_severity": "", + "min_severity": "" + } + ], + "kubernetes_stateful_set": [ + { + "id": "kubernetes_stateful_set.prometheus", + "name": "prometheus", + "module_name": "root", + "source": "terraform-k8s-provider/stateful_set.tf", + "plan_root": "terraform-k8s-provider", + "line": 1, + "type": "kubernetes_stateful_set", + "config": { + "metadata": [ + { + "annotations": { + "SomeAnnotation": "foobar" + }, + "labels": { + "addonmanager.kubernetes.io/mode": "Reconcile", + "k8s-app": "prometheus", + "kubernetes.io/cluster-service": "true", + "version": "v2.2.1" + }, + "name": "prometheus" + } + ], + "spec": [ + { + "pod_management_policy": "Parallel", + "replicas": 1, + "revision_history_limit": 5, + "selector": [ + { + "match_labels": { + "k8s-app": "prometheus" } - ], - "service_name": "prometheus", - "template": [ - { - "metadata": [ - { - "annotations": {}, - "labels": { - "k8s-app": "prometheus" - } + } + ], + "service_name": "prometheus", + "template": [ + { + "metadata": [ + { + "annotations": {}, + "labels": { + "k8s-app": "prometheus" } - ], - "spec": [ - { - "container": [ - { - "args": [ - "--volume-dir=/etc/config", - "--webhook-url=http://localhost:9090/-/reload" - ], - "image": "jimmidyson/configmap-reload:v0.1", - "image_pull_policy": "IfNotPresent", - "name": "prometheus-server-configmap-reload", - "resources": [ - { - "limits": { - "cpu": "10m", - "memory": "10Mi" - }, - "requests": { - "cpu": "10m", - "memory": "10Mi" - } - } - ], - "volume_mount": [ - { - "mount_path": "/etc/config", - "name": "config-volume", - "read_only": true - } - ] - }, - { - "args": [ - "--config.file=/etc/config/prometheus.yml", - "--storage.tsdb.path=/data", - "--web.console.libraries=/etc/prometheus/console_libraries", - "--web.console.templates=/etc/prometheus/consoles", - "--web.enable-lifecycle" - ], - "image": "prom/prometheus:v2.2.1", - "image_pull_policy": "IfNotPresent", - "liveness_probe": [ - { - "http_get": [ - { - "path": "/-/healthy", - "port": 9090, - "scheme": "HTTPS" - } - ], - "initial_delay_seconds": 30, - "timeout_seconds": 30 - } - ], - "name": "prometheus-server", - "port": [ - { - "container_port": 9090 - } - ], - "readiness_probe": [ - { - "http_get": [ - { - "path": "/-/ready", - "port": 9090 - } - ], - "initial_delay_seconds": 30, - "timeout_seconds": 30 + } + ], + "spec": [ + { + "container": [ + { + "args": [ + "--volume-dir=/etc/config", + "--webhook-url=http://localhost:9090/-/reload" + ], + "image": "jimmidyson/configmap-reload:v0.1", + "image_pull_policy": "IfNotPresent", + "name": "prometheus-server-configmap-reload", + "resources": [ + { + "limits": { + "cpu": "10m", + "memory": "10Mi" + }, + "requests": { + "cpu": "10m", + "memory": "10Mi" } - ], - "resources": [ - { - "limits": { - "cpu": "200m", - "memory": "1000Mi" - }, - "requests": { - "cpu": "200m", - "memory": "1000Mi" + } + ], + "volume_mount": [ + { + "mount_path": "/etc/config", + "name": "config-volume", + "read_only": true + } + ] + }, + { + "args": [ + "--config.file=/etc/config/prometheus.yml", + "--storage.tsdb.path=/data", + "--web.console.libraries=/etc/prometheus/console_libraries", + "--web.console.templates=/etc/prometheus/consoles", + "--web.enable-lifecycle" + ], + "image": "prom/prometheus:v2.2.1", + "image_pull_policy": "IfNotPresent", + "liveness_probe": [ + { + "http_get": [ + { + "path": "/-/healthy", + "port": 9090, + "scheme": "HTTPS" } - } - ], - "volume_mount": [ - { - "mount_path": "/etc/config", - "name": "config-volume" + ], + "initial_delay_seconds": 30, + "timeout_seconds": 30 + } + ], + "name": "prometheus-server", + "port": [ + { + "container_port": 9090 + } + ], + "readiness_probe": [ + { + "http_get": [ + { + "path": "/-/ready", + "port": 9090 + } + ], + "initial_delay_seconds": 30, + "timeout_seconds": 30 + } + ], + "resources": [ + { + "limits": { + "cpu": "200m", + "memory": "1000Mi" }, - { - "mount_path": "/data", - "name": "prometheus-data", - "sub_path": "" - } - ] - } - ], - "init_container": [ - { - "command": [ - "chown", - "-R", - "65534:65534", - "/data" - ], - "image": "busybox:latest", - "image_pull_policy": "IfNotPresent", - "name": "init-chown-data", - "volume_mount": [ - { - "mount_path": "/data", - "name": "prometheus-data", - "sub_path": "" - } - ] - } - ], - "service_account_name": "prometheus", - "termination_grace_period_seconds": 300, - "volume": [ - { - "config_map": [ - { - "name": "prometheus-config" + "requests": { + "cpu": "200m", + "memory": "1000Mi" } - ], - "name": "config-volume" - } - ] - } - ] - } - ], - "update_strategy": [ - { - "rolling_update": [ - { - "partition": 1 - } - ], - "type": "RollingUpdate" - } - ], - "volume_claim_template": [ - { - "metadata": [ - { - "name": "prometheus-data" - } - ], - "spec": [ - { - "access_modes": [ - "ReadWriteOnce" - ], - "resources": [ - { - "requests": { - "storage": "16Gi" } + ], + "volume_mount": [ + { + "mount_path": "/etc/config", + "name": "config-volume" + }, + { + "mount_path": "/data", + "name": "prometheus-data", + "sub_path": "" + } + ] + } + ], + "init_container": [ + { + "command": [ + "chown", + "-R", + "65534:65534", + "/data" + ], + "image": "busybox:latest", + "image_pull_policy": "IfNotPresent", + "name": "init-chown-data", + "volume_mount": [ + { + "mount_path": "/data", + "name": "prometheus-data", + "sub_path": "" + } + ] + } + ], + "service_account_name": "prometheus", + "termination_grace_period_seconds": 300, + "volume": [ + { + "config_map": [ + { + "name": "prometheus-config" + } + ], + "name": "config-volume" + } + ] + } + ] + } + ], + "update_strategy": [ + { + "rolling_update": [ + { + "partition": 1 + } + ], + "type": "RollingUpdate" + } + ], + "volume_claim_template": [ + { + "metadata": [ + { + "name": "prometheus-data" + } + ], + "spec": [ + { + "access_modes": [ + "ReadWriteOnce" + ], + "resources": [ + { + "requests": { + "storage": "16Gi" } - ], - "storage_class_name": "standard" - } - ] - } - ] - } - ] - }, - "skip_rules": null, - "max_severity": "", - "min_severity": "", - "container_images": [ - { - "name": "prometheus-server-configmap-reload", - "image": "jimmidyson/configmap-reload:v0.1" - }, - { - "name": "prometheus-server", - "image": "prom/prometheus:v2.2.1" - } - ], - "init_container_images": [ - { - "name": "init-chown-data", - "image": "busybox:latest" + } + ], + "storage_class_name": "standard" + } + ] + } + ] } ] - } - ] - } \ No newline at end of file + }, + "skip_rules": null, + "max_severity": "", + "min_severity": "", + "container_images": [ + { + "name": "prometheus-server-configmap-reload", + "image": "jimmidyson/configmap-reload:v0.1" + }, + { + "name": "prometheus-server", + "image": "prom/prometheus:v2.2.1" + } + ], + "init_container_images": [ + { + "name": "init-chown-data", + "image": "busybox:latest" + } + ] + } + ] +} \ No newline at end of file