From 14128962030da48b9a8e9b84d7a930f202bbd886 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Mon, 18 Jul 2022 14:19:12 +0200 Subject: [PATCH 1/9] chore: remove usage of ResolveReadAttributesFunc --- .../aws/cloudformation_stack_enumerator.go | 3 ++ .../remote/aws/dynamodb_table_enumerator.go | 4 ++- .../aws/ec2_network_acl_rule_enumerator.go | 8 ++--- .../remote/aws/lambda_function_enumerator.go | 4 ++- .../aws/s3_bucket_analytic_enumerator.go | 3 +- .../remote/aws/s3_bucket_enumerator.go | 2 +- .../aws/s3_bucket_inventory_enumerator.go | 3 +- .../aws/s3_bucket_metrics_enumerator.go | 3 +- .../aws/s3_bucket_notification_enumerator.go | 2 +- .../remote/aws/s3_bucket_policy_enumerator.go | 2 +- .../remote/aws/sns_topic_enumerator.go | 4 ++- .../remote/aws/sns_topic_policy_enumerator.go | 4 ++- .../aws/sns_topic_subscription_enumerator.go | 5 ++- enumeration/remote/common/details_fetcher.go | 8 +++-- ...oogle_compute_instance_group_enumerator.go | 9 ++--- .../google_compute_router_enumerator.go | 6 +++- .../google_storage_bucket_enumerator.go | 4 ++- ...ipalloc-017d5267e4dda73f1.res.golden.json} | 0 ...0ad6d657494d17ee2-6-allow.res.golden.json} | 0 ...ad6d657494d17ee2-17-allow.res.golden.json} | 0 ...de54ef59074b622e-17-allow.res.golden.json} | 0 ...-0ad6d657494d17ee2-6-deny.res.golden.json} | 0 ...0de54ef59074b622e-17-deny.res.golden.json} | 0 ....0.0_16-CreateRouteTable-.res.golden.json} | 0 ...ute-rtb-0169b0937fd963ddc.res.golden.json} | 0 ...ble-rtb-0169b0937fd963ddc.res.golden.json} | 0 ...ute-rtb-0169b0937fd963ddc.res.golden.json} | 0 ...ute-rtb-02780c485f0be93c5.res.golden.json} | 0 ...ble-rtb-02780c485f0be93c5.res.golden.json} | 0 ...ute-rtb-02780c485f0be93c5.res.golden.json} | 0 ...ble-rtb-096bdfb69309c54c3.res.golden.json} | 0 ...ute-rtb-096bdfb69309c54c3.res.golden.json} | 0 ...ute-rtb-096bdfb69309c54c3.res.golden.json} | 0 ...ws_iam_role-test_role_0-_.res.golden.json} | 0 ...ws_iam_role-test_role_1-_.res.golden.json} | 0 ...ws_iam_role-test_role_2-_.res.golden.json} | 0 ...olicy-role0-0-test_role_0.res.golden.json} | 0 ...olicy-role0-1-test_role_0.res.golden.json} | 0 ...olicy-role0-2-test_role_0.res.golden.json} | 0 ...olicy-role1-0-test_role_1.res.golden.json} | 0 ...olicy-role1-1-test_role_1.res.golden.json} | 0 ...olicy-role1-2-test_role_1.res.golden.json} | 0 ...TWFM__test2.foo-2.com_A-A.res.golden.json} | 0 ...__test2.foo-2.com_TXT-TXT.res.golden.json} | 0 ...383UC8WYSBZTWFM_test0_A-A.res.golden.json} | 0 ...C8WYSBZTWFM_test0_TXT-TXT.res.golden.json} | 0 ...ZTWFM_test1.foo-2.com_A-A.res.golden.json} | 0 ...M_test1.foo-2.com_TXT-TXT.res.golden.json} | 0 ...383HV75H96J919W_test2_A-A.res.golden.json} | 0 ...0GLIB82T1EH2G__.test4_A-A.res.golden.json} | 0 ...B82T1EH2G_foo-0.com_NS-NS.res.golden.json} | 0 ...360GLIB82T1EH2G_test0_A-A.res.golden.json} | 0 ...360GLIB82T1EH2G_test1_A-A.res.golden.json} | 0 ...360GLIB82T1EH2G_test2_A-A.res.golden.json} | 0 ...om_047081014315_bar.fifo-.res.golden.json} | 0 ...aws.com_047081014315_baz-.res.golden.json} | 0 ...aws.com_047081014315_foo-.res.golden.json} | 0 ...0cc8b3c3c2851705a--egress.res.golden.json} | 0 ...0254c038e32f25530--egress.res.golden.json} | 0 ...254c038e32f25530--ingress.res.golden.json} | 0 ...254c038e32f25530--ingress.res.golden.json} | 0 ...0254c038e32f25530--egress.res.golden.json} | 0 ...0cc8b3c3c2851705a--egress.res.golden.json} | 0 ...25530-sg-9e0204ff-ingress.res.golden.json} | 0 ...254c038e32f25530--ingress.res.golden.json} | 0 ...cc8b3c3c2851705a--ingress.res.golden.json} | 0 ...254c038e32f25530--ingress.res.golden.json} | 0 ...0cc8b3c3c2851705a--egress.res.golden.json} | 0 ...dd10eb325b92074be71cf00f0.res.golden.json} | 0 ...52b1dc18c3bb9dbb4e05914a5.res.golden.json} | 0 ...eptanceTestSecurityGroup1.res.golden.json} | 0 ...eptanceTestSecurityGroup2.res.golden.json} | 0 ...st-thisisatestusingtf.com.res.golden.json} | 0 ...st-thisisatestusingtf.com.res.golden.json} | 0 ...st-thisisatestusingtf.com.res.golden.json} | 0 ...st-thisisatestusingtf.com.res.golden.json} | 0 ...st-thisisatestusingtf.com.res.golden.json} | 0 ...st-thisisatestusingtf.com.res.golden.json} | 0 ...mx-thisisatestusingtf.com.res.golden.json} | 0 ...mx-thisisatestusingtf.com.res.golden.json} | 0 ...tr-thisisatestusingtf.com.res.golden.json} | 0 ...tr-thisisatestusingtf.com.res.golden.json} | 0 ...tr-thisisatestusingtf.com.res.golden.json} | 0 ...tr-thisisatestusingtf.com.res.golden.json} | 0 ...xt-thisisatestusingtf.com.res.golden.json} | 0 ...xt-thisisatestusingtf.com.res.golden.json} | 0 ...s_example-key-example-key.res.golden.json} | 0 ...example-key2-example-key2.res.golden.json} | 0 .../resource/aws/aws_appautoscaling_policy.go | 8 ----- .../resource/aws/aws_appautoscaling_target.go | 6 ---- .../resource/aws/aws_cloudformation_stack.go | 11 ------ .../resource/aws/aws_default_route_table.go | 5 --- .../resource/aws/aws_dynamodb_table.go | 5 --- .../resource/aws/aws_iam_access_key.go | 7 ---- .../aws/aws_iam_role_policy_attachment.go | 6 ---- .../aws/aws_iam_user_policy_attachment.go | 6 ---- .../resource/aws/aws_lambda_function.go | 6 ---- .../resource/aws/aws_network_acl_rule.go | 11 ++---- enumeration/resource/aws/aws_rds_cluster.go | 6 ---- enumeration/resource/aws/aws_route.go | 15 -------- .../aws/aws_route_table_association.go | 7 ---- enumeration/resource/aws/aws_s3_bucket.go | 5 --- .../aws_s3_bucket_analytics_configuration.go | 5 --- .../resource/aws/aws_s3_bucket_inventory.go | 5 --- .../resource/aws/aws_s3_bucket_metric.go | 5 --- .../aws/aws_s3_bucket_notification.go | 5 --- .../resource/aws/aws_s3_bucket_policy.go | 5 --- .../resource/aws/aws_security_group_rule.go | 35 ------------------- enumeration/resource/aws/aws_sns_topic.go | 5 --- .../resource/aws/aws_sns_topic_policy.go | 6 ---- .../aws/aws_sns_topic_subscription.go | 6 ---- .../resource/azurerm/azurerm_lb_rule.go | 5 --- .../google/google_compute_firewall.go | 6 ---- .../google/google_compute_instance_group.go | 7 ---- .../resource/google/google_compute_network.go | 5 --- .../resource/google/google_compute_router.go | 12 ------- .../google/google_compute_subnetwork.go | 6 ---- .../google/google_project_iam_member.go | 7 ---- .../resource/google/google_storage_bucket.go | 5 --- .../google_storage_bucket_iam_member.go | 7 ---- enumeration/resource/google/metadatas.go | 1 - enumeration/resource/schemas.go | 11 ------ pkg/middlewares/aws_network_acl_expander.go | 2 +- .../aws_network_acl_expander_test.go | 19 +++++----- pkg/resource/aws/aws_network_acl_rule.go | 2 +- 125 files changed, 65 insertions(+), 285 deletions(-) rename enumeration/remote/test/aws_ec2_eip_association_single/{aws_eip_association-eipassoc-0e9a7356e30f0c3d1.res.golden.json => aws_eip_association-eipassoc-0e9a7356e30f0c3d1-eipalloc-017d5267e4dda73f1.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_network_acl_rule/{aws_network_acl_rule-nacl-2289824980-false-acl-0ad6d657494d17ee2-200.res.golden.json => aws_network_acl_rule-nacl-2289824980-___0-acl-0ad6d657494d17ee2-6-allow.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_network_acl_rule/{aws_network_acl_rule-nacl-246660311-true-acl-0ad6d657494d17ee2-100.res.golden.json => aws_network_acl_rule-nacl-246660311-172.16.1.0_0-acl-0ad6d657494d17ee2-17-allow.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_network_acl_rule/{aws_network_acl_rule-nacl-4268384215-true-acl-0de54ef59074b622e-100.res.golden.json => aws_network_acl_rule-nacl-4268384215-172.16.1.0_0-acl-0de54ef59074b622e-17-allow.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_network_acl_rule/{aws_network_acl_rule-nacl-4293207588-false-acl-0ad6d657494d17ee2-100.res.golden.json => aws_network_acl_rule-nacl-4293207588-0.0.0.0_0-acl-0ad6d657494d17ee2-6-deny.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_network_acl_rule/{aws_network_acl_rule-nacl-515082162-false-acl-0de54ef59074b622e-100.res.golden.json => aws_network_acl_rule-nacl-515082162-0.0.0.0_0-acl-0de54ef59074b622e-17-deny.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_route_multiple/{aws_route-r-179966490-10.0.0.0_16-.res.golden.json => aws_route-r-179966490-10.0.0.0_16-CreateRouteTable-.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_route_multiple/{aws_route-r-rtb-0169b0937fd963ddc1080289494-0.0.0.0_0-rtb-0169b0937fd963ddc.res.golden.json => aws_route-r-rtb-0169b0937fd963ddc1080289494-0.0.0.0_0-igw-030e74f73bd67f21b-CreateRoute-rtb-0169b0937fd963ddc.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_route_multiple/{aws_route-r-rtb-0169b0937fd963ddc179966490-10.0.0.0_16-rtb-0169b0937fd963ddc.res.golden.json => aws_route-r-rtb-0169b0937fd963ddc179966490-10.0.0.0_16-CreateRouteTable-rtb-0169b0937fd963ddc.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_route_multiple/{aws_route-r-rtb-0169b0937fd963ddc2750132062-___0-rtb-0169b0937fd963ddc.res.golden.json => aws_route-r-rtb-0169b0937fd963ddc2750132062-___0-igw-030e74f73bd67f21b-CreateRoute-rtb-0169b0937fd963ddc.res.golden.json} (100%) mode change 100755 => 100644 rename enumeration/remote/test/aws_ec2_route_multiple/{aws_route-r-rtb-02780c485f0be93c51325105504-10.1.2.0_24-rtb-02780c485f0be93c5.res.golden.json => aws_route-r-rtb-02780c485f0be93c51325105504-10.1.2.0_24-igw-030e74f73bd67f21b-CreateRoute-rtb-02780c485f0be93c5.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_route_multiple/{aws_route-r-rtb-02780c485f0be93c5179966490-10.0.0.0_16-rtb-02780c485f0be93c5.res.golden.json => aws_route-r-rtb-02780c485f0be93c5179966490-10.0.0.0_16-CreateRouteTable-rtb-02780c485f0be93c5.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_route_multiple/{aws_route-r-rtb-02780c485f0be93c53362780110-10.1.1.0_24-rtb-02780c485f0be93c5.res.golden.json => aws_route-r-rtb-02780c485f0be93c53362780110-10.1.1.0_24-igw-030e74f73bd67f21b-CreateRoute-rtb-02780c485f0be93c5.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_route_multiple/{aws_route-r-rtb-096bdfb69309c54c3179966490-10.0.0.0_16-rtb-096bdfb69309c54c3.res.golden.json => aws_route-r-rtb-096bdfb69309c54c3179966490-10.0.0.0_16-CreateRouteTable-rtb-096bdfb69309c54c3.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_route_multiple/{aws_route-r-rtb-096bdfb69309c54c3243279527-1.1.1.1_32-rtb-096bdfb69309c54c3.res.golden.json => aws_route-r-rtb-096bdfb69309c54c3243279527-1.1.1.1_32-igw-030e74f73bd67f21b-CreateRoute-rtb-096bdfb69309c54c3.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_route_multiple/{aws_route-r-rtb-096bdfb69309c54c32750132062-___0-rtb-096bdfb69309c54c3.res.golden.json => aws_route-r-rtb-096bdfb69309c54c32750132062-___0-igw-030e74f73bd67f21b-CreateRoute-rtb-096bdfb69309c54c3.res.golden.json} (100%) rename enumeration/remote/test/aws_iam_role_multiple/{aws_iam_role-test_role_0.res.golden.json => aws_iam_role-test_role_0-_.res.golden.json} (100%) rename enumeration/remote/test/aws_iam_role_multiple/{aws_iam_role-test_role_1.res.golden.json => aws_iam_role-test_role_1-_.res.golden.json} (100%) rename enumeration/remote/test/aws_iam_role_multiple/{aws_iam_role-test_role_2.res.golden.json => aws_iam_role-test_role_2-_.res.golden.json} (100%) rename enumeration/remote/test/aws_iam_role_policy_multiple/{aws_iam_role_policy-test_role_0_policy-role0-0.res.golden.json => aws_iam_role_policy-test_role_0_policy-role0-0-test_role_0.res.golden.json} (100%) rename enumeration/remote/test/aws_iam_role_policy_multiple/{aws_iam_role_policy-test_role_0_policy-role0-1.res.golden.json => aws_iam_role_policy-test_role_0_policy-role0-1-test_role_0.res.golden.json} (100%) rename enumeration/remote/test/aws_iam_role_policy_multiple/{aws_iam_role_policy-test_role_0_policy-role0-2.res.golden.json => aws_iam_role_policy-test_role_0_policy-role0-2-test_role_0.res.golden.json} (100%) rename enumeration/remote/test/aws_iam_role_policy_multiple/{aws_iam_role_policy-test_role_1_policy-role1-0.res.golden.json => aws_iam_role_policy-test_role_1_policy-role1-0-test_role_1.res.golden.json} (100%) rename enumeration/remote/test/aws_iam_role_policy_multiple/{aws_iam_role_policy-test_role_1_policy-role1-1.res.golden.json => aws_iam_role_policy-test_role_1_policy-role1-1-test_role_1.res.golden.json} (100%) rename enumeration/remote/test/aws_iam_role_policy_multiple/{aws_iam_role_policy-test_role_1_policy-role1-2.res.golden.json => aws_iam_role_policy-test_role_1_policy-role1-2-test_role_1.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_explicit_subdomain/{aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_A.res.golden.json => aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_A-A.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_explicit_subdomain/{aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT.res.golden.json => aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT-TXT.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_explicit_subdomain/{aws_route53_record-Z06486383UC8WYSBZTWFM_test0_A.res.golden.json => aws_route53_record-Z06486383UC8WYSBZTWFM_test0_A-A.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_explicit_subdomain/{aws_route53_record-Z06486383UC8WYSBZTWFM_test0_TXT.res.golden.json => aws_route53_record-Z06486383UC8WYSBZTWFM_test0_TXT-TXT.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_explicit_subdomain/{aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_A.res.golden.json => aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_A-A.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_explicit_subdomain/{aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT.res.golden.json => aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT-TXT.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_multiples/{aws_route53_record-Z10347383HV75H96J919W_test2_A.res.golden.json => aws_route53_record-Z10347383HV75H96J919W_test2_A-A.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_multiples/{aws_route53_record-Z1035360GLIB82T1EH2G__.test4_A.res.golden.json => aws_route53_record-Z1035360GLIB82T1EH2G__.test4_A-A.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_multiples/{aws_route53_record-Z1035360GLIB82T1EH2G_foo-0.com_NS.res.golden.json => aws_route53_record-Z1035360GLIB82T1EH2G_foo-0.com_NS-NS.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_multiples/{aws_route53_record-Z1035360GLIB82T1EH2G_test0_A.res.golden.json => aws_route53_record-Z1035360GLIB82T1EH2G_test0_A-A.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_multiples/{aws_route53_record-Z1035360GLIB82T1EH2G_test1_A.res.golden.json => aws_route53_record-Z1035360GLIB82T1EH2G_test1_A-A.res.golden.json} (100%) rename enumeration/remote/test/aws_route53_record_multiples/{aws_route53_record-Z1035360GLIB82T1EH2G_test2_A.res.golden.json => aws_route53_record-Z1035360GLIB82T1EH2G_test2_A-A.res.golden.json} (100%) rename enumeration/remote/test/aws_sqs_queue_policy_multiple/{aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json => aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo-.res.golden.json} (100%) rename enumeration/remote/test/aws_sqs_queue_policy_multiple/{aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_baz.res.golden.json => aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_baz-.res.golden.json} (100%) rename enumeration/remote/test/aws_sqs_queue_policy_multiple/{aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json => aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_foo-.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json => aws_security_group_rule-sgrule-1175318309--1-sg-0cc8b3c3c2851705a--egress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json => aws_security_group_rule-sgrule-1707973622--1-sg-0254c038e32f25530--egress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json => aws_security_group_rule-sgrule-2165103420--1-sg-0254c038e32f25530--ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json => aws_security_group_rule-sgrule-2582518759--1-sg-0254c038e32f25530--ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-2821752134-0-1-___0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json => aws_security_group_rule-sgrule-2821752134--1-sg-0254c038e32f25530--egress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-350400929-0-1-___0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json => aws_security_group_rule-sgrule-350400929--1-sg-0cc8b3c3c2851705a--egress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-3587309474-0-tcp-sg-0254c038e32f25530-false-sg-9e0204ff-65535-ingress.res.golden.json => aws_security_group_rule-sgrule-3587309474-tcp-sg-0254c038e32f25530-sg-9e0204ff-ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-3970541193-0-tcp-sg-0254c038e32f25530-true--65535-ingress.res.golden.json => aws_security_group_rule-sgrule-3970541193-tcp-sg-0254c038e32f25530--ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-tcp-sg-0cc8b3c3c2851705a-false--443-ingress.res.golden.json => aws_security_group_rule-sgrule-453320892-tcp-sg-0cc8b3c3c2851705a--ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-674800228-0-1-___0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json => aws_security_group_rule-sgrule-674800228--1-sg-0254c038e32f25530--ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-0-5-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json => aws_security_group_rule-sgrule-850043874-5-sg-0cc8b3c3c2851705a--egress.res.golden.json} (100%) rename enumeration/remote/test/azurerm_lb_rule_multiple/{2f725aa2c71898229fcfa091837deaa387bee9d8.res.golden.json => 30ebb29ac6440addd10eb325b92074be71cf00f0.res.golden.json} (100%) rename enumeration/remote/test/azurerm_lb_rule_multiple/{17c4e2b7f4cc466670ccbd8dd1d506289fd818c0.res.golden.json => c52b83ec37e084a52b1dc18c3bb9dbb4e05914a5.res.golden.json} (100%) rename enumeration/remote/test/azurerm_network_security_group_multiple/{azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup1.res.golden.json => azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup1-acceptanceTestSecurityGroup1.res.golden.json} (100%) rename enumeration/remote/test/azurerm_network_security_group_multiple/{azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup2.res.golden.json => azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup2-acceptanceTestSecurityGroup2.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_a_record_multiple/{azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_othertest.res.golden.json => azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_othertest-othertest-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_a_record_multiple/{azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_test.res.golden.json => azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_test-test-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/{azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_othertest.res.golden.json => azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_othertest-othertest-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/{azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_test.res.golden.json => azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_test-test-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_cname_record_multiple/{azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_othertest.res.golden.json => azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_othertest-othertest-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_cname_record_multiple/{azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_test.res.golden.json => azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_test-test-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_mx_record_multiple/{azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_othertestmx.res.golden.json => azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_othertestmx-othertestmx-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_mx_record_multiple/{azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_testmx.res.golden.json => azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_testmx-testmx-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/{azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_othertestptr.res.golden.json => azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_othertestptr-othertestptr-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/{azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_testptr.res.golden.json => azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_testptr-testptr-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_srv_record_multiple/{azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_othertestptr.res.golden.json => azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_othertestptr-othertestptr-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_srv_record_multiple/{azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_testptr.res.golden.json => azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_testptr-testptr-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_txt_record_multiple/{azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_othertesttxt.res.golden.json => azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_othertesttxt-othertesttxt-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_private_dns_txt_record_multiple/{azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_testtxt.res.golden.json => azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_testtxt-testtxt-thisisatestusingtf.com.res.golden.json} (100%) rename enumeration/remote/test/azurerm_ssh_public_key_multiple/{azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key.res.golden.json => azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key-example-key.res.golden.json} (100%) rename enumeration/remote/test/azurerm_ssh_public_key_multiple/{azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key2.res.golden.json => azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key2-example-key2.res.golden.json} (100%) diff --git a/enumeration/remote/aws/cloudformation_stack_enumerator.go b/enumeration/remote/aws/cloudformation_stack_enumerator.go index 5be5e5192..f76f9fe77 100644 --- a/enumeration/remote/aws/cloudformation_stack_enumerator.go +++ b/enumeration/remote/aws/cloudformation_stack_enumerator.go @@ -1,6 +1,8 @@ package aws import ( + "strconv" + "github.com/aws/aws-sdk-go/service/cloudformation" "github.com/snyk/driftctl/enumeration/remote/aws/repository" remoteerror "github.com/snyk/driftctl/enumeration/remote/error" @@ -35,6 +37,7 @@ func (e *CloudformationStackEnumerator) Enumerate() ([]*resource.Resource, error for _, stack := range stacks { attrs := map[string]interface{}{} if stack.Parameters != nil && len(stack.Parameters) > 0 { + attrs["parameters.%"] = strconv.FormatInt(int64(len(stack.Parameters)), 10) attrs["parameters"] = flattenParameters(stack.Parameters) } diff --git a/enumeration/remote/aws/dynamodb_table_enumerator.go b/enumeration/remote/aws/dynamodb_table_enumerator.go index 37cdaffe3..cb0c55940 100644 --- a/enumeration/remote/aws/dynamodb_table_enumerator.go +++ b/enumeration/remote/aws/dynamodb_table_enumerator.go @@ -37,7 +37,9 @@ func (e *DynamoDBTableEnumerator) Enumerate() ([]*resource.Resource, error) { e.factory.CreateAbstractResource( string(e.SupportedType()), *table, - map[string]interface{}{}, + map[string]interface{}{ + "table_name": *table, + }, ), ) } diff --git a/enumeration/remote/aws/ec2_network_acl_rule_enumerator.go b/enumeration/remote/aws/ec2_network_acl_rule_enumerator.go index 25aef07a4..3c6ddf9e3 100644 --- a/enumeration/remote/aws/ec2_network_acl_rule_enumerator.go +++ b/enumeration/remote/aws/ec2_network_acl_rule_enumerator.go @@ -37,9 +37,9 @@ func (e *EC2NetworkACLRuleEnumerator) Enumerate() ([]*resource.Resource, error) attrs := map[string]interface{}{ "egress": *entry.Egress, "network_acl_id": *res.NetworkAclId, - "rule_action": *entry.RuleAction, // Used in default middleware - "rule_number": float64(*entry.RuleNumber), // Used in default middleware - "protocol": *entry.Protocol, // Used in default middleware + "rule_action": *entry.RuleAction, // Used in default middleware + "rule_number": *entry.RuleNumber, // Used in default middleware + "protocol": *entry.Protocol, // Used in default middleware } if entry.CidrBlock != nil { @@ -56,7 +56,7 @@ func (e *EC2NetworkACLRuleEnumerator) Enumerate() ([]*resource.Resource, error) string(e.SupportedType()), aws.CreateNetworkACLRuleID( *res.NetworkAclId, - int(float64(*entry.RuleNumber)), + *entry.RuleNumber, *entry.Egress, *entry.Protocol, ), diff --git a/enumeration/remote/aws/lambda_function_enumerator.go b/enumeration/remote/aws/lambda_function_enumerator.go index ec3c23204..4e4d13868 100644 --- a/enumeration/remote/aws/lambda_function_enumerator.go +++ b/enumeration/remote/aws/lambda_function_enumerator.go @@ -37,7 +37,9 @@ func (e *LambdaFunctionEnumerator) Enumerate() ([]*resource.Resource, error) { e.factory.CreateAbstractResource( string(e.SupportedType()), *function.FunctionName, - map[string]interface{}{}, + map[string]interface{}{ + "function_name": *function.FunctionName, + }, ), ) } diff --git a/enumeration/remote/aws/s3_bucket_analytic_enumerator.go b/enumeration/remote/aws/s3_bucket_analytic_enumerator.go index b2c931eea..05c2b6e8b 100644 --- a/enumeration/remote/aws/s3_bucket_analytic_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_analytic_enumerator.go @@ -2,6 +2,7 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws/repository" @@ -69,7 +70,7 @@ func (e *S3BucketAnalyticEnumerator) Enumerate() ([]*resource.Resource, error) { string(e.SupportedType()), id, map[string]interface{}{ - "region": region, + "alias": region, }, ), ) diff --git a/enumeration/remote/aws/s3_bucket_enumerator.go b/enumeration/remote/aws/s3_bucket_enumerator.go index e96b69d57..5e77968f4 100644 --- a/enumeration/remote/aws/s3_bucket_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_enumerator.go @@ -59,7 +59,7 @@ func (e *S3BucketEnumerator) Enumerate() ([]*resource.Resource, error) { string(e.SupportedType()), *bucket.Name, map[string]interface{}{ - "region": region, + "alias": region, }, ), ) diff --git a/enumeration/remote/aws/s3_bucket_inventory_enumerator.go b/enumeration/remote/aws/s3_bucket_inventory_enumerator.go index 975185501..2ab4469a6 100644 --- a/enumeration/remote/aws/s3_bucket_inventory_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_inventory_enumerator.go @@ -2,6 +2,7 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws/repository" @@ -70,7 +71,7 @@ func (e *S3BucketInventoryEnumerator) Enumerate() ([]*resource.Resource, error) string(e.SupportedType()), id, map[string]interface{}{ - "region": region, + "alias": region, }, ), ) diff --git a/enumeration/remote/aws/s3_bucket_metrics_enumerator.go b/enumeration/remote/aws/s3_bucket_metrics_enumerator.go index b70675ff6..4fb5a1cf1 100644 --- a/enumeration/remote/aws/s3_bucket_metrics_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_metrics_enumerator.go @@ -2,6 +2,7 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/aws/repository" @@ -69,7 +70,7 @@ func (e *S3BucketMetricsEnumerator) Enumerate() ([]*resource.Resource, error) { string(e.SupportedType()), id, map[string]interface{}{ - "region": region, + "alias": region, }, ), ) diff --git a/enumeration/remote/aws/s3_bucket_notification_enumerator.go b/enumeration/remote/aws/s3_bucket_notification_enumerator.go index 8f9ec599d..ff813b6a0 100644 --- a/enumeration/remote/aws/s3_bucket_notification_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_notification_enumerator.go @@ -74,7 +74,7 @@ func (e *S3BucketNotificationEnumerator) Enumerate() ([]*resource.Resource, erro string(e.SupportedType()), *bucket.Name, map[string]interface{}{ - "region": region, + "alias": region, }, ), ) diff --git a/enumeration/remote/aws/s3_bucket_policy_enumerator.go b/enumeration/remote/aws/s3_bucket_policy_enumerator.go index c2f860f56..08f218100 100644 --- a/enumeration/remote/aws/s3_bucket_policy_enumerator.go +++ b/enumeration/remote/aws/s3_bucket_policy_enumerator.go @@ -67,7 +67,7 @@ func (e *S3BucketPolicyEnumerator) Enumerate() ([]*resource.Resource, error) { string(e.SupportedType()), *bucket.Name, map[string]interface{}{ - "region": region, + "alias": region, }, ), ) diff --git a/enumeration/remote/aws/sns_topic_enumerator.go b/enumeration/remote/aws/sns_topic_enumerator.go index 608496174..6e2ed5d1b 100644 --- a/enumeration/remote/aws/sns_topic_enumerator.go +++ b/enumeration/remote/aws/sns_topic_enumerator.go @@ -37,7 +37,9 @@ func (e *SNSTopicEnumerator) Enumerate() ([]*resource.Resource, error) { e.factory.CreateAbstractResource( string(e.SupportedType()), *topic.TopicArn, - map[string]interface{}{}, + map[string]interface{}{ + "topic_arn": *topic.TopicArn, + }, ), ) } diff --git a/enumeration/remote/aws/sns_topic_policy_enumerator.go b/enumeration/remote/aws/sns_topic_policy_enumerator.go index 0c6433836..6c143f18c 100644 --- a/enumeration/remote/aws/sns_topic_policy_enumerator.go +++ b/enumeration/remote/aws/sns_topic_policy_enumerator.go @@ -37,7 +37,9 @@ func (e *SNSTopicPolicyEnumerator) Enumerate() ([]*resource.Resource, error) { e.factory.CreateAbstractResource( string(e.SupportedType()), *topic.TopicArn, - map[string]interface{}{}, + map[string]interface{}{ + "topic_arn": *topic.TopicArn, + }, ), ) } diff --git a/enumeration/remote/aws/sns_topic_subscription_enumerator.go b/enumeration/remote/aws/sns_topic_subscription_enumerator.go index eaa89c55f..8fdd3c4f6 100644 --- a/enumeration/remote/aws/sns_topic_subscription_enumerator.go +++ b/enumeration/remote/aws/sns_topic_subscription_enumerator.go @@ -2,6 +2,7 @@ package aws import ( "fmt" + "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote/aws/repository" remoteerror "github.com/snyk/driftctl/enumeration/remote/error" @@ -75,7 +76,9 @@ func (e *SNSTopicSubscriptionEnumerator) Enumerate() ([]*resource.Resource, erro e.factory.CreateAbstractResource( string(e.SupportedType()), *subscription.SubscriptionArn, - map[string]interface{}{}, + map[string]interface{}{ + "SubscriptionId": *subscription.SubscriptionArn, + }, ), ) } diff --git a/enumeration/remote/common/details_fetcher.go b/enumeration/remote/common/details_fetcher.go index f990a61b4..915c07880 100644 --- a/enumeration/remote/common/details_fetcher.go +++ b/enumeration/remote/common/details_fetcher.go @@ -27,8 +27,12 @@ func NewGenericDetailsFetcher(resType resource.ResourceType, provider terraform. func (f *GenericDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.Resource, error) { attributes := map[string]string{} - if res.Schema().ResolveReadAttributesFunc != nil { - attributes = res.Schema().ResolveReadAttributesFunc(res) + if res.Attributes() != nil { + for k, v := range *res.Attributes() { + if str, ok := v.(string); ok { + attributes[k] = str + } + } } ctyVal, err := f.reader.ReadResource(terraform.ReadResourceArgs{ Ty: f.resType, diff --git a/enumeration/remote/google/google_compute_instance_group_enumerator.go b/enumeration/remote/google/google_compute_instance_group_enumerator.go index dfa987c34..fbb3ad9a4 100644 --- a/enumeration/remote/google/google_compute_instance_group_enumerator.go +++ b/enumeration/remote/google/google_compute_instance_group_enumerator.go @@ -1,9 +1,10 @@ package google import ( + "strings" + remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/remote/google/repository" - "strings" "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" @@ -46,9 +47,9 @@ func (e *GoogleComputeInstanceGroupEnumerator) Enumerate() ([]*resource.Resource string(e.SupportedType()), trimResourceName(res.GetName()), map[string]interface{}{ - "name": res.GetDisplayName(), - "project": project, - "location": res.GetLocation(), + "name": res.GetDisplayName(), + "project": project, + "zone": res.GetLocation(), }, ), ) diff --git a/enumeration/remote/google/google_compute_router_enumerator.go b/enumeration/remote/google/google_compute_router_enumerator.go index 7c2d3f184..8edebf4d8 100644 --- a/enumeration/remote/google/google_compute_router_enumerator.go +++ b/enumeration/remote/google/google_compute_router_enumerator.go @@ -37,7 +37,11 @@ func (e *GoogleComputeRouterEnumerator) Enumerate() ([]*resource.Resource, error e.factory.CreateAbstractResource( string(e.SupportedType()), trimResourceName(res.GetName()), - map[string]interface{}{}, + map[string]interface{}{ + "name": res.GetDisplayName(), + "region": res.GetLocation(), + "project": res.GetProject(), + }, ), ) } diff --git a/enumeration/remote/google/google_storage_bucket_enumerator.go b/enumeration/remote/google/google_storage_bucket_enumerator.go index 03237cb38..cdc0be5c7 100644 --- a/enumeration/remote/google/google_storage_bucket_enumerator.go +++ b/enumeration/remote/google/google_storage_bucket_enumerator.go @@ -38,7 +38,9 @@ func (e *GoogleStorageBucketEnumerator) Enumerate() ([]*resource.Resource, error e.factory.CreateAbstractResource( string(e.SupportedType()), res.DisplayName, - map[string]interface{}{}, + map[string]interface{}{ + "name": res.DisplayName, + }, ), ) } diff --git a/enumeration/remote/test/aws_ec2_eip_association_single/aws_eip_association-eipassoc-0e9a7356e30f0c3d1.res.golden.json b/enumeration/remote/test/aws_ec2_eip_association_single/aws_eip_association-eipassoc-0e9a7356e30f0c3d1-eipalloc-017d5267e4dda73f1.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_eip_association_single/aws_eip_association-eipassoc-0e9a7356e30f0c3d1.res.golden.json rename to enumeration/remote/test/aws_ec2_eip_association_single/aws_eip_association-eipassoc-0e9a7356e30f0c3d1-eipalloc-017d5267e4dda73f1.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-false-acl-0ad6d657494d17ee2-200.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-___0-acl-0ad6d657494d17ee2-6-allow.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-false-acl-0ad6d657494d17ee2-200.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-___0-acl-0ad6d657494d17ee2-6-allow.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-true-acl-0ad6d657494d17ee2-100.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-172.16.1.0_0-acl-0ad6d657494d17ee2-17-allow.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-true-acl-0ad6d657494d17ee2-100.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-172.16.1.0_0-acl-0ad6d657494d17ee2-17-allow.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-true-acl-0de54ef59074b622e-100.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-172.16.1.0_0-acl-0de54ef59074b622e-17-allow.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-true-acl-0de54ef59074b622e-100.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-172.16.1.0_0-acl-0de54ef59074b622e-17-allow.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-false-acl-0ad6d657494d17ee2-100.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-0.0.0.0_0-acl-0ad6d657494d17ee2-6-deny.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-false-acl-0ad6d657494d17ee2-100.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-0.0.0.0_0-acl-0ad6d657494d17ee2-6-deny.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-false-acl-0de54ef59074b622e-100.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-0.0.0.0_0-acl-0de54ef59074b622e-17-deny.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-false-acl-0de54ef59074b622e-100.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-0.0.0.0_0-acl-0de54ef59074b622e-17-deny.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-179966490-10.0.0.0_16-.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-179966490-10.0.0.0_16-CreateRouteTable-.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-179966490-10.0.0.0_16-.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-179966490-10.0.0.0_16-CreateRouteTable-.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc1080289494-0.0.0.0_0-rtb-0169b0937fd963ddc.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc1080289494-0.0.0.0_0-igw-030e74f73bd67f21b-CreateRoute-rtb-0169b0937fd963ddc.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc1080289494-0.0.0.0_0-rtb-0169b0937fd963ddc.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc1080289494-0.0.0.0_0-igw-030e74f73bd67f21b-CreateRoute-rtb-0169b0937fd963ddc.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc179966490-10.0.0.0_16-rtb-0169b0937fd963ddc.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc179966490-10.0.0.0_16-CreateRouteTable-rtb-0169b0937fd963ddc.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc179966490-10.0.0.0_16-rtb-0169b0937fd963ddc.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc179966490-10.0.0.0_16-CreateRouteTable-rtb-0169b0937fd963ddc.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc2750132062-___0-rtb-0169b0937fd963ddc.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc2750132062-___0-igw-030e74f73bd67f21b-CreateRoute-rtb-0169b0937fd963ddc.res.golden.json old mode 100755 new mode 100644 similarity index 100% rename from enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc2750132062-___0-rtb-0169b0937fd963ddc.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-0169b0937fd963ddc2750132062-___0-igw-030e74f73bd67f21b-CreateRoute-rtb-0169b0937fd963ddc.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c51325105504-10.1.2.0_24-rtb-02780c485f0be93c5.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c51325105504-10.1.2.0_24-igw-030e74f73bd67f21b-CreateRoute-rtb-02780c485f0be93c5.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c51325105504-10.1.2.0_24-rtb-02780c485f0be93c5.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c51325105504-10.1.2.0_24-igw-030e74f73bd67f21b-CreateRoute-rtb-02780c485f0be93c5.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c5179966490-10.0.0.0_16-rtb-02780c485f0be93c5.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c5179966490-10.0.0.0_16-CreateRouteTable-rtb-02780c485f0be93c5.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c5179966490-10.0.0.0_16-rtb-02780c485f0be93c5.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c5179966490-10.0.0.0_16-CreateRouteTable-rtb-02780c485f0be93c5.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c53362780110-10.1.1.0_24-rtb-02780c485f0be93c5.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c53362780110-10.1.1.0_24-igw-030e74f73bd67f21b-CreateRoute-rtb-02780c485f0be93c5.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c53362780110-10.1.1.0_24-rtb-02780c485f0be93c5.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-02780c485f0be93c53362780110-10.1.1.0_24-igw-030e74f73bd67f21b-CreateRoute-rtb-02780c485f0be93c5.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3179966490-10.0.0.0_16-rtb-096bdfb69309c54c3.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3179966490-10.0.0.0_16-CreateRouteTable-rtb-096bdfb69309c54c3.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3179966490-10.0.0.0_16-rtb-096bdfb69309c54c3.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3179966490-10.0.0.0_16-CreateRouteTable-rtb-096bdfb69309c54c3.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3243279527-1.1.1.1_32-rtb-096bdfb69309c54c3.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3243279527-1.1.1.1_32-igw-030e74f73bd67f21b-CreateRoute-rtb-096bdfb69309c54c3.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3243279527-1.1.1.1_32-rtb-096bdfb69309c54c3.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c3243279527-1.1.1.1_32-igw-030e74f73bd67f21b-CreateRoute-rtb-096bdfb69309c54c3.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c32750132062-___0-rtb-096bdfb69309c54c3.res.golden.json b/enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c32750132062-___0-igw-030e74f73bd67f21b-CreateRoute-rtb-096bdfb69309c54c3.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c32750132062-___0-rtb-096bdfb69309c54c3.res.golden.json rename to enumeration/remote/test/aws_ec2_route_multiple/aws_route-r-rtb-096bdfb69309c54c32750132062-___0-igw-030e74f73bd67f21b-CreateRoute-rtb-096bdfb69309c54c3.res.golden.json diff --git a/enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_0.res.golden.json b/enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_0-_.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_0.res.golden.json rename to enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_0-_.res.golden.json diff --git a/enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_1.res.golden.json b/enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_1-_.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_1.res.golden.json rename to enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_1-_.res.golden.json diff --git a/enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_2.res.golden.json b/enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_2-_.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_2.res.golden.json rename to enumeration/remote/test/aws_iam_role_multiple/aws_iam_role-test_role_2-_.res.golden.json diff --git a/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-0.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-0-test_role_0.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-0.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-0-test_role_0.res.golden.json diff --git a/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-1.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-1-test_role_0.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-1.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-1-test_role_0.res.golden.json diff --git a/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-2.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-2-test_role_0.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-2.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_0_policy-role0-2-test_role_0.res.golden.json diff --git a/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-0.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-0-test_role_1.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-0.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-0-test_role_1.res.golden.json diff --git a/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-1.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-1-test_role_1.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-1.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-1-test_role_1.res.golden.json diff --git a/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-2.res.golden.json b/enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-2-test_role_1.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-2.res.golden.json rename to enumeration/remote/test/aws_iam_role_policy_multiple/aws_iam_role_policy-test_role_1_policy-role1-2-test_role_1.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_A.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_A-A.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_A-A.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT-TXT.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT-TXT.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_A.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_A-A.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_A-A.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_TXT.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_TXT-TXT.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_TXT.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test0_TXT-TXT.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_A.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_A-A.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_A-A.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT.res.golden.json b/enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT-TXT.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT.res.golden.json rename to enumeration/remote/test/aws_route53_record_explicit_subdomain/aws_route53_record-Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT-TXT.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z10347383HV75H96J919W_test2_A.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z10347383HV75H96J919W_test2_A-A.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z10347383HV75H96J919W_test2_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z10347383HV75H96J919W_test2_A-A.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G__.test4_A.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G__.test4_A-A.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G__.test4_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G__.test4_A-A.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_foo-0.com_NS.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_foo-0.com_NS-NS.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_foo-0.com_NS.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_foo-0.com_NS-NS.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test0_A.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test0_A-A.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test0_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test0_A-A.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test1_A.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test1_A-A.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test1_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test1_A-A.res.golden.json diff --git a/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test2_A.res.golden.json b/enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test2_A-A.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test2_A.res.golden.json rename to enumeration/remote/test/aws_route53_record_multiples/aws_route53_record-Z1035360GLIB82T1EH2G_test2_A-A.res.golden.json diff --git a/enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json b/enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo-.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo.res.golden.json rename to enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_bar.fifo-.res.golden.json diff --git a/enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_baz.res.golden.json b/enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_baz-.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_baz.res.golden.json rename to enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_baz-.res.golden.json diff --git a/enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json b/enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_foo-.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_foo.res.golden.json rename to enumeration/remote/test/aws_sqs_queue_policy_multiple/aws_sqs_queue_policy-https___sqs.eu-west-3.amazonaws.com_047081014315_foo-.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309--1-sg-0cc8b3c3c2851705a--egress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309--1-sg-0cc8b3c3c2851705a--egress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622--1-sg-0254c038e32f25530--egress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622--1-sg-0254c038e32f25530--egress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420--1-sg-0254c038e32f25530--ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420--1-sg-0254c038e32f25530--ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759--1-sg-0254c038e32f25530--ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759--1-sg-0254c038e32f25530--ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134-0-1-___0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134--1-sg-0254c038e32f25530--egress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134-0-1-___0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134--1-sg-0254c038e32f25530--egress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929-0-1-___0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929--1-sg-0cc8b3c3c2851705a--egress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929-0-1-___0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929--1-sg-0cc8b3c3c2851705a--egress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-0-tcp-sg-0254c038e32f25530-false-sg-9e0204ff-65535-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-tcp-sg-0254c038e32f25530-sg-9e0204ff-ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-0-tcp-sg-0254c038e32f25530-false-sg-9e0204ff-65535-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-tcp-sg-0254c038e32f25530-sg-9e0204ff-ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-0-tcp-sg-0254c038e32f25530-true--65535-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-tcp-sg-0254c038e32f25530--ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-0-tcp-sg-0254c038e32f25530-true--65535-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-tcp-sg-0254c038e32f25530--ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-tcp-sg-0cc8b3c3c2851705a-false--443-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-tcp-sg-0cc8b3c3c2851705a--ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-tcp-sg-0cc8b3c3c2851705a-false--443-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-tcp-sg-0cc8b3c3c2851705a--ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228-0-1-___0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228--1-sg-0254c038e32f25530--ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228-0-1-___0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228--1-sg-0254c038e32f25530--ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-0-5-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-5-sg-0cc8b3c3c2851705a--egress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-0-5-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-5-sg-0cc8b3c3c2851705a--egress.res.golden.json diff --git a/enumeration/remote/test/azurerm_lb_rule_multiple/2f725aa2c71898229fcfa091837deaa387bee9d8.res.golden.json b/enumeration/remote/test/azurerm_lb_rule_multiple/30ebb29ac6440addd10eb325b92074be71cf00f0.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_lb_rule_multiple/2f725aa2c71898229fcfa091837deaa387bee9d8.res.golden.json rename to enumeration/remote/test/azurerm_lb_rule_multiple/30ebb29ac6440addd10eb325b92074be71cf00f0.res.golden.json diff --git a/enumeration/remote/test/azurerm_lb_rule_multiple/17c4e2b7f4cc466670ccbd8dd1d506289fd818c0.res.golden.json b/enumeration/remote/test/azurerm_lb_rule_multiple/c52b83ec37e084a52b1dc18c3bb9dbb4e05914a5.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_lb_rule_multiple/17c4e2b7f4cc466670ccbd8dd1d506289fd818c0.res.golden.json rename to enumeration/remote/test/azurerm_lb_rule_multiple/c52b83ec37e084a52b1dc18c3bb9dbb4e05914a5.res.golden.json diff --git a/enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup1.res.golden.json b/enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup1-acceptanceTestSecurityGroup1.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup1.res.golden.json rename to enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup1-acceptanceTestSecurityGroup1.res.golden.json diff --git a/enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup2.res.golden.json b/enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup2-acceptanceTestSecurityGroup2.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup2.res.golden.json rename to enumeration/remote/test/azurerm_network_security_group_multiple/azurerm_network_security_group-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_example-resources_providers_Microsoft.Network_networkSecurityGroups_acceptanceTestSecurityGroup2-acceptanceTestSecurityGroup2.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_othertest.res.golden.json b/enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_othertest-othertest-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_othertest.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_othertest-othertest-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_test.res.golden.json b/enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_test-test-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_test.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_a_record_multiple/azurerm_private_dns_a_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_A_test-test-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_othertest.res.golden.json b/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_othertest-othertest-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_othertest.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_othertest-othertest-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_test.res.golden.json b/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_test-test-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_test.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/azurerm_private_dns_aaaa_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_AAAA_test-test-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_othertest.res.golden.json b/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_othertest-othertest-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_othertest.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_othertest-othertest-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_test.res.golden.json b/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_test-test-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_test.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_cname_record_multiple/azurerm_private_dns_cname_record-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_CNAME_test-test-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_othertestmx.res.golden.json b/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_othertestmx-othertestmx-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_othertestmx.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_othertestmx-othertestmx-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_testmx.res.golden.json b/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_testmx-testmx-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_testmx.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_mx_record_multiple/azurerm_private_dns_mx_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_MX_testmx-testmx-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_othertestptr.res.golden.json b/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_othertestptr-othertestptr-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_othertestptr.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_othertestptr-othertestptr-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_testptr.res.golden.json b/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_testptr-testptr-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_testptr.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/azurerm_private_dns_ptr_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_PTR_testptr-testptr-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_othertestptr.res.golden.json b/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_othertestptr-othertestptr-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_othertestptr.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_othertestptr-othertestptr-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_testptr.res.golden.json b/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_testptr-testptr-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_testptr.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_srv_record_multiple/azurerm_private_dns_srv_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_SRV_testptr-testptr-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_othertesttxt.res.golden.json b/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_othertesttxt-othertesttxt-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_othertesttxt.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_othertesttxt-othertesttxt-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_testtxt.res.golden.json b/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_testtxt-testtxt-thisisatestusingtf.com.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_testtxt.res.golden.json rename to enumeration/remote/test/azurerm_private_dns_txt_record_multiple/azurerm_private_dns_txt_record-_subscriptions_8cb43347-a79f-4bb2-a8b4-c838b41fa5a5_resourceGroups_martin-dev_providers_Microsoft.Network_privateDnsZones_thisisatestusingtf.com_TXT_testtxt-testtxt-thisisatestusingtf.com.res.golden.json diff --git a/enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key.res.golden.json b/enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key-example-key.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key.res.golden.json rename to enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key-example-key.res.golden.json diff --git a/enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key2.res.golden.json b/enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key2-example-key2.res.golden.json similarity index 100% rename from enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key2.res.golden.json rename to enumeration/remote/test/azurerm_ssh_public_key_multiple/azurerm_ssh_public_key-_subscriptions_7bfb2c5c-7308-46ed-8ae4-fffa356eb406_resourceGroups_TESTRESGROUP_providers_Microsoft.Compute_sshPublicKeys_example-key2-example-key2.res.golden.json diff --git a/enumeration/resource/aws/aws_appautoscaling_policy.go b/enumeration/resource/aws/aws_appautoscaling_policy.go index b212828a1..33c6ea0b1 100644 --- a/enumeration/resource/aws/aws_appautoscaling_policy.go +++ b/enumeration/resource/aws/aws_appautoscaling_policy.go @@ -5,14 +5,6 @@ import "github.com/snyk/driftctl/enumeration/resource" const AwsAppAutoscalingPolicyResourceType = "aws_appautoscaling_policy" func initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsAppAutoscalingPolicyResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attributes().GetString("name"), - "resource_id": *res.Attributes().GetString("resource_id"), - "service_namespace": *res.Attributes().GetString("service_namespace"), - "scalable_dimension": *res.Attributes().GetString("scalable_dimension"), - } - }) resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingPolicyResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { diff --git a/enumeration/resource/aws/aws_appautoscaling_target.go b/enumeration/resource/aws/aws_appautoscaling_target.go index bd01002ad..ada967b9c 100644 --- a/enumeration/resource/aws/aws_appautoscaling_target.go +++ b/enumeration/resource/aws/aws_appautoscaling_target.go @@ -5,12 +5,6 @@ import "github.com/snyk/driftctl/enumeration/resource" const AwsAppAutoscalingTargetResourceType = "aws_appautoscaling_target" func initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "service_namespace": *res.Attributes().GetString("service_namespace"), - "scalable_dimension": *res.Attributes().GetString("scalable_dimension"), - } - }) resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { diff --git a/enumeration/resource/aws/aws_cloudformation_stack.go b/enumeration/resource/aws/aws_cloudformation_stack.go index 27531968b..531a70c4f 100644 --- a/enumeration/resource/aws/aws_cloudformation_stack.go +++ b/enumeration/resource/aws/aws_cloudformation_stack.go @@ -1,22 +1,11 @@ package aws import ( - "strconv" - - "github.com/hashicorp/terraform/flatmap" "github.com/snyk/driftctl/enumeration/resource" ) const AwsCloudformationStackResourceType = "aws_cloudformation_stack" func initAwsCloudformationStackMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsCloudformationStackResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]interface{}) - if v := res.Attributes().GetMap("parameters"); v != nil { - attrs["parameters.%"] = strconv.FormatInt(int64(len(v)), 10) - attrs["parameters"] = v - } - return flatmap.Flatten(attrs) - }) resourceSchemaRepository.SetFlags(AwsCloudformationStackResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/aws/aws_default_route_table.go b/enumeration/resource/aws/aws_default_route_table.go index 2386d3460..0965c995c 100644 --- a/enumeration/resource/aws/aws_default_route_table.go +++ b/enumeration/resource/aws/aws_default_route_table.go @@ -5,11 +5,6 @@ import "github.com/snyk/driftctl/enumeration/resource" const AwsDefaultRouteTableResourceType = "aws_default_route_table" func initAwsDefaultRouteTableMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsDefaultRouteTableResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "vpc_id": *res.Attributes().GetString("vpc_id"), - } - }) resourceSchemaRepository.SetFlags(AwsDefaultRouteTableResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetNormalizeFunc(AwsDefaultRouteTableResourceType, func(res *resource.Resource) { val := res.Attrs diff --git a/enumeration/resource/aws/aws_dynamodb_table.go b/enumeration/resource/aws/aws_dynamodb_table.go index 11bad21ea..582900d95 100644 --- a/enumeration/resource/aws/aws_dynamodb_table.go +++ b/enumeration/resource/aws/aws_dynamodb_table.go @@ -7,11 +7,6 @@ import ( const AwsDynamodbTableResourceType = "aws_dynamodb_table" func initAwsDynamodbTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsDynamodbTableResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "table_name": res.ResourceId(), - } - }) resourceSchemaRepository.SetFlags(AwsDynamodbTableResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/aws/aws_iam_access_key.go b/enumeration/resource/aws/aws_iam_access_key.go index 3706284e3..46e9e3a6b 100644 --- a/enumeration/resource/aws/aws_iam_access_key.go +++ b/enumeration/resource/aws/aws_iam_access_key.go @@ -7,13 +7,6 @@ import ( const AwsIamAccessKeyResourceType = "aws_iam_access_key" func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "user": *res.Attributes().GetString("user"), - } - }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/enumeration/resource/aws/aws_iam_role_policy_attachment.go b/enumeration/resource/aws/aws_iam_role_policy_attachment.go index 763e1664e..a9d83f241 100644 --- a/enumeration/resource/aws/aws_iam_role_policy_attachment.go +++ b/enumeration/resource/aws/aws_iam_role_policy_attachment.go @@ -5,11 +5,5 @@ import "github.com/snyk/driftctl/enumeration/resource" const AwsIamRolePolicyAttachmentResourceType = "aws_iam_role_policy_attachment" func initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsIamRolePolicyAttachmentResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "role": *res.Attributes().GetString("role"), - "policy_arn": *res.Attributes().GetString("policy_arn"), - } - }) resourceSchemaRepository.SetFlags(AwsIamRolePolicyAttachmentResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/aws/aws_iam_user_policy_attachment.go b/enumeration/resource/aws/aws_iam_user_policy_attachment.go index 06f1bef30..9b7a41d15 100644 --- a/enumeration/resource/aws/aws_iam_user_policy_attachment.go +++ b/enumeration/resource/aws/aws_iam_user_policy_attachment.go @@ -5,11 +5,5 @@ import "github.com/snyk/driftctl/enumeration/resource" const AwsIamUserPolicyAttachmentResourceType = "aws_iam_user_policy_attachment" func initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsIamUserPolicyAttachmentResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "user": *res.Attributes().GetString("user"), - "policy_arn": *res.Attributes().GetString("policy_arn"), - } - }) resourceSchemaRepository.SetFlags(AwsIamUserPolicyAttachmentResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/aws/aws_lambda_function.go b/enumeration/resource/aws/aws_lambda_function.go index 1a16b4f47..a0c0bb253 100644 --- a/enumeration/resource/aws/aws_lambda_function.go +++ b/enumeration/resource/aws/aws_lambda_function.go @@ -7,11 +7,5 @@ import ( const AwsLambdaFunctionResourceType = "aws_lambda_function" func initAwsLambdaFunctionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsLambdaFunctionResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "function_name": res.ResourceId(), - } - }) resourceSchemaRepository.SetFlags(AwsLambdaFunctionResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/aws/aws_network_acl_rule.go b/enumeration/resource/aws/aws_network_acl_rule.go index d646937be..8058f50f4 100644 --- a/enumeration/resource/aws/aws_network_acl_rule.go +++ b/enumeration/resource/aws/aws_network_acl_rule.go @@ -15,7 +15,7 @@ func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepos resourceSchemaRepository.SetFlags(AwsNetworkACLRuleResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) map[string]string { - ruleNumber := strconv.FormatInt(int64(*res.Attrs.GetFloat64("rule_number")), 10) + ruleNumber := strconv.FormatInt(int64(*res.Attrs.GetInt("rule_number")), 10) if ruleNumber == "32767" { ruleNumber = "*" } @@ -50,16 +50,9 @@ func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepos return attrs }) - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "network_acl_id": *res.Attrs.GetString("network_acl_id"), - "rule_number": strconv.FormatInt(int64(*res.Attrs.GetFloat64("rule_number")), 10), - "egress": strconv.FormatBool(*res.Attrs.GetBool("egress")), - } - }) } -func CreateNetworkACLRuleID(networkAclId string, ruleNumber int, egress bool, protocol string) string { +func CreateNetworkACLRuleID(networkAclId string, ruleNumber int64, egress bool, protocol string) string { var buf bytes.Buffer buf.WriteString(fmt.Sprintf("%s-", networkAclId)) buf.WriteString(fmt.Sprintf("%d-", ruleNumber)) diff --git a/enumeration/resource/aws/aws_rds_cluster.go b/enumeration/resource/aws/aws_rds_cluster.go index 563783516..615d5d81c 100644 --- a/enumeration/resource/aws/aws_rds_cluster.go +++ b/enumeration/resource/aws/aws_rds_cluster.go @@ -7,11 +7,5 @@ import ( const AwsRDSClusterResourceType = "aws_rds_cluster" func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsRDSClusterResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "cluster_identifier": *res.Attributes().GetString("cluster_identifier"), - "database_name": *res.Attributes().GetString("database_name"), - } - }) resourceSchemaRepository.SetFlags(AwsRDSClusterResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/aws/aws_route.go b/enumeration/resource/aws/aws_route.go index 65b045661..2771e5838 100644 --- a/enumeration/resource/aws/aws_route.go +++ b/enumeration/resource/aws/aws_route.go @@ -10,21 +10,6 @@ import ( const AwsRouteResourceType = "aws_route" func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsRouteResourceType, func(res *resource.Resource) map[string]string { - attributes := map[string]string{ - "route_table_id": *res.Attributes().GetString("route_table_id"), - } - if ipv4 := res.Attributes().GetString("destination_cidr_block"); ipv4 != nil && *ipv4 != "" { - attributes["destination_cidr_block"] = *ipv4 - } - if ipv6 := res.Attributes().GetString("destination_ipv6_cidr_block"); ipv6 != nil && *ipv6 != "" { - attributes["destination_ipv6_cidr_block"] = *ipv6 - } - if prefixes := res.Attributes().GetString("destination_prefix_list_id"); prefixes != nil && *prefixes != "" { - attributes["destination_prefix_list_id"] = *prefixes - } - return attributes - }) resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/enumeration/resource/aws/aws_route_table_association.go b/enumeration/resource/aws/aws_route_table_association.go index 75ae4c5c8..1632de70b 100644 --- a/enumeration/resource/aws/aws_route_table_association.go +++ b/enumeration/resource/aws/aws_route_table_association.go @@ -5,13 +5,6 @@ import "github.com/snyk/driftctl/enumeration/resource" const AwsRouteTableAssociationResourceType = "aws_route_table_association" func initAwsRouteTableAssociationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsRouteTableAssociationResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "route_table_id": *res.Attributes().GetString("route_table_id"), - } - }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteTableAssociationResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/enumeration/resource/aws/aws_s3_bucket.go b/enumeration/resource/aws/aws_s3_bucket.go index 81c12b04e..11d578e6a 100644 --- a/enumeration/resource/aws/aws_s3_bucket.go +++ b/enumeration/resource/aws/aws_s3_bucket.go @@ -7,11 +7,6 @@ import ( const AwsS3BucketResourceType = "aws_s3_bucket" func initAwsS3BucketMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "alias": *res.Attributes().GetString("region"), - } - }) resourceSchemaRepository.UpdateSchema(AwsS3BucketResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ "policy": func(attributeSchema *resource.AttributeSchema) { attributeSchema.JsonString = true diff --git a/enumeration/resource/aws/aws_s3_bucket_analytics_configuration.go b/enumeration/resource/aws/aws_s3_bucket_analytics_configuration.go index 5f894cf42..470d5faaf 100644 --- a/enumeration/resource/aws/aws_s3_bucket_analytics_configuration.go +++ b/enumeration/resource/aws/aws_s3_bucket_analytics_configuration.go @@ -5,10 +5,5 @@ import "github.com/snyk/driftctl/enumeration/resource" const AwsS3BucketAnalyticsConfigurationResourceType = "aws_s3_bucket_analytics_configuration" func initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketAnalyticsConfigurationResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "alias": *res.Attributes().GetString("region"), - } - }) resourceSchemaRepository.SetFlags(AwsS3BucketAnalyticsConfigurationResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/aws/aws_s3_bucket_inventory.go b/enumeration/resource/aws/aws_s3_bucket_inventory.go index 6e07eaad6..7424fc84e 100644 --- a/enumeration/resource/aws/aws_s3_bucket_inventory.go +++ b/enumeration/resource/aws/aws_s3_bucket_inventory.go @@ -5,10 +5,5 @@ import "github.com/snyk/driftctl/enumeration/resource" const AwsS3BucketInventoryResourceType = "aws_s3_bucket_inventory" func initAwsS3BucketInventoryMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketInventoryResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "alias": *res.Attributes().GetString("region"), - } - }) resourceSchemaRepository.SetFlags(AwsS3BucketInventoryResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/aws/aws_s3_bucket_metric.go b/enumeration/resource/aws/aws_s3_bucket_metric.go index 29b238d60..68e14a8df 100644 --- a/enumeration/resource/aws/aws_s3_bucket_metric.go +++ b/enumeration/resource/aws/aws_s3_bucket_metric.go @@ -5,10 +5,5 @@ import "github.com/snyk/driftctl/enumeration/resource" const AwsS3BucketMetricResourceType = "aws_s3_bucket_metric" func initAwsS3BucketMetricMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketMetricResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "alias": *res.Attributes().GetString("region"), - } - }) resourceSchemaRepository.SetFlags(AwsS3BucketMetricResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/aws/aws_s3_bucket_notification.go b/enumeration/resource/aws/aws_s3_bucket_notification.go index 1f425e1fe..789ff720f 100644 --- a/enumeration/resource/aws/aws_s3_bucket_notification.go +++ b/enumeration/resource/aws/aws_s3_bucket_notification.go @@ -5,10 +5,5 @@ import "github.com/snyk/driftctl/enumeration/resource" const AwsS3BucketNotificationResourceType = "aws_s3_bucket_notification" func initAwsS3BucketNotificationMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketNotificationResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "alias": *res.Attributes().GetString("region"), - } - }) resourceSchemaRepository.SetFlags(AwsS3BucketNotificationResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/aws/aws_s3_bucket_policy.go b/enumeration/resource/aws/aws_s3_bucket_policy.go index 35ec77546..5f2822a33 100644 --- a/enumeration/resource/aws/aws_s3_bucket_policy.go +++ b/enumeration/resource/aws/aws_s3_bucket_policy.go @@ -7,11 +7,6 @@ import ( const AwsS3BucketPolicyResourceType = "aws_s3_bucket_policy" func initAwsS3BucketPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsS3BucketPolicyResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "alias": *res.Attributes().GetString("region"), - } - }) resourceSchemaRepository.UpdateSchema(AwsS3BucketPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ "policy": func(attributeSchema *resource.AttributeSchema) { attributeSchema.JsonString = true diff --git a/enumeration/resource/aws/aws_security_group_rule.go b/enumeration/resource/aws/aws_security_group_rule.go index 48436ac6e..406970424 100644 --- a/enumeration/resource/aws/aws_security_group_rule.go +++ b/enumeration/resource/aws/aws_security_group_rule.go @@ -5,7 +5,6 @@ import ( "fmt" "strings" - "github.com/hashicorp/terraform/flatmap" "github.com/hashicorp/terraform/helper/hashcode" "github.com/snyk/driftctl/enumeration/resource" ) @@ -56,40 +55,6 @@ func CreateSecurityGroupRuleIdHash(attrs *resource.Attributes) string { } func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]interface{}) - if v, ok := res.Attributes().Get("type"); ok { - attrs["type"] = v - } - if v, ok := res.Attributes().Get("protocol"); ok { - attrs["protocol"] = v - } - if v := res.Attributes().GetInt("from_port"); v != nil { - attrs["from_port"] = *v - } - if v := res.Attributes().GetInt("to_port"); v != nil { - attrs["to_port"] = *v - } - if v, ok := res.Attributes().Get("security_group_id"); ok { - attrs["security_group_id"] = v - } - if v, ok := res.Attributes().Get("self"); ok { - attrs["self"] = v - } - if v, ok := res.Attributes().Get("cidr_blocks"); ok { - attrs["cidr_blocks"] = v - } - if v, ok := res.Attributes().Get("ipv6_cidr_blocks"); ok { - attrs["ipv6_cidr_blocks"] = v - } - if v, ok := res.Attributes().Get("prefix_list_ids"); ok { - attrs["prefix_list_ids"] = v - } - if v, ok := res.Attributes().Get("source_security_group_id"); ok { - attrs["source_security_group_id"] = v - } - return flatmap.Flatten(attrs) - }) resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/enumeration/resource/aws/aws_sns_topic.go b/enumeration/resource/aws/aws_sns_topic.go index c60da86e6..ca67dce14 100644 --- a/enumeration/resource/aws/aws_sns_topic.go +++ b/enumeration/resource/aws/aws_sns_topic.go @@ -5,11 +5,6 @@ import "github.com/snyk/driftctl/enumeration/resource" const AwsSnsTopicResourceType = "aws_sns_topic" func initSnsTopicMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "topic_arn": res.ResourceId(), - } - }) resourceSchemaRepository.UpdateSchema(AwsSnsTopicResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ "delivery_policy": func(attributeSchema *resource.AttributeSchema) { attributeSchema.JsonString = true diff --git a/enumeration/resource/aws/aws_sns_topic_policy.go b/enumeration/resource/aws/aws_sns_topic_policy.go index 25869100f..3efcf2536 100644 --- a/enumeration/resource/aws/aws_sns_topic_policy.go +++ b/enumeration/resource/aws/aws_sns_topic_policy.go @@ -7,12 +7,6 @@ import ( const AwsSnsTopicPolicyResourceType = "aws_sns_topic_policy" func initSnsTopicPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicPolicyResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "topic_arn": res.ResourceId(), - } - }) - resourceSchemaRepository.UpdateSchema(AwsSnsTopicPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ "policy": func(attributeSchema *resource.AttributeSchema) { attributeSchema.JsonString = true diff --git a/enumeration/resource/aws/aws_sns_topic_subscription.go b/enumeration/resource/aws/aws_sns_topic_subscription.go index 0cde9ec5a..46505ff05 100644 --- a/enumeration/resource/aws/aws_sns_topic_subscription.go +++ b/enumeration/resource/aws/aws_sns_topic_subscription.go @@ -7,12 +7,6 @@ import ( const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription" func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "SubscriptionId": res.ResourceId(), - } - }) - resourceSchemaRepository.UpdateSchema(AwsSnsTopicSubscriptionResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ "delivery_policy": func(attributeSchema *resource.AttributeSchema) { attributeSchema.JsonString = true diff --git a/enumeration/resource/azurerm/azurerm_lb_rule.go b/enumeration/resource/azurerm/azurerm_lb_rule.go index ea5a5fcd1..c1ae97c8b 100644 --- a/enumeration/resource/azurerm/azurerm_lb_rule.go +++ b/enumeration/resource/azurerm/azurerm_lb_rule.go @@ -5,11 +5,6 @@ import "github.com/snyk/driftctl/enumeration/resource" const AzureLoadBalancerRuleResourceType = "azurerm_lb_rule" func initAzureLoadBalancerRuleMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "loadbalancer_id": *res.Attributes().GetString("loadbalancer_id"), - } - }) resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) if name := res.Attributes().GetString("name"); name != nil && *name != "" { diff --git a/enumeration/resource/google/google_compute_firewall.go b/enumeration/resource/google/google_compute_firewall.go index 4b836b5f7..e8cb38eba 100644 --- a/enumeration/resource/google/google_compute_firewall.go +++ b/enumeration/resource/google/google_compute_firewall.go @@ -5,11 +5,5 @@ import "github.com/snyk/driftctl/enumeration/resource" const GoogleComputeFirewallResourceType = "google_compute_firewall" func initGoogleComputeFirewallMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeFirewallResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attrs.GetString("name"), - "project": *res.Attrs.GetString("project"), - } - }) resourceSchemaRepository.SetFlags(GoogleComputeFirewallResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/google/google_compute_instance_group.go b/enumeration/resource/google/google_compute_instance_group.go index e2cd6c4f2..75c250d92 100644 --- a/enumeration/resource/google/google_compute_instance_group.go +++ b/enumeration/resource/google/google_compute_instance_group.go @@ -5,13 +5,6 @@ import "github.com/snyk/driftctl/enumeration/resource" const GoogleComputeInstanceGroupResourceType = "google_compute_instance_group" func initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attributes().GetString("name"), - "project": *res.Attributes().GetString("project"), - "zone": *res.Attributes().GetString("location"), - } - }) resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) if v := res.Attributes().GetString("name"); v != nil && *v != "" { diff --git a/enumeration/resource/google/google_compute_network.go b/enumeration/resource/google/google_compute_network.go index 850fc61ab..bde14716f 100644 --- a/enumeration/resource/google/google_compute_network.go +++ b/enumeration/resource/google/google_compute_network.go @@ -5,10 +5,5 @@ import "github.com/snyk/driftctl/enumeration/resource" const GoogleComputeNetworkResourceType = "google_compute_network" func initGoogleComputeNetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeNetworkResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attributes().GetString("name"), - } - }) resourceSchemaRepository.SetFlags(GoogleComputeNetworkResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/google/google_compute_router.go b/enumeration/resource/google/google_compute_router.go index 43ae2b129..74255bc8f 100644 --- a/enumeration/resource/google/google_compute_router.go +++ b/enumeration/resource/google/google_compute_router.go @@ -1,15 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleComputeRouterResourceType = "google_compute_router" - -func initGoogleComputeRouterMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeRouterResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attrs.GetString("name"), - "region": *res.Attrs.GetString("region"), - "project": *res.Attrs.GetString("project"), - } - }) -} diff --git a/enumeration/resource/google/google_compute_subnetwork.go b/enumeration/resource/google/google_compute_subnetwork.go index c88670d90..444101bf6 100644 --- a/enumeration/resource/google/google_compute_subnetwork.go +++ b/enumeration/resource/google/google_compute_subnetwork.go @@ -5,12 +5,6 @@ import "github.com/snyk/driftctl/enumeration/resource" const GoogleComputeSubnetworkResourceType = "google_compute_subnetwork" func initGoogleComputeSubnetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleComputeSubnetworkResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attributes().GetString("name"), - "region": *res.Attributes().GetString("region"), - } - }) resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeSubnetworkResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) diff --git a/enumeration/resource/google/google_project_iam_member.go b/enumeration/resource/google/google_project_iam_member.go index 1d29be10d..612cec429 100644 --- a/enumeration/resource/google/google_project_iam_member.go +++ b/enumeration/resource/google/google_project_iam_member.go @@ -5,13 +5,6 @@ import "github.com/snyk/driftctl/enumeration/resource" const GoogleProjectIamMemberResourceType = "google_project_iam_member" func initGoogleProjectIAMMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleProjectIamMemberResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "project": *res.Attrs.GetString("project"), - "role": *res.Attrs.GetString("role"), - "member": *res.Attrs.GetString("member"), - } - }) resourceSchemaRepository.SetFlags(GoogleProjectIamMemberResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/google/google_storage_bucket.go b/enumeration/resource/google/google_storage_bucket.go index 42ecc5f52..f28b5ae1d 100644 --- a/enumeration/resource/google/google_storage_bucket.go +++ b/enumeration/resource/google/google_storage_bucket.go @@ -5,10 +5,5 @@ import "github.com/snyk/driftctl/enumeration/resource" const GoogleStorageBucketResourceType = "google_storage_bucket" func initGoogleStorageBucketMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleStorageBucketResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": res.ResourceId(), - } - }) resourceSchemaRepository.SetFlags(GoogleStorageBucketResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/google/google_storage_bucket_iam_member.go b/enumeration/resource/google/google_storage_bucket_iam_member.go index 3be214014..0c110fcee 100644 --- a/enumeration/resource/google/google_storage_bucket_iam_member.go +++ b/enumeration/resource/google/google_storage_bucket_iam_member.go @@ -5,13 +5,6 @@ import "github.com/snyk/driftctl/enumeration/resource" const GoogleStorageBucketIamMemberResourceType = "google_storage_bucket_iam_member" func initGoogleStorageBucketIamBMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetResolveReadAttributesFunc(GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "bucket": *res.Attrs.GetString("bucket"), - "role": *res.Attrs.GetString("role"), - "member": *res.Attrs.GetString("member"), - } - }) resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) map[string]string { attrs := map[string]string{ "bucket": *res.Attrs.GetString("bucket"), diff --git a/enumeration/resource/google/metadatas.go b/enumeration/resource/google/metadatas.go index 9cb8c8763..fd27a8de7 100644 --- a/enumeration/resource/google/metadatas.go +++ b/enumeration/resource/google/metadatas.go @@ -5,7 +5,6 @@ import "github.com/snyk/driftctl/enumeration/resource" func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { initGoogleStorageBucketMetadata(resourceSchemaRepository) initGoogleComputeFirewallMetadata(resourceSchemaRepository) - initGoogleComputeRouterMetadata(resourceSchemaRepository) initGoogleComputeNetworkMetadata(resourceSchemaRepository) initGoogleStorageBucketIamBMemberMetadata(resourceSchemaRepository) initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository) diff --git a/enumeration/resource/schemas.go b/enumeration/resource/schemas.go index 4fdf43bb4..a21cb7984 100644 --- a/enumeration/resource/schemas.go +++ b/enumeration/resource/schemas.go @@ -35,7 +35,6 @@ type Schema struct { Attributes map[string]AttributeSchema NormalizeFunc func(res *Resource) HumanReadableAttributesFunc func(res *Resource) map[string]string - ResolveReadAttributesFunc func(res *Resource) map[string]string DiscriminantFunc func(*Resource, *Resource) bool } @@ -61,7 +60,6 @@ type SchemaRepositoryInterface interface { UpdateSchema(typ string, schemasMutators map[string]func(attributeSchema *AttributeSchema)) SetNormalizeFunc(typ string, normalizeFunc func(res *Resource)) SetHumanReadableAttributesFunc(typ string, humanReadableAttributesFunc func(res *Resource) map[string]string) - SetResolveReadAttributesFunc(typ string, resolveReadAttributesFunc func(res *Resource) map[string]string) SetDiscriminantFunc(string, func(*Resource, *Resource) bool) } @@ -166,15 +164,6 @@ func (r *SchemaRepository) SetHumanReadableAttributesFunc(typ string, humanReada (*metadata).HumanReadableAttributesFunc = humanReadableAttributesFunc } -func (r *SchemaRepository) SetResolveReadAttributesFunc(typ string, resolveReadAttributesFunc func(res *Resource) map[string]string) { - metadata, exist := r.GetSchema(typ) - if !exist { - logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to add read resource attributes, no schema found") - return - } - (*metadata).ResolveReadAttributesFunc = resolveReadAttributesFunc -} - func (r *SchemaRepository) SetDiscriminantFunc(typ string, fn func(self, res *Resource) bool) { metadata, exist := r.GetSchema(typ) if !exist { diff --git a/pkg/middlewares/aws_network_acl_expander.go b/pkg/middlewares/aws_network_acl_expander.go index 3f09d6ea9..ae4935460 100644 --- a/pkg/middlewares/aws_network_acl_expander.go +++ b/pkg/middlewares/aws_network_acl_expander.go @@ -86,7 +86,7 @@ func (e *AwsNetworkACLExpander) expandBlock(resourcesFromState *[]*resource.Reso aws.AwsNetworkACLRuleResourceType, aws.CreateNetworkACLRuleID( networkAclId, - int(attrs["rule_number"].(float64)), + int64(attrs["rule_number"].(int)), egress, attrs["protocol"].(string), ), diff --git a/pkg/middlewares/aws_network_acl_expander_test.go b/pkg/middlewares/aws_network_acl_expander_test.go index 9b9bf7949..3341e086a 100644 --- a/pkg/middlewares/aws_network_acl_expander_test.go +++ b/pkg/middlewares/aws_network_acl_expander_test.go @@ -1,10 +1,11 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" + "github.com/snyk/driftctl/enumeration/terraform" + "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" @@ -87,7 +88,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "17", - "rule_number": 100.0, + "rule_number": 100, "to_port": 80, }, ).Once().Return(&resource.Resource{ @@ -114,7 +115,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "6", - "rule_number": 101.0, + "rule_number": 101, "to_port": 80, }, ).Once().Return(&resource.Resource{ @@ -141,7 +142,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "6", - "rule_number": 103.0, + "rule_number": 103, "to_port": 80, }, ).Once().Return(&resource.Resource{ @@ -168,7 +169,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "17", - "rule_number": 100.0, + "rule_number": 100, "to_port": 80, }, ).Once().Return(&resource.Resource{ @@ -190,7 +191,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "17", - "rule_no": 100.0, + "rule_no": 100, "to_port": 80, }, }, @@ -203,7 +204,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "6", - "rule_no": 101.0, + "rule_no": 101, "to_port": 80, }, // This one exist in state, test that we do not duplicate it @@ -216,7 +217,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "6", - "rule_no": 103.0, + "rule_no": 103, "to_port": 80, }, }, @@ -235,7 +236,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "17", - "rule_no": 100.0, + "rule_no": 100, "to_port": 80, }, }, diff --git a/pkg/resource/aws/aws_network_acl_rule.go b/pkg/resource/aws/aws_network_acl_rule.go index 18b7dd540..0dc19886c 100644 --- a/pkg/resource/aws/aws_network_acl_rule.go +++ b/pkg/resource/aws/aws_network_acl_rule.go @@ -182,7 +182,7 @@ func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepos // This workaround is mandatory to harmonize resources ID res.Id = aws.CreateNetworkACLRuleID( *res.Attrs.GetString("network_acl_id"), - int(*res.Attrs.GetFloat64("rule_number")), + int64(*res.Attrs.GetInt("rule_number")), *res.Attrs.GetBool("egress"), *res.Attrs.GetString("protocol"), ) From 1ece051636ce4ae67f02bf93d364c829f2fdaba2 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Thu, 21 Jul 2022 10:37:03 +0200 Subject: [PATCH 2/9] chore: moved metadata to driftctl --- enumeration/remote/aws/init.go | 14 +- .../remote/aws_api_gateway_scanner_test.go | 91 ++---- .../remote/aws_apigatewayv2_scanner_test.go | 61 +--- ...aws_applicationautoscaling_scanner_test.go | 14 +- .../remote/aws_autoscaling_scanner_test.go | 5 +- .../remote/aws_cloudformation_scanner_test.go | 5 +- .../remote/aws_cloudfront_scanner_test.go | 5 +- .../remote/aws_dynamodb_scanner_test.go | 5 +- enumeration/remote/aws_ec2_scanner_test.go | 107 ++----- enumeration/remote/aws_ecr_scanner_test.go | 10 +- .../remote/aws_elasticache_scanner_test.go | 6 +- enumeration/remote/aws_elb_scanner_test.go | 5 +- enumeration/remote/aws_elbv2_scanner_test.go | 9 +- enumeration/remote/aws_iam_scanner_test.go | 45 +-- enumeration/remote/aws_kms_scanner_test.go | 9 +- enumeration/remote/aws_lambda_scanner_test.go | 11 +- enumeration/remote/aws_rds_scanner_test.go | 15 +- .../remote/aws_route53_scanner_test.go | 13 +- enumeration/remote/aws_s3_scanner_test.go | 30 +- enumeration/remote/aws_sns_scanner_test.go | 13 +- enumeration/remote/aws_sqs_scanner_test.go | 9 +- enumeration/remote/azurerm/init.go | 16 +- .../remote/azurerm_compute_scanner_test.go | 11 +- .../azurerm_containerregistry_scanner_test.go | 6 +- .../remote/azurerm_network_scanner_test.go | 46 +-- .../remote/azurerm_postgresql_scanner_test.go | 11 +- .../remote/azurerm_privatedns_scanner_test.go | 42 +-- .../remote/azurerm_resources_scanner_test.go | 6 +- .../remote/azurerm_storage_scanner_test.go | 11 +- enumeration/remote/github/init.go | 14 +- .../github_branch_protection_scanner_test.go | 5 +- .../remote/github_membership_scanner_test.go | 5 +- .../remote/github_repository_scanner_test.go | 5 +- .../github_team_membership_scanner_test.go | 5 +- .../remote/github_team_scanner_test.go | 5 +- enumeration/remote/google/init.go | 14 +- .../remote/google_bigquery_scanner_test.go | 17 +- .../remote/google_bigtable_scanner_test.go | 17 +- .../google_cloudfunctions_scanner_test.go | 10 +- .../remote/google_cloudrun_scanner_test.go | 9 +- .../remote/google_compute_scanner_test.go | 110 +++---- .../remote/google_network_scanner_test.go | 9 +- .../remote/google_project_scanner_test.go | 10 +- enumeration/remote/google_sql_scanner_test.go | 10 +- .../remote/google_storage_scanner_test.go | 17 +- enumeration/remote/remote.go | 16 +- .../results.golden.json | 4 +- .../results.golden.json | 10 +- .../results.golden.json | 2 +- .../aws_ec2_eip_multiple/results.golden.json | 49 +++- .../aws_ec2_network_acl/results.golden.json | 4 +- .../results.golden.json | 62 ++-- .../results.golden.json | 16 +- .../results.golden.json | 6 +- .../results.golden.json | 2 +- .../results.golden.json | 16 +- .../results.golden.json | 4 +- .../results.golden.json | 4 +- .../results.golden.json | 4 +- .../results.golden.json | 4 +- .../results.golden.json | 10 +- .../results.golden.json | 4 +- .../results.golden.json | 4 +- .../results.golden.json | 4 +- .../results.golden.json | 4 +- .../results.golden.json | 48 +-- .../results.golden.json | 8 +- .../results.golden.json | 6 +- .../results.golden.json | 12 - .../google_storage_bucket/results.golden.json | 48 +-- .../results.golden.json | 8 - enumeration/resource/aws/aws_ami.go | 8 - .../resource/aws/aws_apigatewayv2_mapping.go | 20 -- .../resource/aws/aws_apigatewayv2_model.go | 13 - .../resource/aws/aws_appautoscaling_policy.go | 13 - .../resource/aws/aws_appautoscaling_target.go | 13 - .../resource/aws/aws_cloudformation_stack.go | 8 - .../aws/aws_cloudfront_distribution.go | 8 - enumeration/resource/aws/aws_db_instance.go | 8 - .../resource/aws/aws_db_subnet_group.go | 8 - .../resource/aws/aws_default_network_acl.go | 8 - .../resource/aws/aws_default_route_table.go | 10 - .../aws/aws_default_security_group.go | 8 - .../resource/aws/aws_default_subnet.go | 8 - enumeration/resource/aws/aws_default_vpc.go | 6 - .../resource/aws/aws_dynamodb_table.go | 9 - .../aws/aws_ebs_encryption_by_default.go | 6 - enumeration/resource/aws/aws_ebs_snapshot.go | 8 - enumeration/resource/aws/aws_ebs_volume.go | 8 - .../resource/aws/aws_ecr_repository.go | 7 - enumeration/resource/aws/aws_eip.go | 8 - .../resource/aws/aws_eip_association.go | 6 - .../resource/aws/aws_iam_access_key.go | 16 - enumeration/resource/aws/aws_iam_policy.go | 13 - .../resource/aws/aws_iam_policy_attachment.go | 8 - enumeration/resource/aws/aws_iam_role.go | 13 - .../resource/aws/aws_iam_role_policy.go | 13 - .../aws/aws_iam_role_policy_attachment.go | 6 - enumeration/resource/aws/aws_iam_user.go | 8 - .../resource/aws/aws_iam_user_policy.go | 13 - .../aws/aws_iam_user_policy_attachment.go | 6 - enumeration/resource/aws/aws_instance.go | 18 -- .../resource/aws/aws_internet_gateway.go | 8 - enumeration/resource/aws/aws_key_pair.go | 8 - enumeration/resource/aws/aws_kms_alias.go | 8 - enumeration/resource/aws/aws_kms_key.go | 13 - .../aws/aws_lambda_event_source_mapping.go | 19 -- .../resource/aws/aws_lambda_function.go | 8 - .../resource/aws/aws_launch_template.go | 6 - enumeration/resource/aws/aws_lb.go | 10 - enumeration/resource/aws/aws_nat_gateway.go | 6 - enumeration/resource/aws/aws_network_acl.go | 8 - .../resource/aws/aws_network_acl_rule.go | 43 --- enumeration/resource/aws/aws_rds_cluster.go | 8 - enumeration/resource/aws/aws_route.go | 22 -- .../resource/aws/aws_route53_health_check.go | 40 --- .../resource/aws/aws_route53_record.go | 22 -- enumeration/resource/aws/aws_route53_zone.go | 16 - enumeration/resource/aws/aws_route_table.go | 10 - .../aws/aws_route_table_association.go | 20 -- enumeration/resource/aws/aws_s3_bucket.go | 13 - .../aws_s3_bucket_analytics_configuration.go | 6 - .../resource/aws/aws_s3_bucket_inventory.go | 6 - .../resource/aws/aws_s3_bucket_metric.go | 6 - .../aws/aws_s3_bucket_notification.go | 6 - .../resource/aws/aws_s3_bucket_policy.go | 13 - .../resource/aws/aws_security_group.go | 6 - .../resource/aws/aws_security_group_rule.go | 85 ------ enumeration/resource/aws/aws_sns_topic.go | 25 -- .../resource/aws/aws_sns_topic_policy.go | 13 - .../aws/aws_sns_topic_subscription.go | 17 -- enumeration/resource/aws/aws_sqs_queue.go | 8 - .../resource/aws/aws_sqs_queue_policy.go | 13 - enumeration/resource/aws/aws_subnet.go | 8 - enumeration/resource/aws/aws_vpc.go | 6 - enumeration/resource/aws/metadatas.go | 70 ----- .../azurerm/azurerm_container_registry.go | 13 - .../resource/azurerm/azurerm_firewall.go | 13 - enumeration/resource/azurerm/azurerm_image.go | 16 - enumeration/resource/azurerm/azurerm_lb.go | 13 - .../resource/azurerm/azurerm_lb_rule.go | 13 - .../azurerm/azurerm_network_security_group.go | 14 - .../azurerm/azurerm_postgresql_database.go | 13 - .../azurerm/azurerm_postgresql_server.go | 13 - .../azurerm/azurerm_private_dns_a_record.go | 19 -- .../azurerm_private_dns_aaaa_record.go | 19 -- .../azurerm_private_dns_cname_record.go | 18 -- .../azurerm/azurerm_private_dns_mx_record.go | 22 -- .../azurerm/azurerm_private_dns_ptr_record.go | 19 -- .../azurerm/azurerm_private_dns_srv_record.go | 19 -- .../azurerm/azurerm_private_dns_txt_record.go | 19 -- .../azurerm/azurerm_private_dns_zone.go | 8 - .../resource/azurerm/azurerm_public_ip.go | 13 - .../azurerm/azurerm_resource_group.go | 13 - enumeration/resource/azurerm/azurerm_route.go | 20 -- .../resource/azurerm/azurerm_route_table.go | 15 - .../azurerm/azurerm_ssh_public_key.go | 17 -- .../azurerm/azurerm_virtual_network.go | 15 - enumeration/resource/azurerm/metadata.go | 28 -- .../github/github_branch_protection.go | 36 --- .../resource/github/github_membership.go | 7 - .../resource/github/github_repository.go | 6 - enumeration/resource/github/github_team.go | 16 - .../resource/github/github_team_membership.go | 7 - enumeration/resource/github/metadatas.go | 11 - .../google/google_bigquery_dataset.go | 10 - .../resource/google/google_bigquery_table.go | 10 - .../resource/google/google_compute_address.go | 11 - .../resource/google/google_compute_disk.go | 10 - .../google/google_compute_firewall.go | 6 - .../google/google_compute_global_address.go | 11 - .../google/google_compute_health_check.go | 10 - .../resource/google/google_compute_image.go | 10 - .../google/google_compute_instance_group.go | 13 - .../google_compute_instance_group_manager.go | 12 - .../resource/google/google_compute_network.go | 6 - .../google/google_compute_subnetwork.go | 14 - .../google/google_project_iam_member.go | 7 - .../resource/google/google_storage_bucket.go | 6 - .../google_storage_bucket_iam_member.go | 15 - enumeration/resource/google/metadatas.go | 21 -- enumeration/terraform/resource_factory.go | 18 +- pkg/analyser/analyzer_test.go | 4 +- pkg/cmd/scan.go | 28 +- pkg/cmd/scan/output/console_test.go | 2 +- pkg/driftctl_test.go | 50 ++-- pkg/iac/supplier/supplier_test.go | 7 +- .../terraform/state/terraform_state_reader.go | 3 +- .../state/terraform_state_reader_test.go | 28 +- .../aws_alb_listener_transformer.go | 2 +- .../aws_alb_listener_transformer_test.go | 12 +- pkg/middlewares/aws_alb_transformer.go | 2 +- pkg/middlewares/aws_alb_transformer_test.go | 12 +- .../aws_api_gateway_api_expander.go | 2 +- .../aws_api_gateway_api_expander_test.go | 28 +- ...pi_gateway_base_path_mapping_reconciler.go | 2 +- ...teway_base_path_mapping_reconciler_test.go | 2 +- .../aws_api_gateway_deployment_expander.go | 2 +- ...ws_api_gateway_deployment_expander_test.go | 10 +- ...aws_api_gateway_domain_names_reconciler.go | 2 +- ...pi_gateway_domain_names_reconciler_test.go | 2 +- .../aws_api_gateway_resource_expander.go | 2 +- .../aws_api_gateway_resource_expander_test.go | 10 +- ...ws_api_gateway_rest_api_policy_expander.go | 2 +- ...i_gateway_rest_api_policy_expander_test.go | 10 +- pkg/middlewares/aws_bucket_policy_expander.go | 2 +- .../aws_bucket_policy_expander_test.go | 12 +- ...ws_console_api_gateway_gateway_response.go | 2 +- ...nsole_api_gateway_gateway_response_test.go | 2 +- .../aws_default_api_gateway_account.go | 2 +- .../aws_default_api_gateway_account_test.go | 2 +- pkg/middlewares/aws_default_igw_route.go | 2 +- pkg/middlewares/aws_default_igw_route_test.go | 2 +- .../aws_default_internet_gateway.go | 2 +- .../aws_default_internet_gateway_test.go | 2 +- pkg/middlewares/aws_default_network_acl.go | 2 +- .../aws_default_network_acl_rule.go | 2 +- .../aws_default_network_acl_rule_test.go | 2 +- .../aws_default_network_acl_test.go | 2 +- pkg/middlewares/aws_default_route.go | 2 +- pkg/middlewares/aws_default_route_table.go | 2 +- .../aws_default_route_table_test.go | 2 +- pkg/middlewares/aws_default_route_test.go | 2 +- .../aws_default_security_group_rule.go | 2 +- .../aws_default_security_group_rule_test.go | 2 +- .../aws_default_sqs_queue_policy.go | 2 +- .../aws_default_sqs_queue_policy_test.go | 2 +- pkg/middlewares/aws_default_subnet.go | 2 +- pkg/middlewares/aws_default_vpc.go | 2 +- pkg/middlewares/aws_defaults.go | 2 +- pkg/middlewares/aws_defaults_test.go | 2 +- ...ws_ebs_encryption_by_default_reconciler.go | 2 +- ...s_encryption_by_default_reconciler_test.go | 16 +- .../aws_eip_association_expander.go | 2 +- .../aws_iam_policy_attachement_transformer.go | 2 +- ...iam_policy_attachement_transformer_test.go | 14 +- pkg/middlewares/aws_instance_block_device.go | 2 +- .../aws_instance_block_device_test.go | 12 +- pkg/middlewares/aws_instance_eip.go | 2 +- pkg/middlewares/aws_instance_eip_test.go | 2 +- pkg/middlewares/aws_nat_gateway_eip_assoc.go | 2 +- .../aws_nat_gateway_eip_assoc_test.go | 2 +- pkg/middlewares/aws_network_acl_expander.go | 2 +- .../aws_network_acl_expander_test.go | 11 +- .../aws_rds_cluster_instance_expander.go | 2 +- .../aws_rds_cluster_instance_expander_test.go | 12 +- .../aws_role_managed_policy_expander.go | 2 +- pkg/middlewares/aws_route_table_expander.go | 2 +- .../aws_route_table_expander_test.go | 19 +- ..._bucket_public_access_block_reconcilier.go | 2 +- ...et_public_access_block_reconcilier_test.go | 2 +- .../aws_sns_topic_policy_expander.go | 3 +- .../aws_sns_topic_policy_expander_test.go | 19 +- .../aws_sqs_queue_policy_expander.go | 3 +- .../aws_sqs_queue_policy_expander_test.go | 22 +- .../azurerm_route_expander_test.go | 8 +- .../azurerm_subnet_expander_test.go | 8 +- pkg/middlewares/default_vpc_test.go | 2 +- .../google_iam_binding_tranformer_test.go | 18 +- .../google_iam_policy_tranformer_test.go | 14 +- .../iam_policy_attachment_expander.go | 2 +- .../iam_policy_attachment_expander_test.go | 15 +- pkg/middlewares/route53_records.go | 2 +- .../route53_records_id_reconcilier.go | 2 +- .../route53_records_id_reconcilier_test.go | 2 +- pkg/middlewares/route53_records_test.go | 2 +- pkg/middlewares/s3_bucket_acl.go | 2 +- pkg/middlewares/s3_bucket_acl_test.go | 2 +- pkg/middlewares/vpc_security_group_default.go | 2 +- .../vpc_security_group_default_test.go | 2 +- pkg/middlewares/vpc_security_group_rules.go | 2 +- .../vpc_security_group_rules_test.go | 9 +- pkg/resource/aws/aws_alb.go | 3 + pkg/resource/aws/aws_alb_listener.go | 3 + pkg/resource/aws/aws_ami.go | 11 +- pkg/resource/aws/aws_api_gateway_account.go | 3 + pkg/resource/aws/aws_api_gateway_api_key.go | 3 + .../aws/aws_api_gateway_authorizer.go | 3 + .../aws/aws_api_gateway_base_path_mapping.go | 3 + .../aws/aws_api_gateway_deployment.go | 3 + .../aws/aws_api_gateway_domain_name.go | 3 + .../aws/aws_api_gateway_gateway_response.go | 3 + .../aws/aws_api_gateway_integration.go | 3 + .../aws_api_gateway_integration_response.go | 3 + pkg/resource/aws/aws_api_gateway_method.go | 3 + .../aws/aws_api_gateway_method_response.go | 3 + .../aws/aws_api_gateway_method_settings.go | 3 + pkg/resource/aws/aws_api_gateway_model.go | 3 + .../aws/aws_api_gateway_request_validator.go | 3 + pkg/resource/aws/aws_api_gateway_resource.go | 3 + pkg/resource/aws/aws_api_gateway_rest_api.go | 3 + .../aws/aws_api_gateway_rest_api_policy.go | 3 + pkg/resource/aws/aws_api_gateway_stage.go | 3 + pkg/resource/aws/aws_api_gateway_vpc_link.go | 3 + pkg/resource/aws/aws_apigatewayv2_api.go | 3 + .../aws/aws_apigatewayv2_authorizer.go | 3 + .../aws/aws_apigatewayv2_deployment.go | 3 + .../aws/aws_apigatewayv2_domain_name.go | 3 + .../aws/aws_apigatewayv2_integration.go | 3 + .../aws_apigatewayv2_integration_response.go | 3 + pkg/resource/aws/aws_apigatewayv2_mapping.go | 23 ++ pkg/resource/aws/aws_apigatewayv2_model.go | 16 + pkg/resource/aws/aws_apigatewayv2_route.go | 3 + .../aws/aws_apigatewayv2_route_response.go | 3 + pkg/resource/aws/aws_apigatewayv2_stage.go | 3 + pkg/resource/aws/aws_apigatewayv2_vpc_link.go | 3 + pkg/resource/aws/aws_appautoscaling_policy.go | 16 + .../aws_appautoscaling_scheduled_action.go | 3 + pkg/resource/aws/aws_appautoscaling_target.go | 17 +- pkg/resource/aws/aws_cloudformation_stack.go | 10 +- .../aws/aws_cloudfront_distribution.go | 11 +- pkg/resource/aws/aws_db_instance.go | 10 +- pkg/resource/aws/aws_db_subnet_group.go | 10 +- pkg/resource/aws/aws_default_network_acl.go | 11 +- pkg/resource/aws/aws_default_route_table.go | 13 + .../aws/aws_default_security_group.go | 10 +- pkg/resource/aws/aws_default_subnet.go | 10 +- pkg/resource/aws/aws_default_vpc.go | 9 + pkg/resource/aws/aws_dynamodb_table.go | 10 +- .../aws/aws_ebs_encryption_by_default.go | 9 + pkg/resource/aws/aws_ebs_snapshot.go | 10 +- pkg/resource/aws/aws_ebs_volume.go | 10 +- pkg/resource/aws/aws_ecr_repository.go | 10 +- pkg/resource/aws/aws_ecr_repository_policy.go | 3 + pkg/resource/aws/aws_eip.go | 10 +- pkg/resource/aws/aws_eip_association.go | 9 + pkg/resource/aws/aws_elasticache_cluster.go | 3 + pkg/resource/aws/aws_elb.go | 3 + pkg/resource/aws/aws_iam_access_key.go | 19 +- pkg/resource/aws/aws_iam_group.go | 3 + pkg/resource/aws/aws_iam_group_policy.go | 3 + .../aws/aws_iam_group_policy_attachment.go | 3 + pkg/resource/aws/aws_iam_policy.go | 11 +- pkg/resource/aws/aws_iam_policy_attachment.go | 10 +- pkg/resource/aws/aws_iam_role.go | 15 +- pkg/resource/aws/aws_iam_role_policy.go | 14 + .../aws/aws_iam_role_policy_attachment.go | 9 + pkg/resource/aws/aws_iam_user.go | 10 +- pkg/resource/aws/aws_iam_user_policy.go | 14 + .../aws/aws_iam_user_policy_attachment.go | 9 + pkg/resource/aws/aws_instance.go | 17 +- pkg/resource/aws/aws_internet_gateway.go | 9 + pkg/resource/aws/aws_key_pair.go | 10 +- pkg/resource/aws/aws_kms_alias.go | 10 +- pkg/resource/aws/aws_kms_key.go | 11 +- .../aws/aws_lambda_event_source_mapping.go | 21 +- pkg/resource/aws/aws_lambda_function.go | 10 +- pkg/resource/aws/aws_launch_configuration.go | 3 + pkg/resource/aws/aws_launch_template.go | 9 + pkg/resource/aws/aws_lb.go | 13 + pkg/resource/aws/aws_lb_listener.go | 3 + pkg/resource/aws/aws_nat_gateway.go | 9 + pkg/resource/aws/aws_network_acl.go | 9 + pkg/resource/aws/aws_network_acl_rule.go | 58 +++- pkg/resource/aws/aws_rds_cluster.go | 10 +- pkg/resource/aws/aws_rds_cluster_instance.go | 3 + pkg/resource/aws/aws_route.go | 43 ++- pkg/resource/aws/aws_route53_health_check.go | 43 +++ pkg/resource/aws/aws_route53_record.go | 24 +- pkg/resource/aws/aws_route53_zone.go | 18 +- pkg/resource/aws/aws_route_table.go | 13 + .../aws/aws_route_table_association.go | 23 ++ pkg/resource/aws/aws_s3_bucket.go | 15 +- .../aws_s3_bucket_analytics_configuration.go | 9 + pkg/resource/aws/aws_s3_bucket_inventory.go | 9 + pkg/resource/aws/aws_s3_bucket_metric.go | 9 + .../aws/aws_s3_bucket_notification.go | 9 + pkg/resource/aws/aws_s3_bucket_policy.go | 11 +- .../aws/aws_s3_bucket_public_access_block.go | 3 + pkg/resource/aws/aws_security_group.go | 10 +- pkg/resource/aws/aws_security_group_rule.go | 136 ++++++++- pkg/resource/aws/aws_sns_topic.go | 29 +- pkg/resource/aws/aws_sns_topic_policy.go | 11 +- .../aws/aws_sns_topic_subscription.go | 15 +- pkg/resource/aws/aws_sqs_queue.go | 9 + pkg/resource/aws/aws_sqs_queue_policy.go | 11 +- pkg/resource/aws/aws_subnet.go | 10 +- pkg/resource/aws/aws_vpc.go | 9 + .../resource/aws/metadata_test.go | 4 +- pkg/resource/aws/metadatas.go | 25 ++ .../azurerm/azurerm_container_registry.go | 16 + pkg/resource/azurerm/azurerm_firewall.go | 16 + pkg/resource/azurerm/azurerm_image.go | 17 ++ pkg/resource/azurerm/azurerm_lb.go | 16 + pkg/resource/azurerm/azurerm_lb_rule.go | 17 +- .../azurerm/azurerm_network_security_group.go | 18 +- .../azurerm/azurerm_postgresql_database.go | 16 + .../azurerm/azurerm_postgresql_server.go | 16 + .../azurerm/azurerm_private_dns_a_record.go | 21 +- .../azurerm_private_dns_aaaa_record.go | 21 +- .../azurerm_private_dns_cname_record.go | 21 +- .../azurerm/azurerm_private_dns_mx_record.go | 24 +- .../azurerm/azurerm_private_dns_ptr_record.go | 21 +- .../azurerm/azurerm_private_dns_srv_record.go | 21 +- .../azurerm/azurerm_private_dns_txt_record.go | 21 +- .../azurerm/azurerm_private_dns_zone.go | 10 +- pkg/resource/azurerm/azurerm_public_ip.go | 16 + .../azurerm/azurerm_resource_group.go | 16 + pkg/resource/azurerm/azurerm_route.go | 21 ++ pkg/resource/azurerm/azurerm_route_table.go | 16 + .../azurerm/azurerm_ssh_public_key.go | 19 +- .../azurerm/azurerm_storage_account.go | 3 + .../azurerm/azurerm_storage_container.go | 3 + pkg/resource/azurerm/azurerm_subnet.go | 3 + .../azurerm/azurerm_virtual_network.go | 16 + pkg/resource/azurerm/metadata.go | 11 + .../resource/azurerm/metadata_test.go | 4 +- pkg/resource/factory.go | 37 +++ .../github/github_branch_protection.go | 34 ++- pkg/resource/github/github_membership.go | 7 +- pkg/resource/github/github_repository.go | 6 +- pkg/resource/github/github_team.go | 16 +- pkg/resource/github/github_team_membership.go | 7 +- .../resource/github/metadata_test.go | 4 +- .../google/google_bigquery_dataset.go | 15 + pkg/resource/google/google_bigquery_table.go | 13 + .../google/google_bigtable_instance.go | 3 + pkg/resource/google/google_bigtable_table.go | 3 + .../google/google_cloudfunctions_function.go | 3 + .../google/google_cloudrun_service.go | 3 + pkg/resource/google/google_compute_address.go | 14 + pkg/resource/google/google_compute_disk.go | 13 + .../google/google_compute_firewall.go | 6 +- .../google/google_compute_forwarding_rule.go | 3 + .../google/google_compute_global_address.go | 14 + .../google_compute_global_forwarding_rule.go | 3 + .../google/google_compute_health_check.go | 13 + pkg/resource/google/google_compute_image.go | 13 + .../google/google_compute_instance.go | 3 + .../google/google_compute_instance_group.go | 13 +- .../google_compute_instance_group_manager.go | 15 + pkg/resource/google/google_compute_network.go | 6 +- .../google/google_compute_node_group.go | 3 + pkg/resource/google/google_compute_router.go | 3 + .../google/google_compute_subnetwork.go | 14 +- .../google/google_dns_managed_zone.go | 3 + .../google/google_project_iam_binding.go | 3 + .../google/google_project_iam_member.go | 6 +- .../google/google_project_iam_policy.go | 3 + .../google/google_sql_database_instance.go | 3 + pkg/resource/google/google_storage_bucket.go | 6 +- .../google_storage_bucket_iam_binding.go | 3 + .../google_storage_bucket_iam_member.go | 15 +- .../google_storage_bucket_iam_policy.go | 3 + .../resource/google/metadata_test.go | 4 +- pkg/resource/google/metadatas.go | 12 +- pkg/resource/init_metadatas.go | 29 -- .../resource}/mock_ResourceFactory.go | 2 +- pkg/resource/resource_types.go | 273 ++++++++++++++++++ test/test_diff.go | 86 +++++- 450 files changed, 2696 insertions(+), 2952 deletions(-) delete mode 100644 enumeration/resource/aws/metadatas.go delete mode 100644 enumeration/resource/azurerm/metadata.go delete mode 100644 enumeration/resource/github/metadatas.go delete mode 100644 enumeration/resource/google/metadatas.go create mode 100644 pkg/resource/aws/aws_alb.go create mode 100644 pkg/resource/aws/aws_alb_listener.go create mode 100644 pkg/resource/aws/aws_api_gateway_account.go create mode 100644 pkg/resource/aws/aws_api_gateway_api_key.go create mode 100644 pkg/resource/aws/aws_api_gateway_authorizer.go create mode 100644 pkg/resource/aws/aws_api_gateway_base_path_mapping.go create mode 100644 pkg/resource/aws/aws_api_gateway_deployment.go create mode 100644 pkg/resource/aws/aws_api_gateway_domain_name.go create mode 100644 pkg/resource/aws/aws_api_gateway_gateway_response.go create mode 100644 pkg/resource/aws/aws_api_gateway_integration.go create mode 100644 pkg/resource/aws/aws_api_gateway_integration_response.go create mode 100644 pkg/resource/aws/aws_api_gateway_method.go create mode 100644 pkg/resource/aws/aws_api_gateway_method_response.go create mode 100644 pkg/resource/aws/aws_api_gateway_method_settings.go create mode 100644 pkg/resource/aws/aws_api_gateway_model.go create mode 100644 pkg/resource/aws/aws_api_gateway_request_validator.go create mode 100644 pkg/resource/aws/aws_api_gateway_resource.go create mode 100644 pkg/resource/aws/aws_api_gateway_rest_api.go create mode 100644 pkg/resource/aws/aws_api_gateway_rest_api_policy.go create mode 100644 pkg/resource/aws/aws_api_gateway_stage.go create mode 100644 pkg/resource/aws/aws_api_gateway_vpc_link.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_api.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_authorizer.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_deployment.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_domain_name.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_integration.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_integration_response.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_mapping.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_model.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_route.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_route_response.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_stage.go create mode 100644 pkg/resource/aws/aws_apigatewayv2_vpc_link.go create mode 100644 pkg/resource/aws/aws_appautoscaling_policy.go create mode 100644 pkg/resource/aws/aws_appautoscaling_scheduled_action.go create mode 100644 pkg/resource/aws/aws_default_route_table.go create mode 100644 pkg/resource/aws/aws_default_vpc.go create mode 100644 pkg/resource/aws/aws_ebs_encryption_by_default.go create mode 100644 pkg/resource/aws/aws_ecr_repository_policy.go create mode 100644 pkg/resource/aws/aws_eip_association.go create mode 100644 pkg/resource/aws/aws_elasticache_cluster.go create mode 100644 pkg/resource/aws/aws_elb.go create mode 100644 pkg/resource/aws/aws_iam_group.go create mode 100644 pkg/resource/aws/aws_iam_group_policy.go create mode 100644 pkg/resource/aws/aws_iam_group_policy_attachment.go create mode 100644 pkg/resource/aws/aws_iam_role_policy.go create mode 100644 pkg/resource/aws/aws_iam_role_policy_attachment.go create mode 100644 pkg/resource/aws/aws_iam_user_policy.go create mode 100644 pkg/resource/aws/aws_iam_user_policy_attachment.go create mode 100644 pkg/resource/aws/aws_internet_gateway.go create mode 100644 pkg/resource/aws/aws_launch_configuration.go create mode 100644 pkg/resource/aws/aws_launch_template.go create mode 100644 pkg/resource/aws/aws_lb.go create mode 100644 pkg/resource/aws/aws_lb_listener.go create mode 100644 pkg/resource/aws/aws_nat_gateway.go create mode 100644 pkg/resource/aws/aws_network_acl.go create mode 100644 pkg/resource/aws/aws_rds_cluster_instance.go create mode 100644 pkg/resource/aws/aws_route53_health_check.go create mode 100644 pkg/resource/aws/aws_route_table.go create mode 100644 pkg/resource/aws/aws_route_table_association.go create mode 100644 pkg/resource/aws/aws_s3_bucket_analytics_configuration.go create mode 100644 pkg/resource/aws/aws_s3_bucket_inventory.go create mode 100644 pkg/resource/aws/aws_s3_bucket_metric.go create mode 100644 pkg/resource/aws/aws_s3_bucket_notification.go create mode 100644 pkg/resource/aws/aws_s3_bucket_public_access_block.go create mode 100644 pkg/resource/aws/aws_sqs_queue.go create mode 100644 pkg/resource/aws/aws_vpc.go rename {enumeration => pkg}/resource/aws/metadata_test.go (98%) create mode 100644 pkg/resource/azurerm/azurerm_container_registry.go create mode 100644 pkg/resource/azurerm/azurerm_firewall.go create mode 100644 pkg/resource/azurerm/azurerm_image.go create mode 100644 pkg/resource/azurerm/azurerm_lb.go create mode 100644 pkg/resource/azurerm/azurerm_postgresql_database.go create mode 100644 pkg/resource/azurerm/azurerm_postgresql_server.go create mode 100644 pkg/resource/azurerm/azurerm_public_ip.go create mode 100644 pkg/resource/azurerm/azurerm_resource_group.go create mode 100644 pkg/resource/azurerm/azurerm_route.go create mode 100644 pkg/resource/azurerm/azurerm_route_table.go create mode 100644 pkg/resource/azurerm/azurerm_storage_account.go create mode 100644 pkg/resource/azurerm/azurerm_storage_container.go create mode 100644 pkg/resource/azurerm/azurerm_subnet.go create mode 100644 pkg/resource/azurerm/azurerm_virtual_network.go rename {enumeration => pkg}/resource/azurerm/metadata_test.go (94%) create mode 100644 pkg/resource/factory.go rename {enumeration => pkg}/resource/github/metadata_test.go (88%) create mode 100644 pkg/resource/google/google_bigquery_dataset.go create mode 100644 pkg/resource/google/google_bigquery_table.go create mode 100644 pkg/resource/google/google_bigtable_instance.go create mode 100644 pkg/resource/google/google_bigtable_table.go create mode 100644 pkg/resource/google/google_cloudfunctions_function.go create mode 100644 pkg/resource/google/google_cloudrun_service.go create mode 100644 pkg/resource/google/google_compute_address.go create mode 100644 pkg/resource/google/google_compute_disk.go create mode 100644 pkg/resource/google/google_compute_forwarding_rule.go create mode 100644 pkg/resource/google/google_compute_global_address.go create mode 100644 pkg/resource/google/google_compute_global_forwarding_rule.go create mode 100644 pkg/resource/google/google_compute_health_check.go create mode 100644 pkg/resource/google/google_compute_image.go create mode 100644 pkg/resource/google/google_compute_instance.go create mode 100644 pkg/resource/google/google_compute_instance_group_manager.go create mode 100644 pkg/resource/google/google_compute_node_group.go create mode 100644 pkg/resource/google/google_compute_router.go create mode 100644 pkg/resource/google/google_dns_managed_zone.go create mode 100644 pkg/resource/google/google_project_iam_binding.go create mode 100644 pkg/resource/google/google_project_iam_policy.go create mode 100644 pkg/resource/google/google_sql_database_instance.go create mode 100644 pkg/resource/google/google_storage_bucket_iam_binding.go create mode 100644 pkg/resource/google/google_storage_bucket_iam_policy.go rename {enumeration => pkg}/resource/google/metadata_test.go (93%) delete mode 100644 pkg/resource/init_metadatas.go rename {enumeration/terraform => pkg/resource}/mock_ResourceFactory.go (98%) create mode 100644 pkg/resource/resource_types.go diff --git a/enumeration/remote/aws/init.go b/enumeration/remote/aws/init.go index c14a7eddc..ebd808b1d 100644 --- a/enumeration/remote/aws/init.go +++ b/enumeration/remote/aws/init.go @@ -17,13 +17,7 @@ import ( * Required to use Scanner */ -func Init(version string, alerter *alerter.Alerter, - providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common.RemoteLibrary, - progress enumeration.ProgressCounter, - resourceSchemaRepository *resource.SchemaRepository, - factory resource.ResourceFactory, - configDir string) error { +func Init(version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, remoteLibrary *common.RemoteLibrary, progress enumeration.ProgressCounter, factory resource.ResourceFactory, configDir string) error { provider, err := NewAWSTerraformProvider(version, progress, configDir) if err != nil { @@ -248,11 +242,5 @@ func Init(version string, alerter *alerter.Alerter, remoteLibrary.AddEnumerator(NewElastiCacheClusterEnumerator(elasticacheRepository, factory)) - err = resourceSchemaRepository.Init(terraform.AWS, provider.Version(), provider.Schema()) - if err != nil { - return err - } - aws.InitResourcesMetadata(resourceSchemaRepository) - return nil } diff --git a/enumeration/remote/aws_api_gateway_scanner_test.go b/enumeration/remote/aws_api_gateway_scanner_test.go index bc6c1d5d4..9f0d7f2f9 100644 --- a/enumeration/remote/aws_api_gateway_scanner_test.go +++ b/enumeration/remote/aws_api_gateway_scanner_test.go @@ -18,7 +18,6 @@ import ( "github.com/snyk/driftctl/mocks" "github.com/snyk/driftctl/test/remote" - testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -69,10 +68,7 @@ func TestApiGatewayRestApi(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -146,10 +142,7 @@ func TestApiGatewayAccount(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -229,10 +222,7 @@ func TestApiGatewayApiKey(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -330,10 +320,7 @@ func TestApiGatewayAuthorizer(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -427,10 +414,7 @@ func TestApiGatewayStage(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -524,10 +508,7 @@ func TestApiGatewayResource(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -603,10 +584,7 @@ func TestApiGatewayDomainName(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -682,10 +660,7 @@ func TestApiGatewayVpcLink(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -779,10 +754,7 @@ func TestApiGatewayRequestValidator(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -865,10 +837,7 @@ func TestApiGatewayRestApiPolicy(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -962,10 +931,7 @@ func TestApiGatewayBasePathMapping(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1067,10 +1033,7 @@ func TestApiGatewayMethod(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1164,10 +1127,7 @@ func TestApiGatewayModel(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1273,10 +1233,7 @@ func TestApiGatewayMethodResponse(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1370,10 +1327,7 @@ func TestApiGatewayGatewayResponse(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1475,10 +1429,7 @@ func TestApiGatewayMethodSettings(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1580,10 +1531,7 @@ func TestApiGatewayIntegration(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1689,10 +1637,7 @@ func TestApiGatewayIntegrationResponse(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_apigatewayv2_scanner_test.go b/enumeration/remote/aws_apigatewayv2_scanner_test.go index dc86cede1..5b6570fa6 100644 --- a/enumeration/remote/aws_apigatewayv2_scanner_test.go +++ b/enumeration/remote/aws_apigatewayv2_scanner_test.go @@ -19,7 +19,6 @@ import ( resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -66,10 +65,7 @@ func TestApiGatewayV2Api(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -155,10 +151,7 @@ func TestApiGatewayV2Route(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -264,10 +257,7 @@ func TestApiGatewayV2Deployment(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -343,10 +333,7 @@ func TestApiGatewayV2VpcLink(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -445,10 +432,7 @@ func TestApiGatewayV2Authorizer(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -553,10 +537,7 @@ func TestApiGatewayV2Integration(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -664,10 +645,7 @@ func TestApiGatewayV2Model(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -747,10 +725,7 @@ func TestApiGatewayV2Stage(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -868,10 +843,7 @@ func TestApiGatewayV2RouteResponse(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -993,10 +965,7 @@ func TestApiGatewayV2Mapping(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1072,10 +1041,7 @@ func TestApiGatewayV2DomainName(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1193,10 +1159,7 @@ func TestApiGatewayV2IntegrationResponse(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_applicationautoscaling_scanner_test.go b/enumeration/remote/aws_applicationautoscaling_scanner_test.go index 8fea7dfe8..57e325c36 100644 --- a/enumeration/remote/aws_applicationautoscaling_scanner_test.go +++ b/enumeration/remote/aws_applicationautoscaling_scanner_test.go @@ -21,7 +21,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -67,9 +66,7 @@ func TestAppAutoScalingTarget(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -170,9 +167,7 @@ func TestAppAutoScalingPolicy(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -290,10 +285,7 @@ func TestAppAutoScalingScheduledAction(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_autoscaling_scanner_test.go b/enumeration/remote/aws_autoscaling_scanner_test.go index eb66ba726..7e7f3cded 100644 --- a/enumeration/remote/aws_autoscaling_scanner_test.go +++ b/enumeration/remote/aws_autoscaling_scanner_test.go @@ -19,7 +19,6 @@ import ( resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -73,9 +72,7 @@ func TestAutoscaling_LaunchConfiguration(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_cloudformation_scanner_test.go b/enumeration/remote/aws_cloudformation_scanner_test.go index 4fd7ba82c..7aa504b85 100644 --- a/enumeration/remote/aws_cloudformation_scanner_test.go +++ b/enumeration/remote/aws_cloudformation_scanner_test.go @@ -23,7 +23,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -66,9 +65,7 @@ func TestCloudformationStack(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/aws_cloudfront_scanner_test.go b/enumeration/remote/aws_cloudfront_scanner_test.go index 84a2731b4..e708d3c7c 100644 --- a/enumeration/remote/aws_cloudfront_scanner_test.go +++ b/enumeration/remote/aws_cloudfront_scanner_test.go @@ -23,7 +23,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -65,9 +64,7 @@ func TestCloudfrontDistribution(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/aws_dynamodb_scanner_test.go b/enumeration/remote/aws_dynamodb_scanner_test.go index 454c1fbb9..7858d57e2 100644 --- a/enumeration/remote/aws_dynamodb_scanner_test.go +++ b/enumeration/remote/aws_dynamodb_scanner_test.go @@ -22,7 +22,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -67,9 +66,7 @@ func TestDynamoDBTable(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/aws_ec2_scanner_test.go b/enumeration/remote/aws_ec2_scanner_test.go index 426d09514..ba530babe 100644 --- a/enumeration/remote/aws_ec2_scanner_test.go +++ b/enumeration/remote/aws_ec2_scanner_test.go @@ -23,7 +23,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -66,9 +65,7 @@ func TestEC2EbsVolume(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -163,9 +160,7 @@ func TestEC2EbsSnapshot(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -262,9 +257,7 @@ func TestEC2Eip(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -315,7 +308,7 @@ func TestEC2Eip(t *testing.T) { if err != nil { return } - test.TestAgainstGoldenFile(got, resourceaws.AwsEipResourceType, c.dirName, provider, deserializer, shouldUpdate, tt) + test.TestAgainstGoldenFileNoCty(got, resourceaws.AwsEipResourceType, c.dirName, provider, deserializer, shouldUpdate, tt) alerter.AssertExpectations(tt) fakeRepo.AssertExpectations(tt) }) @@ -359,9 +352,7 @@ func TestEC2Ami(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -456,9 +447,7 @@ func TestEC2KeyPair(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -555,9 +544,7 @@ func TestEC2EipAssociation(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -662,9 +649,7 @@ func TestEC2Instance(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -759,9 +744,7 @@ func TestEC2InternetGateway(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -873,9 +856,7 @@ func TestVPC(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -984,9 +965,7 @@ func TestDefaultVPC(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1150,9 +1129,7 @@ func TestEC2RouteTableAssociation(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1270,9 +1247,7 @@ func TestEC2Subnet(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1390,9 +1365,7 @@ func TestEC2DefaultSubnet(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1497,9 +1470,7 @@ func TestEC2RouteTable(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1604,9 +1575,7 @@ func TestEC2DefaultRouteTable(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1711,9 +1680,7 @@ func TestVpcSecurityGroup(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1818,9 +1785,7 @@ func TestVpcDefaultSecurityGroup(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1914,9 +1879,7 @@ func TestEC2NatGateway(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2032,9 +1995,7 @@ func TestEC2NetworkACL(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2185,10 +2146,7 @@ func TestEC2NetworkACLRule(t *testing.T) { }, } - version := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", version) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2205,8 +2163,7 @@ func TestEC2NetworkACLRule(t *testing.T) { c.mocks(fakeRepo, alerter) var repo repository.EC2Repository = fakeRepo - providerVersion := version - realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestAwsProvider(providerLibrary, "3.19.0") if err != nil { t.Fatal(err) } @@ -2299,9 +2256,7 @@ func TestEC2DefaultNetworkACL(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2468,9 +2423,7 @@ func TestEC2Route(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2659,9 +2612,7 @@ func TestVpcSecurityGroupRule(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2758,9 +2709,7 @@ func TestEC2LaunchTemplate(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -2846,9 +2795,7 @@ func TestEC2EbsEncryptionByDefault(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/aws_ecr_scanner_test.go b/enumeration/remote/aws_ecr_scanner_test.go index 60fd9f534..810c92f92 100644 --- a/enumeration/remote/aws_ecr_scanner_test.go +++ b/enumeration/remote/aws_ecr_scanner_test.go @@ -23,7 +23,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -68,9 +67,7 @@ func TestECRRepository(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -161,10 +158,7 @@ func TestECRRepositoryPolicy(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_elasticache_scanner_test.go b/enumeration/remote/aws_elasticache_scanner_test.go index 05e3a14a0..4bd44bf30 100644 --- a/enumeration/remote/aws_elasticache_scanner_test.go +++ b/enumeration/remote/aws_elasticache_scanner_test.go @@ -19,7 +19,6 @@ import ( resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -78,10 +77,7 @@ func TestElastiCacheCluster(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_elb_scanner_test.go b/enumeration/remote/aws_elb_scanner_test.go index b0243705a..299a6fbe0 100644 --- a/enumeration/remote/aws_elb_scanner_test.go +++ b/enumeration/remote/aws_elb_scanner_test.go @@ -19,7 +19,6 @@ import ( resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -81,9 +80,7 @@ func TestELB_LoadBalancer(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_elbv2_scanner_test.go b/enumeration/remote/aws_elbv2_scanner_test.go index c16e79ecc..79424ccd7 100644 --- a/enumeration/remote/aws_elbv2_scanner_test.go +++ b/enumeration/remote/aws_elbv2_scanner_test.go @@ -19,7 +19,6 @@ import ( resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -82,9 +81,7 @@ func TestELBV2_LoadBalancer(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -210,9 +207,7 @@ func TestELBV2_LoadBalancerListener(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_iam_scanner_test.go b/enumeration/remote/aws_iam_scanner_test.go index 07a9e22cd..35a3ea9a8 100644 --- a/enumeration/remote/aws_iam_scanner_test.go +++ b/enumeration/remote/aws_iam_scanner_test.go @@ -23,7 +23,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -75,9 +74,8 @@ func TestIamUser(t *testing.T) { wantErr: nil, }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -214,9 +212,8 @@ func TestIamUserPolicy(t *testing.T) { wantErr: nil, }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -321,9 +318,7 @@ func TestIamPolicy(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -441,9 +436,7 @@ func TestIamRole(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -624,9 +617,7 @@ func TestIamRolePolicyAttachment(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -762,9 +753,7 @@ func TestIamAccessKey(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -975,9 +964,7 @@ func TestIamUserPolicyAttachment(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -1106,9 +1093,7 @@ func TestIamRolePolicy(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -1207,10 +1192,7 @@ func TestIamGroupPolicy(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1284,10 +1266,7 @@ func TestIamGroup(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/aws_kms_scanner_test.go b/enumeration/remote/aws_kms_scanner_test.go index fa0bf8e2b..8a00d19fe 100644 --- a/enumeration/remote/aws_kms_scanner_test.go +++ b/enumeration/remote/aws_kms_scanner_test.go @@ -23,7 +23,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -67,9 +66,7 @@ func TestKMSKey(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -165,9 +162,7 @@ func TestKMSAlias(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/aws_lambda_scanner_test.go b/enumeration/remote/aws_lambda_scanner_test.go index 89fea5adb..808d0fa23 100644 --- a/enumeration/remote/aws_lambda_scanner_test.go +++ b/enumeration/remote/aws_lambda_scanner_test.go @@ -19,7 +19,6 @@ import ( "github.com/pkg/errors" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" @@ -87,9 +86,7 @@ func TestScanLambdaFunction(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -140,7 +137,7 @@ func TestScanLambdaFunction(t *testing.T) { if err != nil { return } - test.TestAgainstGoldenFile(got, resourceaws.AwsLambdaFunctionResourceType, c.dirName, provider, deserializer, shouldUpdate, tt) + test.TestAgainstGoldenFileNoCty(got, resourceaws.AwsLambdaFunctionResourceType, c.dirName, provider, deserializer, shouldUpdate, tt) alerter.AssertExpectations(tt) fakeRepo.AssertExpectations(tt) }) @@ -203,9 +200,7 @@ func TestScanLambdaEventSourceMapping(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/aws_rds_scanner_test.go b/enumeration/remote/aws_rds_scanner_test.go index 64eeb627e..e8c9c528a 100644 --- a/enumeration/remote/aws_rds_scanner_test.go +++ b/enumeration/remote/aws_rds_scanner_test.go @@ -23,7 +23,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -75,9 +74,7 @@ func TestRDSDBInstance(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -128,7 +125,7 @@ func TestRDSDBInstance(t *testing.T) { if err != nil { return } - test.TestAgainstGoldenFile(got, resourceaws.AwsDbInstanceResourceType, c.dirName, provider, deserializer, shouldUpdate, tt) + test.TestAgainstGoldenFileNoCty(got, resourceaws.AwsDbInstanceResourceType, c.dirName, provider, deserializer, shouldUpdate, tt) alerter.AssertExpectations(tt) fakeRepo.AssertExpectations(tt) }) @@ -172,9 +169,7 @@ func TestRDSDBSubnetGroup(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -274,9 +269,7 @@ func TestRDSCluster(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/aws_route53_scanner_test.go b/enumeration/remote/aws_route53_scanner_test.go index e7354dff4..af405cecc 100644 --- a/enumeration/remote/aws_route53_scanner_test.go +++ b/enumeration/remote/aws_route53_scanner_test.go @@ -18,7 +18,6 @@ import ( "github.com/pkg/errors" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" @@ -70,9 +69,7 @@ func TestRoute53_HealthCheck(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -205,9 +202,7 @@ func TestRoute53_Zone(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -415,9 +410,7 @@ func TestRoute53_Record(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/aws_s3_scanner_test.go b/enumeration/remote/aws_s3_scanner_test.go index 114543982..691dad472 100644 --- a/enumeration/remote/aws_s3_scanner_test.go +++ b/enumeration/remote/aws_s3_scanner_test.go @@ -21,7 +21,6 @@ import ( "github.com/pkg/errors" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" @@ -89,9 +88,7 @@ func TestS3Bucket(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -249,9 +246,7 @@ func TestS3BucketInventory(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -435,9 +430,7 @@ func TestS3BucketNotification(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -596,9 +589,7 @@ func TestS3BucketMetrics(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -754,9 +745,7 @@ func TestS3BucketPolicy(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -880,10 +869,7 @@ func TestS3BucketPublicAccessBlock(t *testing.T) { }, } - providerVersion := "3.19.0" - schemaRepository := testresource.InitFakeSchemaRepository("aws", providerVersion) - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -1021,9 +1007,7 @@ func TestS3BucketAnalytic(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/aws_sns_scanner_test.go b/enumeration/remote/aws_sns_scanner_test.go index 67c0d0522..5943eec5a 100644 --- a/enumeration/remote/aws_sns_scanner_test.go +++ b/enumeration/remote/aws_sns_scanner_test.go @@ -19,7 +19,6 @@ import ( "github.com/pkg/errors" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" @@ -72,9 +71,7 @@ func TestScanSNSTopic(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -172,9 +169,7 @@ func TestSNSTopicPolicyScan(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -289,9 +284,7 @@ func TestSNSTopicSubscriptionScan(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { diff --git a/enumeration/remote/aws_sqs_scanner_test.go b/enumeration/remote/aws_sqs_scanner_test.go index 0fed8535b..3d9cda288 100644 --- a/enumeration/remote/aws_sqs_scanner_test.go +++ b/enumeration/remote/aws_sqs_scanner_test.go @@ -23,7 +23,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -68,9 +67,7 @@ func TestSQSQueue(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -195,9 +192,7 @@ func TestSQSQueuePolicy(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - resourceaws.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { diff --git a/enumeration/remote/azurerm/init.go b/enumeration/remote/azurerm/init.go index e42344a80..d6b274fbe 100644 --- a/enumeration/remote/azurerm/init.go +++ b/enumeration/remote/azurerm/init.go @@ -13,15 +13,7 @@ import ( "github.com/snyk/driftctl/enumeration/terraform" ) -func Init( - version string, - alerter *alerter.Alerter, - providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common.RemoteLibrary, - progress enumeration.ProgressCounter, - resourceSchemaRepository *resource.SchemaRepository, - factory resource.ResourceFactory, - configDir string) error { +func Init(version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, remoteLibrary *common.RemoteLibrary, progress enumeration.ProgressCounter, factory resource.ResourceFactory, configDir string) error { provider, err := NewAzureTerraformProvider(version, progress, configDir) if err != nil { @@ -95,11 +87,5 @@ func Init( remoteLibrary.AddEnumerator(NewAzurermSSHPublicKeyEnumerator(computeRepo, factory)) remoteLibrary.AddDetailsFetcher(azurerm.AzureSSHPublicKeyResourceType, common.NewGenericDetailsFetcher(azurerm.AzureSSHPublicKeyResourceType, provider, deserializer)) - err = resourceSchemaRepository.Init(terraform.AZURE, provider.Version(), provider.Schema()) - if err != nil { - return err - } - azurerm.InitResourcesMetadata(resourceSchemaRepository) - return nil } diff --git a/enumeration/remote/azurerm_compute_scanner_test.go b/enumeration/remote/azurerm_compute_scanner_test.go index 55a67355b..4e37a9e3b 100644 --- a/enumeration/remote/azurerm_compute_scanner_test.go +++ b/enumeration/remote/azurerm_compute_scanner_test.go @@ -22,7 +22,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -90,10 +89,7 @@ func TestAzurermCompute_Image(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -171,10 +167,7 @@ func TestAzurermCompute_SSHPublicKey(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/azurerm_containerregistry_scanner_test.go b/enumeration/remote/azurerm_containerregistry_scanner_test.go index 06fbaadf9..b62f2f9d7 100644 --- a/enumeration/remote/azurerm_containerregistry_scanner_test.go +++ b/enumeration/remote/azurerm_containerregistry_scanner_test.go @@ -17,7 +17,6 @@ import ( resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -76,10 +75,7 @@ func TestAzurermContainerRegistry(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/azurerm_network_scanner_test.go b/enumeration/remote/azurerm_network_scanner_test.go index 3c74afee2..24240746d 100644 --- a/enumeration/remote/azurerm_network_scanner_test.go +++ b/enumeration/remote/azurerm_network_scanner_test.go @@ -22,7 +22,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -84,10 +83,7 @@ func TestAzurermVirtualNetwork(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -177,10 +173,7 @@ func TestAzurermRouteTables(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -326,10 +319,7 @@ func TestAzurermRoutes(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -459,10 +449,7 @@ func TestAzurermSubnets(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -552,10 +539,7 @@ func TestAzurermFirewalls(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -645,10 +629,7 @@ func TestAzurermPublicIP(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -729,10 +710,7 @@ func TestAzurermSecurityGroups(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -848,10 +826,7 @@ func TestAzurermLoadBalancers(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -950,10 +925,7 @@ func TestAzurermLoadBalancerRules(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/azurerm_postgresql_scanner_test.go b/enumeration/remote/azurerm_postgresql_scanner_test.go index 7a6b57143..ed54f6d95 100644 --- a/enumeration/remote/azurerm_postgresql_scanner_test.go +++ b/enumeration/remote/azurerm_postgresql_scanner_test.go @@ -17,7 +17,6 @@ import ( resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -82,10 +81,7 @@ func TestAzurermPostgresqlServer(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -208,10 +204,7 @@ func TestAzurermPostgresqlDatabase(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/azurerm_privatedns_scanner_test.go b/enumeration/remote/azurerm_privatedns_scanner_test.go index f6da66cad..a88da35cd 100644 --- a/enumeration/remote/azurerm_privatedns_scanner_test.go +++ b/enumeration/remote/azurerm_privatedns_scanner_test.go @@ -22,7 +22,7 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" + terraformtest "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -87,10 +87,7 @@ func TestAzurermPrivateDNSZone(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -241,10 +238,7 @@ func TestAzurermPrivateDNSARecord(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -396,10 +390,7 @@ func TestAzurermPrivateDNSAAAARecord(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -539,10 +530,7 @@ func TestAzurermPrivateDNSCNAMERecord(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -693,10 +681,7 @@ func TestAzurermPrivateDNSPTRRecord(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -848,10 +833,7 @@ func TestAzurermPrivateDNSMXRecord(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1002,10 +984,7 @@ func TestAzurermPrivateDNSSRVRecord(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { @@ -1156,10 +1135,7 @@ func TestAzurermPrivateDNSTXTRecord(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/azurerm_resources_scanner_test.go b/enumeration/remote/azurerm_resources_scanner_test.go index edf1c6327..eeddbcf15 100644 --- a/enumeration/remote/azurerm_resources_scanner_test.go +++ b/enumeration/remote/azurerm_resources_scanner_test.go @@ -17,7 +17,6 @@ import ( resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -74,10 +73,7 @@ func TestAzurermResourceGroups(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/azurerm_storage_scanner_test.go b/enumeration/remote/azurerm_storage_scanner_test.go index 588f65f4d..a4da45e58 100644 --- a/enumeration/remote/azurerm_storage_scanner_test.go +++ b/enumeration/remote/azurerm_storage_scanner_test.go @@ -16,7 +16,6 @@ import ( resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" ) @@ -79,10 +78,7 @@ func TestAzurermStorageAccount(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { @@ -224,10 +220,7 @@ func TestAzurermStorageContainer(t *testing.T) { }, } - providerVersion := "2.71.0" - schemaRepository := testresource.InitFakeSchemaRepository("azurerm", providerVersion) - resourceazure.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range tests { t.Run(c.test, func(tt *testing.T) { diff --git a/enumeration/remote/github/init.go b/enumeration/remote/github/init.go index c2b016e2d..61cc322b5 100644 --- a/enumeration/remote/github/init.go +++ b/enumeration/remote/github/init.go @@ -15,13 +15,7 @@ import ( * Required to use Scanner */ -func Init(version string, alerter *alerter.Alerter, - providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common.RemoteLibrary, - progress enumeration.ProgressCounter, - resourceSchemaRepository *resource.SchemaRepository, - factory resource.ResourceFactory, - configDir string) error { +func Init(version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, remoteLibrary *common.RemoteLibrary, progress enumeration.ProgressCounter, factory resource.ResourceFactory, configDir string) error { provider, err := NewGithubTerraformProvider(version, progress, configDir) if err != nil { @@ -53,11 +47,5 @@ func Init(version string, alerter *alerter.Alerter, remoteLibrary.AddEnumerator(NewGithubBranchProtectionEnumerator(repository, factory)) remoteLibrary.AddDetailsFetcher(github.GithubBranchProtectionResourceType, common.NewGenericDetailsFetcher(github.GithubBranchProtectionResourceType, provider, deserializer)) - err = resourceSchemaRepository.Init(terraform.GITHUB, provider.Version(), provider.Schema()) - if err != nil { - return err - } - github.InitResourcesMetadata(resourceSchemaRepository) - return nil } diff --git a/enumeration/remote/github_branch_protection_scanner_test.go b/enumeration/remote/github_branch_protection_scanner_test.go index 1fa3c7388..3242865d7 100644 --- a/enumeration/remote/github_branch_protection_scanner_test.go +++ b/enumeration/remote/github_branch_protection_scanner_test.go @@ -15,7 +15,6 @@ import ( githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" tftest "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" @@ -68,9 +67,7 @@ func TestScanGithubBranchProtection(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") - githubres.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { diff --git a/enumeration/remote/github_membership_scanner_test.go b/enumeration/remote/github_membership_scanner_test.go index 7cfcb5239..9a4d28433 100644 --- a/enumeration/remote/github_membership_scanner_test.go +++ b/enumeration/remote/github_membership_scanner_test.go @@ -15,7 +15,6 @@ import ( githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" tftest "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" @@ -64,9 +63,7 @@ func TestScanGithubMembership(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") - githubres.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { diff --git a/enumeration/remote/github_repository_scanner_test.go b/enumeration/remote/github_repository_scanner_test.go index ad93d598b..76e5aea4e 100644 --- a/enumeration/remote/github_repository_scanner_test.go +++ b/enumeration/remote/github_repository_scanner_test.go @@ -15,7 +15,6 @@ import ( githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" tftest "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" @@ -64,9 +63,7 @@ func TestScanGithubRepository(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") - githubres.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/github_team_membership_scanner_test.go b/enumeration/remote/github_team_membership_scanner_test.go index a3cc733eb..37de03c24 100644 --- a/enumeration/remote/github_team_membership_scanner_test.go +++ b/enumeration/remote/github_team_membership_scanner_test.go @@ -15,7 +15,6 @@ import ( githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" tftest "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" @@ -64,9 +63,7 @@ func TestScanGithubTeamMembership(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") - githubres.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { diff --git a/enumeration/remote/github_team_scanner_test.go b/enumeration/remote/github_team_scanner_test.go index 958e6c890..249722b88 100644 --- a/enumeration/remote/github_team_scanner_test.go +++ b/enumeration/remote/github_team_scanner_test.go @@ -15,7 +15,6 @@ import ( githubres "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/mocks" - testresource "github.com/snyk/driftctl/test/resource" tftest "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/mock" @@ -65,9 +64,7 @@ func TestScanGithubTeam(t *testing.T) { }, } - schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") - githubres.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range tests { diff --git a/enumeration/remote/google/init.go b/enumeration/remote/google/init.go index 0bb89a3e3..2e14cfff9 100644 --- a/enumeration/remote/google/init.go +++ b/enumeration/remote/google/init.go @@ -18,13 +18,7 @@ import ( "google.golang.org/api/cloudresourcemanager/v1" ) -func Init(version string, alerter *alerter.Alerter, - providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common.RemoteLibrary, - progress enumeration.ProgressCounter, - resourceSchemaRepository *resource.SchemaRepository, - factory resource.ResourceFactory, - configDir string) error { +func Init(version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, remoteLibrary *common.RemoteLibrary, progress enumeration.ProgressCounter, factory resource.ResourceFactory, configDir string) error { provider, err := NewGCPTerraformProvider(version, progress, configDir) if err != nil { @@ -111,11 +105,5 @@ func Init(version string, alerter *alerter.Alerter, remoteLibrary.AddEnumerator(NewGoogleComputeInstanceGroupManagerEnumerator(assetRepository, factory)) remoteLibrary.AddEnumerator(NewGoogleComputeGlobalForwardingRuleEnumerator(assetRepository, factory)) - err = resourceSchemaRepository.Init(terraform.GOOGLE, provider.Version(), provider.Schema()) - if err != nil { - return err - } - google.InitResourcesMetadata(resourceSchemaRepository) - return nil } diff --git a/enumeration/remote/google_bigquery_scanner_test.go b/enumeration/remote/google_bigquery_scanner_test.go index b43a0e826..1cc44d3c1 100644 --- a/enumeration/remote/google_bigquery_scanner_test.go +++ b/enumeration/remote/google_bigquery_scanner_test.go @@ -13,11 +13,10 @@ import ( "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/resource" - googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" testgoogle "github.com/snyk/driftctl/test/google" - testresource "github.com/snyk/driftctl/test/resource" + terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -80,10 +79,7 @@ func TestGoogleBigqueryDataset(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -102,7 +98,7 @@ func TestGoogleBigqueryDataset(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -183,10 +179,7 @@ func TestGoogleBigqueryTable(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -205,7 +198,7 @@ func TestGoogleBigqueryTable(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } diff --git a/enumeration/remote/google_bigtable_scanner_test.go b/enumeration/remote/google_bigtable_scanner_test.go index cf4daa63e..ebbd84c7e 100644 --- a/enumeration/remote/google_bigtable_scanner_test.go +++ b/enumeration/remote/google_bigtable_scanner_test.go @@ -13,11 +13,10 @@ import ( "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/resource" - googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" testgoogle "github.com/snyk/driftctl/test/google" - testresource "github.com/snyk/driftctl/test/resource" + terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -117,10 +116,7 @@ func TestGoogleBigtableInstance(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -139,7 +135,7 @@ func TestGoogleBigtableInstance(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -243,10 +239,7 @@ func TestGoogleBigtableTable(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -265,7 +258,7 @@ func TestGoogleBigtableTable(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } diff --git a/enumeration/remote/google_cloudfunctions_scanner_test.go b/enumeration/remote/google_cloudfunctions_scanner_test.go index 4e9cb9bc8..0dd531457 100644 --- a/enumeration/remote/google_cloudfunctions_scanner_test.go +++ b/enumeration/remote/google_cloudfunctions_scanner_test.go @@ -13,11 +13,10 @@ import ( "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/resource" - googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" testgoogle "github.com/snyk/driftctl/test/google" - testresource "github.com/snyk/driftctl/test/resource" + terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -104,10 +103,7 @@ func TestGoogleCloudFunctionsFunction(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -126,7 +122,7 @@ func TestGoogleCloudFunctionsFunction(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } diff --git a/enumeration/remote/google_cloudrun_scanner_test.go b/enumeration/remote/google_cloudrun_scanner_test.go index 84afa4f1f..37726a807 100644 --- a/enumeration/remote/google_cloudrun_scanner_test.go +++ b/enumeration/remote/google_cloudrun_scanner_test.go @@ -17,7 +17,7 @@ import ( "github.com/snyk/driftctl/mocks" testgoogle "github.com/snyk/driftctl/test/google" - testresource "github.com/snyk/driftctl/test/resource" + terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -99,10 +99,7 @@ func TestGoogleCloudRunService(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -121,7 +118,7 @@ func TestGoogleCloudRunService(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } diff --git a/enumeration/remote/google_compute_scanner_test.go b/enumeration/remote/google_compute_scanner_test.go index ff3e01dfe..449b9e60b 100644 --- a/enumeration/remote/google_compute_scanner_test.go +++ b/enumeration/remote/google_compute_scanner_test.go @@ -3,6 +3,8 @@ package remote import ( "testing" + resource2 "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/enumeration" "github.com/snyk/driftctl/enumeration/remote/alerts" "github.com/snyk/driftctl/enumeration/remote/cache" @@ -19,7 +21,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testgoogle "github.com/snyk/driftctl/test/google" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -89,11 +90,8 @@ func TestGoogleComputeFirewall(t *testing.T) { }, } - providerVersion := "3.78.0" resType := resource.ResourceType(googleresource.GoogleComputeFirewallResourceType) - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -115,7 +113,7 @@ func TestGoogleComputeFirewall(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -227,10 +225,7 @@ func TestGoogleComputeRouter(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -249,7 +244,7 @@ func TestGoogleComputeRouter(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -331,10 +326,7 @@ func TestGoogleComputeInstance(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -353,7 +345,7 @@ func TestGoogleComputeInstance(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -440,11 +432,8 @@ func TestGoogleComputeNetwork(t *testing.T) { }, } - providerVersion := "3.78.0" resType := resource.ResourceType(googleresource.GoogleComputeNetworkResourceType) - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -466,7 +455,7 @@ func TestGoogleComputeNetwork(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -562,11 +551,8 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { }, } - providerVersion := "3.78.0" - resType := resource.ResourceType(googleresource.GoogleComputeInstanceGroupResourceType) - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + resType := resource2.ResourceType(googleresource.GoogleComputeInstanceGroupResourceType) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -588,7 +574,7 @@ func TestGoogleComputeInstanceGroup(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -698,10 +684,7 @@ func TestGoogleComputeAddress(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -720,7 +703,7 @@ func TestGoogleComputeAddress(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -824,10 +807,7 @@ func TestGoogleComputeGlobalAddress(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -846,7 +826,7 @@ func TestGoogleComputeGlobalAddress(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -933,11 +913,8 @@ func TestGoogleComputeSubnetwork(t *testing.T) { }, } - providerVersion := "3.78.0" resType := resource.ResourceType(googleresource.GoogleComputeSubnetworkResourceType) - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -959,7 +936,7 @@ func TestGoogleComputeSubnetwork(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -1057,10 +1034,7 @@ func TestGoogleComputeDisk(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -1079,7 +1053,7 @@ func TestGoogleComputeDisk(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -1167,10 +1141,7 @@ func TestGoogleComputeImage(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -1189,7 +1160,7 @@ func TestGoogleComputeImage(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -1277,10 +1248,7 @@ func TestGoogleComputeHealthCheck(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -1299,7 +1267,7 @@ func TestGoogleComputeHealthCheck(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -1387,10 +1355,7 @@ func TestGoogleComputeNodeGroup(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -1409,7 +1374,7 @@ func TestGoogleComputeNodeGroup(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -1496,10 +1461,7 @@ func TestGoogleComputeForwardingRule(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -1518,7 +1480,7 @@ func TestGoogleComputeForwardingRule(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -1606,10 +1568,7 @@ func TestGoogleComputeInstanceGroupManager(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -1628,7 +1587,7 @@ func TestGoogleComputeInstanceGroupManager(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -1715,10 +1674,7 @@ func TestGoogleComputeGlobalForwardingRule(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -1737,7 +1693,7 @@ func TestGoogleComputeGlobalForwardingRule(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } diff --git a/enumeration/remote/google_network_scanner_test.go b/enumeration/remote/google_network_scanner_test.go index 338290198..a6798a830 100644 --- a/enumeration/remote/google_network_scanner_test.go +++ b/enumeration/remote/google_network_scanner_test.go @@ -17,7 +17,7 @@ import ( "github.com/snyk/driftctl/mocks" testgoogle "github.com/snyk/driftctl/test/google" - testresource "github.com/snyk/driftctl/test/resource" + terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -105,10 +105,7 @@ func TestGoogleDNSNanagedZone(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -127,7 +124,7 @@ func TestGoogleDNSNanagedZone(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } diff --git a/enumeration/remote/google_project_scanner_test.go b/enumeration/remote/google_project_scanner_test.go index a28f9acfe..8880300fc 100644 --- a/enumeration/remote/google_project_scanner_test.go +++ b/enumeration/remote/google_project_scanner_test.go @@ -18,7 +18,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -87,11 +86,8 @@ func TestGoogleProjectIAMMember(t *testing.T) { }, } - providerVersion := "3.78.0" resType := resource.ResourceType(googleresource.GoogleProjectIamMemberResourceType) - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -109,7 +105,7 @@ func TestGoogleProjectIAMMember(t *testing.T) { c.setupAlerterMock(alerter) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -134,7 +130,7 @@ func TestGoogleProjectIAMMember(t *testing.T) { } alerter.AssertExpectations(tt) testFilter.AssertExpectations(tt) - test.TestAgainstGoldenFile(got, resType.String(), c.dirName, provider, deserializer, shouldUpdate, tt) + test.TestAgainstGoldenFileNoCty(got, resType.String(), c.dirName, provider, deserializer, shouldUpdate, tt) }) } } diff --git a/enumeration/remote/google_sql_scanner_test.go b/enumeration/remote/google_sql_scanner_test.go index 66167ed49..2b61ac4e0 100644 --- a/enumeration/remote/google_sql_scanner_test.go +++ b/enumeration/remote/google_sql_scanner_test.go @@ -13,11 +13,10 @@ import ( "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/resource" - googleresource "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/mocks" testgoogle "github.com/snyk/driftctl/test/google" - testresource "github.com/snyk/driftctl/test/resource" + terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -102,10 +101,7 @@ func TestGoogleSQLDatabaseInstance(t *testing.T) { }, } - providerVersion := "3.78.0" - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() for _, c := range cases { t.Run(c.test, func(tt *testing.T) { @@ -124,7 +120,7 @@ func TestGoogleSQLDatabaseInstance(t *testing.T) { tt.Fatal(err) } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } diff --git a/enumeration/remote/google_storage_scanner_test.go b/enumeration/remote/google_storage_scanner_test.go index d1277199e..e2e174fcd 100644 --- a/enumeration/remote/google_storage_scanner_test.go +++ b/enumeration/remote/google_storage_scanner_test.go @@ -23,7 +23,6 @@ import ( "github.com/snyk/driftctl/test" "github.com/snyk/driftctl/test/goldenfile" testgoogle "github.com/snyk/driftctl/test/google" - testresource "github.com/snyk/driftctl/test/resource" terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" @@ -89,11 +88,8 @@ func TestGoogleStorageBucket(t *testing.T) { }, } - providerVersion := "3.78.0" resType := resource.ResourceType(googleresource.GoogleStorageBucketResourceType) - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -119,7 +115,7 @@ func TestGoogleStorageBucket(t *testing.T) { } } - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -263,11 +259,8 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { }, } - providerVersion := "3.78.0" resType := resource.ResourceType(googleresource.GoogleStorageBucketIamMemberResourceType) - schemaRepository := testresource.InitFakeSchemaRepository("google", providerVersion) - googleresource.InitResourcesMetadata(schemaRepository) - factory := terraform.NewTerraformResourceFactory(schemaRepository) + factory := terraform.NewTerraformResourceFactory() deserializer := resource.NewDeserializer(factory) for _, c := range cases { @@ -305,7 +298,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { } var assetRepository repository.AssetRepository = assetRepo - realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, providerVersion) + realProvider, err := terraform2.InitTestGoogleProvider(providerLibrary, "3.78.0") if err != nil { tt.Fatal(err) } @@ -325,7 +318,7 @@ func TestGoogleStorageBucketIAMMember(t *testing.T) { } alerter.AssertExpectations(tt) testFilter.AssertExpectations(tt) - test.TestAgainstGoldenFile(got, resType.String(), c.dirName, provider, deserializer, shouldUpdate, tt) + test.TestAgainstGoldenFileNoCty(got, resType.String(), c.dirName, provider, deserializer, shouldUpdate, tt) }) } } diff --git a/enumeration/remote/remote.go b/enumeration/remote/remote.go index 0025d8533..d054000a0 100644 --- a/enumeration/remote/remote.go +++ b/enumeration/remote/remote.go @@ -29,22 +29,16 @@ func IsSupported(remote string) bool { return false } -func Activate(remote, version string, alerter *alerter.Alerter, - providerLibrary *terraform.ProviderLibrary, - remoteLibrary *common.RemoteLibrary, - progress enumeration.ProgressCounter, - resourceSchemaRepository *resource.SchemaRepository, - factory resource.ResourceFactory, - configDir string) error { +func Activate(remote, version string, alerter *alerter.Alerter, providerLibrary *terraform.ProviderLibrary, remoteLibrary *common.RemoteLibrary, progress enumeration.ProgressCounter, factory resource.ResourceFactory, configDir string) error { switch remote { case common.RemoteAWSTerraform: - return aws.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) + return aws.Init(version, alerter, providerLibrary, remoteLibrary, progress, factory, configDir) case common.RemoteGithubTerraform: - return github.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) + return github.Init(version, alerter, providerLibrary, remoteLibrary, progress, factory, configDir) case common.RemoteGoogleTerraform: - return google.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) + return google.Init(version, alerter, providerLibrary, remoteLibrary, progress, factory, configDir) case common.RemoteAzureTerraform: - return azurerm.Init(version, alerter, providerLibrary, remoteLibrary, progress, resourceSchemaRepository, factory, configDir) + return azurerm.Init(version, alerter, providerLibrary, remoteLibrary, progress, factory, configDir) default: return errors.Errorf("unsupported remote '%s'", remote) diff --git a/enumeration/remote/test/aws_appautoscaling_policy_single/results.golden.json b/enumeration/remote/test/aws_appautoscaling_policy_single/results.golden.json index 56c4fd0d5..a201446f7 100755 --- a/enumeration/remote/test/aws_appautoscaling_policy_single/results.golden.json +++ b/enumeration/remote/test/aws_appautoscaling_policy_single/results.golden.json @@ -7,10 +7,10 @@ "resource_id": "table/GameScores", "scalable_dimension": "dynamodb:table:ReadCapacityUnits", "service_namespace": "dynamodb", - "step_scaling_policy_configuration": null, + "step_scaling_policy_configuration": [], "target_tracking_scaling_policy_configuration": [ { - "customized_metric_specification": null, + "customized_metric_specification": [], "disable_scale_in": false, "predefined_metric_specification": [ { diff --git a/enumeration/remote/test/aws_cloudformation_stack_multiple/results.golden.json b/enumeration/remote/test/aws_cloudformation_stack_multiple/results.golden.json index 7b25d7958..821cb0b5f 100755 --- a/enumeration/remote/test/aws_cloudformation_stack_multiple/results.golden.json +++ b/enumeration/remote/test/aws_cloudformation_stack_multiple/results.golden.json @@ -7,13 +7,13 @@ "name": "foo-stack", "notification_arns": null, "on_failure": null, - "outputs": null, + "outputs": {}, "parameters": { "VPCCidr": "10.0.0.0/16" }, "policy_body": null, "policy_url": null, - "tags": null, + "tags": {}, "template_body": "{\"Parameters\":{\"VPCCidr\":{\"Default\":\"10.0.0.0/16\",\"Description\":\"Enter the CIDR block for the VPC. Default is 10.0.0.0/16.\",\"Type\":\"String\"}},\"Resources\":{\"myVpc\":{\"Properties\":{\"CidrBlock\":{\"Ref\":\"VPCCidr\"},\"Tags\":[{\"Key\":\"Name\",\"Value\":\"Primary_CF_VPC\"}]},\"Type\":\"AWS::EC2::VPC\"}}}", "template_url": null, "timeout_in_minutes": null, @@ -29,11 +29,11 @@ "name": "bar-stack", "notification_arns": null, "on_failure": null, - "outputs": null, - "parameters": null, + "outputs": {}, + "parameters": {}, "policy_body": null, "policy_url": null, - "tags": null, + "tags": {}, "template_body": "Resources:\n myUser:\n Type: AWS::IAM::User\n Properties:\n UserName: \"bar_cfn\"\n", "template_url": null, "timeout_in_minutes": null, diff --git a/enumeration/remote/test/aws_ec2_default_network_acl/results.golden.json b/enumeration/remote/test/aws_ec2_default_network_acl/results.golden.json index 1df22de5e..99742b671 100755 --- a/enumeration/remote/test/aws_ec2_default_network_acl/results.golden.json +++ b/enumeration/remote/test/aws_ec2_default_network_acl/results.golden.json @@ -38,7 +38,7 @@ "subnet-ad17e3cb", "subnet-afa656f0" ], - "tags": null, + "tags": {}, "vpc_id": "vpc-41d1d13b" } ] \ No newline at end of file diff --git a/enumeration/remote/test/aws_ec2_eip_multiple/results.golden.json b/enumeration/remote/test/aws_ec2_eip_multiple/results.golden.json index 1aa11f3ca..302fb60c6 100755 --- a/enumeration/remote/test/aws_ec2_eip_multiple/results.golden.json +++ b/enumeration/remote/test/aws_ec2_eip_multiple/results.golden.json @@ -1 +1,48 @@ -[{"allocation_id":null,"associate_with_private_ip":null,"association_id":"","customer_owned_ip":"","customer_owned_ipv4_pool":"","domain":"vpc","id":"eipalloc-0cf714dc097c992cc","instance":"","network_interface":"","private_dns":null,"private_ip":"","public_dns":"ec2-52-47-35-117.eu-west-3.compute.amazonaws.com","public_ip":"52.47.35.117","public_ipv4_pool":"amazon","tags":{},"timeouts":{"delete":null,"read":null,"update":null},"vpc":true},{"allocation_id":null,"associate_with_private_ip":null,"association_id":"eipassoc-0e9a7356e30f0c3d1","customer_owned_ip":"","customer_owned_ipv4_pool":"","domain":"vpc","id":"eipalloc-017d5267e4dda73f1","instance":"i-0d3650a23f4e45dc0","network_interface":"eni-0f35ce5577bbab251","private_dns":"ip-172-31-22-12.eu-west-3.compute.internal","private_ip":"172.31.22.12","public_dns":"ec2-35-180-239-105.eu-west-3.compute.amazonaws.com","public_ip":"35.180.239.105","public_ipv4_pool":"amazon","tags":{},"timeouts":{"delete":null,"read":null,"update":null},"vpc":true}] \ No newline at end of file +[ + { + "allocation_id": null, + "associate_with_private_ip": null, + "association_id": "", + "customer_owned_ip": "", + "customer_owned_ipv4_pool": "", + "domain": "vpc", + "id": "eipalloc-0cf714dc097c992cc", + "instance": "", + "network_interface": "", + "private_dns": null, + "private_ip": "", + "public_dns": "ec2-52-47-35-117.eu-west-3.compute.amazonaws.com", + "public_ip": "52.47.35.117", + "public_ipv4_pool": "amazon", + "tags": {}, + "timeouts": { + "delete": null, + "read": null, + "update": null + }, + "vpc": true + }, + { + "allocation_id": null, + "associate_with_private_ip": null, + "association_id": "eipassoc-0e9a7356e30f0c3d1", + "customer_owned_ip": "", + "customer_owned_ipv4_pool": "", + "domain": "vpc", + "id": "eipalloc-017d5267e4dda73f1", + "instance": "i-0d3650a23f4e45dc0", + "network_interface": "eni-0f35ce5577bbab251", + "private_dns": "ip-172-31-22-12.eu-west-3.compute.internal", + "private_ip": "172.31.22.12", + "public_dns": "ec2-35-180-239-105.eu-west-3.compute.amazonaws.com", + "public_ip": "35.180.239.105", + "public_ipv4_pool": "amazon", + "tags": {}, + "timeouts": { + "delete": null, + "read": null, + "update": null + }, + "vpc": true + } +] \ No newline at end of file diff --git a/enumeration/remote/test/aws_ec2_network_acl/results.golden.json b/enumeration/remote/test/aws_ec2_network_acl/results.golden.json index 895110d43..672a99770 100755 --- a/enumeration/remote/test/aws_ec2_network_acl/results.golden.json +++ b/enumeration/remote/test/aws_ec2_network_acl/results.golden.json @@ -29,7 +29,7 @@ } ], "owner_id": "929327065333", - "subnet_ids": null, + "subnet_ids": [], "tags": { "Name": "test" }, @@ -65,7 +65,7 @@ } ], "owner_id": "929327065333", - "subnet_ids": null, + "subnet_ids": [], "tags": { "Name": "test2" }, diff --git a/enumeration/remote/test/aws_launch_template_multiple/results.golden.json b/enumeration/remote/test/aws_launch_template_multiple/results.golden.json index f2f08555f..f1b7da63a 100755 --- a/enumeration/remote/test/aws_launch_template_multiple/results.golden.json +++ b/enumeration/remote/test/aws_launch_template_multiple/results.golden.json @@ -1,40 +1,40 @@ [ { "arn": "arn:aws:ec2:us-east-1:533948124879:launch-template/lt-00b2d18c6cee7fe23", - "block_device_mappings": null, - "capacity_reservation_specification": null, - "cpu_options": null, - "credit_specification": null, + "block_device_mappings": [], + "capacity_reservation_specification": [], + "cpu_options": [], + "credit_specification": [], "default_version": 1, "description": "", "disable_api_termination": false, "ebs_optimized": "", - "elastic_gpu_specifications": null, - "elastic_inference_accelerator": null, - "hibernation_options": null, - "iam_instance_profile": null, + "elastic_gpu_specifications": [], + "elastic_inference_accelerator": [], + "hibernation_options": [], + "iam_instance_profile": [], "id": "lt-00b2d18c6cee7fe23", "image_id": "ami-000b3a073fc20e415", "instance_initiated_shutdown_behavior": "", - "instance_market_options": null, + "instance_market_options": [], "instance_type": "t3.micro", "kernel_id": "", "key_name": "", "latest_version": 1, - "license_specification": null, - "metadata_options": null, - "monitoring": null, + "license_specification": [], + "metadata_options": [], + "monitoring": [], "name": "test-template-2", "name_prefix": null, - "network_interfaces": null, - "placement": null, + "network_interfaces": [], + "placement": [], "ram_disk_id": "", - "security_group_names": null, - "tag_specifications": null, - "tags": null, + "security_group_names": [], + "tag_specifications": [], + "tags": {}, "update_default_version": null, "user_data": "", - "vpc_security_group_ids": null + "vpc_security_group_ids": [] }, { "arn": "arn:aws:ec2:us-east-1:533948124879:launch-template/lt-0ed993d09ce6afc67", @@ -59,7 +59,7 @@ "capacity_reservation_specification": [ { "capacity_reservation_preference": "open", - "capacity_reservation_target": null + "capacity_reservation_target": [] } ], "cpu_options": [ @@ -73,19 +73,19 @@ "description": "", "disable_api_termination": true, "ebs_optimized": "true", - "elastic_gpu_specifications": null, - "elastic_inference_accelerator": null, - "hibernation_options": null, - "iam_instance_profile": null, + "elastic_gpu_specifications": [], + "elastic_inference_accelerator": [], + "hibernation_options": [], + "iam_instance_profile": [], "id": "lt-0ed993d09ce6afc67", "image_id": "ami-000b3a073fc20e415", "instance_initiated_shutdown_behavior": "terminate", - "instance_market_options": null, + "instance_market_options": [], "instance_type": "", "kernel_id": "", "key_name": "", "latest_version": 1, - "license_specification": null, + "license_specification": [], "metadata_options": [ { "http_endpoint": "enabled", @@ -107,12 +107,12 @@ "description": "", "device_index": 0, "ipv4_address_count": 0, - "ipv4_addresses": null, + "ipv4_addresses": [], "ipv6_address_count": 0, - "ipv6_addresses": null, + "ipv6_addresses": [], "network_interface_id": "", "private_ip_address": "", - "security_groups": null, + "security_groups": [], "subnet_id": "" } ], @@ -128,7 +128,7 @@ } ], "ram_disk_id": "", - "security_group_names": null, + "security_group_names": [], "tag_specifications": [ { "resource_type": "instance", @@ -137,9 +137,9 @@ } } ], - "tags": null, + "tags": {}, "update_default_version": null, "user_data": "", - "vpc_security_group_ids": null + "vpc_security_group_ids": [] } ] \ No newline at end of file diff --git a/enumeration/remote/test/aws_rds_clusters_results/results.golden.json b/enumeration/remote/test/aws_rds_clusters_results/results.golden.json index a17efc9d7..f5371321e 100755 --- a/enumeration/remote/test/aws_rds_clusters_results/results.golden.json +++ b/enumeration/remote/test/aws_rds_clusters_results/results.golden.json @@ -22,7 +22,7 @@ "db_subnet_group_name": "default", "deletion_protection": false, "enable_http_endpoint": false, - "enabled_cloudwatch_logs_exports": null, + "enabled_cloudwatch_logs_exports": [], "endpoint": "aurora-cluster-demo.cluster-cd539r6quiux.us-east-1.rds.amazonaws.com", "engine": "aurora-postgresql", "engine_mode": "provisioned", @@ -31,7 +31,7 @@ "global_cluster_identifier": "", "hosted_zone_id": "Z2R2ITUGPM61AM", "iam_database_authentication_enabled": false, - "iam_roles": null, + "iam_roles": [], "id": "aurora-cluster-demo", "kms_key_id": "", "master_password": null, @@ -43,12 +43,12 @@ "replication_source_identifier": "", "restore_to_point_in_time": null, "s3_import": null, - "scaling_configuration": null, + "scaling_configuration": [], "skip_final_snapshot": null, "snapshot_identifier": null, "source_region": null, "storage_encrypted": false, - "tags": null, + "tags": {}, "timeouts": {}, "vpc_security_group_ids": [ "sg-49e38646" @@ -77,7 +77,7 @@ "db_subnet_group_name": "default", "deletion_protection": false, "enable_http_endpoint": false, - "enabled_cloudwatch_logs_exports": null, + "enabled_cloudwatch_logs_exports": [], "endpoint": "aurora-cluster-demo.cluster-cd539r6quiux.us-east-1.rds.amazonaws.com", "engine": "aurora-postgresql", "engine_mode": "provisioned", @@ -86,7 +86,7 @@ "global_cluster_identifier": "", "hosted_zone_id": "Z2R2ITUGPM61AM", "iam_database_authentication_enabled": false, - "iam_roles": null, + "iam_roles": [], "id": "aurora-cluster-demo-2", "kms_key_id": "", "master_password": null, @@ -98,12 +98,12 @@ "replication_source_identifier": "", "restore_to_point_in_time": null, "s3_import": null, - "scaling_configuration": null, + "scaling_configuration": [], "skip_final_snapshot": null, "snapshot_identifier": null, "source_region": null, "storage_encrypted": false, - "tags": null, + "tags": {}, "timeouts": {}, "vpc_security_group_ids": [ "sg-49e38646" diff --git a/enumeration/remote/test/aws_rds_db_instance_multiple/results.golden.json b/enumeration/remote/test/aws_rds_db_instance_multiple/results.golden.json index 69cb3feab..351ad6513 100755 --- a/enumeration/remote/test/aws_rds_db_instance_multiple/results.golden.json +++ b/enumeration/remote/test/aws_rds_db_instance_multiple/results.golden.json @@ -17,7 +17,7 @@ "deletion_protection": true, "domain": "", "domain_iam_role_name": "", - "enabled_cloudwatch_logs_exports": null, + "enabled_cloudwatch_logs_exports": [], "endpoint": "database-1.c4j6qwp34sb1.eu-west-3.rds.amazonaws.com:5432", "engine": "postgres", "engine_version": "12.3", @@ -49,7 +49,7 @@ "replicate_source_db": "", "resource_id": "db-HNCUL5PDUDVYNCZNSR546B2DVI", "s3_import": null, - "security_group_names": null, + "security_group_names": [], "skip_final_snapshot": null, "snapshot_identifier": null, "status": "modifying", @@ -120,7 +120,7 @@ "replicate_source_db": "", "resource_id": "db-C22NACLA2B45VA3WLVG6TKEAJE", "s3_import": null, - "security_group_names": null, + "security_group_names": [], "skip_final_snapshot": null, "snapshot_identifier": null, "status": "available", diff --git a/enumeration/remote/test/aws_rds_db_instance_single/results.golden.json b/enumeration/remote/test/aws_rds_db_instance_single/results.golden.json index c7b9676fd..d2f3fc19c 100755 --- a/enumeration/remote/test/aws_rds_db_instance_single/results.golden.json +++ b/enumeration/remote/test/aws_rds_db_instance_single/results.golden.json @@ -52,7 +52,7 @@ "replicate_source_db": "", "resource_id": "db-C22NACLA2B45VA3WLVG6TKEAJE", "s3_import": null, - "security_group_names": null, + "security_group_names": [], "skip_final_snapshot": null, "snapshot_identifier": null, "status": "available", diff --git a/enumeration/remote/test/azurerm_network_security_group_multiple/results.golden.json b/enumeration/remote/test/azurerm_network_security_group_multiple/results.golden.json index 3daa87adc..f0d3479b5 100755 --- a/enumeration/remote/test/azurerm_network_security_group_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_network_security_group_multiple/results.golden.json @@ -4,8 +4,8 @@ "location": "westeurope", "name": "acceptanceTestSecurityGroup2", "resource_group_name": "example-resources", - "security_rule": null, - "tags": null, + "security_rule": [], + "tags": {}, "timeouts": {} }, { @@ -18,19 +18,19 @@ "access": "Allow", "description": "", "destination_address_prefix": "*", - "destination_address_prefixes": null, - "destination_application_security_group_ids": null, + "destination_address_prefixes": [], + "destination_application_security_group_ids": [], "destination_port_range": "*", - "destination_port_ranges": null, + "destination_port_ranges": [], "direction": "Inbound", "name": "test123", "priority": 100, "protocol": "Tcp", "source_address_prefix": "*", - "source_address_prefixes": null, - "source_application_security_group_ids": null, + "source_address_prefixes": [], + "source_application_security_group_ids": [], "source_port_range": "*", - "source_port_ranges": null + "source_port_ranges": [] } ], "tags": { diff --git a/enumeration/remote/test/azurerm_private_dns_a_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_a_record_multiple/results.golden.json index f0b58fc98..5acc56c13 100755 --- a/enumeration/remote/test/azurerm_private_dns_a_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_a_record_multiple/results.golden.json @@ -8,7 +8,7 @@ "10.0.180.20" ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" @@ -21,7 +21,7 @@ "10.0.180.20" ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" diff --git a/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/results.golden.json index cc30ef5a6..66de6f5d5 100755 --- a/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_aaaaa_record_multiple/results.golden.json @@ -8,7 +8,7 @@ "fd5d:70bc:930e:d008::7335" ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" @@ -22,7 +22,7 @@ "fd5d:70bc:930e:d008::7335" ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" diff --git a/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/results.golden.json index db9064a6e..22f192df0 100755 --- a/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_cname_record_multiple/results.golden.json @@ -5,7 +5,7 @@ "name": "test", "record": "test.com", "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" @@ -16,7 +16,7 @@ "name": "othertest", "record": "othertest.com", "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" diff --git a/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/results.golden.json index c0f56139d..37c1951fb 100755 --- a/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_mx_record_multiple/results.golden.json @@ -10,7 +10,7 @@ } ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" @@ -30,7 +30,7 @@ } ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" diff --git a/enumeration/remote/test/azurerm_private_dns_private_zone_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_private_zone_multiple/results.golden.json index a10659653..2cf875856 100755 --- a/enumeration/remote/test/azurerm_private_dns_private_zone_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_private_zone_multiple/results.golden.json @@ -17,11 +17,11 @@ "refresh_time": 3600, "retry_time": 300, "serial_number": 1, - "tags": null, + "tags": {}, "ttl": 3600 } ], - "tags": null, + "tags": {}, "timeouts": {} }, { @@ -42,7 +42,7 @@ "refresh_time": 3600, "retry_time": 300, "serial_number": 1, - "tags": null, + "tags": {}, "ttl": 3600 } ], @@ -69,11 +69,11 @@ "refresh_time": 3600, "retry_time": 300, "serial_number": 1, - "tags": null, + "tags": {}, "ttl": 3600 } ], - "tags": null, + "tags": {}, "timeouts": {} } ] \ No newline at end of file diff --git a/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/results.golden.json index 3a42c39bb..8edbc9cd7 100755 --- a/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_ptr_record_multiple/results.golden.json @@ -7,7 +7,7 @@ "ptr3.thisisatestusingtf.com" ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" @@ -21,7 +21,7 @@ "ptr2.thisisatestusingtf.com" ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" diff --git a/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/results.golden.json index 08ca167d6..93d1f552c 100755 --- a/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_srv_record_multiple/results.golden.json @@ -18,7 +18,7 @@ } ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" @@ -36,7 +36,7 @@ } ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" diff --git a/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/results.golden.json b/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/results.golden.json index 7dfe177fa..9f0dee43c 100755 --- a/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_private_dns_txt_record_multiple/results.golden.json @@ -9,7 +9,7 @@ } ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" @@ -27,7 +27,7 @@ } ], "resource_group_name": "martin-dev", - "tags": null, + "tags": {}, "timeouts": {}, "ttl": 300, "zone_name": "thisisatestusingtf.com" diff --git a/enumeration/remote/test/azurerm_ssh_public_key_multiple/results.golden.json b/enumeration/remote/test/azurerm_ssh_public_key_multiple/results.golden.json index 4cef8a321..f854fa687 100755 --- a/enumeration/remote/test/azurerm_ssh_public_key_multiple/results.golden.json +++ b/enumeration/remote/test/azurerm_ssh_public_key_multiple/results.golden.json @@ -5,7 +5,7 @@ "name": "example-key2", "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCjeC5sO1EdEfZOrdVCpuOgXcXsKZg9zgfJbHgQgX1R2Nd8mNQrUjpsB4XLHNZ3T6UYrsSh7oxYC3UFu6peO4LmA2WTe2wCWVFn9WW/Lo99WcA/G/fGj6s5HK5CHFVPXnNxM47QJMNm5BWOM55+EWP839SHLH9Fk63H575x7jxZvBvaV0uL84XuVpiEBKhnpQfT4cJGoGLOGgjM+TpHyosbKldu5q2UTF9nOGpmLuku41oihqiPPSJnJRv3TDKFi4mIl9Iz5HJINWvLl1kdCfyjPcHcH5GO0tuA9rP5AbsmG5EAGOKtuFipYA4MyY9SYriZ2V1vpgefUS9lilg9hIPEj/8ZPTxf62XeyC1dQ3cOz6yPWR2sODyVECVf6mrmhZPTjVX+DorByX2uBzLDzF9jGMFMJRhxi0yVpXsqBrP+ps9G+s7oNUDp771d1Bix+gm5EyebEbdiQuf0/8wDlhY5jYAFJW1xkPKXcjJdM1FuVVS1B8zhvRVEJZUngruVfh/7jJUOWNS44F7rVz5a4r/vs84ObFIMeYdFn+uxgUqOlNMAvXLvJ2GzlPXInXW90Uv+JJ5msny/5ygGfHr2D6xOf6P7r7oSalXwjd9BcRS6/4GQAY6LVfPwrpnrpyJBiK/FhEbR+ctfDo81eKhmp0EyxvSJGW46/26/kqHvchf+rQ== ?\n", "resource_group_name": "TESTRESGROUP", - "tags": null, + "tags": {}, "timeouts": {} }, { @@ -14,7 +14,7 @@ "name": "example-key", "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCjeC5sO1EdEfZOrdVCpuOgXcXsKZg9zgfJbHgQgX1R2Nd8mNQrUjpsB4XLHNZ3T6UYrsSh7oxYC3UFu6peO4LmA2WTe2wCWVFn9WW/Lo99WcA/G/fGj6s5HK5CHFVPXnNxM47QJMNm5BWOM55+EWP839SHLH9Fk63H575x7jxZvBvaV0uL84XuVpiEBKhnpQfT4cJGoGLOGgjM+TpHyosbKldu5q2UTF9nOGpmLuku41oihqiPPSJnJRv3TDKFi4mIl9Iz5HJINWvLl1kdCfyjPcHcH5GO0tuA9rP5AbsmG5EAGOKtuFipYA4MyY9SYriZ2V1vpgefUS9lilg9hIPEj/8ZPTxf62XeyC1dQ3cOz6yPWR2sODyVECVf6mrmhZPTjVX+DorByX2uBzLDzF9jGMFMJRhxi0yVpXsqBrP+ps9G+s7oNUDp771d1Bix+gm5EyebEbdiQuf0/8wDlhY5jYAFJW1xkPKXcjJdM1FuVVS1B8zhvRVEJZUngruVfh/7jJUOWNS44F7rVz5a4r/vs84ObFIMeYdFn+uxgUqOlNMAvXLvJ2GzlPXInXW90Uv+JJ5msny/5ygGfHr2D6xOf6P7r7oSalXwjd9BcRS6/4GQAY6LVfPwrpnrpyJBiK/FhEbR+ctfDo81eKhmp0EyxvSJGW46/26/kqHvchf+rQ== ?\n", "resource_group_name": "TESTRESGROUP", - "tags": null, + "tags": {}, "timeouts": {} } ] \ No newline at end of file diff --git a/enumeration/remote/test/google_compute_firewall/results.golden.json b/enumeration/remote/test/google_compute_firewall/results.golden.json index b6948683b..21eb1c776 100755 --- a/enumeration/remote/test/google_compute_firewall/results.golden.json +++ b/enumeration/remote/test/google_compute_firewall/results.golden.json @@ -10,31 +10,31 @@ "protocol": "tcp" }, { - "ports": null, + "ports": [], "protocol": "icmp" } ], "creation_timestamp": "2021-09-14T05:21:08.730-07:00", - "deny": null, + "deny": [], "description": "", - "destination_ranges": null, + "destination_ranges": [], "direction": "INGRESS", "disabled": false, "enable_logging": null, "id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-1", - "log_config": null, + "log_config": [], "name": "test-firewall-1", "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/networks/test-network", "priority": 1000, "project": "cloudskiff-dev-elie", "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/firewalls/test-firewall-1", - "source_ranges": null, - "source_service_accounts": null, + "source_ranges": [], + "source_service_accounts": [], "source_tags": [ "web" ], - "target_service_accounts": null, - "target_tags": null, + "target_service_accounts": [], + "target_tags": [], "timeouts": {} }, { @@ -48,31 +48,31 @@ "protocol": "tcp" }, { - "ports": null, + "ports": [], "protocol": "icmp" } ], "creation_timestamp": "2021-09-14T05:21:08.744-07:00", - "deny": null, + "deny": [], "description": "", - "destination_ranges": null, + "destination_ranges": [], "direction": "INGRESS", "disabled": false, "enable_logging": null, "id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-0", - "log_config": null, + "log_config": [], "name": "test-firewall-0", "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/networks/test-network", "priority": 1000, "project": "cloudskiff-dev-elie", "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/firewalls/test-firewall-0", - "source_ranges": null, - "source_service_accounts": null, + "source_ranges": [], + "source_service_accounts": [], "source_tags": [ "web" ], - "target_service_accounts": null, - "target_tags": null, + "target_service_accounts": [], + "target_tags": [], "timeouts": {} }, { @@ -86,31 +86,31 @@ "protocol": "tcp" }, { - "ports": null, + "ports": [], "protocol": "icmp" } ], "creation_timestamp": "2021-09-14T05:21:08.624-07:00", - "deny": null, + "deny": [], "description": "", - "destination_ranges": null, + "destination_ranges": [], "direction": "INGRESS", "disabled": false, "enable_logging": null, "id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-2", - "log_config": null, + "log_config": [], "name": "test-firewall-2", "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/networks/test-network", "priority": 1000, "project": "cloudskiff-dev-elie", "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/firewalls/test-firewall-2", - "source_ranges": null, - "source_service_accounts": null, + "source_ranges": [], + "source_service_accounts": [], "source_tags": [ "web" ], - "target_service_accounts": null, - "target_tags": null, + "target_service_accounts": [], + "target_tags": [], "timeouts": {} } ] \ No newline at end of file diff --git a/enumeration/remote/test/google_compute_instance_group/results.golden.json b/enumeration/remote/test/google_compute_instance_group/results.golden.json index b1bfeceb7..a82fb1524 100755 --- a/enumeration/remote/test/google_compute_instance_group/results.golden.json +++ b/enumeration/remote/test/google_compute_instance_group/results.golden.json @@ -2,9 +2,9 @@ { "description": "Terraform test instance group", "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", - "instances": null, + "instances": [], "name": "driftctl-test-2", - "named_port": null, + "named_port": [], "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network", "project": "cloudskiff-dev-raphael", "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", @@ -15,9 +15,9 @@ { "description": "Terraform test instance group", "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", - "instances": null, + "instances": [], "name": "driftctl-test-1", - "named_port": null, + "named_port": [], "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network", "project": "cloudskiff-dev-raphael", "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", diff --git a/enumeration/remote/test/google_compute_subnetwork_multiple/results.golden.json b/enumeration/remote/test/google_compute_subnetwork_multiple/results.golden.json index 074a306ef..5b57d2bf0 100755 --- a/enumeration/remote/test/google_compute_subnetwork_multiple/results.golden.json +++ b/enumeration/remote/test/google_compute_subnetwork_multiple/results.golden.json @@ -6,7 +6,7 @@ "gateway_address": "10.2.0.1", "id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-1", "ip_cidr_range": "10.2.0.0/16", - "log_config": null, + "log_config": [], "name": "driftctl-unittest-1", "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network-1871346572", "private_ip_google_access": false, @@ -29,7 +29,7 @@ "gateway_address": "10.2.0.1", "id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-2", "ip_cidr_range": "10.2.0.0/16", - "log_config": null, + "log_config": [], "name": "driftctl-unittest-2", "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network-2871346572", "private_ip_google_access": false, @@ -52,7 +52,7 @@ "gateway_address": "10.2.0.1", "id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-3", "ip_cidr_range": "10.2.0.0/16", - "log_config": null, + "log_config": [], "name": "driftctl-unittest-3", "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network-3871346572", "private_ip_google_access": false, diff --git a/enumeration/remote/test/google_project_member_listing_multiple/results.golden.json b/enumeration/remote/test/google_project_member_listing_multiple/results.golden.json index 5c7b2ffc9..2fb478e1e 100755 --- a/enumeration/remote/test/google_project_member_listing_multiple/results.golden.json +++ b/enumeration/remote/test/google_project_member_listing_multiple/results.golden.json @@ -1,47 +1,35 @@ [ { - "condition": null, - "etag": null, "id": "/roles/storage.admin/user:martin.guibert@cloudskiff.com", "member": "user:martin.guibert@cloudskiff.com", "project": "", "role": "roles/storage.admin" }, { - "condition": null, - "etag": null, "id": "/roles/viewer/serviceAccount:driftctl@cloudskiff-dev-martin.iam.gserviceaccount.com", "member": "serviceAccount:driftctl@cloudskiff-dev-martin.iam.gserviceaccount.com", "project": "", "role": "roles/viewer" }, { - "condition": null, - "etag": null, "id": "/roles/cloudasset.viewer/serviceAccount:driftctl@cloudskiff-dev-martin.iam.gserviceaccount.com", "member": "serviceAccount:driftctl@cloudskiff-dev-martin.iam.gserviceaccount.com", "project": "", "role": "roles/cloudasset.viewer" }, { - "condition": null, - "etag": null, "id": "/roles/iam.securityReviewer/serviceAccount:driftctl@cloudskiff-dev-martin.iam.gserviceaccount.com", "member": "serviceAccount:driftctl@cloudskiff-dev-martin.iam.gserviceaccount.com", "project": "", "role": "roles/iam.securityReviewer" }, { - "condition": null, - "etag": null, "id": "/roles/editor/serviceAccount:drifctl-admin@cloudskiff-dev-martin.iam.gserviceaccount.com", "member": "serviceAccount:drifctl-admin@cloudskiff-dev-martin.iam.gserviceaccount.com", "project": "", "role": "roles/editor" }, { - "condition": null, - "etag": null, "id": "/roles/editor/user:martin.guibert@cloudskiff.com", "member": "user:martin.guibert@cloudskiff.com", "project": "", diff --git a/enumeration/remote/test/google_storage_bucket/results.golden.json b/enumeration/remote/test/google_storage_bucket/results.golden.json index 8775f9511..9a928d942 100755 --- a/enumeration/remote/test/google_storage_bucket/results.golden.json +++ b/enumeration/remote/test/google_storage_bucket/results.golden.json @@ -1,68 +1,68 @@ [ { "bucket_policy_only": true, - "cors": null, + "cors": [], "default_event_based_hold": false, - "encryption": null, + "encryption": [], "force_destroy": null, "id": "driftctl-unittest-3", - "labels": null, - "lifecycle_rule": null, + "labels": {}, + "lifecycle_rule": [], "location": "EU", - "logging": null, + "logging": [], "name": "driftctl-unittest-3", "project": "elie-dev", "requester_pays": false, - "retention_policy": null, + "retention_policy": [], "self_link": "https://www.googleapis.com/storage/v1/b/driftctl-unittest-3", "storage_class": "STANDARD", "uniform_bucket_level_access": true, "url": "gs://driftctl-unittest-3", - "versioning": null, - "website": null + "versioning": [], + "website": [] }, { "bucket_policy_only": true, - "cors": null, + "cors": [], "default_event_based_hold": false, - "encryption": null, + "encryption": [], "force_destroy": null, "id": "driftctl-unittest-2", - "labels": null, - "lifecycle_rule": null, + "labels": {}, + "lifecycle_rule": [], "location": "EU", - "logging": null, + "logging": [], "name": "driftctl-unittest-2", "project": "elie-dev", "requester_pays": false, - "retention_policy": null, + "retention_policy": [], "self_link": "https://www.googleapis.com/storage/v1/b/driftctl-unittest-2", "storage_class": "STANDARD", "uniform_bucket_level_access": true, "url": "gs://driftctl-unittest-2", - "versioning": null, - "website": null + "versioning": [], + "website": [] }, { "bucket_policy_only": true, - "cors": null, + "cors": [], "default_event_based_hold": false, - "encryption": null, + "encryption": [], "force_destroy": null, "id": "driftctl-unittest-1", - "labels": null, - "lifecycle_rule": null, + "labels": {}, + "lifecycle_rule": [], "location": "EU", - "logging": null, + "logging": [], "name": "driftctl-unittest-1", "project": "elie-dev", "requester_pays": false, - "retention_policy": null, + "retention_policy": [], "self_link": "https://www.googleapis.com/storage/v1/b/driftctl-unittest-1", "storage_class": "STANDARD", "uniform_bucket_level_access": true, "url": "gs://driftctl-unittest-1", - "versioning": null, - "website": null + "versioning": [], + "website": [] } ] \ No newline at end of file diff --git a/enumeration/remote/test/google_storage_bucket_member_listing_multiple/results.golden.json b/enumeration/remote/test/google_storage_bucket_member_listing_multiple/results.golden.json index 5caec119e..e14f477f3 100755 --- a/enumeration/remote/test/google_storage_bucket_member_listing_multiple/results.golden.json +++ b/enumeration/remote/test/google_storage_bucket_member_listing_multiple/results.golden.json @@ -1,32 +1,24 @@ [ { "bucket": "b/dctlgstoragebucketiambinding-1", - "condition": null, - "etag": null, "id": "b/dctlgstoragebucketiambinding-1/roles/storage.admin/user:elie.charra@cloudskiff.com", "member": "user:elie.charra@cloudskiff.com", "role": "roles/storage.admin" }, { "bucket": "b/dctlgstoragebucketiambinding-1", - "condition": null, - "etag": null, "id": "b/dctlgstoragebucketiambinding-1/roles/storage.objectViewer/user:william.beuil@cloudskiff.com", "member": "user:william.beuil@cloudskiff.com", "role": "roles/storage.objectViewer" }, { "bucket": "b/dctlgstoragebucketiambinding-2", - "condition": null, - "etag": null, "id": "b/dctlgstoragebucketiambinding-2/roles/storage.admin/user:william.beuil@cloudskiff.com", "member": "user:william.beuil@cloudskiff.com", "role": "roles/storage.admin" }, { "bucket": "b/dctlgstoragebucketiambinding-2", - "condition": null, - "etag": null, "id": "b/dctlgstoragebucketiambinding-2/roles/storage.objectViewer/user:elie.charra@cloudskiff.com", "member": "user:elie.charra@cloudskiff.com", "role": "roles/storage.objectViewer" diff --git a/enumeration/resource/aws/aws_ami.go b/enumeration/resource/aws/aws_ami.go index ac8fec7db..b568ef7fa 100644 --- a/enumeration/resource/aws/aws_ami.go +++ b/enumeration/resource/aws/aws_ami.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsAmiResourceType = "aws_ami" - -func initAwsAmiMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsAmiResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_apigatewayv2_mapping.go b/enumeration/resource/aws/aws_apigatewayv2_mapping.go index dd563a9a2..9b64c9612 100644 --- a/enumeration/resource/aws/aws_apigatewayv2_mapping.go +++ b/enumeration/resource/aws/aws_apigatewayv2_mapping.go @@ -1,23 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsApiGatewayV2MappingResourceType = "aws_apigatewayv2_api_mapping" - -func initAwsApiGatewayV2MappingMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc( - AwsApiGatewayV2MappingResourceType, - func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - - if v := res.Attributes().GetString("api_id"); v != nil { - attrs["Api"] = *v - } - if v := res.Attributes().GetString("stage"); v != nil { - attrs["Stage"] = *v - } - - return attrs - }, - ) -} diff --git a/enumeration/resource/aws/aws_apigatewayv2_model.go b/enumeration/resource/aws/aws_apigatewayv2_model.go index 471ae4937..929c1b154 100644 --- a/enumeration/resource/aws/aws_apigatewayv2_model.go +++ b/enumeration/resource/aws/aws_apigatewayv2_model.go @@ -1,16 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsApiGatewayV2ModelResourceType = "aws_apigatewayv2_model" - -func initAwsApiGatewayV2ModelMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc( - AwsApiGatewayV2ModelResourceType, - func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attributes().GetString("name"), - } - }, - ) -} diff --git a/enumeration/resource/aws/aws_appautoscaling_policy.go b/enumeration/resource/aws/aws_appautoscaling_policy.go index 33c6ea0b1..08b445e75 100644 --- a/enumeration/resource/aws/aws_appautoscaling_policy.go +++ b/enumeration/resource/aws/aws_appautoscaling_policy.go @@ -1,16 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsAppAutoscalingPolicyResourceType = "aws_appautoscaling_policy" - -func initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingPolicyResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { - attrs["Scalable dimension"] = *v - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsAppAutoscalingPolicyResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_appautoscaling_target.go b/enumeration/resource/aws/aws_appautoscaling_target.go index ada967b9c..4eb618a61 100644 --- a/enumeration/resource/aws/aws_appautoscaling_target.go +++ b/enumeration/resource/aws/aws_appautoscaling_target.go @@ -1,16 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsAppAutoscalingTargetResourceType = "aws_appautoscaling_target" - -func initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { - attrs["Scalable dimension"] = *v - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsAppAutoscalingTargetResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_cloudformation_stack.go b/enumeration/resource/aws/aws_cloudformation_stack.go index 531a70c4f..c3e575929 100644 --- a/enumeration/resource/aws/aws_cloudformation_stack.go +++ b/enumeration/resource/aws/aws_cloudformation_stack.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsCloudformationStackResourceType = "aws_cloudformation_stack" - -func initAwsCloudformationStackMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsCloudformationStackResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_cloudfront_distribution.go b/enumeration/resource/aws/aws_cloudfront_distribution.go index 8d51bbe63..1d8fde58c 100644 --- a/enumeration/resource/aws/aws_cloudfront_distribution.go +++ b/enumeration/resource/aws/aws_cloudfront_distribution.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsCloudfrontDistributionResourceType = "aws_cloudfront_distribution" - -func initAwsCloudfrontDistributionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsCloudfrontDistributionResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_db_instance.go b/enumeration/resource/aws/aws_db_instance.go index 2632e5543..75ceaa8ad 100644 --- a/enumeration/resource/aws/aws_db_instance.go +++ b/enumeration/resource/aws/aws_db_instance.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsDbInstanceResourceType = "aws_db_instance" - -func initAwsDbInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsDbInstanceResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_db_subnet_group.go b/enumeration/resource/aws/aws_db_subnet_group.go index faa474c7c..f2df7bd91 100644 --- a/enumeration/resource/aws/aws_db_subnet_group.go +++ b/enumeration/resource/aws/aws_db_subnet_group.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsDbSubnetGroupResourceType = "aws_db_subnet_group" - -func initAwsDbSubnetGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsDbSubnetGroupResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_default_network_acl.go b/enumeration/resource/aws/aws_default_network_acl.go index f15deb288..858214408 100644 --- a/enumeration/resource/aws/aws_default_network_acl.go +++ b/enumeration/resource/aws/aws_default_network_acl.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsDefaultNetworkACLResourceType = "aws_default_network_acl" - -func initAwsDefaultNetworkACLMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsDefaultNetworkACLResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_default_route_table.go b/enumeration/resource/aws/aws_default_route_table.go index 0965c995c..7169755a8 100644 --- a/enumeration/resource/aws/aws_default_route_table.go +++ b/enumeration/resource/aws/aws_default_route_table.go @@ -1,13 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsDefaultRouteTableResourceType = "aws_default_route_table" - -func initAwsDefaultRouteTableMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsDefaultRouteTableResourceType, resource.FlagDeepMode) - resourceSchemaRepository.SetNormalizeFunc(AwsDefaultRouteTableResourceType, func(res *resource.Resource) { - val := res.Attrs - val.SafeDelete([]string{"timeouts"}) - }) -} diff --git a/enumeration/resource/aws/aws_default_security_group.go b/enumeration/resource/aws/aws_default_security_group.go index 000b24e13..c12a6be37 100644 --- a/enumeration/resource/aws/aws_default_security_group.go +++ b/enumeration/resource/aws/aws_default_security_group.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsDefaultSecurityGroupResourceType = "aws_default_security_group" - -func initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsDefaultSecurityGroupResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_default_subnet.go b/enumeration/resource/aws/aws_default_subnet.go index 74702a1e7..33ca0f6d0 100644 --- a/enumeration/resource/aws/aws_default_subnet.go +++ b/enumeration/resource/aws/aws_default_subnet.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsDefaultSubnetResourceType = "aws_default_subnet" - -func initAwsDefaultSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsDefaultSubnetResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_default_vpc.go b/enumeration/resource/aws/aws_default_vpc.go index 62a02a122..46d13514e 100644 --- a/enumeration/resource/aws/aws_default_vpc.go +++ b/enumeration/resource/aws/aws_default_vpc.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsDefaultVpcResourceType = "aws_default_vpc" - -func initAwsDefaultVpcMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsDefaultVpcResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_dynamodb_table.go b/enumeration/resource/aws/aws_dynamodb_table.go index 582900d95..be70d3fd5 100644 --- a/enumeration/resource/aws/aws_dynamodb_table.go +++ b/enumeration/resource/aws/aws_dynamodb_table.go @@ -1,12 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsDynamodbTableResourceType = "aws_dynamodb_table" - -func initAwsDynamodbTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsDynamodbTableResourceType, resource.FlagDeepMode) - -} diff --git a/enumeration/resource/aws/aws_ebs_encryption_by_default.go b/enumeration/resource/aws/aws_ebs_encryption_by_default.go index 502b99f38..a8d923393 100644 --- a/enumeration/resource/aws/aws_ebs_encryption_by_default.go +++ b/enumeration/resource/aws/aws_ebs_encryption_by_default.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsEbsEncryptionByDefaultResourceType = "aws_ebs_encryption_by_default" - -func initAwsEbsEncryptionByDefaultMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsEbsEncryptionByDefaultResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_ebs_snapshot.go b/enumeration/resource/aws/aws_ebs_snapshot.go index e18e2cb68..b7ee73849 100644 --- a/enumeration/resource/aws/aws_ebs_snapshot.go +++ b/enumeration/resource/aws/aws_ebs_snapshot.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsEbsSnapshotResourceType = "aws_ebs_snapshot" - -func initAwsEbsSnapshotMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsEbsSnapshotResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_ebs_volume.go b/enumeration/resource/aws/aws_ebs_volume.go index d362ba4ee..5da7af4e8 100644 --- a/enumeration/resource/aws/aws_ebs_volume.go +++ b/enumeration/resource/aws/aws_ebs_volume.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsEbsVolumeResourceType = "aws_ebs_volume" - -func initAwsEbsVolumeMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsEbsVolumeResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_ecr_repository.go b/enumeration/resource/aws/aws_ecr_repository.go index 4f1d1ccd8..b33eedd2d 100644 --- a/enumeration/resource/aws/aws_ecr_repository.go +++ b/enumeration/resource/aws/aws_ecr_repository.go @@ -1,10 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsEcrRepositoryResourceType = "aws_ecr_repository" - -func initAwsEcrRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - - resourceSchemaRepository.SetFlags(AwsEcrRepositoryResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_eip.go b/enumeration/resource/aws/aws_eip.go index e1d914c4d..e11368b1d 100644 --- a/enumeration/resource/aws/aws_eip.go +++ b/enumeration/resource/aws/aws_eip.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsEipResourceType = "aws_eip" - -func initAwsEipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsEipResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_eip_association.go b/enumeration/resource/aws/aws_eip_association.go index 60248114b..44bff2904 100644 --- a/enumeration/resource/aws/aws_eip_association.go +++ b/enumeration/resource/aws/aws_eip_association.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsEipAssociationResourceType = "aws_eip_association" - -func initAwsEipAssociationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsEipAssociationResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_iam_access_key.go b/enumeration/resource/aws/aws_iam_access_key.go index 46e9e3a6b..926c5bea3 100644 --- a/enumeration/resource/aws/aws_iam_access_key.go +++ b/enumeration/resource/aws/aws_iam_access_key.go @@ -1,19 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsIamAccessKeyResourceType = "aws_iam_access_key" - -func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if user := val.GetString("user"); user != nil && *user != "" { - attrs["User"] = *user - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsIamAccessKeyResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_iam_policy.go b/enumeration/resource/aws/aws_iam_policy.go index 538411ac1..c789edbe3 100644 --- a/enumeration/resource/aws/aws_iam_policy.go +++ b/enumeration/resource/aws/aws_iam_policy.go @@ -1,16 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsIamPolicyResourceType = "aws_iam_policy" - -func initAwsIAMPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsIamPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetFlags(AwsIamPolicyResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_iam_policy_attachment.go b/enumeration/resource/aws/aws_iam_policy_attachment.go index 088f0b14d..38aa52b86 100644 --- a/enumeration/resource/aws/aws_iam_policy_attachment.go +++ b/enumeration/resource/aws/aws_iam_policy_attachment.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsIamPolicyAttachmentResourceType = "aws_iam_policy_attachment" - -func initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsIamPolicyAttachmentResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_iam_role.go b/enumeration/resource/aws/aws_iam_role.go index e736f29c3..e84358c5e 100644 --- a/enumeration/resource/aws/aws_iam_role.go +++ b/enumeration/resource/aws/aws_iam_role.go @@ -1,16 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsIamRoleResourceType = "aws_iam_role" - -func initAwsIAMRoleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsIamRoleResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "assume_role_policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetFlags(AwsIamRoleResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_iam_role_policy.go b/enumeration/resource/aws/aws_iam_role_policy.go index d5ed4580e..70567d169 100644 --- a/enumeration/resource/aws/aws_iam_role_policy.go +++ b/enumeration/resource/aws/aws_iam_role_policy.go @@ -1,16 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsIamRolePolicyResourceType = "aws_iam_role_policy" - -func initAwsIAMRolePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsIamRolePolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetFlags(AwsIamRolePolicyResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_iam_role_policy_attachment.go b/enumeration/resource/aws/aws_iam_role_policy_attachment.go index a9d83f241..e82fb536f 100644 --- a/enumeration/resource/aws/aws_iam_role_policy_attachment.go +++ b/enumeration/resource/aws/aws_iam_role_policy_attachment.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsIamRolePolicyAttachmentResourceType = "aws_iam_role_policy_attachment" - -func initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsIamRolePolicyAttachmentResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_iam_user.go b/enumeration/resource/aws/aws_iam_user.go index e79413be5..3683e19fd 100644 --- a/enumeration/resource/aws/aws_iam_user.go +++ b/enumeration/resource/aws/aws_iam_user.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsIamUserResourceType = "aws_iam_user" - -func initAwsIAMUserMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsIamUserResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_iam_user_policy.go b/enumeration/resource/aws/aws_iam_user_policy.go index 3de42a38c..b902d5ea5 100644 --- a/enumeration/resource/aws/aws_iam_user_policy.go +++ b/enumeration/resource/aws/aws_iam_user_policy.go @@ -1,16 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsIamUserPolicyResourceType = "aws_iam_user_policy" - -func initAwsIAMUserPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsIamUserPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetFlags(AwsIamUserPolicyResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_iam_user_policy_attachment.go b/enumeration/resource/aws/aws_iam_user_policy_attachment.go index 9b7a41d15..e0a32d7df 100644 --- a/enumeration/resource/aws/aws_iam_user_policy_attachment.go +++ b/enumeration/resource/aws/aws_iam_user_policy_attachment.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsIamUserPolicyAttachmentResourceType = "aws_iam_user_policy_attachment" - -func initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsIamUserPolicyAttachmentResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_instance.go b/enumeration/resource/aws/aws_instance.go index 98f12250a..eff36719f 100644 --- a/enumeration/resource/aws/aws_instance.go +++ b/enumeration/resource/aws/aws_instance.go @@ -1,21 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsInstanceResourceType = "aws_instance" - -func initAwsInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsInstanceResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if tags := val.GetMap("tags"); tags != nil { - if name, ok := tags["Name"]; ok { - attrs["Name"] = name.(string) - } - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsInstanceResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_internet_gateway.go b/enumeration/resource/aws/aws_internet_gateway.go index 4c6c69664..8b33dcf7b 100644 --- a/enumeration/resource/aws/aws_internet_gateway.go +++ b/enumeration/resource/aws/aws_internet_gateway.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsInternetGatewayResourceType = "aws_internet_gateway" - -func initAwsInternetGatewayMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsInternetGatewayResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_key_pair.go b/enumeration/resource/aws/aws_key_pair.go index 35514570d..1afb8f3d6 100644 --- a/enumeration/resource/aws/aws_key_pair.go +++ b/enumeration/resource/aws/aws_key_pair.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsKeyPairResourceType = "aws_key_pair" - -func initAwsKeyPairMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsKeyPairResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_kms_alias.go b/enumeration/resource/aws/aws_kms_alias.go index ff6750f19..f9b72f60b 100644 --- a/enumeration/resource/aws/aws_kms_alias.go +++ b/enumeration/resource/aws/aws_kms_alias.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsKmsAliasResourceType = "aws_kms_alias" - -func initAwsKmsAliasMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsKmsAliasResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_kms_key.go b/enumeration/resource/aws/aws_kms_key.go index 9e2658ae8..515ee8278 100644 --- a/enumeration/resource/aws/aws_kms_key.go +++ b/enumeration/resource/aws/aws_kms_key.go @@ -1,16 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsKmsKeyResourceType = "aws_kms_key" - -func initAwsKmsKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsKmsKeyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetFlags(AwsKmsKeyResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_lambda_event_source_mapping.go b/enumeration/resource/aws/aws_lambda_event_source_mapping.go index 25e66a7b3..7b445d61f 100644 --- a/enumeration/resource/aws/aws_lambda_event_source_mapping.go +++ b/enumeration/resource/aws/aws_lambda_event_source_mapping.go @@ -1,22 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsLambdaEventSourceMappingResourceType = "aws_lambda_event_source_mapping" - -func initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsLambdaEventSourceMappingResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - source := val.GetString("event_source_arn") - dest := val.GetString("function_name") - if source != nil && *source != "" && dest != nil && *dest != "" { - attrs["Source"] = *source - attrs["Dest"] = *dest - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsLambdaEventSourceMappingResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_lambda_function.go b/enumeration/resource/aws/aws_lambda_function.go index a0c0bb253..2a96322ab 100644 --- a/enumeration/resource/aws/aws_lambda_function.go +++ b/enumeration/resource/aws/aws_lambda_function.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsLambdaFunctionResourceType = "aws_lambda_function" - -func initAwsLambdaFunctionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsLambdaFunctionResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_launch_template.go b/enumeration/resource/aws/aws_launch_template.go index ce931e208..057cae083 100644 --- a/enumeration/resource/aws/aws_launch_template.go +++ b/enumeration/resource/aws/aws_launch_template.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsLaunchTemplateResourceType = "aws_launch_template" - -func initAwsLaunchTemplateMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsLaunchTemplateResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_lb.go b/enumeration/resource/aws/aws_lb.go index 791f8068f..c96853443 100644 --- a/enumeration/resource/aws/aws_lb.go +++ b/enumeration/resource/aws/aws_lb.go @@ -1,13 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsLoadBalancerResourceType = "aws_lb" - -func initAwsLoadBalancerMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsLoadBalancerResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "Name": *res.Attributes().GetString("name"), - } - }) -} diff --git a/enumeration/resource/aws/aws_nat_gateway.go b/enumeration/resource/aws/aws_nat_gateway.go index c51f3a98b..9dd9290b7 100644 --- a/enumeration/resource/aws/aws_nat_gateway.go +++ b/enumeration/resource/aws/aws_nat_gateway.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsNatGatewayResourceType = "aws_nat_gateway" - -func initNatGatewayMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsNatGatewayResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_network_acl.go b/enumeration/resource/aws/aws_network_acl.go index 46973ef15..f0d19dc27 100644 --- a/enumeration/resource/aws/aws_network_acl.go +++ b/enumeration/resource/aws/aws_network_acl.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsNetworkACLResourceType = "aws_network_acl" - -func initAwsNetworkACLMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsNetworkACLResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_network_acl_rule.go b/enumeration/resource/aws/aws_network_acl_rule.go index 8058f50f4..32ea15f55 100644 --- a/enumeration/resource/aws/aws_network_acl_rule.go +++ b/enumeration/resource/aws/aws_network_acl_rule.go @@ -3,55 +3,12 @@ package aws import ( "bytes" "fmt" - "strconv" "github.com/hashicorp/terraform/helper/hashcode" - "github.com/snyk/driftctl/enumeration/resource" ) const AwsNetworkACLRuleResourceType = "aws_network_acl_rule" -func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsNetworkACLRuleResourceType, resource.FlagDeepMode) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) map[string]string { - - ruleNumber := strconv.FormatInt(int64(*res.Attrs.GetInt("rule_number")), 10) - if ruleNumber == "32767" { - ruleNumber = "*" - } - - attrs := map[string]string{ - "Network": *res.Attrs.GetString("network_acl_id"), - "Egress": strconv.FormatBool(*res.Attrs.GetBool("egress")), - "Rule number": ruleNumber, - } - - if proto := res.Attrs.GetString("protocol"); proto != nil { - if *proto == "-1" { - *proto = "All" - } - attrs["Protocol"] = *proto - } - - if res.Attrs.GetFloat64("from_port") != nil && res.Attrs.GetFloat64("to_port") != nil { - attrs["Port range"] = fmt.Sprintf("%d - %d", - int64(*res.Attrs.GetFloat64("from_port")), - int64(*res.Attrs.GetFloat64("to_port")), - ) - } - - if cidr := res.Attrs.GetString("cidr_block"); cidr != nil && *cidr != "" { - attrs["CIDR"] = *cidr - } - - if cidr := res.Attrs.GetString("ipv6_cidr_block"); cidr != nil && *cidr != "" { - attrs["CIDR"] = *cidr - } - - return attrs - }) -} - func CreateNetworkACLRuleID(networkAclId string, ruleNumber int64, egress bool, protocol string) string { var buf bytes.Buffer buf.WriteString(fmt.Sprintf("%s-", networkAclId)) diff --git a/enumeration/resource/aws/aws_rds_cluster.go b/enumeration/resource/aws/aws_rds_cluster.go index 615d5d81c..d7d564e98 100644 --- a/enumeration/resource/aws/aws_rds_cluster.go +++ b/enumeration/resource/aws/aws_rds_cluster.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsRDSClusterResourceType = "aws_rds_cluster" - -func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsRDSClusterResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_route.go b/enumeration/resource/aws/aws_route.go index 2771e5838..ac1a1a83b 100644 --- a/enumeration/resource/aws/aws_route.go +++ b/enumeration/resource/aws/aws_route.go @@ -4,32 +4,10 @@ import ( "fmt" "github.com/hashicorp/terraform/helper/hashcode" - "github.com/snyk/driftctl/enumeration/resource" ) const AwsRouteResourceType = "aws_route" -func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if rtID := val.GetString("route_table_id"); rtID != nil && *rtID != "" { - attrs["Table"] = *rtID - } - if ipv4 := val.GetString("destination_cidr_block"); ipv4 != nil && *ipv4 != "" { - attrs["Destination"] = *ipv4 - } - if ipv6 := val.GetString("destination_ipv6_cidr_block"); ipv6 != nil && *ipv6 != "" { - attrs["Destination"] = *ipv6 - } - if prefix := val.GetString("destination_prefix_list_id"); prefix != nil && *prefix != "" { - attrs["Destination"] = *prefix - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsRouteResourceType, resource.FlagDeepMode) -} - func CalculateRouteID(tableId, CidrBlock, Ipv6CidrBlock, PrefixListId *string) string { if CidrBlock != nil && *CidrBlock != "" { return fmt.Sprintf("r-%s%d", *tableId, hashcode.String(*CidrBlock)) diff --git a/enumeration/resource/aws/aws_route53_health_check.go b/enumeration/resource/aws/aws_route53_health_check.go index e87e5b376..e3f91392a 100644 --- a/enumeration/resource/aws/aws_route53_health_check.go +++ b/enumeration/resource/aws/aws_route53_health_check.go @@ -1,43 +1,3 @@ package aws -import ( - "fmt" - - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsRoute53HealthCheckResourceType = "aws_route53_health_check" - -func initAwsRoute53HealthCheckMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53HealthCheckResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if tags := val.GetMap("tags"); tags != nil { - if name, ok := tags["Name"]; ok { - attrs["Name"] = name.(string) - } - } - port := val.GetInt("port") - path := val.GetString("resource_path") - if fqdn := val.GetString("fqdn"); fqdn != nil && *fqdn != "" { - attrs["Fqdn"] = *fqdn - if port != nil { - attrs["Port"] = fmt.Sprintf("%d", *port) - } - if path != nil && *path != "" { - attrs["Path"] = *path - } - } - if address := val.GetString("ip_address"); address != nil && *address != "" { - attrs["IpAddress"] = *address - if port != nil { - attrs["Port"] = fmt.Sprintf("%d", *port) - } - if path != nil && *path != "" { - attrs["Path"] = *path - } - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsRoute53HealthCheckResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_route53_record.go b/enumeration/resource/aws/aws_route53_record.go index de67f8c4e..b4cbc4194 100644 --- a/enumeration/resource/aws/aws_route53_record.go +++ b/enumeration/resource/aws/aws_route53_record.go @@ -1,25 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsRoute53RecordResourceType = "aws_route53_record" - -func initAwsRoute53RecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53RecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if fqdn := val.GetString("fqdn"); fqdn != nil && *fqdn != "" { - attrs["Fqdn"] = *fqdn - } - if ty := val.GetString("type"); ty != nil && *ty != "" { - attrs["Type"] = *ty - } - if zoneID := val.GetString("zone_id"); zoneID != nil && *zoneID != "" { - attrs["ZoneId"] = *zoneID - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsRoute53RecordResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_route53_zone.go b/enumeration/resource/aws/aws_route53_zone.go index 4d188b05f..678213cfb 100644 --- a/enumeration/resource/aws/aws_route53_zone.go +++ b/enumeration/resource/aws/aws_route53_zone.go @@ -1,19 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsRoute53ZoneResourceType = "aws_route53_zone" - -func initAwsRoute53ZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53ZoneResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsRoute53ZoneResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_route_table.go b/enumeration/resource/aws/aws_route_table.go index edef38567..f389e53e7 100644 --- a/enumeration/resource/aws/aws_route_table.go +++ b/enumeration/resource/aws/aws_route_table.go @@ -1,13 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsRouteTableResourceType = "aws_route_table" - -func initAwsRouteTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsRouteTableResourceType, resource.FlagDeepMode) - resourceSchemaRepository.SetNormalizeFunc(AwsRouteTableResourceType, func(res *resource.Resource) { - val := res.Attrs - val.SafeDelete([]string{"timeouts"}) - }) -} diff --git a/enumeration/resource/aws/aws_route_table_association.go b/enumeration/resource/aws/aws_route_table_association.go index 1632de70b..e253e0e69 100644 --- a/enumeration/resource/aws/aws_route_table_association.go +++ b/enumeration/resource/aws/aws_route_table_association.go @@ -1,23 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsRouteTableAssociationResourceType = "aws_route_table_association" - -func initAwsRouteTableAssociationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteTableAssociationResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if rtID := val.GetString("route_table_id"); rtID != nil && *rtID != "" { - attrs["Table"] = *rtID - } - if gtwID := val.GetString("gateway_id"); gtwID != nil && *gtwID != "" { - attrs["Gateway"] = *gtwID - } - if subnetID := val.GetString("subnet_id"); subnetID != nil && *subnetID != "" { - attrs["Subnet"] = *subnetID - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsRouteTableAssociationResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_s3_bucket.go b/enumeration/resource/aws/aws_s3_bucket.go index 11d578e6a..0dc0ccf98 100644 --- a/enumeration/resource/aws/aws_s3_bucket.go +++ b/enumeration/resource/aws/aws_s3_bucket.go @@ -1,16 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsS3BucketResourceType = "aws_s3_bucket" - -func initAwsS3BucketMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsS3BucketResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetFlags(AwsS3BucketResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_s3_bucket_analytics_configuration.go b/enumeration/resource/aws/aws_s3_bucket_analytics_configuration.go index 470d5faaf..ad2da52fe 100644 --- a/enumeration/resource/aws/aws_s3_bucket_analytics_configuration.go +++ b/enumeration/resource/aws/aws_s3_bucket_analytics_configuration.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsS3BucketAnalyticsConfigurationResourceType = "aws_s3_bucket_analytics_configuration" - -func initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsS3BucketAnalyticsConfigurationResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_s3_bucket_inventory.go b/enumeration/resource/aws/aws_s3_bucket_inventory.go index 7424fc84e..f03ad346f 100644 --- a/enumeration/resource/aws/aws_s3_bucket_inventory.go +++ b/enumeration/resource/aws/aws_s3_bucket_inventory.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsS3BucketInventoryResourceType = "aws_s3_bucket_inventory" - -func initAwsS3BucketInventoryMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsS3BucketInventoryResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_s3_bucket_metric.go b/enumeration/resource/aws/aws_s3_bucket_metric.go index 68e14a8df..6a13b37c6 100644 --- a/enumeration/resource/aws/aws_s3_bucket_metric.go +++ b/enumeration/resource/aws/aws_s3_bucket_metric.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsS3BucketMetricResourceType = "aws_s3_bucket_metric" - -func initAwsS3BucketMetricMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsS3BucketMetricResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_s3_bucket_notification.go b/enumeration/resource/aws/aws_s3_bucket_notification.go index 789ff720f..bd6b7098c 100644 --- a/enumeration/resource/aws/aws_s3_bucket_notification.go +++ b/enumeration/resource/aws/aws_s3_bucket_notification.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsS3BucketNotificationResourceType = "aws_s3_bucket_notification" - -func initAwsS3BucketNotificationMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsS3BucketNotificationResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_s3_bucket_policy.go b/enumeration/resource/aws/aws_s3_bucket_policy.go index 5f2822a33..e8c650874 100644 --- a/enumeration/resource/aws/aws_s3_bucket_policy.go +++ b/enumeration/resource/aws/aws_s3_bucket_policy.go @@ -1,16 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsS3BucketPolicyResourceType = "aws_s3_bucket_policy" - -func initAwsS3BucketPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsS3BucketPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetFlags(AwsS3BucketPolicyResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_security_group.go b/enumeration/resource/aws/aws_security_group.go index 55510c70d..13c748a2a 100644 --- a/enumeration/resource/aws/aws_security_group.go +++ b/enumeration/resource/aws/aws_security_group.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsSecurityGroupResourceType = "aws_security_group" - -func initAwsSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsSecurityGroupResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_security_group_rule.go b/enumeration/resource/aws/aws_security_group_rule.go index 406970424..96efcbdce 100644 --- a/enumeration/resource/aws/aws_security_group_rule.go +++ b/enumeration/resource/aws/aws_security_group_rule.go @@ -3,7 +3,6 @@ package aws import ( "bytes" "fmt" - "strings" "github.com/hashicorp/terraform/helper/hashcode" "github.com/snyk/driftctl/enumeration/resource" @@ -53,87 +52,3 @@ func CreateSecurityGroupRuleIdHash(attrs *resource.Attributes) string { return fmt.Sprintf("sgrule-%d", hashcode.String(buf.String())) } - -func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if sgID := val.GetString("security_group_id"); sgID != nil && *sgID != "" { - attrs["SecurityGroup"] = *sgID - } - if protocol := val.GetString("protocol"); protocol != nil && *protocol != "" { - if *protocol == "-1" { - *protocol = "All" - } - attrs["Protocol"] = *protocol - } - fromPort := val.GetInt("from_port") - toPort := val.GetInt("to_port") - if fromPort != nil && toPort != nil { - portRange := "All" - if *fromPort != 0 && *fromPort == *toPort { - portRange = fmt.Sprintf("%d", *fromPort) - } - if *fromPort != 0 && *toPort != 0 && *fromPort != *toPort { - portRange = fmt.Sprintf("%d-%d", *fromPort, *toPort) - } - attrs["Ports"] = portRange - } - ty := val.GetString("type") - if ty != nil && *ty != "" { - attrs["Type"] = *ty - var sourceOrDestination string - switch *ty { - case "egress": - sourceOrDestination = "Destination" - case "ingress": - sourceOrDestination = "Source" - } - if ipv4 := val.GetSlice("cidr_blocks"); len(ipv4) > 0 { - attrs[sourceOrDestination] = join(ipv4, ", ") - } - if ipv6 := val.GetSlice("ipv6_cidr_blocks"); len(ipv6) > 0 { - attrs[sourceOrDestination] = join(ipv6, ", ") - } - if prefixList := val.GetSlice("prefix_list_ids"); len(prefixList) > 0 { - attrs[sourceOrDestination] = join(prefixList, ", ") - } - if sourceSgID := val.GetString("source_security_group_id"); sourceSgID != nil && *sourceSgID != "" { - attrs[sourceOrDestination] = *sourceSgID - } - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsSecurityGroupRuleResourceType, resource.FlagDeepMode) -} - -func join(elems []interface{}, sep string) string { - firstElemt, ok := elems[0].(string) - if !ok { - panic("cannot join a slice that contains something else than strings") - } - switch len(elems) { - case 0: - return "" - case 1: - - return firstElemt - } - n := len(sep) * (len(elems) - 1) - for i := 0; i < len(elems); i++ { - n += len(elems[i].(string)) - } - - var b strings.Builder - b.Grow(n) - b.WriteString(firstElemt) - for _, s := range elems[1:] { - b.WriteString(sep) - elem, ok := s.(string) - if !ok { - panic("cannot join a slice that contains something else than strings") - } - b.WriteString(elem) - } - return b.String() -} diff --git a/enumeration/resource/aws/aws_sns_topic.go b/enumeration/resource/aws/aws_sns_topic.go index ca67dce14..8e1d83a56 100644 --- a/enumeration/resource/aws/aws_sns_topic.go +++ b/enumeration/resource/aws/aws_sns_topic.go @@ -1,28 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsSnsTopicResourceType = "aws_sns_topic" - -func initSnsTopicMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsSnsTopicResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "delivery_policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsSnsTopicResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - if displayName := val.GetString("display_name"); displayName != nil && *displayName != "" { - attrs["DisplayName"] = *displayName - } - } - return attrs - }) - resourceSchemaRepository.SetFlags(AwsSnsTopicResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_sns_topic_policy.go b/enumeration/resource/aws/aws_sns_topic_policy.go index 3efcf2536..e6a95bc83 100644 --- a/enumeration/resource/aws/aws_sns_topic_policy.go +++ b/enumeration/resource/aws/aws_sns_topic_policy.go @@ -1,16 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsSnsTopicPolicyResourceType = "aws_sns_topic_policy" - -func initSnsTopicPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsSnsTopicPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetFlags(AwsSnsTopicPolicyResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_sns_topic_subscription.go b/enumeration/resource/aws/aws_sns_topic_subscription.go index 46505ff05..8473925c4 100644 --- a/enumeration/resource/aws/aws_sns_topic_subscription.go +++ b/enumeration/resource/aws/aws_sns_topic_subscription.go @@ -1,20 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription" - -func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsSnsTopicSubscriptionResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "delivery_policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - "filter_policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - - resourceSchemaRepository.SetFlags(AwsSnsTopicSubscriptionResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_sqs_queue.go b/enumeration/resource/aws/aws_sqs_queue.go index b6ee1dcf5..5f72d488f 100644 --- a/enumeration/resource/aws/aws_sqs_queue.go +++ b/enumeration/resource/aws/aws_sqs_queue.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsSqsQueueResourceType = "aws_sqs_queue" - -func initSqsQueueMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsSqsQueueResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_sqs_queue_policy.go b/enumeration/resource/aws/aws_sqs_queue_policy.go index 422e2d03b..5c7802805 100644 --- a/enumeration/resource/aws/aws_sqs_queue_policy.go +++ b/enumeration/resource/aws/aws_sqs_queue_policy.go @@ -1,16 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsSqsQueuePolicyResourceType = "aws_sqs_queue_policy" - -func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.UpdateSchema(AwsSqsQueuePolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ - "policy": func(attributeSchema *resource.AttributeSchema) { - attributeSchema.JsonString = true - }, - }) - resourceSchemaRepository.SetFlags(AwsSqsQueuePolicyResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_subnet.go b/enumeration/resource/aws/aws_subnet.go index e25361a18..dcd0d1069 100644 --- a/enumeration/resource/aws/aws_subnet.go +++ b/enumeration/resource/aws/aws_subnet.go @@ -1,11 +1,3 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AwsSubnetResourceType = "aws_subnet" - -func initAwsSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsSubnetResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/aws_vpc.go b/enumeration/resource/aws/aws_vpc.go index 8d7ae9acb..cd8ad7186 100644 --- a/enumeration/resource/aws/aws_vpc.go +++ b/enumeration/resource/aws/aws_vpc.go @@ -1,9 +1,3 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" - const AwsVpcResourceType = "aws_vpc" - -func initAwsVpcMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AwsVpcResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/aws/metadatas.go b/enumeration/resource/aws/metadatas.go deleted file mode 100644 index c6aac2b9b..000000000 --- a/enumeration/resource/aws/metadatas.go +++ /dev/null @@ -1,70 +0,0 @@ -package aws - -import "github.com/snyk/driftctl/enumeration/resource" - -func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - initAwsAmiMetaData(resourceSchemaRepository) - initAwsCloudfrontDistributionMetaData(resourceSchemaRepository) - initAwsDbInstanceMetaData(resourceSchemaRepository) - initAwsDbSubnetGroupMetaData(resourceSchemaRepository) - initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository) - initAwsDefaultSubnetMetaData(resourceSchemaRepository) - initAwsDefaultVpcMetaData(resourceSchemaRepository) - initAwsDefaultRouteTableMetadata(resourceSchemaRepository) - initAwsDynamodbTableMetaData(resourceSchemaRepository) - initAwsEbsSnapshotMetaData(resourceSchemaRepository) - initAwsInstanceMetaData(resourceSchemaRepository) - initAwsInternetGatewayMetaData(resourceSchemaRepository) - initAwsEbsVolumeMetaData(resourceSchemaRepository) - initAwsEipMetaData(resourceSchemaRepository) - initAwsEipAssociationMetaData(resourceSchemaRepository) - initAwsS3BucketMetaData(resourceSchemaRepository) - initAwsS3BucketPolicyMetaData(resourceSchemaRepository) - initAwsS3BucketInventoryMetadata(resourceSchemaRepository) - initAwsS3BucketMetricMetadata(resourceSchemaRepository) - initAwsS3BucketNotificationMetadata(resourceSchemaRepository) - initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository) - initAwsEcrRepositoryMetaData(resourceSchemaRepository) - initAwsRouteMetaData(resourceSchemaRepository) - initAwsRouteTableAssociationMetaData(resourceSchemaRepository) - initAwsRoute53RecordMetaData(resourceSchemaRepository) - initAwsRoute53ZoneMetaData(resourceSchemaRepository) - initAwsRoute53HealthCheckMetaData(resourceSchemaRepository) - initAwsRouteTableMetaData(resourceSchemaRepository) - initSnsTopicSubscriptionMetaData(resourceSchemaRepository) - initSnsTopicPolicyMetaData(resourceSchemaRepository) - initSnsTopicMetaData(resourceSchemaRepository) - initSqsQueueMetaData(resourceSchemaRepository) - initAwsIAMAccessKeyMetaData(resourceSchemaRepository) - initAwsIAMPolicyMetaData(resourceSchemaRepository) - initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository) - initAwsIAMRoleMetaData(resourceSchemaRepository) - initAwsIAMRolePolicyMetaData(resourceSchemaRepository) - initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository) - initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository) - initAwsIAMUserMetaData(resourceSchemaRepository) - initAwsIAMUserPolicyMetaData(resourceSchemaRepository) - initAwsKeyPairMetaData(resourceSchemaRepository) - initAwsKmsKeyMetaData(resourceSchemaRepository) - initAwsKmsAliasMetaData(resourceSchemaRepository) - initAwsLambdaFunctionMetaData(resourceSchemaRepository) - initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository) - initNatGatewayMetaData(resourceSchemaRepository) - initAwsNetworkACLMetaData(resourceSchemaRepository) - initAwsNetworkACLRuleMetaData(resourceSchemaRepository) - initAwsDefaultNetworkACLMetaData(resourceSchemaRepository) - initAwsSubnetMetaData(resourceSchemaRepository) - initAwsSQSQueuePolicyMetaData(resourceSchemaRepository) - initAwsSecurityGroupRuleMetaData(resourceSchemaRepository) - initAwsSecurityGroupMetaData(resourceSchemaRepository) - initAwsRDSClusterMetaData(resourceSchemaRepository) - initAwsCloudformationStackMetaData(resourceSchemaRepository) - initAwsVpcMetaData(resourceSchemaRepository) - initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository) - initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository) - initAwsLaunchTemplateMetaData(resourceSchemaRepository) - initAwsApiGatewayV2ModelMetaData(resourceSchemaRepository) - initAwsApiGatewayV2MappingMetaData(resourceSchemaRepository) - initAwsEbsEncryptionByDefaultMetaData(resourceSchemaRepository) - initAwsLoadBalancerMetaData(resourceSchemaRepository) -} diff --git a/enumeration/resource/azurerm/azurerm_container_registry.go b/enumeration/resource/azurerm/azurerm_container_registry.go index 4a6d52b65..f6c07ea00 100644 --- a/enumeration/resource/azurerm/azurerm_container_registry.go +++ b/enumeration/resource/azurerm/azurerm_container_registry.go @@ -1,16 +1,3 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" - const AzureContainerRegistryResourceType = "azurerm_container_registry" - -func initAzureContainerRegistryMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureContainerRegistryResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) -} diff --git a/enumeration/resource/azurerm/azurerm_firewall.go b/enumeration/resource/azurerm/azurerm_firewall.go index ded79fe2a..be8380f0b 100644 --- a/enumeration/resource/azurerm/azurerm_firewall.go +++ b/enumeration/resource/azurerm/azurerm_firewall.go @@ -1,16 +1,3 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" - const AzureFirewallResourceType = "azurerm_firewall" - -func initAzureFirewallMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureFirewallResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) -} diff --git a/enumeration/resource/azurerm/azurerm_image.go b/enumeration/resource/azurerm/azurerm_image.go index a86e8d2e4..f58f90d85 100644 --- a/enumeration/resource/azurerm/azurerm_image.go +++ b/enumeration/resource/azurerm/azurerm_image.go @@ -1,19 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzureImageResourceType = "azurerm_image" - -func initAzureImageMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureImageResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - - if v := res.Attributes().GetString("name"); v != nil && *v != "" { - attrs["Name"] = *v - } - - return attrs - }) -} diff --git a/enumeration/resource/azurerm/azurerm_lb.go b/enumeration/resource/azurerm/azurerm_lb.go index 04a7cc0d5..53489f38e 100644 --- a/enumeration/resource/azurerm/azurerm_lb.go +++ b/enumeration/resource/azurerm/azurerm_lb.go @@ -1,16 +1,3 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" - const AzureLoadBalancerResourceType = "azurerm_lb" - -func initAzureLoadBalancerMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureLoadBalancerResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) -} diff --git a/enumeration/resource/azurerm/azurerm_lb_rule.go b/enumeration/resource/azurerm/azurerm_lb_rule.go index c1ae97c8b..848d7fff9 100644 --- a/enumeration/resource/azurerm/azurerm_lb_rule.go +++ b/enumeration/resource/azurerm/azurerm_lb_rule.go @@ -1,16 +1,3 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" - const AzureLoadBalancerRuleResourceType = "azurerm_lb_rule" - -func initAzureLoadBalancerRuleMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - if name := res.Attributes().GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzureLoadBalancerRuleResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/azurerm/azurerm_network_security_group.go b/enumeration/resource/azurerm/azurerm_network_security_group.go index 29303ba1c..30ba15a0e 100644 --- a/enumeration/resource/azurerm/azurerm_network_security_group.go +++ b/enumeration/resource/azurerm/azurerm_network_security_group.go @@ -1,17 +1,3 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" - const AzureNetworkSecurityGroupResourceType = "azurerm_network_security_group" - -func initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureNetworkSecurityGroupResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzureNetworkSecurityGroupResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/azurerm/azurerm_postgresql_database.go b/enumeration/resource/azurerm/azurerm_postgresql_database.go index 7a5784f95..2058c7b19 100644 --- a/enumeration/resource/azurerm/azurerm_postgresql_database.go +++ b/enumeration/resource/azurerm/azurerm_postgresql_database.go @@ -1,16 +1,3 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" - const AzurePostgresqlDatabaseResourceType = "azurerm_postgresql_database" - -func initAzurePostgresqlDatabaseMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePostgresqlDatabaseResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) -} diff --git a/enumeration/resource/azurerm/azurerm_postgresql_server.go b/enumeration/resource/azurerm/azurerm_postgresql_server.go index 167e68c3e..cd4269323 100644 --- a/enumeration/resource/azurerm/azurerm_postgresql_server.go +++ b/enumeration/resource/azurerm/azurerm_postgresql_server.go @@ -1,16 +1,3 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" - const AzurePostgresqlServerResourceType = "azurerm_postgresql_server" - -func initAzurePostgresqlServerMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePostgresqlServerResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) -} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_a_record.go b/enumeration/resource/azurerm/azurerm_private_dns_a_record.go index 014ebb7f6..e6b955b33 100644 --- a/enumeration/resource/azurerm/azurerm_private_dns_a_record.go +++ b/enumeration/resource/azurerm/azurerm_private_dns_a_record.go @@ -1,22 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzurePrivateDNSARecordResourceType = "azurerm_private_dns_a_record" - -func initAzurePrivateDNSARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSARecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSARecordResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_aaaa_record.go b/enumeration/resource/azurerm/azurerm_private_dns_aaaa_record.go index ad3582928..bece10dd8 100644 --- a/enumeration/resource/azurerm/azurerm_private_dns_aaaa_record.go +++ b/enumeration/resource/azurerm/azurerm_private_dns_aaaa_record.go @@ -1,22 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzurePrivateDNSAAAARecordResourceType = "azurerm_private_dns_aaaa_record" - -func initAzurePrivateDNSAAAARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSAAAARecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSAAAARecordResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_cname_record.go b/enumeration/resource/azurerm/azurerm_private_dns_cname_record.go index 5673ddff1..12d1aa3e6 100644 --- a/enumeration/resource/azurerm/azurerm_private_dns_cname_record.go +++ b/enumeration/resource/azurerm/azurerm_private_dns_cname_record.go @@ -1,21 +1,3 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" - const AzurePrivateDNSCNameRecordResourceType = "azurerm_private_dns_cname_record" - -func initAzurePrivateDNSCNameRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AzurePrivateDNSCNameRecordResourceType, resource.FlagDeepMode) - - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSCNameRecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) -} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_mx_record.go b/enumeration/resource/azurerm/azurerm_private_dns_mx_record.go index 478a721cc..3fb56baf4 100644 --- a/enumeration/resource/azurerm/azurerm_private_dns_mx_record.go +++ b/enumeration/resource/azurerm/azurerm_private_dns_mx_record.go @@ -1,25 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzurePrivateDNSMXRecordResourceType = "azurerm_private_dns_mx_record" - -func initAzurePrivateDNSMXRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) { - res.Attributes().SafeDelete([]string{"timeouts"}) - }) - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSMXRecordResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_ptr_record.go b/enumeration/resource/azurerm/azurerm_private_dns_ptr_record.go index 59ea61355..bc949ebcc 100644 --- a/enumeration/resource/azurerm/azurerm_private_dns_ptr_record.go +++ b/enumeration/resource/azurerm/azurerm_private_dns_ptr_record.go @@ -1,22 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzurePrivateDNSPTRRecordResourceType = "azurerm_private_dns_ptr_record" - -func initAzurePrivateDNSPTRRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSPTRRecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSPTRRecordResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_srv_record.go b/enumeration/resource/azurerm/azurerm_private_dns_srv_record.go index 91942d1cd..9cb3b214a 100644 --- a/enumeration/resource/azurerm/azurerm_private_dns_srv_record.go +++ b/enumeration/resource/azurerm/azurerm_private_dns_srv_record.go @@ -1,22 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzurePrivateDNSSRVRecordResourceType = "azurerm_private_dns_srv_record" - -func initAzurePrivateDNSSRVRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSSRVRecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSSRVRecordResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_txt_record.go b/enumeration/resource/azurerm/azurerm_private_dns_txt_record.go index 173675421..724d2f198 100644 --- a/enumeration/resource/azurerm/azurerm_private_dns_txt_record.go +++ b/enumeration/resource/azurerm/azurerm_private_dns_txt_record.go @@ -1,22 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzurePrivateDNSTXTRecordResourceType = "azurerm_private_dns_txt_record" - -func initAzurePrivateDNSTXTRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSTXTRecordResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - if zone := val.GetString("zone_name"); zone != nil && *zone != "" { - attrs["Zone"] = *zone - } - return attrs - }) - resourceSchemaRepository.SetFlags(AzurePrivateDNSTXTRecordResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/azurerm/azurerm_private_dns_zone.go b/enumeration/resource/azurerm/azurerm_private_dns_zone.go index 19075ea3a..0114a2901 100644 --- a/enumeration/resource/azurerm/azurerm_private_dns_zone.go +++ b/enumeration/resource/azurerm/azurerm_private_dns_zone.go @@ -1,11 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzurePrivateDNSZoneResourceType = "azurerm_private_dns_zone" - -func initAzurePrivateDNSZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(AzurePrivateDNSZoneResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/azurerm/azurerm_public_ip.go b/enumeration/resource/azurerm/azurerm_public_ip.go index ac3d07102..6a7324322 100644 --- a/enumeration/resource/azurerm/azurerm_public_ip.go +++ b/enumeration/resource/azurerm/azurerm_public_ip.go @@ -1,16 +1,3 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" - const AzurePublicIPResourceType = "azurerm_public_ip" - -func initAzurePublicIPMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePublicIPResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) -} diff --git a/enumeration/resource/azurerm/azurerm_resource_group.go b/enumeration/resource/azurerm/azurerm_resource_group.go index f30885cb7..dfcff5c68 100644 --- a/enumeration/resource/azurerm/azurerm_resource_group.go +++ b/enumeration/resource/azurerm/azurerm_resource_group.go @@ -1,16 +1,3 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" - const AzureResourceGroupResourceType = "azurerm_resource_group" - -func initAzureResourceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureResourceGroupResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) -} diff --git a/enumeration/resource/azurerm/azurerm_route.go b/enumeration/resource/azurerm/azurerm_route.go index 79789fc1f..08a0baa09 100644 --- a/enumeration/resource/azurerm/azurerm_route.go +++ b/enumeration/resource/azurerm/azurerm_route.go @@ -1,23 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzureRouteResourceType = "azurerm_route" - -func initAzureRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureRouteResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - - if v := res.Attributes().GetString("name"); v != nil && *v != "" { - attrs["Name"] = *v - } - - if v := res.Attributes().GetString("route_table_name"); v != nil && *v != "" { - attrs["Table"] = *v - } - - return attrs - }) -} diff --git a/enumeration/resource/azurerm/azurerm_route_table.go b/enumeration/resource/azurerm/azurerm_route_table.go index d0056f6aa..466374eda 100644 --- a/enumeration/resource/azurerm/azurerm_route_table.go +++ b/enumeration/resource/azurerm/azurerm_route_table.go @@ -1,18 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzureRouteTableResourceType = "azurerm_route_table" - -func initAzureRouteTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureRouteTableResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - - if v := res.Attributes().GetString("name"); v != nil && *v != "" { - attrs["Name"] = *v - } - return attrs - }) -} diff --git a/enumeration/resource/azurerm/azurerm_ssh_public_key.go b/enumeration/resource/azurerm/azurerm_ssh_public_key.go index 1d648ba28..6a1280d63 100644 --- a/enumeration/resource/azurerm/azurerm_ssh_public_key.go +++ b/enumeration/resource/azurerm/azurerm_ssh_public_key.go @@ -1,20 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzureSSHPublicKeyResourceType = "azurerm_ssh_public_key" - -func initAzureSSHPublicKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureSSHPublicKeyResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - - if v := res.Attributes().GetString("name"); v != nil && *v != "" { - attrs["Name"] = *v - } - - return attrs - }) - resourceSchemaRepository.SetFlags(AzureSSHPublicKeyResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/azurerm/azurerm_virtual_network.go b/enumeration/resource/azurerm/azurerm_virtual_network.go index 790413f15..ef8d54886 100644 --- a/enumeration/resource/azurerm/azurerm_virtual_network.go +++ b/enumeration/resource/azurerm/azurerm_virtual_network.go @@ -1,18 +1,3 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" -) - const AzureVirtualNetworkResourceType = "azurerm_virtual_network" - -func initAzureVirtualNetworkMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureVirtualNetworkResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - - if v := res.Attributes().GetString("name"); v != nil && *v != "" { - attrs["Name"] = *v - } - return attrs - }) -} diff --git a/enumeration/resource/azurerm/metadata.go b/enumeration/resource/azurerm/metadata.go deleted file mode 100644 index 5051e2267..000000000 --- a/enumeration/resource/azurerm/metadata.go +++ /dev/null @@ -1,28 +0,0 @@ -package azurerm - -import "github.com/snyk/driftctl/enumeration/resource" - -func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - initAzureVirtualNetworkMetaData(resourceSchemaRepository) - initAzureRouteTableMetaData(resourceSchemaRepository) - initAzureRouteMetaData(resourceSchemaRepository) - initAzureResourceGroupMetadata(resourceSchemaRepository) - initAzureContainerRegistryMetadata(resourceSchemaRepository) - initAzureFirewallMetadata(resourceSchemaRepository) - initAzurePostgresqlServerMetadata(resourceSchemaRepository) - initAzurePublicIPMetadata(resourceSchemaRepository) - initAzurePostgresqlDatabaseMetadata(resourceSchemaRepository) - initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository) - initAzureLoadBalancerMetadata(resourceSchemaRepository) - initAzurePrivateDNSZoneMetaData(resourceSchemaRepository) - initAzurePrivateDNSARecordMetaData(resourceSchemaRepository) - initAzurePrivateDNSAAAARecordMetaData(resourceSchemaRepository) - initAzurePrivateDNSPTRRecordMetaData(resourceSchemaRepository) - initAzurePrivateDNSSRVRecordMetaData(resourceSchemaRepository) - initAzurePrivateDNSMXRecordMetaData(resourceSchemaRepository) - initAzurePrivateDNSTXTRecordMetaData(resourceSchemaRepository) - initAzureImageMetaData(resourceSchemaRepository) - initAzureSSHPublicKeyMetaData(resourceSchemaRepository) - initAzurePrivateDNSCNameRecordMetaData(resourceSchemaRepository) - initAzureLoadBalancerRuleMetadata(resourceSchemaRepository) -} diff --git a/enumeration/resource/github/github_branch_protection.go b/enumeration/resource/github/github_branch_protection.go index 03c5b22d0..7275f6268 100644 --- a/enumeration/resource/github/github_branch_protection.go +++ b/enumeration/resource/github/github_branch_protection.go @@ -1,39 +1,3 @@ -// GENERATED, DO NOT EDIT THIS FILE package github -import ( - "encoding/base64" - - "github.com/snyk/driftctl/enumeration/resource" -) - const GithubBranchProtectionResourceType = "github_branch_protection" - -func initGithubBranchProtectionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GithubBranchProtectionResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - pattern := val.GetString("pattern") - repoID := val.GetString("repository_id") - if pattern != nil && *pattern != "" { - id := "" - if repoID != nil && *repoID != "" { - decodedID, err := base64.StdEncoding.DecodeString(*repoID) - if err == nil { - id = string(decodedID) - } - } - if id == "" { - attrs["Branch"] = *pattern - attrs["Id"] = res.ResourceId() - return attrs - } - attrs["Branch"] = *pattern - attrs["RepoId"] = id - return attrs - } - attrs["Id"] = res.ResourceId() - return attrs - }) - resourceSchemaRepository.SetFlags(GithubBranchProtectionResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/github/github_membership.go b/enumeration/resource/github/github_membership.go index 2a5dbd67a..de4172968 100644 --- a/enumeration/resource/github/github_membership.go +++ b/enumeration/resource/github/github_membership.go @@ -1,10 +1,3 @@ -// GENERATED, DO NOT EDIT THIS FILE package github -import "github.com/snyk/driftctl/enumeration/resource" - const GithubMembershipResourceType = "github_membership" - -func initGithubMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(GithubMembershipResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/github/github_repository.go b/enumeration/resource/github/github_repository.go index 80f0e31cc..535d61d19 100644 --- a/enumeration/resource/github/github_repository.go +++ b/enumeration/resource/github/github_repository.go @@ -1,9 +1,3 @@ package github -import "github.com/snyk/driftctl/enumeration/resource" - const GithubRepositoryResourceType = "github_repository" - -func initGithubRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(GithubRepositoryResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/github/github_team.go b/enumeration/resource/github/github_team.go index 6d679b396..aa32fce7b 100644 --- a/enumeration/resource/github/github_team.go +++ b/enumeration/resource/github/github_team.go @@ -1,19 +1,3 @@ -// GENERATED, DO NOT EDIT THIS FILE package github -import "github.com/snyk/driftctl/enumeration/resource" - const GithubTeamResourceType = "github_team" - -func initGithubTeamMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GithubTeamResourceType, func(res *resource.Resource) map[string]string { - val := res.Attrs - attrs := make(map[string]string) - attrs["Id"] = res.ResourceId() - if name := val.GetString("name"); name != nil && *name != "" { - attrs["Name"] = *name - } - return attrs - }) - resourceSchemaRepository.SetFlags(GithubTeamResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/github/github_team_membership.go b/enumeration/resource/github/github_team_membership.go index b2056879e..46eb4b74b 100644 --- a/enumeration/resource/github/github_team_membership.go +++ b/enumeration/resource/github/github_team_membership.go @@ -1,10 +1,3 @@ -// GENERATED, DO NOT EDIT THIS FILE package github -import "github.com/snyk/driftctl/enumeration/resource" - const GithubTeamMembershipResourceType = "github_team_membership" - -func initGithubTeamMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(GithubTeamMembershipResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/github/metadatas.go b/enumeration/resource/github/metadatas.go deleted file mode 100644 index 246227851..000000000 --- a/enumeration/resource/github/metadatas.go +++ /dev/null @@ -1,11 +0,0 @@ -package github - -import "github.com/snyk/driftctl/enumeration/resource" - -func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - initGithubBranchProtectionMetaData(resourceSchemaRepository) - initGithubMembershipMetaData(resourceSchemaRepository) - initGithubRepositoryMetaData(resourceSchemaRepository) - initGithubTeamMetaData(resourceSchemaRepository) - initGithubTeamMembershipMetaData(resourceSchemaRepository) -} diff --git a/enumeration/resource/google/google_bigquery_dataset.go b/enumeration/resource/google/google_bigquery_dataset.go index db663d490..e30b21de8 100644 --- a/enumeration/resource/google/google_bigquery_dataset.go +++ b/enumeration/resource/google/google_bigquery_dataset.go @@ -1,13 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleBigqueryDatasetResourceType = "google_bigquery_dataset" - -func initGoogleBigqueryDatasetMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleBigqueryDatasetResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attrs.GetString("friendly_name"), - } - }) -} diff --git a/enumeration/resource/google/google_bigquery_table.go b/enumeration/resource/google/google_bigquery_table.go index 9c39658d1..eddf837dd 100644 --- a/enumeration/resource/google/google_bigquery_table.go +++ b/enumeration/resource/google/google_bigquery_table.go @@ -1,13 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleBigqueryTableResourceType = "google_bigquery_table" - -func initGoogleBigqueryTableMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleBigqueryTableResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "name": *res.Attrs.GetString("friendly_name"), - } - }) -} diff --git a/enumeration/resource/google/google_compute_address.go b/enumeration/resource/google/google_compute_address.go index a37732855..85249fd08 100644 --- a/enumeration/resource/google/google_compute_address.go +++ b/enumeration/resource/google/google_compute_address.go @@ -1,14 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleComputeAddressResourceType = "google_compute_address" - -func initGoogleComputeAddressMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeAddressResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "Name": *res.Attributes().GetString("name"), - "Address": *res.Attributes().GetString("address"), - } - }) -} diff --git a/enumeration/resource/google/google_compute_disk.go b/enumeration/resource/google/google_compute_disk.go index ed40a222e..bef0de819 100644 --- a/enumeration/resource/google/google_compute_disk.go +++ b/enumeration/resource/google/google_compute_disk.go @@ -1,13 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleComputeDiskResourceType = "google_compute_disk" - -func initGoogleComputeDiskMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeDiskResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "Name": *res.Attributes().GetString("name"), - } - }) -} diff --git a/enumeration/resource/google/google_compute_firewall.go b/enumeration/resource/google/google_compute_firewall.go index e8cb38eba..ae5f4361b 100644 --- a/enumeration/resource/google/google_compute_firewall.go +++ b/enumeration/resource/google/google_compute_firewall.go @@ -1,9 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleComputeFirewallResourceType = "google_compute_firewall" - -func initGoogleComputeFirewallMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(GoogleComputeFirewallResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/google/google_compute_global_address.go b/enumeration/resource/google/google_compute_global_address.go index 1c3af037c..ac4b99fdd 100644 --- a/enumeration/resource/google/google_compute_global_address.go +++ b/enumeration/resource/google/google_compute_global_address.go @@ -1,14 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleComputeGlobalAddressResourceType = "google_compute_global_address" - -func initGoogleComputeGlobalAddressMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeGlobalAddressResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "Name": *res.Attributes().GetString("name"), - "Address": *res.Attributes().GetString("address"), - } - }) -} diff --git a/enumeration/resource/google/google_compute_health_check.go b/enumeration/resource/google/google_compute_health_check.go index c33b81731..3cc34cbc6 100644 --- a/enumeration/resource/google/google_compute_health_check.go +++ b/enumeration/resource/google/google_compute_health_check.go @@ -1,13 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleComputeHealthCheckResourceType = "google_compute_health_check" - -func initGoogleComputeHealthCheckMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeHealthCheckResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "Name": *res.Attributes().GetString("name"), - } - }) -} diff --git a/enumeration/resource/google/google_compute_image.go b/enumeration/resource/google/google_compute_image.go index f52788da5..32ff8e5b1 100644 --- a/enumeration/resource/google/google_compute_image.go +++ b/enumeration/resource/google/google_compute_image.go @@ -1,13 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleComputeImageResourceType = "google_compute_image" - -func initGoogleComputeImageMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeImageResourceType, func(res *resource.Resource) map[string]string { - return map[string]string{ - "Name": *res.Attributes().GetString("name"), - } - }) -} diff --git a/enumeration/resource/google/google_compute_instance_group.go b/enumeration/resource/google/google_compute_instance_group.go index 75c250d92..ebbad3ee7 100644 --- a/enumeration/resource/google/google_compute_instance_group.go +++ b/enumeration/resource/google/google_compute_instance_group.go @@ -1,16 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleComputeInstanceGroupResourceType = "google_compute_instance_group" - -func initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - if v := res.Attributes().GetString("name"); v != nil && *v != "" { - attrs["Name"] = *v - } - return attrs - }) - resourceSchemaRepository.SetFlags(GoogleComputeInstanceGroupResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/google/google_compute_instance_group_manager.go b/enumeration/resource/google/google_compute_instance_group_manager.go index 35ab1fbbc..334201a90 100644 --- a/enumeration/resource/google/google_compute_instance_group_manager.go +++ b/enumeration/resource/google/google_compute_instance_group_manager.go @@ -1,15 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleComputeInstanceGroupManagerResourceType = "google_compute_instance_group_manager" - -func initComputeInstanceGroupManagerMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeInstanceGroupManagerResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - if v := res.Attributes().GetString("name"); v != nil && *v != "" { - attrs["Name"] = *v - } - return attrs - }) -} diff --git a/enumeration/resource/google/google_compute_network.go b/enumeration/resource/google/google_compute_network.go index bde14716f..dbf73dbb0 100644 --- a/enumeration/resource/google/google_compute_network.go +++ b/enumeration/resource/google/google_compute_network.go @@ -1,9 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleComputeNetworkResourceType = "google_compute_network" - -func initGoogleComputeNetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(GoogleComputeNetworkResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/google/google_compute_subnetwork.go b/enumeration/resource/google/google_compute_subnetwork.go index 444101bf6..0491a399b 100644 --- a/enumeration/resource/google/google_compute_subnetwork.go +++ b/enumeration/resource/google/google_compute_subnetwork.go @@ -1,17 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleComputeSubnetworkResourceType = "google_compute_subnetwork" - -func initGoogleComputeSubnetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeSubnetworkResourceType, func(res *resource.Resource) map[string]string { - attrs := make(map[string]string) - - if v := res.Attributes().GetString("name"); v != nil && *v != "" { - attrs["Name"] = *v - } - return attrs - }) - resourceSchemaRepository.SetFlags(GoogleComputeSubnetworkResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/google/google_project_iam_member.go b/enumeration/resource/google/google_project_iam_member.go index 612cec429..11aac41a5 100644 --- a/enumeration/resource/google/google_project_iam_member.go +++ b/enumeration/resource/google/google_project_iam_member.go @@ -1,10 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleProjectIamMemberResourceType = "google_project_iam_member" - -func initGoogleProjectIAMMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(GoogleProjectIamMemberResourceType, resource.FlagDeepMode) - -} diff --git a/enumeration/resource/google/google_storage_bucket.go b/enumeration/resource/google/google_storage_bucket.go index f28b5ae1d..45586afd0 100644 --- a/enumeration/resource/google/google_storage_bucket.go +++ b/enumeration/resource/google/google_storage_bucket.go @@ -1,9 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleStorageBucketResourceType = "google_storage_bucket" - -func initGoogleStorageBucketMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetFlags(GoogleStorageBucketResourceType, resource.FlagDeepMode) -} diff --git a/enumeration/resource/google/google_storage_bucket_iam_member.go b/enumeration/resource/google/google_storage_bucket_iam_member.go index 0c110fcee..45d2fc53e 100644 --- a/enumeration/resource/google/google_storage_bucket_iam_member.go +++ b/enumeration/resource/google/google_storage_bucket_iam_member.go @@ -1,18 +1,3 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" - const GoogleStorageBucketIamMemberResourceType = "google_storage_bucket_iam_member" - -func initGoogleStorageBucketIamBMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) map[string]string { - attrs := map[string]string{ - "bucket": *res.Attrs.GetString("bucket"), - "role": *res.Attrs.GetString("role"), - "member": *res.Attrs.GetString("member"), - } - return attrs - }) - resourceSchemaRepository.SetFlags(GoogleStorageBucketIamMemberResourceType, resource.FlagDeepMode) - -} diff --git a/enumeration/resource/google/metadatas.go b/enumeration/resource/google/metadatas.go deleted file mode 100644 index fd27a8de7..000000000 --- a/enumeration/resource/google/metadatas.go +++ /dev/null @@ -1,21 +0,0 @@ -package google - -import "github.com/snyk/driftctl/enumeration/resource" - -func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - initGoogleStorageBucketMetadata(resourceSchemaRepository) - initGoogleComputeFirewallMetadata(resourceSchemaRepository) - initGoogleComputeNetworkMetadata(resourceSchemaRepository) - initGoogleStorageBucketIamBMemberMetadata(resourceSchemaRepository) - initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository) - initGoogleBigqueryDatasetMetadata(resourceSchemaRepository) - initGoogleBigqueryTableMetadata(resourceSchemaRepository) - initGoogleProjectIAMMemberMetadata(resourceSchemaRepository) - initGoogleComputeAddressMetadata(resourceSchemaRepository) - initGoogleComputeGlobalAddressMetadata(resourceSchemaRepository) - initGoogleComputeSubnetworkMetadata(resourceSchemaRepository) - initGoogleComputeDiskMetadata(resourceSchemaRepository) - initGoogleComputeImageMetadata(resourceSchemaRepository) - initGoogleComputeHealthCheckMetadata(resourceSchemaRepository) - initComputeInstanceGroupManagerMetadata(resourceSchemaRepository) -} diff --git a/enumeration/terraform/resource_factory.go b/enumeration/terraform/resource_factory.go index e80d3097c..f6f43377e 100644 --- a/enumeration/terraform/resource_factory.go +++ b/enumeration/terraform/resource_factory.go @@ -4,31 +4,19 @@ import ( "github.com/snyk/driftctl/enumeration/resource" ) -type TerraformResourceFactory struct { - resourceSchemaRepository resource.SchemaRepositoryInterface -} +type TerraformResourceFactory struct{} -func NewTerraformResourceFactory(resourceSchemaRepository resource.SchemaRepositoryInterface) *TerraformResourceFactory { - return &TerraformResourceFactory{ - resourceSchemaRepository: resourceSchemaRepository, - } +func NewTerraformResourceFactory() *TerraformResourceFactory { + return &TerraformResourceFactory{} } func (r *TerraformResourceFactory) CreateAbstractResource(ty, id string, data map[string]interface{}) *resource.Resource { attributes := resource.Attributes(data) - attributes.SanitizeDefaults() - schema, _ := r.resourceSchemaRepository.GetSchema(ty) res := resource.Resource{ Id: id, Type: ty, Attrs: &attributes, - Sch: schema, - } - - schema, exist := r.resourceSchemaRepository.(*resource.SchemaRepository).GetSchema(ty) - if exist && schema.NormalizeFunc != nil { - schema.NormalizeFunc(&res) } return &res diff --git a/pkg/analyser/analyzer_test.go b/pkg/analyser/analyzer_test.go index 16bdca891..9b0c116ac 100644 --- a/pkg/analyser/analyzer_test.go +++ b/pkg/analyser/analyzer_test.go @@ -7,7 +7,6 @@ import ( "time" alerter2 "github.com/snyk/driftctl/enumeration/alerter" - aws2 "github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/pkg/filter" "github.com/stretchr/testify/mock" @@ -19,7 +18,7 @@ import ( "github.com/snyk/driftctl/test/goldenfile" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" "github.com/r3labs/diff/v2" ) @@ -1167,7 +1166,6 @@ func TestAnalyze(t *testing.T) { repo := testresource.InitFakeSchemaRepository("aws", "3.19.0") aws.InitResourcesMetadata(repo) - aws2.InitResourcesMetadata(repo) options := AnalyzerOptions{Deep: true} if c.options != nil { diff --git a/pkg/cmd/scan.go b/pkg/cmd/scan.go index 482d9f81b..af2b2ffe2 100644 --- a/pkg/cmd/scan.go +++ b/pkg/cmd/scan.go @@ -19,17 +19,22 @@ import ( "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote" "github.com/snyk/driftctl/enumeration/remote/common" + "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/terraform/lock" "github.com/snyk/driftctl/pkg/analyser" "github.com/snyk/driftctl/pkg/iac/config" "github.com/snyk/driftctl/pkg/iac/terraform/state" "github.com/snyk/driftctl/pkg/memstore" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/pkg/resource/github" + "github.com/snyk/driftctl/pkg/resource/google" "github.com/snyk/driftctl/pkg/telemetry" "github.com/snyk/driftctl/pkg/terraform/hcl" "github.com/spf13/cobra" - "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg" cmderrors "github.com/snyk/driftctl/pkg/cmd/errors" "github.com/snyk/driftctl/pkg/cmd/scan/output" @@ -37,7 +42,6 @@ import ( "github.com/snyk/driftctl/pkg/iac/supplier" "github.com/snyk/driftctl/pkg/iac/terraform/state/backend" globaloutput "github.com/snyk/driftctl/pkg/output" - dctlresource "github.com/snyk/driftctl/pkg/resource" ) func NewScanCmd(opts *pkg.ScanOptions) *cobra.Command { @@ -289,17 +293,26 @@ func scanRun(opts *pkg.ScanOptions) error { resourceSchemaRepository := resource.NewSchemaRepository() - resFactory := terraform.NewTerraformResourceFactory(resourceSchemaRepository) + resFactory := dctlresource.NewDriftctlResourceFactory(resourceSchemaRepository) - err := remote.Activate(opts.To, opts.ProviderVersion, alerter, providerLibrary, remoteLibrary, scanProgress, resourceSchemaRepository, resFactory, opts.ConfigDir) + err := remote.Activate(opts.To, opts.ProviderVersion, alerter, providerLibrary, remoteLibrary, scanProgress, resFactory, opts.ConfigDir) if err != nil { return err } - err = dctlresource.InitMetadatas(opts.To, resourceSchemaRepository) - if err != nil { - return err + switch opts.To { + case common.RemoteAWSTerraform: + aws.InitResourcesMetadata(resourceSchemaRepository) + case common.RemoteGithubTerraform: + github.InitResourcesMetadata(resourceSchemaRepository) + case common.RemoteGoogleTerraform: + google.InitResourcesMetadata(resourceSchemaRepository) + case common.RemoteAzureTerraform: + azurerm.InitResourcesMetadata(resourceSchemaRepository) + default: + return errors.Errorf("unsupported remote '%s'", opts.To) } + // Teardown defer func() { logrus.Trace("Exiting scan cmd") @@ -310,6 +323,7 @@ func scanRun(opts *pkg.ScanOptions) error { logrus.Debug("Checking for driftignore") driftIgnore := filter.NewDriftIgnore(opts.DriftignorePath, opts.Driftignores...) + // TODO use enum library interface here scanner := remote.NewScanner(remoteLibrary, alerter, remote.ScannerOptions{Deep: opts.Deep}, driftIgnore) iacSupplier, err := supplier.GetIACSupplier(opts.From, providerLibrary, opts.BackendOptions, iacProgress, alerter, resFactory, driftIgnore) diff --git a/pkg/cmd/scan/output/console_test.go b/pkg/cmd/scan/output/console_test.go index abdbc2d4a..63af0cdea 100644 --- a/pkg/cmd/scan/output/console_test.go +++ b/pkg/cmd/scan/output/console_test.go @@ -9,7 +9,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/test/goldenfile" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" diff --git a/pkg/driftctl_test.go b/pkg/driftctl_test.go index ce6d974a5..d3ead48ea 100644 --- a/pkg/driftctl_test.go +++ b/pkg/driftctl_test.go @@ -1,22 +1,20 @@ package pkg_test import ( - "github.com/snyk/driftctl/enumeration/terraform" - resource2 "github.com/snyk/driftctl/pkg/resource" - "reflect" "testing" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/enumeration/resource/github" "github.com/snyk/driftctl/pkg" "github.com/snyk/driftctl/pkg/analyser" "github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/memstore" "github.com/snyk/driftctl/pkg/output" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/pkg/resource/github" "github.com/snyk/driftctl/test" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" @@ -64,7 +62,7 @@ func runTest(t *testing.T, cases TestCases) { res.Sch = schema } - stateSupplier := &resource2.MockIaCSupplier{} + stateSupplier := &dctlresource.MockIaCSupplier{} stateSupplier.On("Resources").Return(c.stateResources, nil) stateSupplier.On("SourceCount").Return(uint(2)) @@ -79,10 +77,10 @@ func runTest(t *testing.T, cases TestCases) { remoteSupplier := &resource.MockSupplier{} remoteSupplier.On("Resources").Return(c.remoteResources, nil) - var resourceFactory resource.ResourceFactory = terraform.NewTerraformResourceFactory(repo) + var resourceFactory resource.ResourceFactory = dctlresource.NewDriftctlResourceFactory(repo) if c.mocks != nil { - resourceFactory = &terraform.MockResourceFactory{} + resourceFactory = &dctlresource.MockResourceFactory{} c.mocks(resourceFactory, repo) } @@ -366,7 +364,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { { name: "we should ignore default AWS IAM role when strict mode is disabled", mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On( + factory.(*dctlresource.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role-test-1-policy-test-1", @@ -464,7 +462,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { { name: "we should not ignore default AWS IAM role when strict mode is enabled", mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On( + factory.(*dctlresource.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role-test-1-policy-test-1", @@ -562,7 +560,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { { name: "we should not ignore default AWS IAM role when strict mode is enabled and a filter is specified", mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On( + factory.(*dctlresource.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role-test-1-policy-test-1", @@ -793,7 +791,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On( + factory.(*dctlresource.MockResourceFactory).On( "CreateAbstractResource", aws.AwsS3BucketPolicyResourceType, "foo", @@ -890,7 +888,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, Sch: getSchema(repo, "aws_ebs_volume"), } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "vol-018c5ae89895aca4c", "availability_zone": "us-east-1", @@ -909,7 +907,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, Sch: getSchema(repo, "aws_ebs_volume"), } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "vol-02862d9b39045a3a4", "availability_zone": "us-east-1", @@ -995,7 +993,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table1080289494", mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table1080289494", mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "destination_cidr_block": "0.0.0.0/0", "gateway_id": "igw-07b7844a8fd17a638", @@ -1014,7 +1012,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "state": "active", }, }, nil) - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table2750132062", mock.MatchedBy(func(input map[string]interface{}) bool { + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table2750132062", mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "destination_ipv6_cidr_block": "::/0", "gateway_id": "igw-07b7844a8fd17a638", @@ -1073,7 +1071,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_sns_topic_policy", "foo", map[string]interface{}{ + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_sns_topic_policy", "foo", map[string]interface{}{ "id": "foo", "arn": "arn", "policy": "{\"policy\":\"bar\"}", @@ -1135,7 +1133,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", map[string]interface{}{ + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", map[string]interface{}{ "id": "foo", "queue_url": "foo", "policy": "{\"policy\":\"bar\"}", @@ -1364,7 +1362,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule1.Id, + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule1.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-1707973622", @@ -1396,7 +1394,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule2.Id, + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule2.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-2821752134", @@ -1428,7 +1426,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule3.Id, + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule3.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-2165103420", @@ -1460,7 +1458,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "prefix_list_ids": []interface{}{}, }, } - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule4.Id, + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule4.Id, mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "id": "sgrule-2582518759", @@ -1556,7 +1554,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "iduser1", map[string]interface{}{ + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "iduser1", map[string]interface{}{ "id": "iduser1", "policy_arn": "policy_arn1", "users": []interface{}{"user1"}, @@ -1573,7 +1571,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "roles": []interface{}{}, }, }, nil) - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "user1-policy_arn1", map[string]interface{}{ + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "user1-policy_arn1", map[string]interface{}{ "policy_arn": "policy_arn1", "users": []interface{}{"user1"}, }).Twice().Return(&resource.Resource{ @@ -1584,7 +1582,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "users": []interface{}{"user1"}, }, }, nil) - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "idrole1", map[string]interface{}{ + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "idrole1", map[string]interface{}{ "id": "idrole1", "policy_arn": "policy_arn1", "users": []interface{}{}, @@ -1601,7 +1599,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "roles": []interface{}{"role1"}, }, }, nil) - factory.(*terraform.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role1-policy_arn1", map[string]interface{}{ + factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role1-policy_arn1", map[string]interface{}{ "policy_arn": "policy_arn1", "roles": []interface{}{"role1"}, }).Twice().Return(&resource.Resource{ diff --git a/pkg/iac/supplier/supplier_test.go b/pkg/iac/supplier/supplier_test.go index da8396c6c..e7ae18ba2 100644 --- a/pkg/iac/supplier/supplier_test.go +++ b/pkg/iac/supplier/supplier_test.go @@ -7,12 +7,13 @@ import ( "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/terraform" + "github.com/snyk/driftctl/pkg/resource" + testresource "github.com/snyk/driftctl/test/resource" "github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/iac/config" "github.com/snyk/driftctl/pkg/iac/terraform/state/backend" "github.com/snyk/driftctl/pkg/output" - "github.com/snyk/driftctl/test/resource" ) func TestGetIACSupplier(t *testing.T) { @@ -90,8 +91,8 @@ func TestGetIACSupplier(t *testing.T) { progress := &output.MockProgress{} progress.On("Start").Return().Times(1) - repo := resource.InitFakeSchemaRepository("aws", "3.19.0") - factory := terraform.NewTerraformResourceFactory(repo) + repo := testresource.InitFakeSchemaRepository(terraform.AWS, "3.19.0") + factory := resource.NewDriftctlResourceFactory(repo) alerter := alerter.NewAlerter() testFilter := &filter.MockFilter{} diff --git a/pkg/iac/terraform/state/terraform_state_reader.go b/pkg/iac/terraform/state/terraform_state_reader.go index 16d081ad8..bf6545d3d 100644 --- a/pkg/iac/terraform/state/terraform_state_reader.go +++ b/pkg/iac/terraform/state/terraform_state_reader.go @@ -23,6 +23,7 @@ import ( "github.com/snyk/driftctl/pkg/iac/config" "github.com/snyk/driftctl/pkg/iac/terraform/state/backend" "github.com/snyk/driftctl/pkg/iac/terraform/state/enumerator" + resdriftctl "github.com/snyk/driftctl/pkg/resource" ) const TerraformStateReaderSupplier = "tfstate" @@ -95,7 +96,7 @@ func (r *TerraformStateReader) retrieve() (map[string][]decodedRes, error) { resName := stateRes.Addr.Resource.Name resType := stateRes.Addr.Resource.Type - if !resource.IsResourceTypeSupported(resType) { + if !resdriftctl.IsResourceTypeSupported(resType) { logrus.WithFields(logrus.Fields{ "name": resName, "type": resType, diff --git a/pkg/iac/terraform/state/terraform_state_reader_test.go b/pkg/iac/terraform/state/terraform_state_reader_test.go index dd15c00e2..c9d2919d5 100644 --- a/pkg/iac/terraform/state/terraform_state_reader_test.go +++ b/pkg/iac/terraform/state/terraform_state_reader_test.go @@ -12,19 +12,17 @@ import ( "github.com/snyk/driftctl/enumeration/remote/github" "github.com/snyk/driftctl/enumeration/remote/google" "github.com/snyk/driftctl/enumeration/terraform" - aws2 "github.com/snyk/driftctl/pkg/resource/aws" - azurerm2 "github.com/snyk/driftctl/pkg/resource/azurerm" - github2 "github.com/snyk/driftctl/pkg/resource/github" - google2 "github.com/snyk/driftctl/pkg/resource/google" "github.com/pkg/errors" - resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" - resourceazure "github.com/snyk/driftctl/enumeration/resource/azurerm" - resourcegithub "github.com/snyk/driftctl/enumeration/resource/github" - resourcegoogle "github.com/snyk/driftctl/enumeration/resource/google" "github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/output" + dctlresource "github.com/snyk/driftctl/pkg/resource" + resourceaws "github.com/snyk/driftctl/pkg/resource/aws" + resourceazure "github.com/snyk/driftctl/pkg/resource/azurerm" + resourcegithub "github.com/snyk/driftctl/pkg/resource/github" + resourcegoogle "github.com/snyk/driftctl/pkg/resource/google" testresource "github.com/snyk/driftctl/test/resource" + terraform2 "github.com/snyk/driftctl/test/terraform" "github.com/stretchr/testify/assert" @@ -66,7 +64,7 @@ func TestTerraformStateReader_Source(t *testing.T) { repo := testresource.InitFakeSchemaRepository(terraform.AWS, "3.19.0") resourceaws.InitResourcesMetadata(repo) - factory := terraform.NewTerraformResourceFactory(repo) + factory := dctlresource.NewDriftctlResourceFactory(repo) r := &TerraformStateReader{ config: config.SupplierConfig{ @@ -241,9 +239,8 @@ func TestTerraformStateReader_AWS_Resources(t *testing.T) { repo := testresource.InitFakeSchemaRepository(terraform.AWS, tt.providerVersion) resourceaws.InitResourcesMetadata(repo) - aws2.InitResourcesMetadata(repo) - factory := terraform.NewTerraformResourceFactory(repo) + factory := dctlresource.NewDriftctlResourceFactory(repo) r := &TerraformStateReader{ config: config.SupplierConfig{ @@ -328,8 +325,7 @@ func TestTerraformStateReader_Github_Resources(t *testing.T) { repo := testresource.InitFakeSchemaRepository(terraform.GITHUB, "4.4.0") resourcegithub.InitResourcesMetadata(repo) - github2.InitResourcesMetadata(repo) - factory := terraform.NewTerraformResourceFactory(repo) + factory := dctlresource.NewDriftctlResourceFactory(repo) r := &TerraformStateReader{ config: config.SupplierConfig{ @@ -434,8 +430,7 @@ func TestTerraformStateReader_Google_Resources(t *testing.T) { repo := testresource.InitFakeSchemaRepository(terraform.GOOGLE, providerVersion) resourcegoogle.InitResourcesMetadata(repo) - google2.InitResourcesMetadata(repo) - factory := terraform.NewTerraformResourceFactory(repo) + factory := dctlresource.NewDriftctlResourceFactory(repo) r := &TerraformStateReader{ config: config.SupplierConfig{ @@ -529,8 +524,7 @@ func TestTerraformStateReader_Azure_Resources(t *testing.T) { repo := testresource.InitFakeSchemaRepository(terraform.AZURE, providerVersion) resourceazure.InitResourcesMetadata(repo) - azurerm2.InitResourcesMetadata(repo) - factory := terraform.NewTerraformResourceFactory(repo) + factory := dctlresource.NewDriftctlResourceFactory(repo) r := &TerraformStateReader{ config: config.SupplierConfig{ diff --git a/pkg/middlewares/aws_alb_listener_transformer.go b/pkg/middlewares/aws_alb_listener_transformer.go index b2be01736..5483b74fb 100644 --- a/pkg/middlewares/aws_alb_listener_transformer.go +++ b/pkg/middlewares/aws_alb_listener_transformer.go @@ -2,7 +2,7 @@ package middlewares import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // AwsALBListenerTransformer is a simple middleware to turn all aws_alb_listener resources into aws_lb_listener ones diff --git a/pkg/middlewares/aws_alb_listener_transformer_test.go b/pkg/middlewares/aws_alb_listener_transformer_test.go index 4064a4f86..e4b3cbf09 100644 --- a/pkg/middlewares/aws_alb_listener_transformer_test.go +++ b/pkg/middlewares/aws_alb_listener_transformer_test.go @@ -1,26 +1,26 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsALBListenerTransformer_Execute(t *testing.T) { tests := []struct { name string resourcesFromState []*resource.Resource - mocks func(*terraform.MockResourceFactory) + mocks func(*dctlresource.MockResourceFactory) expected []*resource.Resource }{ { name: "should not transform anything", - mocks: func(factory *terraform.MockResourceFactory) {}, + mocks: func(factory *dctlresource.MockResourceFactory) {}, resourcesFromState: []*resource.Resource{ { Id: "foo", @@ -48,7 +48,7 @@ func TestAwsALBListenerTransformer_Execute(t *testing.T) { }, { name: "should transform ALB into LB", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory. On("CreateAbstractResource", aws.AwsLoadBalancerListenerResourceType, "alb-test", map[string]interface{}{}). Return(&resource.Resource{ @@ -100,7 +100,7 @@ func TestAwsALBListenerTransformer_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mocks != nil { tt.mocks(factory) } diff --git a/pkg/middlewares/aws_alb_transformer.go b/pkg/middlewares/aws_alb_transformer.go index ae9bd54e4..6b961a1fa 100644 --- a/pkg/middlewares/aws_alb_transformer.go +++ b/pkg/middlewares/aws_alb_transformer.go @@ -2,7 +2,7 @@ package middlewares import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // AwsALBTransformer is a simple middleware to turn all aws_alb resources into aws_lb ones diff --git a/pkg/middlewares/aws_alb_transformer_test.go b/pkg/middlewares/aws_alb_transformer_test.go index b5bec4aac..64fcda6b4 100644 --- a/pkg/middlewares/aws_alb_transformer_test.go +++ b/pkg/middlewares/aws_alb_transformer_test.go @@ -1,26 +1,26 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsALBTransformer_Execute(t *testing.T) { tests := []struct { name string resourcesFromState []*resource.Resource - mocks func(*terraform.MockResourceFactory) + mocks func(*dctlresource.MockResourceFactory) expected []*resource.Resource }{ { name: "should not transform anything", - mocks: func(factory *terraform.MockResourceFactory) {}, + mocks: func(factory *dctlresource.MockResourceFactory) {}, resourcesFromState: []*resource.Resource{ { Id: "foo", @@ -48,7 +48,7 @@ func TestAwsALBTransformer_Execute(t *testing.T) { }, { name: "should transform ALB into LB", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory. On("CreateAbstractResource", aws.AwsLoadBalancerResourceType, "alb-test", map[string]interface{}{}). Return(&resource.Resource{ @@ -100,7 +100,7 @@ func TestAwsALBTransformer_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mocks != nil { tt.mocks(factory) } diff --git a/pkg/middlewares/aws_api_gateway_api_expander.go b/pkg/middlewares/aws_api_gateway_api_expander.go index d05f0f3a4..c93f2a0e8 100644 --- a/pkg/middlewares/aws_api_gateway_api_expander.go +++ b/pkg/middlewares/aws_api_gateway_api_expander.go @@ -11,7 +11,7 @@ import ( "github.com/ghodss/yaml" "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Explodes the body attribute of api gateway apis v1|v2 to dedicated resources as per Terraform documentations diff --git a/pkg/middlewares/aws_api_gateway_api_expander_test.go b/pkg/middlewares/aws_api_gateway_api_expander_test.go index e02ae0c7a..9200c412c 100644 --- a/pkg/middlewares/aws_api_gateway_api_expander_test.go +++ b/pkg/middlewares/aws_api_gateway_api_expander_test.go @@ -1,7 +1,6 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "path/filepath" "strings" "testing" @@ -9,7 +8,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { @@ -17,12 +17,12 @@ func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { name string resourcesFromState []*resource.Resource remoteResources []*resource.Resource - mocks func(*terraform.MockResourceFactory) + mocks func(*dctlresource.MockResourceFactory) expected []*resource.Resource }{ { name: "create aws_api_gateway_resource from OpenAPI v3 JSON document", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsApiGatewayResourceResourceType, @@ -231,7 +231,7 @@ func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { }, { name: "create aws_api_gateway_resource from OpenAPI v2 JSON document", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsApiGatewayResourceResourceType, @@ -457,7 +457,7 @@ func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { }, { name: "create resources with same path but not the same rest api id", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsApiGatewayResourceResourceType, @@ -784,7 +784,7 @@ func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { }, { name: "create gateway responses based on OpenAPI v2 and v3", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsApiGatewayGatewayResponseResourceType, @@ -852,7 +852,7 @@ func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { }, { name: "create api gateway resources from OpenAPI v3 YAML document", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsApiGatewayResourceResourceType, @@ -974,7 +974,7 @@ func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { }, { name: "create api gateway resources from OpenAPI v2 YAML document", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsApiGatewayResourceResourceType, @@ -1160,7 +1160,7 @@ func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { Type: aws.AwsApiGatewayV2RouteResourceType, }, }, - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", aws.AwsApiGatewayV2RouteResourceType, "openapi-derived-route-from-remote-1", map[string]interface{}{}). Once().Return(&resource.Resource{ Id: "openapi-derived-route-from-remote-1", @@ -1212,7 +1212,7 @@ func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { Type: aws.AwsApiGatewayV2RouteResourceType, }, }, - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", aws.AwsApiGatewayV2RouteResourceType, "openapi-derived-route-from-remote", map[string]interface{}{}). Once().Return(&resource.Resource{ Id: "openapi-derived-route-from-remote", @@ -1267,7 +1267,7 @@ func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { Type: aws.AwsApiGatewayV2IntegrationResourceType, }, }, - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", aws.AwsApiGatewayV2RouteResourceType, "openapi-derived-route-from-remote", map[string]interface{}{}). Once().Return(&resource.Resource{ Id: "openapi-derived-route-from-remote", @@ -1327,7 +1327,7 @@ func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { Type: aws.AwsApiGatewayV2IntegrationResourceType, }, }, - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", aws.AwsApiGatewayV2RouteResourceType, "openapi-derived-route-from-remote", map[string]interface{}{}). Once().Return(&resource.Resource{ Id: "openapi-derived-route-from-remote", @@ -1343,7 +1343,7 @@ func TestAwsApiGatewayApiExpander_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mocks != nil { tt.mocks(factory) } diff --git a/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler.go b/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler.go index a1286aafd..4d049423f 100644 --- a/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler.go +++ b/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler.go @@ -2,7 +2,7 @@ package middlewares import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // AwsApiGatewayBasePathMappingReconciler is used to reconcile API Gateway base path mapping (v1 and v2) diff --git a/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler_test.go b/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler_test.go index be9d8e3a6..6c6d708eb 100644 --- a/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler_test.go +++ b/pkg/middlewares/aws_api_gateway_base_path_mapping_reconciler_test.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsApiGatewayBasePathMappingReconciler_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_api_gateway_deployment_expander.go b/pkg/middlewares/aws_api_gateway_deployment_expander.go index eb707dcaa..2fcf19be7 100644 --- a/pkg/middlewares/aws_api_gateway_deployment_expander.go +++ b/pkg/middlewares/aws_api_gateway_deployment_expander.go @@ -4,7 +4,7 @@ import ( "strings" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Create a aws_api_gateway_stage resource from a aws_api_gateway_deployment resource and ignore the latter resource diff --git a/pkg/middlewares/aws_api_gateway_deployment_expander_test.go b/pkg/middlewares/aws_api_gateway_deployment_expander_test.go index 33bd74139..9d223b41d 100644 --- a/pkg/middlewares/aws_api_gateway_deployment_expander_test.go +++ b/pkg/middlewares/aws_api_gateway_deployment_expander_test.go @@ -1,21 +1,21 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsApiGatewayDeploymentExpander_Execute(t *testing.T) { tests := []struct { name string resourcesFromState []*resource.Resource - mocks func(*terraform.MockResourceFactory) + mocks func(*dctlresource.MockResourceFactory) expected []*resource.Resource }{ { @@ -56,7 +56,7 @@ func TestAwsApiGatewayDeploymentExpander_Execute(t *testing.T) { }, { name: "stages created from deployment state resources", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsApiGatewayStageResourceType, @@ -101,7 +101,7 @@ func TestAwsApiGatewayDeploymentExpander_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mocks != nil { tt.mocks(factory) } diff --git a/pkg/middlewares/aws_api_gateway_domain_names_reconciler.go b/pkg/middlewares/aws_api_gateway_domain_names_reconciler.go index f56ef52d8..2b9e16e62 100644 --- a/pkg/middlewares/aws_api_gateway_domain_names_reconciler.go +++ b/pkg/middlewares/aws_api_gateway_domain_names_reconciler.go @@ -2,7 +2,7 @@ package middlewares import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Used to reconcile API Gateway domain names (v1 and v2) from both remote diff --git a/pkg/middlewares/aws_api_gateway_domain_names_reconciler_test.go b/pkg/middlewares/aws_api_gateway_domain_names_reconciler_test.go index 4d81325d5..b667522d1 100644 --- a/pkg/middlewares/aws_api_gateway_domain_names_reconciler_test.go +++ b/pkg/middlewares/aws_api_gateway_domain_names_reconciler_test.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsApiGatewayDomainNamesReconciler_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_api_gateway_resource_expander.go b/pkg/middlewares/aws_api_gateway_resource_expander.go index 593ae85b5..1752654b2 100644 --- a/pkg/middlewares/aws_api_gateway_resource_expander.go +++ b/pkg/middlewares/aws_api_gateway_resource_expander.go @@ -4,7 +4,7 @@ import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Explodes api gateway default resource found in aws_api_gateway_rest_api.root_resource_id from state resources to dedicated resources diff --git a/pkg/middlewares/aws_api_gateway_resource_expander_test.go b/pkg/middlewares/aws_api_gateway_resource_expander_test.go index e29ac560c..494fb9c55 100644 --- a/pkg/middlewares/aws_api_gateway_resource_expander_test.go +++ b/pkg/middlewares/aws_api_gateway_resource_expander_test.go @@ -1,26 +1,26 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsApiGatewayResourceExpander_Execute(t *testing.T) { tests := []struct { name string resourcesFromState []*resource.Resource - mocks func(*terraform.MockResourceFactory) + mocks func(*dctlresource.MockResourceFactory) expected []*resource.Resource }{ { name: "create api gateway root resource from rest api", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsApiGatewayResourceResourceType, @@ -91,7 +91,7 @@ func TestAwsApiGatewayResourceExpander_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mocks != nil { tt.mocks(factory) } diff --git a/pkg/middlewares/aws_api_gateway_rest_api_policy_expander.go b/pkg/middlewares/aws_api_gateway_rest_api_policy_expander.go index d6f69080b..408fa099a 100644 --- a/pkg/middlewares/aws_api_gateway_rest_api_policy_expander.go +++ b/pkg/middlewares/aws_api_gateway_rest_api_policy_expander.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Explodes policy found in aws_api_gateway_rest_api.policy from state resources to dedicated resources diff --git a/pkg/middlewares/aws_api_gateway_rest_api_policy_expander_test.go b/pkg/middlewares/aws_api_gateway_rest_api_policy_expander_test.go index fc60c6506..28f07e5d5 100644 --- a/pkg/middlewares/aws_api_gateway_rest_api_policy_expander_test.go +++ b/pkg/middlewares/aws_api_gateway_rest_api_policy_expander_test.go @@ -1,26 +1,26 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsApiGatewayRestApiPolicyPolicyExpander_Execute(t *testing.T) { tests := []struct { name string resourcesFromState []*resource.Resource - mocks func(*terraform.MockResourceFactory) + mocks func(*dctlresource.MockResourceFactory) expected []*resource.Resource }{ { name: "Inline policy, no aws_api_gateway_rest_api_policy attached", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsApiGatewayRestApiPolicyResourceType, @@ -133,7 +133,7 @@ func TestAwsApiGatewayRestApiPolicyPolicyExpander_Execute(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mocks != nil { tt.mocks(factory) } diff --git a/pkg/middlewares/aws_bucket_policy_expander.go b/pkg/middlewares/aws_bucket_policy_expander.go index d7d27822e..e0c5ff1b9 100644 --- a/pkg/middlewares/aws_bucket_policy_expander.go +++ b/pkg/middlewares/aws_bucket_policy_expander.go @@ -4,7 +4,7 @@ import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Explodes policy found in aws_s3_bucket.policy from state resources to dedicated resources diff --git a/pkg/middlewares/aws_bucket_policy_expander_test.go b/pkg/middlewares/aws_bucket_policy_expander_test.go index 941ef244d..52cf460ad 100644 --- a/pkg/middlewares/aws_bucket_policy_expander_test.go +++ b/pkg/middlewares/aws_bucket_policy_expander_test.go @@ -1,7 +1,6 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" @@ -9,19 +8,20 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsBucketPolicyExpander_Execute(t *testing.T) { tests := []struct { name string resourcesFromState []*resource.Resource - mocks func(*terraform.MockResourceFactory) + mocks func(*dctlresource.MockResourceFactory) expected []*resource.Resource }{ { name: "Inline policy, no aws_s3_bucket_policy attached", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsS3BucketPolicyResourceType, @@ -62,7 +62,7 @@ func TestAwsBucketPolicyExpander_Execute(t *testing.T) { }, { name: "No inline policy, aws_s3_bucket_policy attached", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsS3BucketPolicyResourceType, @@ -169,7 +169,7 @@ func TestAwsBucketPolicyExpander_Execute(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mocks != nil { tt.mocks(factory) } diff --git a/pkg/middlewares/aws_console_api_gateway_gateway_response.go b/pkg/middlewares/aws_console_api_gateway_gateway_response.go index 15ab216b8..a102798ad 100644 --- a/pkg/middlewares/aws_console_api_gateway_gateway_response.go +++ b/pkg/middlewares/aws_console_api_gateway_gateway_response.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Each API Gateway rest API has by design all the gateway responses available to edit in the console diff --git a/pkg/middlewares/aws_console_api_gateway_gateway_response_test.go b/pkg/middlewares/aws_console_api_gateway_gateway_response_test.go index 1092e1b0d..5ae5e85bd 100644 --- a/pkg/middlewares/aws_console_api_gateway_gateway_response_test.go +++ b/pkg/middlewares/aws_console_api_gateway_gateway_response_test.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsConsoleApiGatewayGatewayResponse_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_api_gateway_account.go b/pkg/middlewares/aws_default_api_gateway_account.go index 43653d3f4..278715b6d 100644 --- a/pkg/middlewares/aws_default_api_gateway_account.go +++ b/pkg/middlewares/aws_default_api_gateway_account.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // AwsDefaultApiGatewayAccount is a middleware that ignores the default API Gateway account resource in the current region. diff --git a/pkg/middlewares/aws_default_api_gateway_account_test.go b/pkg/middlewares/aws_default_api_gateway_account_test.go index 680955854..b93602ab0 100644 --- a/pkg/middlewares/aws_default_api_gateway_account_test.go +++ b/pkg/middlewares/aws_default_api_gateway_account_test.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsDefaultApiGatewayAccount_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_igw_route.go b/pkg/middlewares/aws_default_igw_route.go index df38d7568..bb227c151 100644 --- a/pkg/middlewares/aws_default_igw_route.go +++ b/pkg/middlewares/aws_default_igw_route.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Each region has a default vpc which has an internet gateway attached and thus the route table of this diff --git a/pkg/middlewares/aws_default_igw_route_test.go b/pkg/middlewares/aws_default_igw_route_test.go index 8d1918f2c..f6e8ec5eb 100644 --- a/pkg/middlewares/aws_default_igw_route_test.go +++ b/pkg/middlewares/aws_default_igw_route_test.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsDefaultInternetGatewayRoute_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_internet_gateway.go b/pkg/middlewares/aws_default_internet_gateway.go index 675d97e59..79e0d16de 100644 --- a/pkg/middlewares/aws_default_internet_gateway.go +++ b/pkg/middlewares/aws_default_internet_gateway.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Each default vpc has an internet gateway attached that should not be seen as unmanaged if not managed by IaC diff --git a/pkg/middlewares/aws_default_internet_gateway_test.go b/pkg/middlewares/aws_default_internet_gateway_test.go index 757e5af1c..70df7f56a 100644 --- a/pkg/middlewares/aws_default_internet_gateway_test.go +++ b/pkg/middlewares/aws_default_internet_gateway_test.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsDefaultInternetGateway_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_network_acl.go b/pkg/middlewares/aws_default_network_acl.go index f1a15f150..a1b27b66d 100644 --- a/pkg/middlewares/aws_default_network_acl.go +++ b/pkg/middlewares/aws_default_network_acl.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Default network ACL should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_default_network_acl_rule.go b/pkg/middlewares/aws_default_network_acl_rule.go index 776b53736..7990af288 100644 --- a/pkg/middlewares/aws_default_network_acl_rule.go +++ b/pkg/middlewares/aws_default_network_acl_rule.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Default network acl rules should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_default_network_acl_rule_test.go b/pkg/middlewares/aws_default_network_acl_rule_test.go index bce59ad23..5d0b99f0d 100644 --- a/pkg/middlewares/aws_default_network_acl_rule_test.go +++ b/pkg/middlewares/aws_default_network_acl_rule_test.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_network_acl_test.go b/pkg/middlewares/aws_default_network_acl_test.go index d8dd82d76..1fac36574 100644 --- a/pkg/middlewares/aws_default_network_acl_test.go +++ b/pkg/middlewares/aws_default_network_acl_test.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsDefaultNetworkACL_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_route.go b/pkg/middlewares/aws_default_route.go index cf603f64e..adfee4998 100644 --- a/pkg/middlewares/aws_default_route.go +++ b/pkg/middlewares/aws_default_route.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Default routes should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_default_route_table.go b/pkg/middlewares/aws_default_route_table.go index e2bb738a5..62d40c5f1 100644 --- a/pkg/middlewares/aws_default_route_table.go +++ b/pkg/middlewares/aws_default_route_table.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Default route table should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_default_route_table_test.go b/pkg/middlewares/aws_default_route_table_test.go index 26fdc3e89..c33a12e2f 100644 --- a/pkg/middlewares/aws_default_route_table_test.go +++ b/pkg/middlewares/aws_default_route_table_test.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsDefaultRouteTable_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_route_test.go b/pkg/middlewares/aws_default_route_test.go index 3ca2eb0a2..e71be5dfa 100644 --- a/pkg/middlewares/aws_default_route_test.go +++ b/pkg/middlewares/aws_default_route_test.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsDefaultRoute_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_security_group_rule.go b/pkg/middlewares/aws_default_security_group_rule.go index a939cb091..8126235c5 100644 --- a/pkg/middlewares/aws_default_security_group_rule.go +++ b/pkg/middlewares/aws_default_security_group_rule.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Remove default security group rules of the default security group from remote resources diff --git a/pkg/middlewares/aws_default_security_group_rule_test.go b/pkg/middlewares/aws_default_security_group_rule_test.go index 775dbc54d..35b442290 100644 --- a/pkg/middlewares/aws_default_security_group_rule_test.go +++ b/pkg/middlewares/aws_default_security_group_rule_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsDefaultSecurityGroupRule_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_sqs_queue_policy.go b/pkg/middlewares/aws_default_sqs_queue_policy.go index e18a21f32..cc5bfa120 100644 --- a/pkg/middlewares/aws_default_sqs_queue_policy.go +++ b/pkg/middlewares/aws_default_sqs_queue_policy.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // SQS queues from AWS have a weird behaviour when we fetch them. diff --git a/pkg/middlewares/aws_default_sqs_queue_policy_test.go b/pkg/middlewares/aws_default_sqs_queue_policy_test.go index 0c6aa5133..7929fcfb3 100644 --- a/pkg/middlewares/aws_default_sqs_queue_policy_test.go +++ b/pkg/middlewares/aws_default_sqs_queue_policy_test.go @@ -8,7 +8,7 @@ import ( "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsDefaultSQSQueuePolicy_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_default_subnet.go b/pkg/middlewares/aws_default_subnet.go index adc6091cc..d1176c0f6 100644 --- a/pkg/middlewares/aws_default_subnet.go +++ b/pkg/middlewares/aws_default_subnet.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Default subnet should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_default_vpc.go b/pkg/middlewares/aws_default_vpc.go index a12ffccc9..4bff529de 100644 --- a/pkg/middlewares/aws_default_vpc.go +++ b/pkg/middlewares/aws_default_vpc.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Default VPC should not be shown as unmanaged as they are present by default diff --git a/pkg/middlewares/aws_defaults.go b/pkg/middlewares/aws_defaults.go index 7b9b1c877..178ad5c65 100644 --- a/pkg/middlewares/aws_defaults.go +++ b/pkg/middlewares/aws_defaults.go @@ -5,7 +5,7 @@ import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) const defaultIamRolePathPrefix = "/aws-service-role/" diff --git a/pkg/middlewares/aws_defaults_test.go b/pkg/middlewares/aws_defaults_test.go index 9810a8195..c08f3f9a8 100644 --- a/pkg/middlewares/aws_defaults_test.go +++ b/pkg/middlewares/aws_defaults_test.go @@ -6,7 +6,7 @@ import ( "github.com/stretchr/testify/assert" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsDefaults_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_ebs_encryption_by_default_reconciler.go b/pkg/middlewares/aws_ebs_encryption_by_default_reconciler.go index 648427bd2..68cbd69f0 100644 --- a/pkg/middlewares/aws_ebs_encryption_by_default_reconciler.go +++ b/pkg/middlewares/aws_ebs_encryption_by_default_reconciler.go @@ -2,7 +2,7 @@ package middlewares import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // AwsEbsEncryptionByDefaultReconciler is a middleware that either creates an 'aws_ebs_encryption_by_default' resource diff --git a/pkg/middlewares/aws_ebs_encryption_by_default_reconciler_test.go b/pkg/middlewares/aws_ebs_encryption_by_default_reconciler_test.go index 7a60d3c25..524f9284c 100644 --- a/pkg/middlewares/aws_ebs_encryption_by_default_reconciler_test.go +++ b/pkg/middlewares/aws_ebs_encryption_by_default_reconciler_test.go @@ -1,20 +1,20 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsEbsEncryptionByDefaultReconciler_Execute(t *testing.T) { tests := []struct { name string - mocks func(*terraform.MockResourceFactory) + mocks func(*dctlresource.MockResourceFactory) remoteResources []*resource.Resource resourcesFromState []*resource.Resource expectedRemoteResources []*resource.Resource @@ -22,7 +22,7 @@ func TestAwsEbsEncryptionByDefaultReconciler_Execute(t *testing.T) { }{ { name: "test encryption by default is managed", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", aws.AwsEbsEncryptionByDefaultResourceType, "terraform-20220328091515068500000001", @@ -100,7 +100,7 @@ func TestAwsEbsEncryptionByDefaultReconciler_Execute(t *testing.T) { }, { name: "test encryption by default is enabled and unmanaged", - mocks: func(factory *terraform.MockResourceFactory) {}, + mocks: func(factory *dctlresource.MockResourceFactory) {}, remoteResources: []*resource.Resource{ { Id: "bucket-1", @@ -146,7 +146,7 @@ func TestAwsEbsEncryptionByDefaultReconciler_Execute(t *testing.T) { }, { name: "test encryption by default is disabled and unmanaged", - mocks: func(factory *terraform.MockResourceFactory) {}, + mocks: func(factory *dctlresource.MockResourceFactory) {}, remoteResources: []*resource.Resource{ { Id: "test-encryption", @@ -185,7 +185,7 @@ func TestAwsEbsEncryptionByDefaultReconciler_Execute(t *testing.T) { }, { name: "test encryption by default doesn't exist", - mocks: func(factory *terraform.MockResourceFactory) {}, + mocks: func(factory *dctlresource.MockResourceFactory) {}, remoteResources: []*resource.Resource{ { Id: "bucket-1", @@ -242,7 +242,7 @@ func TestAwsEbsEncryptionByDefaultReconciler_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mocks != nil { tt.mocks(factory) } diff --git a/pkg/middlewares/aws_eip_association_expander.go b/pkg/middlewares/aws_eip_association_expander.go index 759815140..00e882d9f 100644 --- a/pkg/middlewares/aws_eip_association_expander.go +++ b/pkg/middlewares/aws_eip_association_expander.go @@ -2,7 +2,7 @@ package middlewares import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) /** diff --git a/pkg/middlewares/aws_iam_policy_attachement_transformer.go b/pkg/middlewares/aws_iam_policy_attachement_transformer.go index 84074f620..77cbb8b66 100644 --- a/pkg/middlewares/aws_iam_policy_attachement_transformer.go +++ b/pkg/middlewares/aws_iam_policy_attachement_transformer.go @@ -2,7 +2,7 @@ package middlewares import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) /** diff --git a/pkg/middlewares/aws_iam_policy_attachement_transformer_test.go b/pkg/middlewares/aws_iam_policy_attachement_transformer_test.go index ae9e3bcdb..ff1a60ac6 100644 --- a/pkg/middlewares/aws_iam_policy_attachement_transformer_test.go +++ b/pkg/middlewares/aws_iam_policy_attachement_transformer_test.go @@ -1,14 +1,14 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" testresource "github.com/snyk/driftctl/test/resource" ) @@ -21,7 +21,7 @@ func TestIamPolicyAttachmentTransformer_Execute(t *testing.T) { name string args argRes expected argRes - mocks func(factory *terraform.MockResourceFactory) + mocks func(factory *dctlresource.MockResourceFactory) }{ { name: "transform user_policy_attachment", @@ -75,7 +75,7 @@ func TestIamPolicyAttachmentTransformer_Execute(t *testing.T) { }, }, }, - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "id1", map[string]interface{}{ "id": "id1", "policy_arn": "policy_arn1", @@ -164,7 +164,7 @@ func TestIamPolicyAttachmentTransformer_Execute(t *testing.T) { }, }, }, - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "id1", map[string]interface{}{ "id": "id1", "policy_arn": "policy_arn1", @@ -253,7 +253,7 @@ func TestIamPolicyAttachmentTransformer_Execute(t *testing.T) { }, }, }, - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "id1", map[string]interface{}{ "id": "id1", "policy_arn": "policy_arn1", @@ -352,7 +352,7 @@ func TestIamPolicyAttachmentTransformer_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mocks != nil { tt.mocks(factory) } diff --git a/pkg/middlewares/aws_instance_block_device.go b/pkg/middlewares/aws_instance_block_device.go index 926faf5d5..e18e16a9b 100644 --- a/pkg/middlewares/aws_instance_block_device.go +++ b/pkg/middlewares/aws_instance_block_device.go @@ -4,7 +4,7 @@ import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Remove root_block_device from aws_instance resources and create dedicated aws_ebs_volume resources diff --git a/pkg/middlewares/aws_instance_block_device_test.go b/pkg/middlewares/aws_instance_block_device_test.go index 2429f90a1..4187c1e55 100644 --- a/pkg/middlewares/aws_instance_block_device_test.go +++ b/pkg/middlewares/aws_instance_block_device_test.go @@ -1,13 +1,13 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" "github.com/stretchr/testify/mock" ) @@ -19,7 +19,7 @@ func TestAwsInstanceBlockDeviceResourceMapper_Execute(t *testing.T) { tests := []struct { name string args args - mocks func(factory *terraform.MockResourceFactory) + mocks func(factory *dctlresource.MockResourceFactory) wantErr bool }{ { @@ -117,7 +117,7 @@ func TestAwsInstanceBlockDeviceResourceMapper_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { foo := resource.Resource{ Id: "vol-02862d9b39045a3a4", Type: "aws_ebs_volume", @@ -250,7 +250,7 @@ func TestAwsInstanceBlockDeviceResourceMapper_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { foo := resource.Resource{ Id: "vol-02862d9b39045a3a4", Type: "aws_ebs_volume", @@ -339,14 +339,14 @@ func TestAwsInstanceBlockDeviceResourceMapper_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) {}, + func(factory *dctlresource.MockResourceFactory) {}, false, }, } for _, c := range tests { t.Run(c.name, func(tt *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if c.mocks != nil { c.mocks(factory) } diff --git a/pkg/middlewares/aws_instance_eip.go b/pkg/middlewares/aws_instance_eip.go index e3a5c95b1..5bfb9780c 100644 --- a/pkg/middlewares/aws_instance_eip.go +++ b/pkg/middlewares/aws_instance_eip.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) type AwsInstanceEIP struct{} diff --git a/pkg/middlewares/aws_instance_eip_test.go b/pkg/middlewares/aws_instance_eip_test.go index c671dc0d2..1dd8c086e 100644 --- a/pkg/middlewares/aws_instance_eip_test.go +++ b/pkg/middlewares/aws_instance_eip_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsInstanceEIP_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_nat_gateway_eip_assoc.go b/pkg/middlewares/aws_nat_gateway_eip_assoc.go index 5dc96ede3..a71a0de7a 100644 --- a/pkg/middlewares/aws_nat_gateway_eip_assoc.go +++ b/pkg/middlewares/aws_nat_gateway_eip_assoc.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) type AwsNatGatewayEipAssoc struct{} diff --git a/pkg/middlewares/aws_nat_gateway_eip_assoc_test.go b/pkg/middlewares/aws_nat_gateway_eip_assoc_test.go index abbb3f648..62e9682ab 100644 --- a/pkg/middlewares/aws_nat_gateway_eip_assoc_test.go +++ b/pkg/middlewares/aws_nat_gateway_eip_assoc_test.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsNatGatewayEipAssoc_Execute(t *testing.T) { diff --git a/pkg/middlewares/aws_network_acl_expander.go b/pkg/middlewares/aws_network_acl_expander.go index ae4935460..72978b46f 100644 --- a/pkg/middlewares/aws_network_acl_expander.go +++ b/pkg/middlewares/aws_network_acl_expander.go @@ -2,7 +2,7 @@ package middlewares import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // This middelware goal is to explode aws_network_acl ingress and egress block into a set of aws_network_acl_rule diff --git a/pkg/middlewares/aws_network_acl_expander_test.go b/pkg/middlewares/aws_network_acl_expander_test.go index 3341e086a..6cc6178e9 100644 --- a/pkg/middlewares/aws_network_acl_expander_test.go +++ b/pkg/middlewares/aws_network_acl_expander_test.go @@ -4,18 +4,17 @@ import ( "strings" "testing" - "github.com/snyk/driftctl/enumeration/terraform" - "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsNetworkACLExpander_Execute(t *testing.T) { tests := []struct { name string - mock func(factory *terraform.MockResourceFactory) + mock func(factory *dctlresource.MockResourceFactory) remoteResources []*resource.Resource resourcesFromState []*resource.Resource expectedFromState, expectedFromRemote []*resource.Resource @@ -68,7 +67,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { }, }, }, - mock: func(factory *terraform.MockResourceFactory) { + mock: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsNetworkACLRuleResourceType, @@ -289,7 +288,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mock != nil { tt.mock(factory) } diff --git a/pkg/middlewares/aws_rds_cluster_instance_expander.go b/pkg/middlewares/aws_rds_cluster_instance_expander.go index 50d391c0f..fc3b45133 100644 --- a/pkg/middlewares/aws_rds_cluster_instance_expander.go +++ b/pkg/middlewares/aws_rds_cluster_instance_expander.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // AwsRDSClusterInstanceExpander search for cluster instances from state to import corresponding remote db instances. diff --git a/pkg/middlewares/aws_rds_cluster_instance_expander_test.go b/pkg/middlewares/aws_rds_cluster_instance_expander_test.go index ce62dba82..8b215675f 100644 --- a/pkg/middlewares/aws_rds_cluster_instance_expander_test.go +++ b/pkg/middlewares/aws_rds_cluster_instance_expander_test.go @@ -1,11 +1,11 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "testing" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" "github.com/stretchr/testify/assert" ) @@ -16,7 +16,7 @@ func TestAwsRDSClusterInstanceExpander_Execute(t *testing.T) { stateResources []*resource.Resource expectedRemoteResources []*resource.Resource expectedStateResources []*resource.Resource - mock func(factory *terraform.MockResourceFactory) + mock func(factory *dctlresource.MockResourceFactory) }{ { name: "should not map any rds cluster instance into db instances", @@ -129,7 +129,7 @@ func TestAwsRDSClusterInstanceExpander_Execute(t *testing.T) { }, }, }, - mock: func(factory *terraform.MockResourceFactory) { + mock: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", aws.AwsDbInstanceResourceType, "aurora-cluster-demo-0", map[string]interface{}{"field": "test"}). Return(&resource.Resource{ Id: "aurora-cluster-demo-0", @@ -217,7 +217,7 @@ func TestAwsRDSClusterInstanceExpander_Execute(t *testing.T) { Attrs: &resource.Attributes{}, }, }, - mock: func(factory *terraform.MockResourceFactory) { + mock: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", aws.AwsDbInstanceResourceType, "aurora-cluster-demo-0", map[string]interface{}{}). Return(&resource.Resource{ Id: "aurora-cluster-demo-0", @@ -230,7 +230,7 @@ func TestAwsRDSClusterInstanceExpander_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mock != nil { tt.mock(factory) } diff --git a/pkg/middlewares/aws_role_managed_policy_expander.go b/pkg/middlewares/aws_role_managed_policy_expander.go index 30d301ebf..195b893ff 100644 --- a/pkg/middlewares/aws_role_managed_policy_expander.go +++ b/pkg/middlewares/aws_role_managed_policy_expander.go @@ -5,7 +5,7 @@ import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // The role of this middleware is to expand policy contained in `managed_policy_arns` to dedicated `aws_iam_policy_attachment` diff --git a/pkg/middlewares/aws_route_table_expander.go b/pkg/middlewares/aws_route_table_expander.go index e4dcbd63f..45ad1a0a2 100644 --- a/pkg/middlewares/aws_route_table_expander.go +++ b/pkg/middlewares/aws_route_table_expander.go @@ -5,7 +5,7 @@ import ( "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Explodes routes found in aws_default_route_table.route and aws_route_table.route to dedicated resources diff --git a/pkg/middlewares/aws_route_table_expander_test.go b/pkg/middlewares/aws_route_table_expander_test.go index cebc6825c..a4be48ad7 100644 --- a/pkg/middlewares/aws_route_table_expander_test.go +++ b/pkg/middlewares/aws_route_table_expander_test.go @@ -1,17 +1,16 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/mocks" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/stretchr/testify/mock" ) func TestAwsRouteTableExpander_Execute(t *testing.T) { @@ -19,7 +18,7 @@ func TestAwsRouteTableExpander_Execute(t *testing.T) { name string input []*resource.Resource expected []*resource.Resource - mock func(factory *terraform.MockResourceFactory) + mock func(factory *dctlresource.MockResourceFactory) }{ { name: "test with nil route attributes", @@ -139,7 +138,7 @@ func TestAwsRouteTableExpander_Execute(t *testing.T) { }, }, }, - mock: func(factory *terraform.MockResourceFactory) { + mock: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", "aws_route", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { return input["id"] == "r-table_from_state1080289494" })).Times(1).Return(&resource.Resource{ @@ -248,7 +247,7 @@ func TestAwsRouteTableExpander_Execute(t *testing.T) { }, }, }, - mock: func(factory *terraform.MockResourceFactory) { + mock: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", "aws_route", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { return input["id"] == "r-default_route_table_from_state1080289494" })).Times(1).Return(&resource.Resource{ @@ -356,7 +355,7 @@ func TestAwsRouteTableExpander_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", "aws_route", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { return input["id"] == "r-default_route_table_from_state1080289494" })).Times(1).Return(&resource.Resource{ @@ -449,7 +448,7 @@ func TestAwsRouteTableExpander_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", "aws_route", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { return input["id"] == "r-table_from_state2750132062" })).Times(1).Return(&resource.Resource{ @@ -472,7 +471,7 @@ func TestAwsRouteTableExpander_Execute(t *testing.T) { t.Run(tt.name, func(t *testing.T) { mockedAlerter := &mocks.AlerterInterface{} - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mock != nil { tt.mock(factory) } diff --git a/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier.go b/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier.go index b040c4e3d..79afe860b 100644 --- a/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier.go +++ b/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier.go @@ -4,7 +4,7 @@ import ( awssdk "github.com/aws/aws-sdk-go/aws" "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // AwsS3BucketPublicAccessBlockReconciler middleware ignores every s3 bucket public block that is set to the default values (every option set to false) diff --git a/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier_test.go b/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier_test.go index 56c009436..a349da024 100644 --- a/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier_test.go +++ b/pkg/middlewares/aws_s3_bucket_public_access_block_reconcilier_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" "github.com/stretchr/testify/assert" ) diff --git a/pkg/middlewares/aws_sns_topic_policy_expander.go b/pkg/middlewares/aws_sns_topic_policy_expander.go index 224c88527..233198aa9 100644 --- a/pkg/middlewares/aws_sns_topic_policy_expander.go +++ b/pkg/middlewares/aws_sns_topic_policy_expander.go @@ -3,9 +3,8 @@ package middlewares import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Explodes policy found in aws_sns_topic from state resources to aws_sns_topic_policy resources diff --git a/pkg/middlewares/aws_sns_topic_policy_expander_test.go b/pkg/middlewares/aws_sns_topic_policy_expander_test.go index f443a1899..31223be69 100644 --- a/pkg/middlewares/aws_sns_topic_policy_expander_test.go +++ b/pkg/middlewares/aws_sns_topic_policy_expander_test.go @@ -1,19 +1,16 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" - "github.com/stretchr/testify/mock" - - awsresource "github.com/snyk/driftctl/enumeration/resource/aws" - testresource "github.com/snyk/driftctl/test/resource" - "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" + awsresource "github.com/snyk/driftctl/pkg/resource/aws" + testresource "github.com/snyk/driftctl/test/resource" + "github.com/stretchr/testify/mock" ) func TestAwsSNSTopicPolicyExpander_Execute(t *testing.T) { @@ -21,7 +18,7 @@ func TestAwsSNSTopicPolicyExpander_Execute(t *testing.T) { name string resourcesFromState *[]*resource.Resource expected *[]*resource.Resource - mock func(factory *terraform.MockResourceFactory) + mock func(factory *dctlresource.MockResourceFactory) wantErr bool }{ { @@ -56,7 +53,7 @@ func TestAwsSNSTopicPolicyExpander_Execute(t *testing.T) { }, }, }, - mock: func(factory *terraform.MockResourceFactory) { + mock: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", awsresource.AwsSnsTopicPolicyResourceType, "ID", map[string]interface{}{ "arn": "arn", "id": "ID", @@ -208,7 +205,7 @@ func TestAwsSNSTopicPolicyExpander_Execute(t *testing.T) { }, }, }, - mock: func(factory *terraform.MockResourceFactory) { + mock: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", awsresource.AwsSnsTopicPolicyResourceType, "ID", mock.MatchedBy(func(input map[string]interface{}) bool { return input["id"] == "ID" })).Once().Return(&resource.Resource{ @@ -227,7 +224,7 @@ func TestAwsSNSTopicPolicyExpander_Execute(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mock != nil { tt.mock(factory) } diff --git a/pkg/middlewares/aws_sqs_queue_policy_expander.go b/pkg/middlewares/aws_sqs_queue_policy_expander.go index 0d4c414eb..814724780 100644 --- a/pkg/middlewares/aws_sqs_queue_policy_expander.go +++ b/pkg/middlewares/aws_sqs_queue_policy_expander.go @@ -2,9 +2,8 @@ package middlewares import ( "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Explodes policy found in aws_sqs_queue.policy from state resources to dedicated resources diff --git a/pkg/middlewares/aws_sqs_queue_policy_expander_test.go b/pkg/middlewares/aws_sqs_queue_policy_expander_test.go index 9db97997d..a51b3b7e2 100644 --- a/pkg/middlewares/aws_sqs_queue_policy_expander_test.go +++ b/pkg/middlewares/aws_sqs_queue_policy_expander_test.go @@ -1,18 +1,16 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" - "github.com/stretchr/testify/mock" - + "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" testresource "github.com/snyk/driftctl/test/resource" - - "github.com/r3labs/diff/v2" + "github.com/stretchr/testify/mock" ) func TestAwsSQSQueuePolicyExpander_Execute(t *testing.T) { @@ -20,7 +18,7 @@ func TestAwsSQSQueuePolicyExpander_Execute(t *testing.T) { name string resourcesFromState []*resource.Resource expected []*resource.Resource - mocks func(factory *terraform.MockResourceFactory) + mocks func(factory *dctlresource.MockResourceFactory) }{ { "Inline policy, no aws_sqs_queue_policy attached", @@ -52,7 +50,7 @@ func TestAwsSQSQueuePolicyExpander_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", map[string]interface{}{ "id": "foo", "queue_url": "foo", @@ -107,7 +105,7 @@ func TestAwsSQSQueuePolicyExpander_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) {}, + func(factory *dctlresource.MockResourceFactory) {}, }, { "Inline policy duplicate aws_sqs_queue_policy", @@ -148,7 +146,7 @@ func TestAwsSQSQueuePolicyExpander_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) {}, + func(factory *dctlresource.MockResourceFactory) {}, }, { "Inline policy and aws_sqs_queue_policy", @@ -198,7 +196,7 @@ func TestAwsSQSQueuePolicyExpander_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", mock.MatchedBy(func(input map[string]interface{}) bool { return input["id"] == "foo" })).Once().Return(&resource.Resource{ @@ -216,7 +214,7 @@ func TestAwsSQSQueuePolicyExpander_Execute(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mocks != nil { tt.mocks(factory) } diff --git a/pkg/middlewares/azurerm_route_expander_test.go b/pkg/middlewares/azurerm_route_expander_test.go index 7a24b7a82..d55065070 100644 --- a/pkg/middlewares/azurerm_route_expander_test.go +++ b/pkg/middlewares/azurerm_route_expander_test.go @@ -1,7 +1,6 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" @@ -9,6 +8,7 @@ import ( "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource/azurerm" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) func TestAzurermRouteExpander_Execute(t *testing.T) { @@ -16,7 +16,7 @@ func TestAzurermRouteExpander_Execute(t *testing.T) { name string input []*resource.Resource expected []*resource.Resource - mock func(factory *terraform.MockResourceFactory) + mock func(factory *dctlresource.MockResourceFactory) }{ { name: "test with nil route attribute", @@ -135,7 +135,7 @@ func TestAzurermRouteExpander_Execute(t *testing.T) { Attrs: &resource.Attributes{}, }, }, - mock: func(factory *terraform.MockResourceFactory) { + mock: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", azurerm.AzureRouteResourceType, @@ -167,7 +167,7 @@ func TestAzurermRouteExpander_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mock != nil { tt.mock(factory) } diff --git a/pkg/middlewares/azurerm_subnet_expander_test.go b/pkg/middlewares/azurerm_subnet_expander_test.go index 95af5fe52..fda7f11fb 100644 --- a/pkg/middlewares/azurerm_subnet_expander_test.go +++ b/pkg/middlewares/azurerm_subnet_expander_test.go @@ -1,7 +1,6 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" @@ -9,6 +8,7 @@ import ( "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource/azurerm" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) func TestAzurermSubnetExpander_Execute(t *testing.T) { @@ -16,7 +16,7 @@ func TestAzurermSubnetExpander_Execute(t *testing.T) { name string input []*resource.Resource expected []*resource.Resource - mock func(factory *terraform.MockResourceFactory) + mock func(factory *dctlresource.MockResourceFactory) }{ { name: "test with nil subnet attribute", @@ -132,7 +132,7 @@ func TestAzurermSubnetExpander_Execute(t *testing.T) { Attrs: &resource.Attributes{}, }, }, - mock: func(factory *terraform.MockResourceFactory) { + mock: func(factory *dctlresource.MockResourceFactory) { factory.On("CreateAbstractResource", azurerm.AzureSubnetResourceType, "subnet1", map[string]interface{}{}).Times(1).Return(&resource.Resource{ Id: "subnet1", Type: azurerm.AzureSubnetResourceType, @@ -148,7 +148,7 @@ func TestAzurermSubnetExpander_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mock != nil { tt.mock(factory) } diff --git a/pkg/middlewares/default_vpc_test.go b/pkg/middlewares/default_vpc_test.go index acc1dc30c..8f544fba6 100644 --- a/pkg/middlewares/default_vpc_test.go +++ b/pkg/middlewares/default_vpc_test.go @@ -3,7 +3,7 @@ package middlewares import ( "testing" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/enumeration/resource" ) diff --git a/pkg/middlewares/google_iam_binding_tranformer_test.go b/pkg/middlewares/google_iam_binding_tranformer_test.go index 57df0cb7b..16d74751d 100644 --- a/pkg/middlewares/google_iam_binding_tranformer_test.go +++ b/pkg/middlewares/google_iam_binding_tranformer_test.go @@ -1,7 +1,6 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" @@ -9,6 +8,7 @@ import ( "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource/google" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) func TestGoogleProjectIAMBindingTransformer_Execute(t *testing.T) { @@ -16,7 +16,7 @@ func TestGoogleProjectIAMBindingTransformer_Execute(t *testing.T) { name string resourcesFromState []*resource.Resource expected []*resource.Resource - mock func(factory *terraform.MockResourceFactory) + mock func(factory *dctlresource.MockResourceFactory) }{ { name: "Test that bindings with nil members does not cause any crash", @@ -146,7 +146,7 @@ func TestGoogleProjectIAMBindingTransformer_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", google.GoogleProjectIamMemberResourceType, "proj/storage.admin/user:elie@cloudskiff.com", @@ -254,14 +254,14 @@ func TestGoogleProjectIAMBindingTransformer_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mock != nil { tt.mock(factory) } @@ -289,7 +289,7 @@ func TestGoogleBucketIAMBindingTransformer_Execute(t *testing.T) { name string resourcesFromState []*resource.Resource expected []*resource.Resource - mock func(factory *terraform.MockResourceFactory) + mock func(factory *dctlresource.MockResourceFactory) }{ { "Test that bucket bindings are transformed into member", @@ -396,7 +396,7 @@ func TestGoogleBucketIAMBindingTransformer_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", google.GoogleStorageBucketIamMemberResourceType, "b/bucket/storage.admin/user:elie@cloudskiff.com", @@ -504,14 +504,14 @@ func TestGoogleBucketIAMBindingTransformer_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { }, }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mock != nil { tt.mock(factory) } diff --git a/pkg/middlewares/google_iam_policy_tranformer_test.go b/pkg/middlewares/google_iam_policy_tranformer_test.go index 7d96c6a61..7b33a7d92 100644 --- a/pkg/middlewares/google_iam_policy_tranformer_test.go +++ b/pkg/middlewares/google_iam_policy_tranformer_test.go @@ -1,7 +1,6 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" @@ -9,6 +8,7 @@ import ( "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/resource/google" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) func TestGoogleProjectIAMPolicyTransformer_Execute(t *testing.T) { @@ -16,7 +16,7 @@ func TestGoogleProjectIAMPolicyTransformer_Execute(t *testing.T) { name string resourcesFromState []*resource.Resource expected []*resource.Resource - mock func(factory *terraform.MockResourceFactory) + mock func(factory *dctlresource.MockResourceFactory) }{ { "Test that project policy are transformed into bindings", @@ -103,7 +103,7 @@ func TestGoogleProjectIAMPolicyTransformer_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", google.GoogleProjectIamMemberResourceType, "project-1/roles/storage.admin/serviceAccount:driftctl@cloudskiff-dev-martin.iam.gserviceaccount.com", @@ -184,7 +184,7 @@ func TestGoogleProjectIAMPolicyTransformer_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mock != nil { tt.mock(factory) } @@ -212,7 +212,7 @@ func TestGoogleBucketIAMPolicyTransformer_Execute(t *testing.T) { name string resourcesFromState []*resource.Resource expected []*resource.Resource - mock func(factory *terraform.MockResourceFactory) + mock func(factory *dctlresource.MockResourceFactory) }{ { "Test that bucket policy are transformed into bindings", @@ -299,7 +299,7 @@ func TestGoogleBucketIAMPolicyTransformer_Execute(t *testing.T) { }, }, }, - func(factory *terraform.MockResourceFactory) { + func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", google.GoogleStorageBucketIamMemberResourceType, "b/dctlgstoragebucketiambinding-1/roles/storage.admin/serviceAccount:driftctl@cloudskiff-dev-martin.iam.gserviceaccount.com", @@ -380,7 +380,7 @@ func TestGoogleBucketIAMPolicyTransformer_Execute(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mock != nil { tt.mock(factory) } diff --git a/pkg/middlewares/iam_policy_attachment_expander.go b/pkg/middlewares/iam_policy_attachment_expander.go index fd87bfc4e..263174ac6 100644 --- a/pkg/middlewares/iam_policy_attachment_expander.go +++ b/pkg/middlewares/iam_policy_attachment_expander.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/snyk/driftctl/enumeration/resource" - resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" + resourceaws "github.com/snyk/driftctl/pkg/resource/aws" ) // Split Policy attachment when there is multiple user and groups and generate a repeatable id diff --git a/pkg/middlewares/iam_policy_attachment_expander_test.go b/pkg/middlewares/iam_policy_attachment_expander_test.go index 29cdac28d..382ac9673 100644 --- a/pkg/middlewares/iam_policy_attachment_expander_test.go +++ b/pkg/middlewares/iam_policy_attachment_expander_test.go @@ -1,15 +1,14 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "strings" "testing" "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" - "github.com/snyk/driftctl/enumeration/resource/aws" - "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestIamPolicyAttachmentExpander_Execute(t *testing.T) { @@ -20,13 +19,13 @@ func TestIamPolicyAttachmentExpander_Execute(t *testing.T) { tests := []struct { name string args resources - mocks func(*terraform.MockResourceFactory) + mocks func(*dctlresource.MockResourceFactory) expected resources wantErr bool }{ { name: "Split users and ReId", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, @@ -186,7 +185,7 @@ func TestIamPolicyAttachmentExpander_Execute(t *testing.T) { }, { name: "Split Roles and ReId", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, @@ -346,7 +345,7 @@ func TestIamPolicyAttachmentExpander_Execute(t *testing.T) { }, { name: "Split Groups and ReId", - mocks: func(factory *terraform.MockResourceFactory) { + mocks: func(factory *dctlresource.MockResourceFactory) { factory.On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, @@ -508,7 +507,7 @@ func TestIamPolicyAttachmentExpander_Execute(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} if tt.mocks != nil { tt.mocks(factory) } diff --git a/pkg/middlewares/route53_records.go b/pkg/middlewares/route53_records.go index 4959a0892..28d3bc54f 100644 --- a/pkg/middlewares/route53_records.go +++ b/pkg/middlewares/route53_records.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Remote NS and SAO records from remote state if not managed by IAC diff --git a/pkg/middlewares/route53_records_id_reconcilier.go b/pkg/middlewares/route53_records_id_reconcilier.go index 29b237218..06873fd4b 100644 --- a/pkg/middlewares/route53_records_id_reconcilier.go +++ b/pkg/middlewares/route53_records_id_reconcilier.go @@ -5,7 +5,7 @@ import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Since AWS returns the FQDN as the name of the remote record, we must change the Id of the diff --git a/pkg/middlewares/route53_records_id_reconcilier_test.go b/pkg/middlewares/route53_records_id_reconcilier_test.go index c30b75c01..8a1c97bc3 100644 --- a/pkg/middlewares/route53_records_id_reconcilier_test.go +++ b/pkg/middlewares/route53_records_id_reconcilier_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" "github.com/stretchr/testify/assert" ) diff --git a/pkg/middlewares/route53_records_test.go b/pkg/middlewares/route53_records_test.go index a74fe2ef4..8c2076721 100644 --- a/pkg/middlewares/route53_records_test.go +++ b/pkg/middlewares/route53_records_test.go @@ -3,7 +3,7 @@ package middlewares import ( "testing" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/enumeration/resource" ) diff --git a/pkg/middlewares/s3_bucket_acl.go b/pkg/middlewares/s3_bucket_acl.go index 11ea3ecbe..35db9b87a 100644 --- a/pkg/middlewares/s3_bucket_acl.go +++ b/pkg/middlewares/s3_bucket_acl.go @@ -4,7 +4,7 @@ import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Remove grant field on remote resources when acl field != private in state diff --git a/pkg/middlewares/s3_bucket_acl_test.go b/pkg/middlewares/s3_bucket_acl_test.go index 9a13a8f6a..9ee582b42 100644 --- a/pkg/middlewares/s3_bucket_acl_test.go +++ b/pkg/middlewares/s3_bucket_acl_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/assert" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" "github.com/snyk/driftctl/enumeration/resource" ) diff --git a/pkg/middlewares/vpc_security_group_default.go b/pkg/middlewares/vpc_security_group_default.go index 68ab7c9c4..9e1a8dc4e 100644 --- a/pkg/middlewares/vpc_security_group_default.go +++ b/pkg/middlewares/vpc_security_group_default.go @@ -3,7 +3,7 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) // Remove default security group from remote resources diff --git a/pkg/middlewares/vpc_security_group_default_test.go b/pkg/middlewares/vpc_security_group_default_test.go index 3700727aa..cdd43b65f 100644 --- a/pkg/middlewares/vpc_security_group_default_test.go +++ b/pkg/middlewares/vpc_security_group_default_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + "github.com/snyk/driftctl/pkg/resource/aws" ) func TestDefaultVPCSecurityGroupShouldBeIgnored(t *testing.T) { diff --git a/pkg/middlewares/vpc_security_group_rules.go b/pkg/middlewares/vpc_security_group_rules.go index 278a28e4c..5193c9591 100644 --- a/pkg/middlewares/vpc_security_group_rules.go +++ b/pkg/middlewares/vpc_security_group_rules.go @@ -4,7 +4,7 @@ import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" - resourceaws "github.com/snyk/driftctl/enumeration/resource/aws" + resourceaws "github.com/snyk/driftctl/pkg/resource/aws" ) // Split security group rule if it needs to given its attributes diff --git a/pkg/middlewares/vpc_security_group_rules_test.go b/pkg/middlewares/vpc_security_group_rules_test.go index cee0351dd..b13a5a95c 100644 --- a/pkg/middlewares/vpc_security_group_rules_test.go +++ b/pkg/middlewares/vpc_security_group_rules_test.go @@ -1,18 +1,17 @@ package middlewares import ( - "github.com/snyk/driftctl/enumeration/terraform" "testing" - "github.com/stretchr/testify/mock" - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" + dctlresource "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/stretchr/testify/mock" ) func TestVPCSecurityGroupRuleSanitizer(t *testing.T) { - factory := &terraform.MockResourceFactory{} + factory := &dctlresource.MockResourceFactory{} factory.On("CreateAbstractResource", aws.AwsSecurityGroupRuleResourceType, "sgrule-1175318309", mock.Anything).Times(1).Return( &resource.Resource{ Id: "sgrule-1175318309", diff --git a/pkg/resource/aws/aws_alb.go b/pkg/resource/aws/aws_alb.go new file mode 100644 index 000000000..15655ebb9 --- /dev/null +++ b/pkg/resource/aws/aws_alb.go @@ -0,0 +1,3 @@ +package aws + +const AwsApplicationLoadBalancerResourceType = "aws_alb" diff --git a/pkg/resource/aws/aws_alb_listener.go b/pkg/resource/aws/aws_alb_listener.go new file mode 100644 index 000000000..47aa4c484 --- /dev/null +++ b/pkg/resource/aws/aws_alb_listener.go @@ -0,0 +1,3 @@ +package aws + +const AwsApplicationLoadBalancerListenerResourceType = "aws_alb_listener" diff --git a/pkg/resource/aws/aws_ami.go b/pkg/resource/aws/aws_ami.go index 95d52108f..b436575e5 100644 --- a/pkg/resource/aws/aws_ami.go +++ b/pkg/resource/aws/aws_ami.go @@ -1,14 +1,13 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsAmiResourceType = "aws_ami" func initAwsAmiMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsAmiResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsAmiResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) - resourceSchemaRepository.SetFlags(aws.AwsAmiResourceType, resource.FlagDeepMode) + resourceSchemaRepository.SetFlags(AwsAmiResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_api_gateway_account.go b/pkg/resource/aws/aws_api_gateway_account.go new file mode 100644 index 000000000..6370f2881 --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_account.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayAccountResourceType = "aws_api_gateway_account" diff --git a/pkg/resource/aws/aws_api_gateway_api_key.go b/pkg/resource/aws/aws_api_gateway_api_key.go new file mode 100644 index 000000000..ee34b6eca --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_api_key.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayApiKeyResourceType = "aws_api_gateway_api_key" diff --git a/pkg/resource/aws/aws_api_gateway_authorizer.go b/pkg/resource/aws/aws_api_gateway_authorizer.go new file mode 100644 index 000000000..25dc217ac --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_authorizer.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayAuthorizerResourceType = "aws_api_gateway_authorizer" diff --git a/pkg/resource/aws/aws_api_gateway_base_path_mapping.go b/pkg/resource/aws/aws_api_gateway_base_path_mapping.go new file mode 100644 index 000000000..23feab7d6 --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_base_path_mapping.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayBasePathMappingResourceType = "aws_api_gateway_base_path_mapping" diff --git a/pkg/resource/aws/aws_api_gateway_deployment.go b/pkg/resource/aws/aws_api_gateway_deployment.go new file mode 100644 index 000000000..4e4a2f23f --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_deployment.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayDeploymentResourceType = "aws_api_gateway_deployment" diff --git a/pkg/resource/aws/aws_api_gateway_domain_name.go b/pkg/resource/aws/aws_api_gateway_domain_name.go new file mode 100644 index 000000000..9f05e1a8d --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_domain_name.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayDomainNameResourceType = "aws_api_gateway_domain_name" diff --git a/pkg/resource/aws/aws_api_gateway_gateway_response.go b/pkg/resource/aws/aws_api_gateway_gateway_response.go new file mode 100644 index 000000000..4f02a9057 --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_gateway_response.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayGatewayResponseResourceType = "aws_api_gateway_gateway_response" diff --git a/pkg/resource/aws/aws_api_gateway_integration.go b/pkg/resource/aws/aws_api_gateway_integration.go new file mode 100644 index 000000000..743f5e3c1 --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_integration.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayIntegrationResourceType = "aws_api_gateway_integration" diff --git a/pkg/resource/aws/aws_api_gateway_integration_response.go b/pkg/resource/aws/aws_api_gateway_integration_response.go new file mode 100644 index 000000000..7170ec58c --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_integration_response.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayIntegrationResponseResourceType = "aws_api_gateway_integration_response" diff --git a/pkg/resource/aws/aws_api_gateway_method.go b/pkg/resource/aws/aws_api_gateway_method.go new file mode 100644 index 000000000..77484f750 --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_method.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayMethodResourceType = "aws_api_gateway_method" diff --git a/pkg/resource/aws/aws_api_gateway_method_response.go b/pkg/resource/aws/aws_api_gateway_method_response.go new file mode 100644 index 000000000..c499500a1 --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_method_response.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayMethodResponseResourceType = "aws_api_gateway_method_response" diff --git a/pkg/resource/aws/aws_api_gateway_method_settings.go b/pkg/resource/aws/aws_api_gateway_method_settings.go new file mode 100644 index 000000000..f3af58606 --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_method_settings.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayMethodSettingsResourceType = "aws_api_gateway_method_settings" diff --git a/pkg/resource/aws/aws_api_gateway_model.go b/pkg/resource/aws/aws_api_gateway_model.go new file mode 100644 index 000000000..7f068d856 --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_model.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayModelResourceType = "aws_api_gateway_model" diff --git a/pkg/resource/aws/aws_api_gateway_request_validator.go b/pkg/resource/aws/aws_api_gateway_request_validator.go new file mode 100644 index 000000000..e11936055 --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_request_validator.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayRequestValidatorResourceType = "aws_api_gateway_request_validator" diff --git a/pkg/resource/aws/aws_api_gateway_resource.go b/pkg/resource/aws/aws_api_gateway_resource.go new file mode 100644 index 000000000..73bce671d --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_resource.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayResourceResourceType = "aws_api_gateway_resource" diff --git a/pkg/resource/aws/aws_api_gateway_rest_api.go b/pkg/resource/aws/aws_api_gateway_rest_api.go new file mode 100644 index 000000000..9880f5716 --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_rest_api.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayRestApiResourceType = "aws_api_gateway_rest_api" diff --git a/pkg/resource/aws/aws_api_gateway_rest_api_policy.go b/pkg/resource/aws/aws_api_gateway_rest_api_policy.go new file mode 100644 index 000000000..95c1a6770 --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_rest_api_policy.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayRestApiPolicyResourceType = "aws_api_gateway_rest_api_policy" diff --git a/pkg/resource/aws/aws_api_gateway_stage.go b/pkg/resource/aws/aws_api_gateway_stage.go new file mode 100644 index 000000000..32a10613c --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_stage.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayStageResourceType = "aws_api_gateway_stage" diff --git a/pkg/resource/aws/aws_api_gateway_vpc_link.go b/pkg/resource/aws/aws_api_gateway_vpc_link.go new file mode 100644 index 000000000..97a15555a --- /dev/null +++ b/pkg/resource/aws/aws_api_gateway_vpc_link.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayVpcLinkResourceType = "aws_api_gateway_vpc_link" diff --git a/pkg/resource/aws/aws_apigatewayv2_api.go b/pkg/resource/aws/aws_apigatewayv2_api.go new file mode 100644 index 000000000..ef468884b --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_api.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayV2ApiResourceType = "aws_apigatewayv2_api" diff --git a/pkg/resource/aws/aws_apigatewayv2_authorizer.go b/pkg/resource/aws/aws_apigatewayv2_authorizer.go new file mode 100644 index 000000000..fb157219c --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_authorizer.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayV2AuthorizerResourceType = "aws_apigatewayv2_authorizer" diff --git a/pkg/resource/aws/aws_apigatewayv2_deployment.go b/pkg/resource/aws/aws_apigatewayv2_deployment.go new file mode 100644 index 000000000..159245add --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_deployment.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayV2DeploymentResourceType = "aws_apigatewayv2_deployment" diff --git a/pkg/resource/aws/aws_apigatewayv2_domain_name.go b/pkg/resource/aws/aws_apigatewayv2_domain_name.go new file mode 100644 index 000000000..9a4687bdb --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_domain_name.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayV2DomainNameResourceType = "aws_apigatewayv2_domain_name" diff --git a/pkg/resource/aws/aws_apigatewayv2_integration.go b/pkg/resource/aws/aws_apigatewayv2_integration.go new file mode 100644 index 000000000..e2db2378b --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_integration.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayV2IntegrationResourceType = "aws_apigatewayv2_integration" diff --git a/pkg/resource/aws/aws_apigatewayv2_integration_response.go b/pkg/resource/aws/aws_apigatewayv2_integration_response.go new file mode 100644 index 000000000..43516aef1 --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_integration_response.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayV2IntegrationResponseResourceType = "aws_apigatewayv2_integration_response" diff --git a/pkg/resource/aws/aws_apigatewayv2_mapping.go b/pkg/resource/aws/aws_apigatewayv2_mapping.go new file mode 100644 index 000000000..dd563a9a2 --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_mapping.go @@ -0,0 +1,23 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsApiGatewayV2MappingResourceType = "aws_apigatewayv2_api_mapping" + +func initAwsApiGatewayV2MappingMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc( + AwsApiGatewayV2MappingResourceType, + func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + + if v := res.Attributes().GetString("api_id"); v != nil { + attrs["Api"] = *v + } + if v := res.Attributes().GetString("stage"); v != nil { + attrs["Stage"] = *v + } + + return attrs + }, + ) +} diff --git a/pkg/resource/aws/aws_apigatewayv2_model.go b/pkg/resource/aws/aws_apigatewayv2_model.go new file mode 100644 index 000000000..471ae4937 --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_model.go @@ -0,0 +1,16 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsApiGatewayV2ModelResourceType = "aws_apigatewayv2_model" + +func initAwsApiGatewayV2ModelMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc( + AwsApiGatewayV2ModelResourceType, + func(res *resource.Resource) map[string]string { + return map[string]string{ + "name": *res.Attributes().GetString("name"), + } + }, + ) +} diff --git a/pkg/resource/aws/aws_apigatewayv2_route.go b/pkg/resource/aws/aws_apigatewayv2_route.go new file mode 100644 index 000000000..6073bbe30 --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_route.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayV2RouteResourceType = "aws_apigatewayv2_route" diff --git a/pkg/resource/aws/aws_apigatewayv2_route_response.go b/pkg/resource/aws/aws_apigatewayv2_route_response.go new file mode 100644 index 000000000..9b27ea1d9 --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_route_response.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayV2RouteResponseResourceType = "aws_apigatewayv2_route_response" diff --git a/pkg/resource/aws/aws_apigatewayv2_stage.go b/pkg/resource/aws/aws_apigatewayv2_stage.go new file mode 100644 index 000000000..be63bd5de --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_stage.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayV2StageResourceType = "aws_apigatewayv2_stage" diff --git a/pkg/resource/aws/aws_apigatewayv2_vpc_link.go b/pkg/resource/aws/aws_apigatewayv2_vpc_link.go new file mode 100644 index 000000000..619986967 --- /dev/null +++ b/pkg/resource/aws/aws_apigatewayv2_vpc_link.go @@ -0,0 +1,3 @@ +package aws + +const AwsApiGatewayV2VpcLinkResourceType = "aws_apigatewayv2_vpc_link" diff --git a/pkg/resource/aws/aws_appautoscaling_policy.go b/pkg/resource/aws/aws_appautoscaling_policy.go new file mode 100644 index 000000000..33c6ea0b1 --- /dev/null +++ b/pkg/resource/aws/aws_appautoscaling_policy.go @@ -0,0 +1,16 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsAppAutoscalingPolicyResourceType = "aws_appautoscaling_policy" + +func initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingPolicyResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { + attrs["Scalable dimension"] = *v + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsAppAutoscalingPolicyResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_appautoscaling_scheduled_action.go b/pkg/resource/aws/aws_appautoscaling_scheduled_action.go new file mode 100644 index 000000000..18d9caeea --- /dev/null +++ b/pkg/resource/aws/aws_appautoscaling_scheduled_action.go @@ -0,0 +1,3 @@ +package aws + +const AwsAppAutoscalingScheduledActionResourceType = "aws_appautoscaling_scheduled_action" diff --git a/pkg/resource/aws/aws_appautoscaling_target.go b/pkg/resource/aws/aws_appautoscaling_target.go index 110037a8e..67ce5e847 100644 --- a/pkg/resource/aws/aws_appautoscaling_target.go +++ b/pkg/resource/aws/aws_appautoscaling_target.go @@ -1,12 +1,19 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsAppAutoscalingTargetResourceType = "aws_appautoscaling_target" func initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetDiscriminantFunc(aws.AwsAppAutoscalingTargetResourceType, func(self, target *resource.Resource) bool { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { + attrs["Scalable dimension"] = *v + } + return attrs + }) + resourceSchemaRepository.SetDiscriminantFunc(AwsAppAutoscalingTargetResourceType, func(self, target *resource.Resource) bool { return *self.Attributes().GetString("scalable_dimension") == *target.Attributes().GetString("scalable_dimension") }) + resourceSchemaRepository.SetFlags(AwsAppAutoscalingTargetResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_cloudformation_stack.go b/pkg/resource/aws/aws_cloudformation_stack.go index b3a53dfbc..d65c62971 100644 --- a/pkg/resource/aws/aws_cloudformation_stack.go +++ b/pkg/resource/aws/aws_cloudformation_stack.go @@ -1,13 +1,13 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsCloudformationStackResourceType = "aws_cloudformation_stack" func initAwsCloudformationStackMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsCloudformationStackResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsCloudformationStackResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetFlags(AwsCloudformationStackResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_cloudfront_distribution.go b/pkg/resource/aws/aws_cloudfront_distribution.go index 714506028..44fbf3af5 100644 --- a/pkg/resource/aws/aws_cloudfront_distribution.go +++ b/pkg/resource/aws/aws_cloudfront_distribution.go @@ -1,12 +1,11 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsCloudfrontDistributionResourceType = "aws_cloudfront_distribution" func initAwsCloudfrontDistributionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsCloudfrontDistributionResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsCloudfrontDistributionResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"etag"}) val.SafeDelete([]string{"last_modified_time"}) @@ -14,4 +13,6 @@ func initAwsCloudfrontDistributionMetaData(resourceSchemaRepository resource.Sch val.SafeDelete([]string{"status"}) val.SafeDelete([]string{"wait_for_deployment"}) }) + resourceSchemaRepository.SetFlags(AwsCloudfrontDistributionResourceType, resource.FlagDeepMode) + } diff --git a/pkg/resource/aws/aws_db_instance.go b/pkg/resource/aws/aws_db_instance.go index 291e4722a..280681fdc 100644 --- a/pkg/resource/aws/aws_db_instance.go +++ b/pkg/resource/aws/aws_db_instance.go @@ -1,12 +1,11 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsDbInstanceResourceType = "aws_db_instance" func initAwsDbInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsDbInstanceResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsDbInstanceResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"delete_automated_backups"}) val.SafeDelete([]string{"final_snapshot_identifier"}) @@ -19,4 +18,5 @@ func initAwsDbInstanceMetaData(resourceSchemaRepository resource.SchemaRepositor val.SafeDelete([]string{"apply_immediately"}) val.DeleteIfDefault("CharacterSetName") }) + resourceSchemaRepository.SetFlags(AwsDbInstanceResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_db_subnet_group.go b/pkg/resource/aws/aws_db_subnet_group.go index f02e554f3..a716cbaac 100644 --- a/pkg/resource/aws/aws_db_subnet_group.go +++ b/pkg/resource/aws/aws_db_subnet_group.go @@ -1,13 +1,13 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsDbSubnetGroupResourceType = "aws_db_subnet_group" func initAwsDbSubnetGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsDbSubnetGroupResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsDbSubnetGroupResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"name_prefix"}) }) + resourceSchemaRepository.SetFlags(AwsDbSubnetGroupResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_default_network_acl.go b/pkg/resource/aws/aws_default_network_acl.go index 0279b62e4..353b5dddd 100644 --- a/pkg/resource/aws/aws_default_network_acl.go +++ b/pkg/resource/aws/aws_default_network_acl.go @@ -1,16 +1,17 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsDefaultNetworkACLResourceType = "aws_default_network_acl" func initAwsDefaultNetworkACLMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsDefaultNetworkACLResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsDefaultNetworkACLResourceType, func(res *resource.Resource) { res.Attrs.SafeDelete([]string{"default_network_acl_id"}) // https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/default_network_acl#managing-subnets-in-a-default-network-acl res.Attrs.SafeDelete([]string{"subnet_ids"}) }) + resourceSchemaRepository.SetFlags(AwsDefaultNetworkACLResourceType, resource.FlagDeepMode) + } diff --git a/pkg/resource/aws/aws_default_route_table.go b/pkg/resource/aws/aws_default_route_table.go new file mode 100644 index 000000000..0965c995c --- /dev/null +++ b/pkg/resource/aws/aws_default_route_table.go @@ -0,0 +1,13 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsDefaultRouteTableResourceType = "aws_default_route_table" + +func initAwsDefaultRouteTableMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsDefaultRouteTableResourceType, resource.FlagDeepMode) + resourceSchemaRepository.SetNormalizeFunc(AwsDefaultRouteTableResourceType, func(res *resource.Resource) { + val := res.Attrs + val.SafeDelete([]string{"timeouts"}) + }) +} diff --git a/pkg/resource/aws/aws_default_security_group.go b/pkg/resource/aws/aws_default_security_group.go index a85a9b10c..6615025cc 100644 --- a/pkg/resource/aws/aws_default_security_group.go +++ b/pkg/resource/aws/aws_default_security_group.go @@ -1,15 +1,15 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsDefaultSecurityGroupResourceType = "aws_default_security_group" func initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsDefaultSecurityGroupResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsDefaultSecurityGroupResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"revoke_rules_on_delete"}) val.SafeDelete([]string{"ingress"}) val.SafeDelete([]string{"egress"}) }) + resourceSchemaRepository.SetFlags(AwsDefaultSecurityGroupResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_default_subnet.go b/pkg/resource/aws/aws_default_subnet.go index fd1663906..d0e597de7 100644 --- a/pkg/resource/aws/aws_default_subnet.go +++ b/pkg/resource/aws/aws_default_subnet.go @@ -1,13 +1,13 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsDefaultSubnetResourceType = "aws_default_subnet" func initAwsDefaultSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsDefaultSubnetResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsDefaultSubnetResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetFlags(AwsDefaultSubnetResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_default_vpc.go b/pkg/resource/aws/aws_default_vpc.go new file mode 100644 index 000000000..62a02a122 --- /dev/null +++ b/pkg/resource/aws/aws_default_vpc.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsDefaultVpcResourceType = "aws_default_vpc" + +func initAwsDefaultVpcMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsDefaultVpcResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_dynamodb_table.go b/pkg/resource/aws/aws_dynamodb_table.go index d6d24a5f2..eb0d4c7dc 100644 --- a/pkg/resource/aws/aws_dynamodb_table.go +++ b/pkg/resource/aws/aws_dynamodb_table.go @@ -1,13 +1,13 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsDynamodbTableResourceType = "aws_dynamodb_table" func initAwsDynamodbTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsDynamodbTableResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsDynamodbTableResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetFlags(AwsDynamodbTableResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_ebs_encryption_by_default.go b/pkg/resource/aws/aws_ebs_encryption_by_default.go new file mode 100644 index 000000000..502b99f38 --- /dev/null +++ b/pkg/resource/aws/aws_ebs_encryption_by_default.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsEbsEncryptionByDefaultResourceType = "aws_ebs_encryption_by_default" + +func initAwsEbsEncryptionByDefaultMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsEbsEncryptionByDefaultResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_ebs_snapshot.go b/pkg/resource/aws/aws_ebs_snapshot.go index 9bce422a6..ff870fa8f 100644 --- a/pkg/resource/aws/aws_ebs_snapshot.go +++ b/pkg/resource/aws/aws_ebs_snapshot.go @@ -1,13 +1,13 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsEbsSnapshotResourceType = "aws_ebs_snapshot" func initAwsEbsSnapshotMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsEbsSnapshotResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsEbsSnapshotResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetFlags(AwsEbsSnapshotResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_ebs_volume.go b/pkg/resource/aws/aws_ebs_volume.go index d69f59a0e..004e611ac 100644 --- a/pkg/resource/aws/aws_ebs_volume.go +++ b/pkg/resource/aws/aws_ebs_volume.go @@ -1,16 +1,16 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsEbsVolumeResourceType = "aws_ebs_volume" func initAwsEbsVolumeMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsEbsVolumeResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsEbsVolumeResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"arn"}) val.SafeDelete([]string{"outpost_arn"}) val.SafeDelete([]string{"snapshot_id"}) val.DeleteIfDefault("throughput") }) + resourceSchemaRepository.SetFlags(AwsEbsVolumeResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_ecr_repository.go b/pkg/resource/aws/aws_ecr_repository.go index 431c3d89b..faea0a071 100644 --- a/pkg/resource/aws/aws_ecr_repository.go +++ b/pkg/resource/aws/aws_ecr_repository.go @@ -1,13 +1,13 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsEcrRepositoryResourceType = "aws_ecr_repository" func initAwsEcrRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsEcrRepositoryResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsEcrRepositoryResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetFlags(AwsEcrRepositoryResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_ecr_repository_policy.go b/pkg/resource/aws/aws_ecr_repository_policy.go new file mode 100644 index 000000000..64433480f --- /dev/null +++ b/pkg/resource/aws/aws_ecr_repository_policy.go @@ -0,0 +1,3 @@ +package aws + +const AwsEcrRepositoryPolicyResourceType = "aws_ecr_repository_policy" diff --git a/pkg/resource/aws/aws_eip.go b/pkg/resource/aws/aws_eip.go index d25e820e1..06fe011f9 100644 --- a/pkg/resource/aws/aws_eip.go +++ b/pkg/resource/aws/aws_eip.go @@ -1,13 +1,13 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsEipResourceType = "aws_eip" func initAwsEipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsEipResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsEipResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetFlags(AwsEipResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_eip_association.go b/pkg/resource/aws/aws_eip_association.go new file mode 100644 index 000000000..60248114b --- /dev/null +++ b/pkg/resource/aws/aws_eip_association.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsEipAssociationResourceType = "aws_eip_association" + +func initAwsEipAssociationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsEipAssociationResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_elasticache_cluster.go b/pkg/resource/aws/aws_elasticache_cluster.go new file mode 100644 index 000000000..46f1bbf35 --- /dev/null +++ b/pkg/resource/aws/aws_elasticache_cluster.go @@ -0,0 +1,3 @@ +package aws + +const AwsElastiCacheClusterResourceType = "aws_elasticache_cluster" diff --git a/pkg/resource/aws/aws_elb.go b/pkg/resource/aws/aws_elb.go new file mode 100644 index 000000000..6f9473648 --- /dev/null +++ b/pkg/resource/aws/aws_elb.go @@ -0,0 +1,3 @@ +package aws + +const AwsClassicLoadBalancerResourceType = "aws_elb" diff --git a/pkg/resource/aws/aws_iam_access_key.go b/pkg/resource/aws/aws_iam_access_key.go index dc506d8b7..240512ac6 100644 --- a/pkg/resource/aws/aws_iam_access_key.go +++ b/pkg/resource/aws/aws_iam_access_key.go @@ -1,13 +1,11 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" -func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +const AwsIamAccessKeyResourceType = "aws_iam_access_key" - resourceSchemaRepository.SetNormalizeFunc(aws.AwsIamAccessKeyResourceType, func(res *resource.Resource) { +func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetNormalizeFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) { val := res.Attrs // As we can't read secrets from aws API once access_key created we need to set // fields retrieved from state to nil to avoid drift @@ -19,4 +17,13 @@ func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaReposit val.SafeDelete([]string{"key_fingerprint"}) val.SafeDelete([]string{"pgp_key"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if user := val.GetString("user"); user != nil && *user != "" { + attrs["User"] = *user + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsIamAccessKeyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_group.go b/pkg/resource/aws/aws_iam_group.go new file mode 100644 index 000000000..e0e653f2b --- /dev/null +++ b/pkg/resource/aws/aws_iam_group.go @@ -0,0 +1,3 @@ +package aws + +const AwsIamGroupResourceType = "aws_iam_group" diff --git a/pkg/resource/aws/aws_iam_group_policy.go b/pkg/resource/aws/aws_iam_group_policy.go new file mode 100644 index 000000000..fe3a86f95 --- /dev/null +++ b/pkg/resource/aws/aws_iam_group_policy.go @@ -0,0 +1,3 @@ +package aws + +const AwsIamGroupPolicyResourceType = "aws_iam_group_policy" diff --git a/pkg/resource/aws/aws_iam_group_policy_attachment.go b/pkg/resource/aws/aws_iam_group_policy_attachment.go new file mode 100644 index 000000000..b6ac3cb91 --- /dev/null +++ b/pkg/resource/aws/aws_iam_group_policy_attachment.go @@ -0,0 +1,3 @@ +package aws + +const AwsIamGroupPolicyAttachmentResourceType = "aws_iam_group_policy_attachment" diff --git a/pkg/resource/aws/aws_iam_policy.go b/pkg/resource/aws/aws_iam_policy.go index e6adfbe66..1718e3b67 100644 --- a/pkg/resource/aws/aws_iam_policy.go +++ b/pkg/resource/aws/aws_iam_policy.go @@ -2,12 +2,13 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" ) +const AwsIamPolicyResourceType = "aws_iam_policy" + func initAwsIAMPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsIamPolicyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsIamPolicyResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) if err == nil { @@ -16,4 +17,10 @@ func initAwsIAMPolicyMetaData(resourceSchemaRepository resource.SchemaRepository val.SafeDelete([]string{"name_prefix"}) }) + resourceSchemaRepository.UpdateSchema(AwsIamPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsIamPolicyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_policy_attachment.go b/pkg/resource/aws/aws_iam_policy_attachment.go index dcfca92d5..36ad1ce46 100644 --- a/pkg/resource/aws/aws_iam_policy_attachment.go +++ b/pkg/resource/aws/aws_iam_policy_attachment.go @@ -1,13 +1,13 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsIamPolicyAttachmentResourceType = "aws_iam_policy_attachment" func initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsIamPolicyAttachmentResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsIamPolicyAttachmentResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"name"}) }) + resourceSchemaRepository.SetFlags(AwsIamPolicyAttachmentResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_role.go b/pkg/resource/aws/aws_iam_role.go index abc9e9876..31c846114 100644 --- a/pkg/resource/aws/aws_iam_role.go +++ b/pkg/resource/aws/aws_iam_role.go @@ -1,13 +1,18 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsIamRoleResourceType = "aws_iam_role" func initAwsIAMRoleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsIamRoleResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsIamRoleResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"force_detach_policies"}) }) + resourceSchemaRepository.UpdateSchema(AwsIamRoleResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "assume_role_policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsIamRoleResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_role_policy.go b/pkg/resource/aws/aws_iam_role_policy.go new file mode 100644 index 000000000..c0fb37567 --- /dev/null +++ b/pkg/resource/aws/aws_iam_role_policy.go @@ -0,0 +1,14 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsIamRolePolicyResourceType = "aws_iam_role_policy" + +func initAwsIAMRolePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.UpdateSchema(AwsIamRolePolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsIamRolePolicyResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_iam_role_policy_attachment.go b/pkg/resource/aws/aws_iam_role_policy_attachment.go new file mode 100644 index 000000000..a9d83f241 --- /dev/null +++ b/pkg/resource/aws/aws_iam_role_policy_attachment.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsIamRolePolicyAttachmentResourceType = "aws_iam_role_policy_attachment" + +func initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsIamRolePolicyAttachmentResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_iam_user.go b/pkg/resource/aws/aws_iam_user.go index 12b1cd938..576cd882d 100644 --- a/pkg/resource/aws/aws_iam_user.go +++ b/pkg/resource/aws/aws_iam_user.go @@ -1,12 +1,11 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsIamUserResourceType = "aws_iam_user" func initAwsIAMUserMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsIamUserResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsIamUserResourceType, func(res *resource.Resource) { val := res.Attrs permissionsBoundary, exist := val.Get("permissions_boundary") if exist && permissionsBoundary == "" { @@ -14,4 +13,5 @@ func initAwsIAMUserMetaData(resourceSchemaRepository resource.SchemaRepositoryIn } val.SafeDelete([]string{"force_destroy"}) }) + resourceSchemaRepository.SetFlags(AwsIamUserResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_user_policy.go b/pkg/resource/aws/aws_iam_user_policy.go new file mode 100644 index 000000000..9eb7ae9e2 --- /dev/null +++ b/pkg/resource/aws/aws_iam_user_policy.go @@ -0,0 +1,14 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsIamUserPolicyResourceType = "aws_iam_user_policy" + +func initAwsIAMUserPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.UpdateSchema(AwsIamUserPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsIamUserPolicyResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_iam_user_policy_attachment.go b/pkg/resource/aws/aws_iam_user_policy_attachment.go new file mode 100644 index 000000000..9b7a41d15 --- /dev/null +++ b/pkg/resource/aws/aws_iam_user_policy_attachment.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsIamUserPolicyAttachmentResourceType = "aws_iam_user_policy_attachment" + +func initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsIamUserPolicyAttachmentResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_instance.go b/pkg/resource/aws/aws_instance.go index 41760ae5b..21fbfff69 100644 --- a/pkg/resource/aws/aws_instance.go +++ b/pkg/resource/aws/aws_instance.go @@ -2,12 +2,14 @@ package aws import ( "github.com/hashicorp/go-version" + "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" ) +const AwsInstanceResourceType = "aws_instance" + func initAwsInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsInstanceResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsInstanceResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) @@ -15,4 +17,15 @@ func initAwsInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryI val.SafeDelete([]string{"instance_initiated_shutdown_behavior"}) } }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsInstanceResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if tags := val.GetMap("tags"); tags != nil { + if name, ok := tags["Name"]; ok { + attrs["Name"] = name.(string) + } + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsInstanceResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_internet_gateway.go b/pkg/resource/aws/aws_internet_gateway.go new file mode 100644 index 000000000..500a664e8 --- /dev/null +++ b/pkg/resource/aws/aws_internet_gateway.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsInternetGatewayResourceType = "aws_internet_gateway" + +func initAwsInternetGatewayMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsInternetGatewayResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_key_pair.go b/pkg/resource/aws/aws_key_pair.go index 0640764c4..387aa690c 100644 --- a/pkg/resource/aws/aws_key_pair.go +++ b/pkg/resource/aws/aws_key_pair.go @@ -1,14 +1,14 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsKeyPairResourceType = "aws_key_pair" func initAwsKeyPairMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsKeyPairResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsKeyPairResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"key_name_prefix"}) val.SafeDelete([]string{"public_key"}) }) + resourceSchemaRepository.SetFlags(AwsKeyPairResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_kms_alias.go b/pkg/resource/aws/aws_kms_alias.go index 4b5cd4178..ae291c509 100644 --- a/pkg/resource/aws/aws_kms_alias.go +++ b/pkg/resource/aws/aws_kms_alias.go @@ -1,14 +1,14 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsKmsAliasResourceType = "aws_kms_alias" func initAwsKmsAliasMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsKmsAliasResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsKmsAliasResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"name"}) val.SafeDelete([]string{"name_prefix"}) }) + resourceSchemaRepository.SetFlags(AwsKmsAliasResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_kms_key.go b/pkg/resource/aws/aws_kms_key.go index ad2425642..e52160a2c 100644 --- a/pkg/resource/aws/aws_kms_key.go +++ b/pkg/resource/aws/aws_kms_key.go @@ -2,12 +2,13 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" ) +const AwsKmsKeyResourceType = "aws_kms_key" + func initAwsKmsKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsKmsKeyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsKmsKeyResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"deletion_window_in_days"}) jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) @@ -16,4 +17,10 @@ func initAwsKmsKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInt } _ = val.SafeSet([]string{"policy"}, jsonString) }) + resourceSchemaRepository.UpdateSchema(AwsKmsKeyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsKmsKeyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_lambda_event_source_mapping.go b/pkg/resource/aws/aws_lambda_event_source_mapping.go index 6723a2d8c..b6dc064b3 100644 --- a/pkg/resource/aws/aws_lambda_event_source_mapping.go +++ b/pkg/resource/aws/aws_lambda_event_source_mapping.go @@ -1,12 +1,11 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsLambdaEventSourceMappingResourceType = "aws_lambda_event_source_mapping" func initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsLambdaEventSourceMappingResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsLambdaEventSourceMappingResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"state_transition_reason"}) val.SafeDelete([]string{"state"}) @@ -15,4 +14,16 @@ func initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository resource.S val.SafeDelete([]string{"last_processing_result"}) val.SafeDelete([]string{"last_modified"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsLambdaEventSourceMappingResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + source := val.GetString("event_source_arn") + dest := val.GetString("function_name") + if source != nil && *source != "" && dest != nil && *dest != "" { + attrs["Source"] = *source + attrs["Dest"] = *dest + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsLambdaEventSourceMappingResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_lambda_function.go b/pkg/resource/aws/aws_lambda_function.go index 2e825e8e6..3dd86ac74 100644 --- a/pkg/resource/aws/aws_lambda_function.go +++ b/pkg/resource/aws/aws_lambda_function.go @@ -1,12 +1,11 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsLambdaFunctionResourceType = "aws_lambda_function" func initAwsLambdaFunctionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsLambdaFunctionResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsLambdaFunctionResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"publish"}) @@ -19,4 +18,5 @@ func initAwsLambdaFunctionMetaData(resourceSchemaRepository resource.SchemaRepos val.DeleteIfDefault("signing_profile_version_arn") val.SafeDelete([]string{"source_code_size"}) }) + resourceSchemaRepository.SetFlags(AwsLambdaFunctionResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_launch_configuration.go b/pkg/resource/aws/aws_launch_configuration.go new file mode 100644 index 000000000..ad75e8489 --- /dev/null +++ b/pkg/resource/aws/aws_launch_configuration.go @@ -0,0 +1,3 @@ +package aws + +const AwsLaunchConfigurationResourceType = "aws_launch_configuration" diff --git a/pkg/resource/aws/aws_launch_template.go b/pkg/resource/aws/aws_launch_template.go new file mode 100644 index 000000000..ce931e208 --- /dev/null +++ b/pkg/resource/aws/aws_launch_template.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsLaunchTemplateResourceType = "aws_launch_template" + +func initAwsLaunchTemplateMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsLaunchTemplateResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_lb.go b/pkg/resource/aws/aws_lb.go new file mode 100644 index 000000000..791f8068f --- /dev/null +++ b/pkg/resource/aws/aws_lb.go @@ -0,0 +1,13 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsLoadBalancerResourceType = "aws_lb" + +func initAwsLoadBalancerMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsLoadBalancerResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "Name": *res.Attributes().GetString("name"), + } + }) +} diff --git a/pkg/resource/aws/aws_lb_listener.go b/pkg/resource/aws/aws_lb_listener.go new file mode 100644 index 000000000..cf919edc0 --- /dev/null +++ b/pkg/resource/aws/aws_lb_listener.go @@ -0,0 +1,3 @@ +package aws + +const AwsLoadBalancerListenerResourceType = "aws_lb_listener" diff --git a/pkg/resource/aws/aws_nat_gateway.go b/pkg/resource/aws/aws_nat_gateway.go new file mode 100644 index 000000000..c51f3a98b --- /dev/null +++ b/pkg/resource/aws/aws_nat_gateway.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsNatGatewayResourceType = "aws_nat_gateway" + +func initNatGatewayMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsNatGatewayResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_network_acl.go b/pkg/resource/aws/aws_network_acl.go new file mode 100644 index 000000000..e2e4650e9 --- /dev/null +++ b/pkg/resource/aws/aws_network_acl.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsNetworkACLResourceType = "aws_network_acl" + +func initAwsNetworkACLMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsNetworkACLResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_network_acl_rule.go b/pkg/resource/aws/aws_network_acl_rule.go index 0dc19886c..2cfd12cb2 100644 --- a/pkg/resource/aws/aws_network_acl_rule.go +++ b/pkg/resource/aws/aws_network_acl_rule.go @@ -1,12 +1,17 @@ package aws import ( + "bytes" + "fmt" "strconv" + "github.com/hashicorp/terraform/helper/hashcode" + "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" ) +const AwsNetworkACLRuleResourceType = "aws_network_acl_rule" + var protocolsNumbers = map[string]int{ // defined at https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml "all": -1, @@ -157,7 +162,7 @@ var protocolsNumbers = map[string]int{ } func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsNetworkACLRuleResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) { res.Attrs.DeleteIfDefault("icmp_code") res.Attrs.DeleteIfDefault("icmp_type") @@ -180,7 +185,7 @@ func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepos // While reading remote we always got protocol as a number. // We cannot predict how the user decided to write the protocol on IaC side. // This workaround is mandatory to harmonize resources ID - res.Id = aws.CreateNetworkACLRuleID( + res.Id = CreateNetworkACLRuleID( *res.Attrs.GetString("network_acl_id"), int64(*res.Attrs.GetInt("rule_number")), *res.Attrs.GetBool("egress"), @@ -191,4 +196,51 @@ func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepos res.Attrs.DeleteIfDefault("cidr_block") res.Attrs.DeleteIfDefault("ipv6_cidr_block") }) + resourceSchemaRepository.SetFlags(AwsNetworkACLRuleResourceType, resource.FlagDeepMode) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) map[string]string { + + ruleNumber := strconv.FormatInt(int64(*res.Attrs.GetInt("rule_number")), 10) + if ruleNumber == "32767" { + ruleNumber = "*" + } + + attrs := map[string]string{ + "Network": *res.Attrs.GetString("network_acl_id"), + "Egress": strconv.FormatBool(*res.Attrs.GetBool("egress")), + "Rule number": ruleNumber, + } + + if proto := res.Attrs.GetString("protocol"); proto != nil { + if *proto == "-1" { + *proto = "All" + } + attrs["Protocol"] = *proto + } + + if res.Attrs.GetFloat64("from_port") != nil && res.Attrs.GetFloat64("to_port") != nil { + attrs["Port range"] = fmt.Sprintf("%d - %d", + int64(*res.Attrs.GetFloat64("from_port")), + int64(*res.Attrs.GetFloat64("to_port")), + ) + } + + if cidr := res.Attrs.GetString("cidr_block"); cidr != nil && *cidr != "" { + attrs["CIDR"] = *cidr + } + + if cidr := res.Attrs.GetString("ipv6_cidr_block"); cidr != nil && *cidr != "" { + attrs["CIDR"] = *cidr + } + + return attrs + }) +} + +func CreateNetworkACLRuleID(networkAclId string, ruleNumber int64, egress bool, protocol string) string { + var buf bytes.Buffer + buf.WriteString(fmt.Sprintf("%s-", networkAclId)) + buf.WriteString(fmt.Sprintf("%d-", ruleNumber)) + buf.WriteString(fmt.Sprintf("%t-", egress)) + buf.WriteString(fmt.Sprintf("%s-", protocol)) + return fmt.Sprintf("nacl-%d", hashcode.String(buf.String())) } diff --git a/pkg/resource/aws/aws_rds_cluster.go b/pkg/resource/aws/aws_rds_cluster.go index 6ade66f36..6a520c649 100644 --- a/pkg/resource/aws/aws_rds_cluster.go +++ b/pkg/resource/aws/aws_rds_cluster.go @@ -1,12 +1,11 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsRDSClusterResourceType = "aws_rds_cluster" func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsRDSClusterResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsRDSClusterResourceType, func(res *resource.Resource) { val := res.Attributes() val.SafeDelete([]string{"timeouts"}) val.SafeDelete([]string{"master_password"}) @@ -17,4 +16,5 @@ func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositor val.SafeDelete([]string{"final_snapshot_identifier"}) val.SafeDelete([]string{"source_region"}) }) + resourceSchemaRepository.SetFlags(AwsRDSClusterResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_rds_cluster_instance.go b/pkg/resource/aws/aws_rds_cluster_instance.go new file mode 100644 index 000000000..593c1f1f2 --- /dev/null +++ b/pkg/resource/aws/aws_rds_cluster_instance.go @@ -0,0 +1,3 @@ +package aws + +const AwsRDSClusterInstanceResourceType = "aws_rds_cluster_instance" diff --git a/pkg/resource/aws/aws_route.go b/pkg/resource/aws/aws_route.go index 61474b512..0325d335b 100644 --- a/pkg/resource/aws/aws_route.go +++ b/pkg/resource/aws/aws_route.go @@ -1,12 +1,17 @@ package aws import ( + "fmt" + + "github.com/hashicorp/terraform/helper/hashcode" + "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" ) +const AwsRouteResourceType = "aws_route" + func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsRouteResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsRouteResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) @@ -25,4 +30,38 @@ func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInte val.DeleteIfDefault("instance_owner_id") val.DeleteIfDefault("carrier_gateway_id") }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if rtID := val.GetString("route_table_id"); rtID != nil && *rtID != "" { + attrs["Table"] = *rtID + } + if ipv4 := val.GetString("destination_cidr_block"); ipv4 != nil && *ipv4 != "" { + attrs["Destination"] = *ipv4 + } + if ipv6 := val.GetString("destination_ipv6_cidr_block"); ipv6 != nil && *ipv6 != "" { + attrs["Destination"] = *ipv6 + } + if prefix := val.GetString("destination_prefix_list_id"); prefix != nil && *prefix != "" { + attrs["Destination"] = *prefix + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsRouteResourceType, resource.FlagDeepMode) +} + +func CalculateRouteID(tableId, CidrBlock, Ipv6CidrBlock, PrefixListId *string) string { + if CidrBlock != nil && *CidrBlock != "" { + return fmt.Sprintf("r-%s%d", *tableId, hashcode.String(*CidrBlock)) + } + + if Ipv6CidrBlock != nil && *Ipv6CidrBlock != "" { + return fmt.Sprintf("r-%s%d", *tableId, hashcode.String(*Ipv6CidrBlock)) + } + + if PrefixListId != nil && *PrefixListId != "" { + return fmt.Sprintf("r-%s%d", *tableId, hashcode.String(*PrefixListId)) + } + + return "" } diff --git a/pkg/resource/aws/aws_route53_health_check.go b/pkg/resource/aws/aws_route53_health_check.go new file mode 100644 index 000000000..e87e5b376 --- /dev/null +++ b/pkg/resource/aws/aws_route53_health_check.go @@ -0,0 +1,43 @@ +package aws + +import ( + "fmt" + + "github.com/snyk/driftctl/enumeration/resource" +) + +const AwsRoute53HealthCheckResourceType = "aws_route53_health_check" + +func initAwsRoute53HealthCheckMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53HealthCheckResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if tags := val.GetMap("tags"); tags != nil { + if name, ok := tags["Name"]; ok { + attrs["Name"] = name.(string) + } + } + port := val.GetInt("port") + path := val.GetString("resource_path") + if fqdn := val.GetString("fqdn"); fqdn != nil && *fqdn != "" { + attrs["Fqdn"] = *fqdn + if port != nil { + attrs["Port"] = fmt.Sprintf("%d", *port) + } + if path != nil && *path != "" { + attrs["Path"] = *path + } + } + if address := val.GetString("ip_address"); address != nil && *address != "" { + attrs["IpAddress"] = *address + if port != nil { + attrs["Port"] = fmt.Sprintf("%d", *port) + } + if path != nil && *path != "" { + attrs["Path"] = *path + } + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsRoute53HealthCheckResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_route53_record.go b/pkg/resource/aws/aws_route53_record.go index 564a2e4e9..c4c9e20c4 100644 --- a/pkg/resource/aws/aws_route53_record.go +++ b/pkg/resource/aws/aws_route53_record.go @@ -1,12 +1,11 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsRoute53RecordResourceType = "aws_route53_record" func initAwsRoute53RecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsRoute53RecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsRoute53RecordResourceType, func(res *resource.Resource) { val := res.Attrs val.DeleteIfDefault("health_check_id") val.DeleteIfDefault("set_identifier") @@ -14,4 +13,19 @@ func initAwsRoute53RecordMetaData(resourceSchemaRepository resource.SchemaReposi val.SafeDelete([]string{"name"}) val.SafeDelete([]string{"allow_overwrite"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53RecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if fqdn := val.GetString("fqdn"); fqdn != nil && *fqdn != "" { + attrs["Fqdn"] = *fqdn + } + if ty := val.GetString("type"); ty != nil && *ty != "" { + attrs["Type"] = *ty + } + if zoneID := val.GetString("zone_id"); zoneID != nil && *zoneID != "" { + attrs["ZoneId"] = *zoneID + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsRoute53RecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_route53_zone.go b/pkg/resource/aws/aws_route53_zone.go index 6166cda9a..419def8bb 100644 --- a/pkg/resource/aws/aws_route53_zone.go +++ b/pkg/resource/aws/aws_route53_zone.go @@ -1,13 +1,21 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsRoute53ZoneResourceType = "aws_route53_zone" func initAwsRoute53ZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsRoute53ZoneResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsRoute53ZoneResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"force_destroy"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53ZoneResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsRoute53ZoneResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_route_table.go b/pkg/resource/aws/aws_route_table.go new file mode 100644 index 000000000..edef38567 --- /dev/null +++ b/pkg/resource/aws/aws_route_table.go @@ -0,0 +1,13 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsRouteTableResourceType = "aws_route_table" + +func initAwsRouteTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsRouteTableResourceType, resource.FlagDeepMode) + resourceSchemaRepository.SetNormalizeFunc(AwsRouteTableResourceType, func(res *resource.Resource) { + val := res.Attrs + val.SafeDelete([]string{"timeouts"}) + }) +} diff --git a/pkg/resource/aws/aws_route_table_association.go b/pkg/resource/aws/aws_route_table_association.go new file mode 100644 index 000000000..1632de70b --- /dev/null +++ b/pkg/resource/aws/aws_route_table_association.go @@ -0,0 +1,23 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsRouteTableAssociationResourceType = "aws_route_table_association" + +func initAwsRouteTableAssociationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteTableAssociationResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if rtID := val.GetString("route_table_id"); rtID != nil && *rtID != "" { + attrs["Table"] = *rtID + } + if gtwID := val.GetString("gateway_id"); gtwID != nil && *gtwID != "" { + attrs["Gateway"] = *gtwID + } + if subnetID := val.GetString("subnet_id"); subnetID != nil && *subnetID != "" { + attrs["Subnet"] = *subnetID + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsRouteTableAssociationResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_s3_bucket.go b/pkg/resource/aws/aws_s3_bucket.go index bfe58785e..dc615c1aa 100644 --- a/pkg/resource/aws/aws_s3_bucket.go +++ b/pkg/resource/aws/aws_s3_bucket.go @@ -1,14 +1,19 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsS3BucketResourceType = "aws_s3_bucket" func initAwsS3BucketMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsS3BucketResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsS3BucketResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"force_destroy"}) val.SafeDelete([]string{"bucket_prefix"}) }) + resourceSchemaRepository.UpdateSchema(AwsS3BucketResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsS3BucketResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_s3_bucket_analytics_configuration.go b/pkg/resource/aws/aws_s3_bucket_analytics_configuration.go new file mode 100644 index 000000000..470d5faaf --- /dev/null +++ b/pkg/resource/aws/aws_s3_bucket_analytics_configuration.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsS3BucketAnalyticsConfigurationResourceType = "aws_s3_bucket_analytics_configuration" + +func initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsS3BucketAnalyticsConfigurationResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_s3_bucket_inventory.go b/pkg/resource/aws/aws_s3_bucket_inventory.go new file mode 100644 index 000000000..7424fc84e --- /dev/null +++ b/pkg/resource/aws/aws_s3_bucket_inventory.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsS3BucketInventoryResourceType = "aws_s3_bucket_inventory" + +func initAwsS3BucketInventoryMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsS3BucketInventoryResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_s3_bucket_metric.go b/pkg/resource/aws/aws_s3_bucket_metric.go new file mode 100644 index 000000000..68e14a8df --- /dev/null +++ b/pkg/resource/aws/aws_s3_bucket_metric.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsS3BucketMetricResourceType = "aws_s3_bucket_metric" + +func initAwsS3BucketMetricMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsS3BucketMetricResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_s3_bucket_notification.go b/pkg/resource/aws/aws_s3_bucket_notification.go new file mode 100644 index 000000000..789ff720f --- /dev/null +++ b/pkg/resource/aws/aws_s3_bucket_notification.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsS3BucketNotificationResourceType = "aws_s3_bucket_notification" + +func initAwsS3BucketNotificationMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsS3BucketNotificationResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_s3_bucket_policy.go b/pkg/resource/aws/aws_s3_bucket_policy.go index de9fc5f7a..3621b5981 100644 --- a/pkg/resource/aws/aws_s3_bucket_policy.go +++ b/pkg/resource/aws/aws_s3_bucket_policy.go @@ -2,12 +2,13 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" ) +const AwsS3BucketPolicyResourceType = "aws_s3_bucket_policy" + func initAwsS3BucketPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsS3BucketPolicyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsS3BucketPolicyResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) if err != nil { @@ -15,4 +16,10 @@ func initAwsS3BucketPolicyMetaData(resourceSchemaRepository resource.SchemaRepos } _ = val.SafeSet([]string{"policy"}, jsonString) }) + resourceSchemaRepository.UpdateSchema(AwsS3BucketPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsS3BucketPolicyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_s3_bucket_public_access_block.go b/pkg/resource/aws/aws_s3_bucket_public_access_block.go new file mode 100644 index 000000000..9cf7105c4 --- /dev/null +++ b/pkg/resource/aws/aws_s3_bucket_public_access_block.go @@ -0,0 +1,3 @@ +package aws + +const AwsS3BucketPublicAccessBlockResourceType = "aws_s3_bucket_public_access_block" diff --git a/pkg/resource/aws/aws_security_group.go b/pkg/resource/aws/aws_security_group.go index 7aba0bbb0..5ded29397 100644 --- a/pkg/resource/aws/aws_security_group.go +++ b/pkg/resource/aws/aws_security_group.go @@ -1,12 +1,11 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsSecurityGroupResourceType = "aws_security_group" func initAwsSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsSecurityGroupResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsSecurityGroupResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"revoke_rules_on_delete"}) val.SafeDelete([]string{"timeouts"}) @@ -15,4 +14,5 @@ func initAwsSecurityGroupMetaData(resourceSchemaRepository resource.SchemaReposi val.SafeDelete([]string{"ingress"}) val.SafeDelete([]string{"egress"}) }) + resourceSchemaRepository.SetFlags(AwsSecurityGroupResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_security_group_rule.go b/pkg/resource/aws/aws_security_group_rule.go index 80546f011..e4e8ea47d 100644 --- a/pkg/resource/aws/aws_security_group_rule.go +++ b/pkg/resource/aws/aws_security_group_rule.go @@ -1,12 +1,18 @@ package aws import ( + "bytes" + "fmt" + "strings" + + "github.com/hashicorp/terraform/helper/hashcode" "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" ) +const AwsSecurityGroupRuleResourceType = "aws_security_group_rule" + func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsSecurityGroupRuleResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) { val := res.Attrs val.DeleteIfDefault("security_group_id") val.DeleteIfDefault("source_security_group_id") @@ -24,8 +30,132 @@ func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository resource.SchemaRe val.SafeDelete([]string{"from_port"}) val.SafeDelete([]string{"to_port"}) - id := aws.CreateSecurityGroupRuleIdHash(val) + id := CreateSecurityGroupRuleIdHash(val) _ = val.SafeSet([]string{"id"}, id) res.Id = id }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if sgID := val.GetString("security_group_id"); sgID != nil && *sgID != "" { + attrs["SecurityGroup"] = *sgID + } + if protocol := val.GetString("protocol"); protocol != nil && *protocol != "" { + if *protocol == "-1" { + *protocol = "All" + } + attrs["Protocol"] = *protocol + } + fromPort := val.GetInt("from_port") + toPort := val.GetInt("to_port") + if fromPort != nil && toPort != nil { + portRange := "All" + if *fromPort != 0 && *fromPort == *toPort { + portRange = fmt.Sprintf("%d", *fromPort) + } + if *fromPort != 0 && *toPort != 0 && *fromPort != *toPort { + portRange = fmt.Sprintf("%d-%d", *fromPort, *toPort) + } + attrs["Ports"] = portRange + } + ty := val.GetString("type") + if ty != nil && *ty != "" { + attrs["Type"] = *ty + var sourceOrDestination string + switch *ty { + case "egress": + sourceOrDestination = "Destination" + case "ingress": + sourceOrDestination = "Source" + } + if ipv4 := val.GetSlice("cidr_blocks"); len(ipv4) > 0 { + attrs[sourceOrDestination] = join(ipv4, ", ") + } + if ipv6 := val.GetSlice("ipv6_cidr_blocks"); len(ipv6) > 0 { + attrs[sourceOrDestination] = join(ipv6, ", ") + } + if prefixList := val.GetSlice("prefix_list_ids"); len(prefixList) > 0 { + attrs[sourceOrDestination] = join(prefixList, ", ") + } + if sourceSgID := val.GetString("source_security_group_id"); sourceSgID != nil && *sourceSgID != "" { + attrs[sourceOrDestination] = *sourceSgID + } + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsSecurityGroupRuleResourceType, resource.FlagDeepMode) +} + +func join(elems []interface{}, sep string) string { + firstElemt, ok := elems[0].(string) + if !ok { + panic("cannot join a slice that contains something else than strings") + } + switch len(elems) { + case 0: + return "" + case 1: + + return firstElemt + } + n := len(sep) * (len(elems) - 1) + for i := 0; i < len(elems); i++ { + n += len(elems[i].(string)) + } + + var b strings.Builder + b.Grow(n) + b.WriteString(firstElemt) + for _, s := range elems[1:] { + b.WriteString(sep) + elem, ok := s.(string) + if !ok { + panic("cannot join a slice that contains something else than strings") + } + b.WriteString(elem) + } + return b.String() +} + +func CreateSecurityGroupRuleIdHash(attrs *resource.Attributes) string { + var buf bytes.Buffer + buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("security_group_id"))) + if attrs.GetInt("from_port") != nil && *attrs.GetInt("from_port") > 0 { + buf.WriteString(fmt.Sprintf("%d-", *attrs.GetInt("from_port"))) + } + if attrs.GetInt("to_port") != nil && *attrs.GetInt("to_port") > 0 { + buf.WriteString(fmt.Sprintf("%d-", *attrs.GetInt("to_port"))) + } + buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("protocol"))) + buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("type"))) + + if attrs.GetSlice("cidr_blocks") != nil { + for _, v := range attrs.GetSlice("cidr_blocks") { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + } + + if attrs.GetSlice("ipv6_cidr_blocks") != nil { + for _, v := range attrs.GetSlice("ipv6_cidr_blocks") { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + } + + if attrs.GetSlice("prefix_list_ids") != nil { + for _, v := range attrs.GetSlice("prefix_list_ids") { + buf.WriteString(fmt.Sprintf("%s-", v)) + } + } + + if (attrs.GetBool("self") != nil && *attrs.GetBool("self")) || + (attrs.GetString("source_security_group_id") != nil && *attrs.GetString("source_security_group_id") != "") { + if attrs.GetBool("self") != nil && *attrs.GetBool("self") { + buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("security_group_id"))) + } else { + buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("source_security_group_id"))) + } + buf.WriteString("-") + } + + return fmt.Sprintf("sgrule-%d", hashcode.String(buf.String())) } diff --git a/pkg/resource/aws/aws_sns_topic.go b/pkg/resource/aws/aws_sns_topic.go index 494069de9..40516244f 100644 --- a/pkg/resource/aws/aws_sns_topic.go +++ b/pkg/resource/aws/aws_sns_topic.go @@ -1,12 +1,11 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsSnsTopicResourceType = "aws_sns_topic" func initSnsTopicMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsSnsTopicResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicResourceType, func(res *resource.Resource) { val := res.Attrs val.DeleteIfDefault("sqs_success_feedback_sample_rate") val.DeleteIfDefault("lambda_success_feedback_sample_rate") @@ -17,4 +16,24 @@ func initSnsTopicMetaData(resourceSchemaRepository resource.SchemaRepositoryInte val.SafeDelete([]string{"name_prefix"}) val.SafeDelete([]string{"owner"}) }) + resourceSchemaRepository.UpdateSchema(AwsSnsTopicResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "delivery_policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsSnsTopicResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + if displayName := val.GetString("display_name"); displayName != nil && *displayName != "" { + attrs["DisplayName"] = *displayName + } + } + return attrs + }) + resourceSchemaRepository.SetFlags(AwsSnsTopicResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_sns_topic_policy.go b/pkg/resource/aws/aws_sns_topic_policy.go index a625cbc7b..a6f034a25 100644 --- a/pkg/resource/aws/aws_sns_topic_policy.go +++ b/pkg/resource/aws/aws_sns_topic_policy.go @@ -2,12 +2,13 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" ) +const AwsSnsTopicPolicyResourceType = "aws_sns_topic_policy" + func initSnsTopicPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsSnsTopicPolicyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicPolicyResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"owner"}) jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) @@ -16,4 +17,10 @@ func initSnsTopicPolicyMetaData(resourceSchemaRepository resource.SchemaReposito } _ = val.SafeSet([]string{"policy"}, jsonString) }) + resourceSchemaRepository.UpdateSchema(AwsSnsTopicPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsSnsTopicPolicyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_sns_topic_subscription.go b/pkg/resource/aws/aws_sns_topic_subscription.go index ed41dacf1..4e508d257 100644 --- a/pkg/resource/aws/aws_sns_topic_subscription.go +++ b/pkg/resource/aws/aws_sns_topic_subscription.go @@ -2,12 +2,13 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" ) +const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription" + func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["delivery_policy"]) if err == nil { @@ -26,4 +27,14 @@ func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRe val.SafeDelete([]string{"confirmation_timeout_in_minutes"}) } }) + resourceSchemaRepository.UpdateSchema(AwsSnsTopicSubscriptionResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "delivery_policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + "filter_policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + + resourceSchemaRepository.SetFlags(AwsSnsTopicSubscriptionResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_sqs_queue.go b/pkg/resource/aws/aws_sqs_queue.go new file mode 100644 index 000000000..7c7aa1bf6 --- /dev/null +++ b/pkg/resource/aws/aws_sqs_queue.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsSqsQueueResourceType = "aws_sqs_queue" + +func initSqsQueueMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsSqsQueueResourceType, resource.FlagDeepMode) +} diff --git a/pkg/resource/aws/aws_sqs_queue_policy.go b/pkg/resource/aws/aws_sqs_queue_policy.go index 7c71accdb..a339ff3ed 100644 --- a/pkg/resource/aws/aws_sqs_queue_policy.go +++ b/pkg/resource/aws/aws_sqs_queue_policy.go @@ -2,12 +2,13 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" "github.com/snyk/driftctl/pkg/helpers" ) +const AwsSqsQueuePolicyResourceType = "aws_sqs_queue_policy" + func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsSqsQueuePolicyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsSqsQueuePolicyResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) if err != nil { @@ -15,4 +16,10 @@ func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository resource.SchemaRepos } _ = val.SafeSet([]string{"policy"}, jsonString) }) + resourceSchemaRepository.UpdateSchema(AwsSqsQueuePolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ + "policy": func(attributeSchema *resource.AttributeSchema) { + attributeSchema.JsonString = true + }, + }) + resourceSchemaRepository.SetFlags(AwsSqsQueuePolicyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_subnet.go b/pkg/resource/aws/aws_subnet.go index 9795a8801..6419b157e 100644 --- a/pkg/resource/aws/aws_subnet.go +++ b/pkg/resource/aws/aws_subnet.go @@ -1,13 +1,13 @@ package aws -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/aws" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsSubnetResourceType = "aws_subnet" func initAwsSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(aws.AwsSubnetResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AwsSubnetResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetFlags(AwsSubnetResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_vpc.go b/pkg/resource/aws/aws_vpc.go new file mode 100644 index 000000000..8d7ae9acb --- /dev/null +++ b/pkg/resource/aws/aws_vpc.go @@ -0,0 +1,9 @@ +package aws + +import "github.com/snyk/driftctl/enumeration/resource" + +const AwsVpcResourceType = "aws_vpc" + +func initAwsVpcMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetFlags(AwsVpcResourceType, resource.FlagDeepMode) +} diff --git a/enumeration/resource/aws/metadata_test.go b/pkg/resource/aws/metadata_test.go similarity index 98% rename from enumeration/resource/aws/metadata_test.go rename to pkg/resource/aws/metadata_test.go index 3dafb3268..aab306ab6 100644 --- a/enumeration/resource/aws/metadata_test.go +++ b/pkg/resource/aws/metadata_test.go @@ -1,8 +1,6 @@ package aws import ( - tf "github.com/snyk/driftctl/enumeration/terraform" - "testing" "github.com/snyk/driftctl/enumeration/resource" @@ -120,7 +118,7 @@ func TestAWS_Metadata_Flags(t *testing.T) { AwsEcrRepositoryPolicyResourceType: {}, } - schemaRepository := testresource.InitFakeSchemaRepository(tf.AWS, "3.19.0") + schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") InitResourcesMetadata(schemaRepository) for ty, flags := range testcases { diff --git a/pkg/resource/aws/metadatas.go b/pkg/resource/aws/metadatas.go index 5a0cc0210..7f3bca99b 100644 --- a/pkg/resource/aws/metadatas.go +++ b/pkg/resource/aws/metadatas.go @@ -4,6 +4,31 @@ import "github.com/snyk/driftctl/enumeration/resource" func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { initAwsAmiMetaData(resourceSchemaRepository) + initAwsApiGatewayV2MappingMetaData(resourceSchemaRepository) + initAwsApiGatewayV2ModelMetaData(resourceSchemaRepository) + initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository) + initAwsDefaultRouteTableMetadata(resourceSchemaRepository) + initAwsDefaultVpcMetaData(resourceSchemaRepository) + initAwsEbsEncryptionByDefaultMetaData(resourceSchemaRepository) + initAwsEipAssociationMetaData(resourceSchemaRepository) + initAwsIAMRolePolicyMetaData(resourceSchemaRepository) + initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository) + initAwsIAMUserPolicyMetaData(resourceSchemaRepository) + initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository) + initAwsInternetGatewayMetaData(resourceSchemaRepository) + initAwsLaunchTemplateMetaData(resourceSchemaRepository) + initAwsLoadBalancerMetaData(resourceSchemaRepository) + initNatGatewayMetaData(resourceSchemaRepository) + initAwsNetworkACLMetaData(resourceSchemaRepository) + initAwsRoute53HealthCheckMetaData(resourceSchemaRepository) + initAwsRouteTableMetaData(resourceSchemaRepository) + initAwsRouteTableAssociationMetaData(resourceSchemaRepository) + initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository) + initAwsS3BucketInventoryMetadata(resourceSchemaRepository) + initAwsS3BucketMetricMetadata(resourceSchemaRepository) + initAwsS3BucketNotificationMetadata(resourceSchemaRepository) + initSqsQueueMetaData(resourceSchemaRepository) + initAwsVpcMetaData(resourceSchemaRepository) initAwsCloudfrontDistributionMetaData(resourceSchemaRepository) initAwsDbInstanceMetaData(resourceSchemaRepository) initAwsDbSubnetGroupMetaData(resourceSchemaRepository) diff --git a/pkg/resource/azurerm/azurerm_container_registry.go b/pkg/resource/azurerm/azurerm_container_registry.go new file mode 100644 index 000000000..4a6d52b65 --- /dev/null +++ b/pkg/resource/azurerm/azurerm_container_registry.go @@ -0,0 +1,16 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureContainerRegistryResourceType = "azurerm_container_registry" + +func initAzureContainerRegistryMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureContainerRegistryResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) +} diff --git a/pkg/resource/azurerm/azurerm_firewall.go b/pkg/resource/azurerm/azurerm_firewall.go new file mode 100644 index 000000000..ded79fe2a --- /dev/null +++ b/pkg/resource/azurerm/azurerm_firewall.go @@ -0,0 +1,16 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureFirewallResourceType = "azurerm_firewall" + +func initAzureFirewallMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureFirewallResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) +} diff --git a/pkg/resource/azurerm/azurerm_image.go b/pkg/resource/azurerm/azurerm_image.go new file mode 100644 index 000000000..0a650295c --- /dev/null +++ b/pkg/resource/azurerm/azurerm_image.go @@ -0,0 +1,17 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureImageResourceType = "azurerm_image" + +func initAzureImageMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureImageResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + + if v := res.Attributes().GetString("name"); v != nil && *v != "" { + attrs["Name"] = *v + } + + return attrs + }) +} diff --git a/pkg/resource/azurerm/azurerm_lb.go b/pkg/resource/azurerm/azurerm_lb.go new file mode 100644 index 000000000..04a7cc0d5 --- /dev/null +++ b/pkg/resource/azurerm/azurerm_lb.go @@ -0,0 +1,16 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureLoadBalancerResourceType = "azurerm_lb" + +func initAzureLoadBalancerMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureLoadBalancerResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) +} diff --git a/pkg/resource/azurerm/azurerm_lb_rule.go b/pkg/resource/azurerm/azurerm_lb_rule.go index 089eee7c4..2fe23ae60 100644 --- a/pkg/resource/azurerm/azurerm_lb_rule.go +++ b/pkg/resource/azurerm/azurerm_lb_rule.go @@ -1,12 +1,19 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/azurerm" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureLoadBalancerRuleResourceType = "azurerm_lb_rule" func initAzureLoadBalancerRuleMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(azurerm.AzureLoadBalancerRuleResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + if name := res.Attributes().GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzureLoadBalancerRuleResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_network_security_group.go b/pkg/resource/azurerm/azurerm_network_security_group.go index b9ff04df9..a86883798 100644 --- a/pkg/resource/azurerm/azurerm_network_security_group.go +++ b/pkg/resource/azurerm/azurerm_network_security_group.go @@ -1,12 +1,20 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/azurerm" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureNetworkSecurityGroupResourceType = "azurerm_network_security_group" func initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(azurerm.AzureNetworkSecurityGroupResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AzureNetworkSecurityGroupResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureNetworkSecurityGroupResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzureNetworkSecurityGroupResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_postgresql_database.go b/pkg/resource/azurerm/azurerm_postgresql_database.go new file mode 100644 index 000000000..7a5784f95 --- /dev/null +++ b/pkg/resource/azurerm/azurerm_postgresql_database.go @@ -0,0 +1,16 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePostgresqlDatabaseResourceType = "azurerm_postgresql_database" + +func initAzurePostgresqlDatabaseMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePostgresqlDatabaseResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) +} diff --git a/pkg/resource/azurerm/azurerm_postgresql_server.go b/pkg/resource/azurerm/azurerm_postgresql_server.go new file mode 100644 index 000000000..167e68c3e --- /dev/null +++ b/pkg/resource/azurerm/azurerm_postgresql_server.go @@ -0,0 +1,16 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePostgresqlServerResourceType = "azurerm_postgresql_server" + +func initAzurePostgresqlServerMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePostgresqlServerResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) +} diff --git a/pkg/resource/azurerm/azurerm_private_dns_a_record.go b/pkg/resource/azurerm/azurerm_private_dns_a_record.go index 467070866..e67af833c 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_a_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_a_record.go @@ -1,12 +1,23 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/azurerm" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePrivateDNSARecordResourceType = "azurerm_private_dns_a_record" func initAzurePrivateDNSARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSARecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSARecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSARecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSARecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go b/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go index 2b0d10034..0c06bb775 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go @@ -1,12 +1,23 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/azurerm" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePrivateDNSAAAARecordResourceType = "azurerm_private_dns_aaaa_record" func initAzurePrivateDNSAAAARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSAAAARecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSAAAARecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSAAAARecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSAAAARecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_cname_record.go b/pkg/resource/azurerm/azurerm_private_dns_cname_record.go index e15b72d13..18a2f9050 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_cname_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_cname_record.go @@ -1,12 +1,23 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/azurerm" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePrivateDNSCNameRecordResourceType = "azurerm_private_dns_cname_record" func initAzurePrivateDNSCNameRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSCNameRecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSCNameRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSCNameRecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSCNameRecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_mx_record.go b/pkg/resource/azurerm/azurerm_private_dns_mx_record.go index 60e92cf1c..e2602954a 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_mx_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_mx_record.go @@ -1,12 +1,26 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/azurerm" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePrivateDNSMXRecordResourceType = "azurerm_private_dns_mx_record" func initAzurePrivateDNSMXRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) { + res.Attributes().SafeDelete([]string{"timeouts"}) + }) + resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSMXRecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go b/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go index c10884b82..c93a4a3ab 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go @@ -1,12 +1,23 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/azurerm" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePrivateDNSPTRRecordResourceType = "azurerm_private_dns_ptr_record" func initAzurePrivateDNSPTRRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSPTRRecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSPTRRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSPTRRecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSPTRRecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_srv_record.go b/pkg/resource/azurerm/azurerm_private_dns_srv_record.go index fbed64f9c..9af2d31bb 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_srv_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_srv_record.go @@ -1,12 +1,23 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/azurerm" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePrivateDNSSRVRecordResourceType = "azurerm_private_dns_srv_record" func initAzurePrivateDNSSRVRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSSRVRecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSSRVRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSSRVRecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSSRVRecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_txt_record.go b/pkg/resource/azurerm/azurerm_private_dns_txt_record.go index 01bbe9b81..f351267cf 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_txt_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_txt_record.go @@ -1,12 +1,23 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/azurerm" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePrivateDNSTXTRecordResourceType = "azurerm_private_dns_txt_record" func initAzurePrivateDNSTXTRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSTXTRecordResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSTXTRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePrivateDNSTXTRecordResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + if zone := val.GetString("zone_name"); zone != nil && *zone != "" { + attrs["Zone"] = *zone + } + return attrs + }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSTXTRecordResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_private_dns_zone.go b/pkg/resource/azurerm/azurerm_private_dns_zone.go index 287761927..d923825db 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_zone.go +++ b/pkg/resource/azurerm/azurerm_private_dns_zone.go @@ -1,13 +1,13 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/azurerm" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePrivateDNSZoneResourceType = "azurerm_private_dns_zone" func initAzurePrivateDNSZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(azurerm.AzurePrivateDNSZoneResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSZoneResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"number_of_record_sets"}) res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetFlags(AzurePrivateDNSZoneResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_public_ip.go b/pkg/resource/azurerm/azurerm_public_ip.go new file mode 100644 index 000000000..ac3d07102 --- /dev/null +++ b/pkg/resource/azurerm/azurerm_public_ip.go @@ -0,0 +1,16 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzurePublicIPResourceType = "azurerm_public_ip" + +func initAzurePublicIPMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePublicIPResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) +} diff --git a/pkg/resource/azurerm/azurerm_resource_group.go b/pkg/resource/azurerm/azurerm_resource_group.go new file mode 100644 index 000000000..f30885cb7 --- /dev/null +++ b/pkg/resource/azurerm/azurerm_resource_group.go @@ -0,0 +1,16 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureResourceGroupResourceType = "azurerm_resource_group" + +func initAzureResourceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureResourceGroupResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) +} diff --git a/pkg/resource/azurerm/azurerm_route.go b/pkg/resource/azurerm/azurerm_route.go new file mode 100644 index 000000000..35ef2c128 --- /dev/null +++ b/pkg/resource/azurerm/azurerm_route.go @@ -0,0 +1,21 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureRouteResourceType = "azurerm_route" + +func initAzureRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureRouteResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + + if v := res.Attributes().GetString("name"); v != nil && *v != "" { + attrs["Name"] = *v + } + + if v := res.Attributes().GetString("route_table_name"); v != nil && *v != "" { + attrs["Table"] = *v + } + + return attrs + }) +} diff --git a/pkg/resource/azurerm/azurerm_route_table.go b/pkg/resource/azurerm/azurerm_route_table.go new file mode 100644 index 000000000..acfb26d97 --- /dev/null +++ b/pkg/resource/azurerm/azurerm_route_table.go @@ -0,0 +1,16 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureRouteTableResourceType = "azurerm_route_table" + +func initAzureRouteTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureRouteTableResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + + if v := res.Attributes().GetString("name"); v != nil && *v != "" { + attrs["Name"] = *v + } + return attrs + }) +} diff --git a/pkg/resource/azurerm/azurerm_ssh_public_key.go b/pkg/resource/azurerm/azurerm_ssh_public_key.go index eaf521edb..a82f894a2 100644 --- a/pkg/resource/azurerm/azurerm_ssh_public_key.go +++ b/pkg/resource/azurerm/azurerm_ssh_public_key.go @@ -1,12 +1,21 @@ package azurerm -import ( - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/azurerm" -) +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureSSHPublicKeyResourceType = "azurerm_ssh_public_key" func initAzureSSHPublicKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(azurerm.AzureSSHPublicKeyResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(AzureSSHPublicKeyResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureSSHPublicKeyResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + + if v := res.Attributes().GetString("name"); v != nil && *v != "" { + attrs["Name"] = *v + } + + return attrs + }) + resourceSchemaRepository.SetFlags(AzureSSHPublicKeyResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/azurerm/azurerm_storage_account.go b/pkg/resource/azurerm/azurerm_storage_account.go new file mode 100644 index 000000000..d0d7c996e --- /dev/null +++ b/pkg/resource/azurerm/azurerm_storage_account.go @@ -0,0 +1,3 @@ +package azurerm + +const AzureStorageAccountResourceType = "azurerm_storage_account" diff --git a/pkg/resource/azurerm/azurerm_storage_container.go b/pkg/resource/azurerm/azurerm_storage_container.go new file mode 100644 index 000000000..b3c373f03 --- /dev/null +++ b/pkg/resource/azurerm/azurerm_storage_container.go @@ -0,0 +1,3 @@ +package azurerm + +const AzureStorageContainerResourceType = "azurerm_storage_container" diff --git a/pkg/resource/azurerm/azurerm_subnet.go b/pkg/resource/azurerm/azurerm_subnet.go new file mode 100644 index 000000000..bcb43335f --- /dev/null +++ b/pkg/resource/azurerm/azurerm_subnet.go @@ -0,0 +1,3 @@ +package azurerm + +const AzureSubnetResourceType = "azurerm_subnet" diff --git a/pkg/resource/azurerm/azurerm_virtual_network.go b/pkg/resource/azurerm/azurerm_virtual_network.go new file mode 100644 index 000000000..a8e358fae --- /dev/null +++ b/pkg/resource/azurerm/azurerm_virtual_network.go @@ -0,0 +1,16 @@ +package azurerm + +import "github.com/snyk/driftctl/enumeration/resource" + +const AzureVirtualNetworkResourceType = "azurerm_virtual_network" + +func initAzureVirtualNetworkMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureVirtualNetworkResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + + if v := res.Attributes().GetString("name"); v != nil && *v != "" { + attrs["Name"] = *v + } + return attrs + }) +} diff --git a/pkg/resource/azurerm/metadata.go b/pkg/resource/azurerm/metadata.go index 0aa92160f..86f14f31b 100644 --- a/pkg/resource/azurerm/metadata.go +++ b/pkg/resource/azurerm/metadata.go @@ -3,6 +3,17 @@ package azurerm import "github.com/snyk/driftctl/enumeration/resource" func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + initAzureContainerRegistryMetadata(resourceSchemaRepository) + initAzureFirewallMetadata(resourceSchemaRepository) + initAzureImageMetaData(resourceSchemaRepository) + initAzureLoadBalancerMetadata(resourceSchemaRepository) + initAzurePostgresqlDatabaseMetadata(resourceSchemaRepository) + initAzurePostgresqlServerMetadata(resourceSchemaRepository) + initAzurePublicIPMetadata(resourceSchemaRepository) + initAzureResourceGroupMetadata(resourceSchemaRepository) + initAzureRouteMetaData(resourceSchemaRepository) + initAzureRouteTableMetaData(resourceSchemaRepository) + initAzureVirtualNetworkMetaData(resourceSchemaRepository) initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository) initAzurePrivateDNSZoneMetaData(resourceSchemaRepository) initAzurePrivateDNSARecordMetaData(resourceSchemaRepository) diff --git a/enumeration/resource/azurerm/metadata_test.go b/pkg/resource/azurerm/metadata_test.go similarity index 94% rename from enumeration/resource/azurerm/metadata_test.go rename to pkg/resource/azurerm/metadata_test.go index 6dff89a1e..725a4c13d 100644 --- a/enumeration/resource/azurerm/metadata_test.go +++ b/pkg/resource/azurerm/metadata_test.go @@ -1,8 +1,6 @@ package azurerm import ( - tf "github.com/snyk/driftctl/enumeration/terraform" - "testing" "github.com/snyk/driftctl/enumeration/resource" @@ -39,7 +37,7 @@ func TestAzureMetadata_Flags(t *testing.T) { AzureLoadBalancerRuleResourceType: {resource.FlagDeepMode}, } - schemaRepository := testresource.InitFakeSchemaRepository(tf.AZURE, "2.71.0") + schemaRepository := testresource.InitFakeSchemaRepository("azurerm", "2.71.0") InitResourcesMetadata(schemaRepository) for ty, flags := range testcases { diff --git a/pkg/resource/factory.go b/pkg/resource/factory.go new file mode 100644 index 000000000..85ad4f0b3 --- /dev/null +++ b/pkg/resource/factory.go @@ -0,0 +1,37 @@ +package resource + +import "github.com/snyk/driftctl/enumeration/resource" + +type ResourceFactory interface { + CreateAbstractResource(ty, id string, data map[string]interface{}) *resource.Resource +} + +type DriftctlResourceFactory struct { + resourceSchemaRepository resource.SchemaRepositoryInterface +} + +func NewDriftctlResourceFactory(resourceSchemaRepository resource.SchemaRepositoryInterface) *DriftctlResourceFactory { + return &DriftctlResourceFactory{ + resourceSchemaRepository: resourceSchemaRepository, + } +} + +func (r *DriftctlResourceFactory) CreateAbstractResource(ty, id string, data map[string]interface{}) *resource.Resource { + attributes := resource.Attributes(data) + attributes.SanitizeDefaults() + + schema, _ := r.resourceSchemaRepository.GetSchema(ty) + res := resource.Resource{ + Id: id, + Type: ty, + Attrs: &attributes, + Sch: schema, + } + + schema, exist := r.resourceSchemaRepository.(*resource.SchemaRepository).GetSchema(ty) + if exist && schema.NormalizeFunc != nil { + schema.NormalizeFunc(&res) + } + + return &res +} diff --git a/pkg/resource/github/github_branch_protection.go b/pkg/resource/github/github_branch_protection.go index 39760431c..0a4d87fa0 100644 --- a/pkg/resource/github/github_branch_protection.go +++ b/pkg/resource/github/github_branch_protection.go @@ -1,14 +1,42 @@ -// GENERATED, DO NOT EDIT THIS FILE package github import ( + "encoding/base64" + "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/github" ) +const GithubBranchProtectionResourceType = "github_branch_protection" + func initGithubBranchProtectionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(github.GithubBranchProtectionResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GithubBranchProtectionResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"repository_id"}) // Terraform provider is always returning nil }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(GithubBranchProtectionResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + pattern := val.GetString("pattern") + repoID := val.GetString("repository_id") + if pattern != nil && *pattern != "" { + id := "" + if repoID != nil && *repoID != "" { + decodedID, err := base64.StdEncoding.DecodeString(*repoID) + if err == nil { + id = string(decodedID) + } + } + if id == "" { + attrs["Branch"] = *pattern + attrs["Id"] = res.ResourceId() + return attrs + } + attrs["Branch"] = *pattern + attrs["RepoId"] = id + return attrs + } + attrs["Id"] = res.ResourceId() + return attrs + }) + resourceSchemaRepository.SetFlags(GithubBranchProtectionResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/github/github_membership.go b/pkg/resource/github/github_membership.go index 09b4e46c3..e41974b7a 100644 --- a/pkg/resource/github/github_membership.go +++ b/pkg/resource/github/github_membership.go @@ -1,14 +1,15 @@ -// GENERATED, DO NOT EDIT THIS FILE package github import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/github" ) +const GithubMembershipResourceType = "github_membership" + func initGithubMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(github.GithubMembershipResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GithubMembershipResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"etag"}) }) + resourceSchemaRepository.SetFlags(GithubMembershipResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/github/github_repository.go b/pkg/resource/github/github_repository.go index 94654bb88..c399b374f 100644 --- a/pkg/resource/github/github_repository.go +++ b/pkg/resource/github/github_repository.go @@ -2,13 +2,15 @@ package github import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/github" ) +const GithubRepositoryResourceType = "github_repository" + func initGithubRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(github.GithubRepositoryResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GithubRepositoryResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"auto_init"}) val.SafeDelete([]string{"etag"}) }) + resourceSchemaRepository.SetFlags(GithubRepositoryResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/github/github_team.go b/pkg/resource/github/github_team.go index 302fcf0cd..ececcc696 100644 --- a/pkg/resource/github/github_team.go +++ b/pkg/resource/github/github_team.go @@ -1,17 +1,27 @@ -// GENERATED, DO NOT EDIT THIS FILE package github import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/github" ) +const GithubTeamResourceType = "github_team" + func initGithubTeamMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(github.GithubTeamResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GithubTeamResourceType, func(res *resource.Resource) { val := res.Attrs if defaultMaintainer, exist := val.Get("create_default_maintainer"); !exist || defaultMaintainer == nil { (*val)["create_default_maintainer"] = false } val.SafeDelete([]string{"etag"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(GithubTeamResourceType, func(res *resource.Resource) map[string]string { + val := res.Attrs + attrs := make(map[string]string) + attrs["Id"] = res.ResourceId() + if name := val.GetString("name"); name != nil && *name != "" { + attrs["Name"] = *name + } + return attrs + }) + resourceSchemaRepository.SetFlags(GithubTeamResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/github/github_team_membership.go b/pkg/resource/github/github_team_membership.go index 4454ed859..fbc32ae2f 100644 --- a/pkg/resource/github/github_team_membership.go +++ b/pkg/resource/github/github_team_membership.go @@ -1,14 +1,15 @@ -// GENERATED, DO NOT EDIT THIS FILE package github import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/github" ) +const GithubTeamMembershipResourceType = "github_team_membership" + func initGithubTeamMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(github.GithubTeamMembershipResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GithubTeamMembershipResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"etag"}) }) + resourceSchemaRepository.SetFlags(GithubTeamMembershipResourceType, resource.FlagDeepMode) } diff --git a/enumeration/resource/github/metadata_test.go b/pkg/resource/github/metadata_test.go similarity index 88% rename from enumeration/resource/github/metadata_test.go rename to pkg/resource/github/metadata_test.go index 7f0902582..fd0977d8b 100644 --- a/enumeration/resource/github/metadata_test.go +++ b/pkg/resource/github/metadata_test.go @@ -1,8 +1,6 @@ package github import ( - tf "github.com/snyk/driftctl/enumeration/terraform" - "testing" "github.com/snyk/driftctl/enumeration/resource" @@ -19,7 +17,7 @@ func TestGitHub_Metadata_Flags(t *testing.T) { GithubTeamResourceType: {resource.FlagDeepMode}, } - schemaRepository := testresource.InitFakeSchemaRepository(tf.GITHUB, "4.4.0") + schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") InitResourcesMetadata(schemaRepository) for ty, flags := range testcases { diff --git a/pkg/resource/google/google_bigquery_dataset.go b/pkg/resource/google/google_bigquery_dataset.go new file mode 100644 index 000000000..c37e423da --- /dev/null +++ b/pkg/resource/google/google_bigquery_dataset.go @@ -0,0 +1,15 @@ +package google + +import ( + "github.com/snyk/driftctl/enumeration/resource" +) + +const GoogleBigqueryDatasetResourceType = "google_bigquery_dataset" + +func initGoogleBigqueryDatasetMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleBigqueryDatasetResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "name": *res.Attrs.GetString("friendly_name"), + } + }) +} diff --git a/pkg/resource/google/google_bigquery_table.go b/pkg/resource/google/google_bigquery_table.go new file mode 100644 index 000000000..9c39658d1 --- /dev/null +++ b/pkg/resource/google/google_bigquery_table.go @@ -0,0 +1,13 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleBigqueryTableResourceType = "google_bigquery_table" + +func initGoogleBigqueryTableMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleBigqueryTableResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "name": *res.Attrs.GetString("friendly_name"), + } + }) +} diff --git a/pkg/resource/google/google_bigtable_instance.go b/pkg/resource/google/google_bigtable_instance.go new file mode 100644 index 000000000..da6160791 --- /dev/null +++ b/pkg/resource/google/google_bigtable_instance.go @@ -0,0 +1,3 @@ +package google + +const GoogleBigTableInstanceResourceType = "google_bigtable_instance" diff --git a/pkg/resource/google/google_bigtable_table.go b/pkg/resource/google/google_bigtable_table.go new file mode 100644 index 000000000..824769a6c --- /dev/null +++ b/pkg/resource/google/google_bigtable_table.go @@ -0,0 +1,3 @@ +package google + +const GoogleBigtableTableResourceType = "google_bigtable_table" diff --git a/pkg/resource/google/google_cloudfunctions_function.go b/pkg/resource/google/google_cloudfunctions_function.go new file mode 100644 index 000000000..77fe0a32b --- /dev/null +++ b/pkg/resource/google/google_cloudfunctions_function.go @@ -0,0 +1,3 @@ +package google + +const GoogleCloudFunctionsFunctionResourceType = "google_cloudfunctions_function" diff --git a/pkg/resource/google/google_cloudrun_service.go b/pkg/resource/google/google_cloudrun_service.go new file mode 100644 index 000000000..f9a361393 --- /dev/null +++ b/pkg/resource/google/google_cloudrun_service.go @@ -0,0 +1,3 @@ +package google + +const GoogleCloudRunServiceResourceType = "google_cloud_run_service" diff --git a/pkg/resource/google/google_compute_address.go b/pkg/resource/google/google_compute_address.go new file mode 100644 index 000000000..a37732855 --- /dev/null +++ b/pkg/resource/google/google_compute_address.go @@ -0,0 +1,14 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleComputeAddressResourceType = "google_compute_address" + +func initGoogleComputeAddressMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeAddressResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "Name": *res.Attributes().GetString("name"), + "Address": *res.Attributes().GetString("address"), + } + }) +} diff --git a/pkg/resource/google/google_compute_disk.go b/pkg/resource/google/google_compute_disk.go new file mode 100644 index 000000000..ed40a222e --- /dev/null +++ b/pkg/resource/google/google_compute_disk.go @@ -0,0 +1,13 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleComputeDiskResourceType = "google_compute_disk" + +func initGoogleComputeDiskMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeDiskResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "Name": *res.Attributes().GetString("name"), + } + }) +} diff --git a/pkg/resource/google/google_compute_firewall.go b/pkg/resource/google/google_compute_firewall.go index 953b90743..7f7d912da 100644 --- a/pkg/resource/google/google_compute_firewall.go +++ b/pkg/resource/google/google_compute_firewall.go @@ -2,11 +2,13 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/google" ) +const GoogleComputeFirewallResourceType = "google_compute_firewall" + func initGoogleComputeFirewallMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(google.GoogleComputeFirewallResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GoogleComputeFirewallResourceType, func(res *resource.Resource) { res.Attrs.SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetFlags(GoogleComputeFirewallResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/google/google_compute_forwarding_rule.go b/pkg/resource/google/google_compute_forwarding_rule.go new file mode 100644 index 000000000..f02afb53a --- /dev/null +++ b/pkg/resource/google/google_compute_forwarding_rule.go @@ -0,0 +1,3 @@ +package google + +const GoogleComputeForwardingRuleResourceType = "google_compute_forwarding_rule" diff --git a/pkg/resource/google/google_compute_global_address.go b/pkg/resource/google/google_compute_global_address.go new file mode 100644 index 000000000..1c3af037c --- /dev/null +++ b/pkg/resource/google/google_compute_global_address.go @@ -0,0 +1,14 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleComputeGlobalAddressResourceType = "google_compute_global_address" + +func initGoogleComputeGlobalAddressMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeGlobalAddressResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "Name": *res.Attributes().GetString("name"), + "Address": *res.Attributes().GetString("address"), + } + }) +} diff --git a/pkg/resource/google/google_compute_global_forwarding_rule.go b/pkg/resource/google/google_compute_global_forwarding_rule.go new file mode 100644 index 000000000..d3182e20a --- /dev/null +++ b/pkg/resource/google/google_compute_global_forwarding_rule.go @@ -0,0 +1,3 @@ +package google + +const GoogleComputeGlobalForwardingRuleResourceType = "google_compute_global_forwarding_rule" diff --git a/pkg/resource/google/google_compute_health_check.go b/pkg/resource/google/google_compute_health_check.go new file mode 100644 index 000000000..c33b81731 --- /dev/null +++ b/pkg/resource/google/google_compute_health_check.go @@ -0,0 +1,13 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleComputeHealthCheckResourceType = "google_compute_health_check" + +func initGoogleComputeHealthCheckMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeHealthCheckResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "Name": *res.Attributes().GetString("name"), + } + }) +} diff --git a/pkg/resource/google/google_compute_image.go b/pkg/resource/google/google_compute_image.go new file mode 100644 index 000000000..f52788da5 --- /dev/null +++ b/pkg/resource/google/google_compute_image.go @@ -0,0 +1,13 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleComputeImageResourceType = "google_compute_image" + +func initGoogleComputeImageMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeImageResourceType, func(res *resource.Resource) map[string]string { + return map[string]string{ + "Name": *res.Attributes().GetString("name"), + } + }) +} diff --git a/pkg/resource/google/google_compute_instance.go b/pkg/resource/google/google_compute_instance.go new file mode 100644 index 000000000..970aad600 --- /dev/null +++ b/pkg/resource/google/google_compute_instance.go @@ -0,0 +1,3 @@ +package google + +const GoogleComputeInstanceResourceType = "google_compute_instance" diff --git a/pkg/resource/google/google_compute_instance_group.go b/pkg/resource/google/google_compute_instance_group.go index 3fe2a939f..2d5c288e4 100644 --- a/pkg/resource/google/google_compute_instance_group.go +++ b/pkg/resource/google/google_compute_instance_group.go @@ -2,11 +2,20 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/google" ) +const GoogleComputeInstanceGroupResourceType = "google_compute_instance_group" + func initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(google.GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + if v := res.Attributes().GetString("name"); v != nil && *v != "" { + attrs["Name"] = *v + } + return attrs + }) + resourceSchemaRepository.SetFlags(GoogleComputeInstanceGroupResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/google/google_compute_instance_group_manager.go b/pkg/resource/google/google_compute_instance_group_manager.go new file mode 100644 index 000000000..35ab1fbbc --- /dev/null +++ b/pkg/resource/google/google_compute_instance_group_manager.go @@ -0,0 +1,15 @@ +package google + +import "github.com/snyk/driftctl/enumeration/resource" + +const GoogleComputeInstanceGroupManagerResourceType = "google_compute_instance_group_manager" + +func initComputeInstanceGroupManagerMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeInstanceGroupManagerResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + if v := res.Attributes().GetString("name"); v != nil && *v != "" { + attrs["Name"] = *v + } + return attrs + }) +} diff --git a/pkg/resource/google/google_compute_network.go b/pkg/resource/google/google_compute_network.go index 2eaa58ceb..0032f5954 100644 --- a/pkg/resource/google/google_compute_network.go +++ b/pkg/resource/google/google_compute_network.go @@ -2,14 +2,16 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/google" ) +const GoogleComputeNetworkResourceType = "google_compute_network" + func initGoogleComputeNetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(google.GoogleComputeNetworkResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GoogleComputeNetworkResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"self_link"}) res.Attributes().SafeDelete([]string{"gateway_ipv4"}) res.Attributes().SafeDelete([]string{"delete_default_routes_on_create"}) }) + resourceSchemaRepository.SetFlags(GoogleComputeNetworkResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/google/google_compute_node_group.go b/pkg/resource/google/google_compute_node_group.go new file mode 100644 index 000000000..e52673a97 --- /dev/null +++ b/pkg/resource/google/google_compute_node_group.go @@ -0,0 +1,3 @@ +package google + +const GoogleComputeNodeGroupResourceType = "google_compute_node_group" diff --git a/pkg/resource/google/google_compute_router.go b/pkg/resource/google/google_compute_router.go new file mode 100644 index 000000000..74255bc8f --- /dev/null +++ b/pkg/resource/google/google_compute_router.go @@ -0,0 +1,3 @@ +package google + +const GoogleComputeRouterResourceType = "google_compute_router" diff --git a/pkg/resource/google/google_compute_subnetwork.go b/pkg/resource/google/google_compute_subnetwork.go index 3632dbd0a..89b9d3952 100644 --- a/pkg/resource/google/google_compute_subnetwork.go +++ b/pkg/resource/google/google_compute_subnetwork.go @@ -2,12 +2,22 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/google" ) +const GoogleComputeSubnetworkResourceType = "google_compute_subnetwork" + func initGoogleComputeSubnetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(google.GoogleComputeSubnetworkResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GoogleComputeSubnetworkResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"self_link"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeSubnetworkResourceType, func(res *resource.Resource) map[string]string { + attrs := make(map[string]string) + + if v := res.Attributes().GetString("name"); v != nil && *v != "" { + attrs["Name"] = *v + } + return attrs + }) + resourceSchemaRepository.SetFlags(GoogleComputeSubnetworkResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/google/google_dns_managed_zone.go b/pkg/resource/google/google_dns_managed_zone.go new file mode 100644 index 000000000..a6ea85e2b --- /dev/null +++ b/pkg/resource/google/google_dns_managed_zone.go @@ -0,0 +1,3 @@ +package google + +const GoogleDNSManagedZoneResourceType = "google_dns_managed_zone" diff --git a/pkg/resource/google/google_project_iam_binding.go b/pkg/resource/google/google_project_iam_binding.go new file mode 100644 index 000000000..096e9e013 --- /dev/null +++ b/pkg/resource/google/google_project_iam_binding.go @@ -0,0 +1,3 @@ +package google + +const GoogleProjectIamBindingResourceType = "google_project_iam_binding" diff --git a/pkg/resource/google/google_project_iam_member.go b/pkg/resource/google/google_project_iam_member.go index 10d33ff1e..f3b06bf26 100644 --- a/pkg/resource/google/google_project_iam_member.go +++ b/pkg/resource/google/google_project_iam_member.go @@ -2,12 +2,14 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/google" ) +const GoogleProjectIamMemberResourceType = "google_project_iam_member" + func initGoogleProjectIAMMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(google.GoogleProjectIamMemberResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GoogleProjectIamMemberResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"force_destroy"}) res.Attributes().SafeDelete([]string{"etag"}) }) + resourceSchemaRepository.SetFlags(GoogleProjectIamMemberResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/google/google_project_iam_policy.go b/pkg/resource/google/google_project_iam_policy.go new file mode 100644 index 000000000..96db80afb --- /dev/null +++ b/pkg/resource/google/google_project_iam_policy.go @@ -0,0 +1,3 @@ +package google + +const GoogleProjectIamPolicyResourceType = "google_project_iam_policy" diff --git a/pkg/resource/google/google_sql_database_instance.go b/pkg/resource/google/google_sql_database_instance.go new file mode 100644 index 000000000..ea35bf748 --- /dev/null +++ b/pkg/resource/google/google_sql_database_instance.go @@ -0,0 +1,3 @@ +package google + +const GoogleSQLDatabaseInstanceResourceType = "google_sql_database_instance" diff --git a/pkg/resource/google/google_storage_bucket.go b/pkg/resource/google/google_storage_bucket.go index 903aabfe6..9ce508f18 100644 --- a/pkg/resource/google/google_storage_bucket.go +++ b/pkg/resource/google/google_storage_bucket.go @@ -2,11 +2,13 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/google" ) +const GoogleStorageBucketResourceType = "google_storage_bucket" + func initGoogleStorageBucketMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(google.GoogleStorageBucketResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GoogleStorageBucketResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"force_destroy"}) }) + resourceSchemaRepository.SetFlags(GoogleStorageBucketResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/google/google_storage_bucket_iam_binding.go b/pkg/resource/google/google_storage_bucket_iam_binding.go new file mode 100644 index 000000000..3d7c0a3e4 --- /dev/null +++ b/pkg/resource/google/google_storage_bucket_iam_binding.go @@ -0,0 +1,3 @@ +package google + +const GoogleStorageBucketIamBindingResourceType = "google_storage_bucket_iam_binding" diff --git a/pkg/resource/google/google_storage_bucket_iam_member.go b/pkg/resource/google/google_storage_bucket_iam_member.go index b1855db1b..a33c26fc3 100644 --- a/pkg/resource/google/google_storage_bucket_iam_member.go +++ b/pkg/resource/google/google_storage_bucket_iam_member.go @@ -2,12 +2,23 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/enumeration/resource/google" ) +const GoogleStorageBucketIamMemberResourceType = "google_storage_bucket_iam_member" + func initGoogleStorageBucketIamBMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { - resourceSchemaRepository.SetNormalizeFunc(google.GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) { + resourceSchemaRepository.SetNormalizeFunc(GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"force_destroy"}) res.Attributes().SafeDelete([]string{"etag"}) }) + resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) map[string]string { + attrs := map[string]string{ + "bucket": *res.Attrs.GetString("bucket"), + "role": *res.Attrs.GetString("role"), + "member": *res.Attrs.GetString("member"), + } + return attrs + }) + resourceSchemaRepository.SetFlags(GoogleStorageBucketIamMemberResourceType, resource.FlagDeepMode) + } diff --git a/pkg/resource/google/google_storage_bucket_iam_policy.go b/pkg/resource/google/google_storage_bucket_iam_policy.go new file mode 100644 index 000000000..b3fbfbadd --- /dev/null +++ b/pkg/resource/google/google_storage_bucket_iam_policy.go @@ -0,0 +1,3 @@ +package google + +const GoogleStorageBucketIamPolicyResourceType = "google_storage_bucket_iam_policy" diff --git a/enumeration/resource/google/metadata_test.go b/pkg/resource/google/metadata_test.go similarity index 93% rename from enumeration/resource/google/metadata_test.go rename to pkg/resource/google/metadata_test.go index 7ff82e995..7181e2126 100644 --- a/enumeration/resource/google/metadata_test.go +++ b/pkg/resource/google/metadata_test.go @@ -3,8 +3,6 @@ package google import ( "testing" - tf "github.com/snyk/driftctl/enumeration/terraform" - "github.com/snyk/driftctl/enumeration/resource" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" @@ -37,7 +35,7 @@ func TestGoogle_Metadata_Flags(t *testing.T) { GoogleComputeGlobalForwardingRuleResourceType: {}, } - schemaRepository := testresource.InitFakeSchemaRepository(tf.GOOGLE, "3.78.0") + schemaRepository := testresource.InitFakeSchemaRepository("google", "3.78.0") InitResourcesMetadata(schemaRepository) for ty, flags := range testcases { diff --git a/pkg/resource/google/metadatas.go b/pkg/resource/google/metadatas.go index 9c74aa5df..0666ba742 100644 --- a/pkg/resource/google/metadatas.go +++ b/pkg/resource/google/metadatas.go @@ -1,8 +1,18 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" +) func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { + initGoogleBigqueryDatasetMetadata(resourceSchemaRepository) + initGoogleBigqueryTableMetadata(resourceSchemaRepository) + initGoogleComputeAddressMetadata(resourceSchemaRepository) + initGoogleComputeDiskMetadata(resourceSchemaRepository) + initGoogleComputeGlobalAddressMetadata(resourceSchemaRepository) + initGoogleComputeHealthCheckMetadata(resourceSchemaRepository) + initGoogleComputeImageMetadata(resourceSchemaRepository) + initComputeInstanceGroupManagerMetadata(resourceSchemaRepository) initGoogleStorageBucketMetadata(resourceSchemaRepository) initGoogleComputeFirewallMetadata(resourceSchemaRepository) initGoogleComputeNetworkMetadata(resourceSchemaRepository) diff --git a/pkg/resource/init_metadatas.go b/pkg/resource/init_metadatas.go deleted file mode 100644 index f1973b613..000000000 --- a/pkg/resource/init_metadatas.go +++ /dev/null @@ -1,29 +0,0 @@ -package resource - -import ( - "github.com/pkg/errors" - "github.com/snyk/driftctl/enumeration/remote/common" - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/resource/github" - "github.com/snyk/driftctl/pkg/resource/google" -) - -func InitMetadatas(remote string, - resourceSchemaRepository *resource.SchemaRepository) error { - switch remote { - case common.RemoteAWSTerraform: - aws.InitResourcesMetadata(resourceSchemaRepository) - case common.RemoteGithubTerraform: - github.InitResourcesMetadata(resourceSchemaRepository) - case common.RemoteGoogleTerraform: - google.InitResourcesMetadata(resourceSchemaRepository) - case common.RemoteAzureTerraform: - azurerm.InitResourcesMetadata(resourceSchemaRepository) - - default: - return errors.Errorf("unsupported remote '%s'", remote) - } - return nil -} diff --git a/enumeration/terraform/mock_ResourceFactory.go b/pkg/resource/mock_ResourceFactory.go similarity index 98% rename from enumeration/terraform/mock_ResourceFactory.go rename to pkg/resource/mock_ResourceFactory.go index fb58c47af..1eec2fab8 100644 --- a/enumeration/terraform/mock_ResourceFactory.go +++ b/pkg/resource/mock_ResourceFactory.go @@ -1,6 +1,6 @@ // Code generated by mockery v2.3.0. DO NOT EDIT. -package terraform +package resource import ( "github.com/snyk/driftctl/enumeration/resource" diff --git a/pkg/resource/resource_types.go b/pkg/resource/resource_types.go new file mode 100644 index 000000000..46c054feb --- /dev/null +++ b/pkg/resource/resource_types.go @@ -0,0 +1,273 @@ +package resource + +type ResourceType string + +var supportedTypes = map[string]ResourceTypeMeta{ + "aws_ami": {}, + "aws_cloudfront_distribution": {}, + "aws_db_instance": {}, + "aws_db_subnet_group": {}, + "aws_default_network_acl": {children: []ResourceType{ + "aws_network_acl_rule", + }}, + "aws_default_route_table": {children: []ResourceType{ + "aws_route", + }}, + "aws_default_security_group": {children: []ResourceType{ + "aws_security_group_rule", + }}, + "aws_default_subnet": {}, + "aws_default_vpc": {children: []ResourceType{ + // VPC are used by aws_internet_gateway to determine if internet gateway is the default one in middleware + "aws_internet_gateway", + }}, + "aws_dynamodb_table": {}, + "aws_ebs_snapshot": {}, + "aws_ebs_volume": {}, + "aws_alb": {children: []ResourceType{ + "aws_lb", + }}, + "aws_lb": {}, + "aws_lb_listener": {}, + "aws_alb_listener": {children: []ResourceType{ + "aws_lb_listener", + }}, + "aws_ebs_encryption_by_default": {}, + "aws_ecr_repository": {}, + "aws_ecr_repository_policy": {}, + "aws_eip": {children: []ResourceType{ + "aws_eip_association", + }}, + "aws_eip_association": {}, + "aws_iam_access_key": {}, + "aws_iam_policy": {}, + "aws_iam_policy_attachment": {}, + "aws_iam_role": {children: []ResourceType{ + "aws_iam_role_policy", + "aws_iam_policy_attachment", + }}, + "aws_iam_role_policy": {children: []ResourceType{ + "aws_iam_role_policy_attachment", + }}, + "aws_iam_role_policy_attachment": {children: []ResourceType{ + "aws_iam_policy_attachment", + }}, + "aws_iam_group_policy_attachment": {children: []ResourceType{ + "aws_iam_policy_attachment", + }}, + "aws_iam_user": {children: []ResourceType{ + "aws_iam_user_policy", + }}, + "aws_iam_user_policy": {children: []ResourceType{ + "aws_iam_user_policy_attachment", + }}, + "aws_iam_user_policy_attachment": {children: []ResourceType{ + "aws_iam_policy_attachment", + }}, + "aws_iam_group_policy": {}, + "aws_iam_group": {}, + "aws_instance": {children: []ResourceType{ + "aws_ebs_volume", + }}, + "aws_internet_gateway": {children: []ResourceType{ + // This is used to determine internet gateway default rule + "aws_route", + }}, + "aws_key_pair": {}, + "aws_kms_alias": {}, + "aws_kms_key": {}, + "aws_lambda_event_source_mapping": {}, + "aws_lambda_function": {}, + "aws_nat_gateway": {}, + "aws_network_acl": {children: []ResourceType{ + "aws_network_acl_rule", + }}, + "aws_network_acl_rule": {}, + "aws_route": {}, + "aws_route53_health_check": {}, + "aws_route53_record": {}, + "aws_route53_zone": {}, + "aws_route_table": {children: []ResourceType{ + "aws_route", + }}, + "aws_route_table_association": {}, + "aws_s3_bucket": {children: []ResourceType{ + "aws_s3_bucket_policy", + }}, + "aws_s3_bucket_analytics_configuration": {}, + "aws_s3_bucket_inventory": {}, + "aws_s3_bucket_metric": {}, + "aws_s3_bucket_notification": {}, + "aws_s3_bucket_policy": {}, + "aws_s3_bucket_public_access_block": {}, + "aws_security_group": {children: []ResourceType{ + "aws_security_group_rule", + }}, + "aws_security_group_rule": {}, + "aws_sns_topic": {children: []ResourceType{ + "aws_sns_topic_policy", + }}, + "aws_sns_topic_policy": {}, + "aws_sns_topic_subscription": {}, + "aws_sqs_queue": {children: []ResourceType{ + "aws_sqs_queue_policy", + }}, + "aws_sqs_queue_policy": {}, + "aws_subnet": {}, + "aws_vpc": {}, + "aws_rds_cluster": {}, + "aws_cloudformation_stack": {}, + "aws_api_gateway_rest_api": {children: []ResourceType{ + "aws_api_gateway_resource", + "aws_api_gateway_rest_api_policy", + "aws_api_gateway_gateway_response", + }}, + "aws_api_gateway_account": {}, + "aws_api_gateway_api_key": {}, + "aws_api_gateway_authorizer": {}, + "aws_api_gateway_deployment": {children: []ResourceType{ + "aws_api_gateway_stage", + }}, + "aws_api_gateway_stage": {}, + "aws_api_gateway_resource": {children: []ResourceType{ + "aws_api_gateway_method", + "aws_api_gateway_integration", + }}, + "aws_api_gateway_domain_name": {}, + "aws_api_gateway_vpc_link": {}, + "aws_api_gateway_request_validator": {}, + "aws_api_gateway_rest_api_policy": {}, + "aws_api_gateway_base_path_mapping": {}, + "aws_api_gateway_model": {}, + "aws_api_gateway_method": {children: []ResourceType{ + "aws_api_gateway_method_response", + }}, + "aws_api_gateway_method_response": {}, + "aws_api_gateway_gateway_response": {}, + "aws_api_gateway_method_settings": {}, + "aws_api_gateway_integration": {children: []ResourceType{ + "aws_api_gateway_integration_response", + }}, + "aws_api_gateway_integration_response": {}, + "aws_appautoscaling_target": {}, + "aws_rds_cluster_instance": {children: []ResourceType{ + "aws_db_instance", + }}, + "aws_appautoscaling_policy": {}, + "aws_appautoscaling_scheduled_action": {}, + "aws_apigatewayv2_api": {children: []ResourceType{ + "aws_apigatewayv2_route", + "aws_apigatewayv2_integration", + }}, + "aws_apigatewayv2_model": {}, + "aws_apigatewayv2_stage": {}, + "aws_apigatewayv2_route_response": {}, + "aws_apigatewayv2_deployment": {}, + "aws_apigatewayv2_domain_name": {}, + "aws_apigatewayv2_api_mapping": {}, + "aws_apigatewayv2_route": {}, + "aws_apigatewayv2_vpc_link": {}, + "aws_apigatewayv2_authorizer": {}, + "aws_apigatewayv2_integration": {}, + "aws_apigatewayv2_integration_response": {}, + "aws_launch_template": {}, + "aws_launch_configuration": {}, + "aws_elb": {}, + "aws_elasticache_cluster": {}, + + "github_branch_protection": {}, + "github_membership": {}, + "github_repository": {}, + "github_team": {}, + "github_team_membership": {}, + + "google_storage_bucket": {}, + "google_compute_firewall": {}, + "google_compute_router": {}, + "google_compute_instance": {}, + "google_compute_network": {}, + "google_storage_bucket_iam_binding": {children: []ResourceType{ + "google_storage_bucket_iam_member", + }}, + "google_storage_bucket_iam_member": {}, + "google_storage_bucket_iam_policy": {children: []ResourceType{ + "google_storage_bucket_iam_member", + }}, + "google_dns_managed_zone": {}, + "google_compute_instance_group": {}, + "google_bigquery_dataset": {}, + "google_bigquery_table": {}, + "google_project_iam_member": {}, + "google_project_iam_binding": {children: []ResourceType{ + "google_project_iam_member", + }}, + "google_project_iam_policy": {children: []ResourceType{ + "google_project_iam_member", + }}, + "google_compute_address": {}, + "google_compute_subnetwork": {}, + "google_cloudfunctions_function": {}, + "google_compute_disk": {}, + "google_bigtable_instance": {}, + "google_bigtable_table": {}, + "google_sql_database_instance": {}, + "google_compute_image": {}, + "google_compute_health_check": {}, + "google_compute_global_address": {}, + "google_compute_node_group": {}, + "google_cloud_run_service": {}, + "google_compute_forwarding_rule": {}, + "google_compute_instance_group_manager": {}, + "google_compute_global_forwarding_rule": {}, + + "azurerm_storage_account": {}, + "azurerm_storage_container": {}, + "azurerm_virtual_network": {children: []ResourceType{ + "azurerm_subnet", + }}, + "azurerm_route_table": {children: []ResourceType{ + "azurerm_route", + }}, + "azurerm_route": {}, + "azurerm_resource_group": {}, + "azurerm_subnet": {}, + "azurerm_container_registry": {}, + "azurerm_firewall": {}, + "azurerm_postgresql_server": {}, + "azurerm_postgresql_database": {}, + "azurerm_public_ip": {}, + "azurerm_network_security_group": {}, + "azurerm_lb": {}, + "azurerm_lb_rule": {}, + "azurerm_private_dns_zone": {}, + "azurerm_private_dns_a_record": {}, + "azurerm_private_dns_aaaa_record": {}, + "azurerm_private_dns_cname_record": {}, + "azurerm_private_dns_ptr_record": {}, + "azurerm_private_dns_srv_record": {}, + "azurerm_private_dns_mx_record": {}, + "azurerm_private_dns_txt_record": {}, + "azurerm_image": {}, + "azurerm_ssh_public_key": {}, +} + +func IsResourceTypeSupported(ty string) bool { + _, exist := supportedTypes[ty] + return exist +} + +func (ty ResourceType) String() string { + return string(ty) +} + +func GetMeta(ty ResourceType) ResourceTypeMeta { + return supportedTypes[ty.String()] +} + +type ResourceTypeMeta struct { + children []ResourceType +} + +func (ty ResourceTypeMeta) GetChildrenTypes() []ResourceType { + return ty.children +} diff --git a/test/test_diff.go b/test/test_diff.go index 9e424f506..6ccb7d85e 100644 --- a/test/test_diff.go +++ b/test/test_diff.go @@ -1,6 +1,7 @@ package test import ( + "encoding/json" "strings" "testing" @@ -12,10 +13,75 @@ import ( "github.com/snyk/driftctl/test/goldenfile" "github.com/zclconf/go-cty/cty" "github.com/zclconf/go-cty/cty/gocty" - "github.com/zclconf/go-cty/cty/json" + ctyjson "github.com/zclconf/go-cty/cty/json" ) -func TestAgainstGoldenFile( +// That method is used to compare the result of the enumeration with the golden file. +// That method does not use cty and types from the terraform provider to deserialize resources. +// Some resources returned by the enumeration may have missing fields, and if we use cty deserialization we're +// gonna recreate those missing fields to respect the schema. +func TestAgainstGoldenFileNoCty( + got []*resource.Resource, + ty string, + dirName string, + _ terraform.TerraformProvider, + _ *resource.Deserializer, + shouldUpdate bool, + tt *testing.T) { + var expectedResources []*resource.Resource + + // update golden file + if shouldUpdate { + attributes := make([]*resource.Attributes, 0, len(got)) + for _, res := range got { + attributes = append(attributes, res.Attributes()) + } + fileContent, err := json.MarshalIndent(attributes, "", " ") + if err != nil { + panic(err) + } + goldenfile.WriteFile(dirName, fileContent, goldenfile.ResultsFilename) + } + + // read golden file + file := goldenfile.ReadFile(dirName, goldenfile.ResultsFilename) + rawResources := make([]map[string]interface{}, 0) + err := json.Unmarshal(file, &rawResources) + if err != nil { + panic(err) + } + + for _, res := range rawResources { + res := res + expectedResources = append(expectedResources, &resource.Resource{ + Id: res["id"].(string), + Type: ty, + Attrs: (*resource.Attributes)(&res), + }) + } + + // diff + differ, err := diff.NewDiffer(diff.SliceOrdering(true)) + if err != nil { + panic(err) + } + + got = resource.Sort(got) + expectedResources = resource.Sort(expectedResources) + + changelog, err := differ.Diff(got, expectedResources) + + if err != nil { + panic(err) + } + if len(changelog) > 0 { + for _, change := range changelog { + tt.Errorf("%s got = %v, want %v", strings.Join(change.Path, "."), awsutil.Prettify(change.From), awsutil.Prettify(change.To)) + } + } +} + +func testAgainstGoldenFileCty( got []*resource.Resource, ty string, dirName string, @@ -37,7 +103,7 @@ func TestAgainstGoldenFile( if err != nil { panic(err) } - unm, err := json.Marshal(ctVal, ctyType) + unm, err := ctyjson.Marshal(ctVal, ctyType) if err != nil { panic(err) } @@ -46,7 +112,7 @@ func TestAgainstGoldenFile( // read golden file file := goldenfile.ReadFile(dirName, goldenfile.ResultsFilename) - decodedJson, err := json.Unmarshal(file, ctyType) + decodedJson, err := ctyjson.Unmarshal(file, ctyType) if err != nil { panic(err) } @@ -76,3 +142,15 @@ func TestAgainstGoldenFile( } } } + +func TestAgainstGoldenFile( + got []*resource.Resource, + ty string, + dirName string, + provider terraform.TerraformProvider, + deserializer *resource.Deserializer, + shouldUpdate bool, + tt *testing.T, +) { + testAgainstGoldenFileCty(got, ty, dirName, provider, deserializer, shouldUpdate, tt) +} From f9065269e8ea23b6de339d12c0089b5150b5f0e2 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Thu, 21 Jul 2022 15:08:43 +0200 Subject: [PATCH 3/9] chore: move schema repo in driftctl --- enumeration/resource/schemas.go | 121 ---------- pkg/analyser/analyzer_test.go | 4 +- pkg/cmd/scan.go | 29 +-- pkg/driftctl.go | 18 +- pkg/driftctl_test.go | 27 +-- .../aws_sns_topic_policy_expander.go | 5 +- .../aws_sqs_queue_policy_expander.go | 5 +- pkg/resource/aws/aws_ami.go | 7 +- pkg/resource/aws/aws_apigatewayv2_mapping.go | 7 +- pkg/resource/aws/aws_apigatewayv2_model.go | 7 +- pkg/resource/aws/aws_appautoscaling_policy.go | 7 +- pkg/resource/aws/aws_appautoscaling_target.go | 7 +- pkg/resource/aws/aws_cloudformation_stack.go | 7 +- .../aws/aws_cloudfront_distribution.go | 7 +- pkg/resource/aws/aws_db_instance.go | 7 +- pkg/resource/aws/aws_db_subnet_group.go | 7 +- pkg/resource/aws/aws_default_network_acl.go | 7 +- pkg/resource/aws/aws_default_route_table.go | 7 +- .../aws/aws_default_security_group.go | 7 +- pkg/resource/aws/aws_default_subnet.go | 7 +- pkg/resource/aws/aws_default_vpc.go | 7 +- pkg/resource/aws/aws_dynamodb_table.go | 7 +- .../aws/aws_ebs_encryption_by_default.go | 7 +- pkg/resource/aws/aws_ebs_snapshot.go | 7 +- pkg/resource/aws/aws_ebs_volume.go | 7 +- pkg/resource/aws/aws_ecr_repository.go | 7 +- pkg/resource/aws/aws_eip.go | 7 +- pkg/resource/aws/aws_eip_association.go | 7 +- pkg/resource/aws/aws_iam_access_key.go | 7 +- pkg/resource/aws/aws_iam_policy.go | 3 +- pkg/resource/aws/aws_iam_policy_attachment.go | 7 +- pkg/resource/aws/aws_iam_role.go | 7 +- pkg/resource/aws/aws_iam_role_policy.go | 7 +- .../aws/aws_iam_role_policy_attachment.go | 7 +- pkg/resource/aws/aws_iam_user.go | 7 +- pkg/resource/aws/aws_iam_user_policy.go | 7 +- .../aws/aws_iam_user_policy_attachment.go | 7 +- pkg/resource/aws/aws_instance.go | 4 +- pkg/resource/aws/aws_internet_gateway.go | 7 +- pkg/resource/aws/aws_key_pair.go | 7 +- pkg/resource/aws/aws_kms_alias.go | 7 +- pkg/resource/aws/aws_kms_key.go | 3 +- .../aws/aws_lambda_event_source_mapping.go | 7 +- pkg/resource/aws/aws_lambda_function.go | 7 +- pkg/resource/aws/aws_launch_template.go | 7 +- pkg/resource/aws/aws_lb.go | 7 +- pkg/resource/aws/aws_nat_gateway.go | 7 +- pkg/resource/aws/aws_network_acl.go | 7 +- pkg/resource/aws/aws_network_acl_rule.go | 3 +- pkg/resource/aws/aws_rds_cluster.go | 7 +- pkg/resource/aws/aws_route.go | 4 +- pkg/resource/aws/aws_route53_health_check.go | 4 +- pkg/resource/aws/aws_route53_record.go | 7 +- pkg/resource/aws/aws_route53_zone.go | 7 +- pkg/resource/aws/aws_route_table.go | 7 +- .../aws/aws_route_table_association.go | 7 +- pkg/resource/aws/aws_s3_bucket.go | 7 +- .../aws_s3_bucket_analytics_configuration.go | 7 +- pkg/resource/aws/aws_s3_bucket_inventory.go | 7 +- pkg/resource/aws/aws_s3_bucket_metric.go | 7 +- .../aws/aws_s3_bucket_notification.go | 7 +- pkg/resource/aws/aws_s3_bucket_policy.go | 3 +- pkg/resource/aws/aws_security_group.go | 7 +- pkg/resource/aws/aws_security_group_rule.go | 3 +- pkg/resource/aws/aws_sns_topic.go | 7 +- pkg/resource/aws/aws_sns_topic_policy.go | 3 +- .../aws/aws_sns_topic_subscription.go | 3 +- pkg/resource/aws/aws_sqs_queue.go | 7 +- pkg/resource/aws/aws_sqs_queue_policy.go | 3 +- pkg/resource/aws/aws_subnet.go | 7 +- pkg/resource/aws/aws_vpc.go | 7 +- pkg/resource/aws/metadata_test.go | 217 +++++++++--------- pkg/resource/aws/metadatas.go | 4 +- .../azurerm/azurerm_container_registry.go | 7 +- pkg/resource/azurerm/azurerm_firewall.go | 7 +- pkg/resource/azurerm/azurerm_image.go | 7 +- pkg/resource/azurerm/azurerm_lb.go | 7 +- pkg/resource/azurerm/azurerm_lb_rule.go | 7 +- .../azurerm/azurerm_network_security_group.go | 7 +- .../azurerm/azurerm_postgresql_database.go | 7 +- .../azurerm/azurerm_postgresql_server.go | 7 +- .../azurerm/azurerm_private_dns_a_record.go | 7 +- .../azurerm_private_dns_aaaa_record.go | 7 +- .../azurerm_private_dns_cname_record.go | 7 +- .../azurerm/azurerm_private_dns_mx_record.go | 7 +- .../azurerm/azurerm_private_dns_ptr_record.go | 7 +- .../azurerm/azurerm_private_dns_srv_record.go | 7 +- .../azurerm/azurerm_private_dns_txt_record.go | 7 +- .../azurerm/azurerm_private_dns_zone.go | 7 +- pkg/resource/azurerm/azurerm_public_ip.go | 7 +- .../azurerm/azurerm_resource_group.go | 7 +- pkg/resource/azurerm/azurerm_route.go | 7 +- pkg/resource/azurerm/azurerm_route_table.go | 7 +- .../azurerm/azurerm_ssh_public_key.go | 7 +- .../azurerm/azurerm_virtual_network.go | 7 +- pkg/resource/azurerm/metadata.go | 4 +- pkg/resource/azurerm/metadata_test.go | 55 ++--- pkg/resource/factory.go | 10 +- .../github/github_branch_protection.go | 4 +- pkg/resource/github/github_membership.go | 3 +- pkg/resource/github/github_repository.go | 3 +- pkg/resource/github/github_team.go | 3 +- pkg/resource/github/github_team_membership.go | 3 +- pkg/resource/github/metadata_test.go | 15 +- pkg/resource/github/metadatas.go | 4 +- .../google/google_bigquery_dataset.go | 3 +- pkg/resource/google/google_bigquery_table.go | 7 +- pkg/resource/google/google_compute_address.go | 7 +- pkg/resource/google/google_compute_disk.go | 7 +- .../google/google_compute_firewall.go | 3 +- .../google/google_compute_global_address.go | 7 +- .../google/google_compute_health_check.go | 7 +- pkg/resource/google/google_compute_image.go | 7 +- .../google/google_compute_instance_group.go | 3 +- .../google_compute_instance_group_manager.go | 7 +- pkg/resource/google/google_compute_network.go | 3 +- .../google/google_compute_subnetwork.go | 3 +- .../google/google_project_iam_member.go | 3 +- pkg/resource/google/google_storage_bucket.go | 3 +- .../google_storage_bucket_iam_member.go | 3 +- pkg/resource/google/metadata_test.go | 51 ++-- pkg/resource/google/metadatas.go | 2 +- pkg/resource/schemas.go | 12 + pkg/resource/schemas/repository.go | 134 +++++++++++ test/resource/resource.go | 13 +- 125 files changed, 836 insertions(+), 544 deletions(-) create mode 100644 pkg/resource/schemas.go create mode 100644 pkg/resource/schemas/repository.go diff --git a/enumeration/resource/schemas.go b/enumeration/resource/schemas.go index a21cb7984..01d5c0390 100644 --- a/enumeration/resource/schemas.go +++ b/enumeration/resource/schemas.go @@ -5,8 +5,6 @@ import ( "github.com/hashicorp/go-version" "github.com/hashicorp/terraform/configs/configschema" - "github.com/hashicorp/terraform/providers" - "github.com/sirupsen/logrus" ) type AttributeSchema struct { @@ -53,122 +51,3 @@ func (s *Schema) IsJsonStringField(path []string) bool { } return metadata.JsonString } - -type SchemaRepositoryInterface interface { - GetSchema(resourceType string) (*Schema, bool) - SetFlags(typ string, flags ...Flags) - UpdateSchema(typ string, schemasMutators map[string]func(attributeSchema *AttributeSchema)) - SetNormalizeFunc(typ string, normalizeFunc func(res *Resource)) - SetHumanReadableAttributesFunc(typ string, humanReadableAttributesFunc func(res *Resource) map[string]string) - SetDiscriminantFunc(string, func(*Resource, *Resource) bool) -} - -type SchemaRepository struct { - schemas map[string]*Schema - ProviderName string - ProviderVersion *version.Version -} - -func NewSchemaRepository() *SchemaRepository { - return &SchemaRepository{ - schemas: make(map[string]*Schema), - } -} - -func (r *SchemaRepository) GetSchema(resourceType string) (*Schema, bool) { - schema, exist := r.schemas[resourceType] - return schema, exist -} - -func (r *SchemaRepository) fetchNestedBlocks(root string, metadata map[string]AttributeSchema, block map[string]*configschema.NestedBlock) { - for s, nestedBlock := range block { - path := s - if root != "" { - path = strings.Join([]string{root, s}, ".") - } - for s2, attr := range nestedBlock.Attributes { - nestedPath := strings.Join([]string{path, s2}, ".") - metadata[nestedPath] = AttributeSchema{ - ConfigSchema: *attr, - } - } - r.fetchNestedBlocks(path, metadata, nestedBlock.BlockTypes) - } -} - -func (r *SchemaRepository) Init(providerName, providerVersion string, schema map[string]providers.Schema) error { - v, err := version.NewVersion(providerVersion) - if err != nil { - return err - } - r.ProviderVersion = v - r.ProviderName = providerName - for typ, sch := range schema { - attributeMetas := map[string]AttributeSchema{} - for s, attribute := range sch.Block.Attributes { - attributeMetas[s] = AttributeSchema{ - ConfigSchema: *attribute, - } - } - - r.fetchNestedBlocks("", attributeMetas, sch.Block.BlockTypes) - - r.schemas[typ] = &Schema{ - ProviderVersion: r.ProviderVersion, - SchemaVersion: sch.Version, - Attributes: attributeMetas, - } - } - return nil -} - -func (r SchemaRepository) SetFlags(typ string, flags ...Flags) { - metadata, exist := r.GetSchema(typ) - if !exist { - logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set flags, no schema found") - return - } - for _, flag := range flags { - metadata.Flags.AddFlag(flag) - } -} - -func (r *SchemaRepository) UpdateSchema(typ string, schemasMutators map[string]func(attributeSchema *AttributeSchema)) { - for s, f := range schemasMutators { - metadata, exist := r.GetSchema(typ) - if !exist { - logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set metadata, no schema found") - return - } - m := (*metadata).Attributes[s] - f(&m) - (*metadata).Attributes[s] = m - } -} - -func (r *SchemaRepository) SetNormalizeFunc(typ string, normalizeFunc func(res *Resource)) { - metadata, exist := r.GetSchema(typ) - if !exist { - logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set normalize func, no schema found") - return - } - (*metadata).NormalizeFunc = normalizeFunc -} - -func (r *SchemaRepository) SetHumanReadableAttributesFunc(typ string, humanReadableAttributesFunc func(res *Resource) map[string]string) { - metadata, exist := r.GetSchema(typ) - if !exist { - logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to add human readable attributes, no schema found") - return - } - (*metadata).HumanReadableAttributesFunc = humanReadableAttributesFunc -} - -func (r *SchemaRepository) SetDiscriminantFunc(typ string, fn func(self, res *Resource) bool) { - metadata, exist := r.GetSchema(typ) - if !exist { - logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set discriminant function, no schema found") - return - } - (*metadata).DiscriminantFunc = fn -} diff --git a/pkg/analyser/analyzer_test.go b/pkg/analyser/analyzer_test.go index 9b0c116ac..68ed848af 100644 --- a/pkg/analyser/analyzer_test.go +++ b/pkg/analyser/analyzer_test.go @@ -6,6 +6,8 @@ import ( "testing" "time" + dctlresource "github.com/snyk/driftctl/pkg/resource" + alerter2 "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/pkg/filter" @@ -1264,7 +1266,7 @@ func TestAnalyze(t *testing.T) { } } -func addSchemaToRes(res *resource.Resource, repo resource.SchemaRepositoryInterface) { +func addSchemaToRes(res *resource.Resource, repo dctlresource.SchemaRepositoryInterface) { schema, _ := repo.GetSchema(res.ResourceType()) res.Sch = schema } diff --git a/pkg/cmd/scan.go b/pkg/cmd/scan.go index af2b2ffe2..657d83642 100644 --- a/pkg/cmd/scan.go +++ b/pkg/cmd/scan.go @@ -19,7 +19,6 @@ import ( "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/remote" "github.com/snyk/driftctl/enumeration/remote/common" - "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/enumeration/terraform" "github.com/snyk/driftctl/enumeration/terraform/lock" "github.com/snyk/driftctl/pkg/analyser" @@ -27,10 +26,7 @@ import ( "github.com/snyk/driftctl/pkg/iac/terraform/state" "github.com/snyk/driftctl/pkg/memstore" dctlresource "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/resource/azurerm" - "github.com/snyk/driftctl/pkg/resource/github" - "github.com/snyk/driftctl/pkg/resource/google" + "github.com/snyk/driftctl/pkg/resource/schemas" "github.com/snyk/driftctl/pkg/telemetry" "github.com/snyk/driftctl/pkg/terraform/hcl" "github.com/spf13/cobra" @@ -291,7 +287,7 @@ func scanRun(opts *pkg.ScanOptions) error { iacProgress := globaloutput.NewProgress("Scanning states", "Scanned states", true) scanProgress := globaloutput.NewProgress("Scanning resources", "Scanned resources", false) - resourceSchemaRepository := resource.NewSchemaRepository() + resourceSchemaRepository := schemas.NewSchemaRepository() resFactory := dctlresource.NewDriftctlResourceFactory(resourceSchemaRepository) @@ -300,17 +296,10 @@ func scanRun(opts *pkg.ScanOptions) error { return err } - switch opts.To { - case common.RemoteAWSTerraform: - aws.InitResourcesMetadata(resourceSchemaRepository) - case common.RemoteGithubTerraform: - github.InitResourcesMetadata(resourceSchemaRepository) - case common.RemoteGoogleTerraform: - google.InitResourcesMetadata(resourceSchemaRepository) - case common.RemoteAzureTerraform: - azurerm.InitResourcesMetadata(resourceSchemaRepository) - default: - return errors.Errorf("unsupported remote '%s'", opts.To) + providerName := common.RemoteParameter(opts.To).GetProviderAddress().Type + err = resourceSchemaRepository.Init(providerName, opts.ProviderVersion, providerLibrary.Provider(opts.To).Schema()) + if err != nil { + return err } // Teardown @@ -355,8 +344,8 @@ func scanRun(opts *pkg.ScanOptions) error { return err } - analysis.ProviderVersion = resourceSchemaRepository.ProviderVersion.String() - analysis.ProviderName = resourceSchemaRepository.ProviderName + analysis.ProviderVersion = opts.ProviderVersion + analysis.ProviderName = opts.To store.Bucket(memstore.TelemetryBucket).Set("provider_name", analysis.ProviderName) validOutput := false @@ -377,7 +366,7 @@ func scanRun(opts *pkg.ScanOptions) error { } globaloutput.Printf(color.WhiteString("Scan duration: %s\n", analysis.Duration.Round(time.Second))) - globaloutput.Printf(color.WhiteString("Provider version used to scan: %s. Use --tf-provider-version to use another version.\n"), resourceSchemaRepository.ProviderVersion.String()) + globaloutput.Printf(color.WhiteString("Provider version used to scan: %s. Use --tf-provider-version to use another version.\n"), opts.ProviderVersion) if !opts.DisableTelemetry { tl := telemetry.NewTelemetry(&build.Build{}) diff --git a/pkg/driftctl.go b/pkg/driftctl.go index 953f4cf42..3bd515f0f 100644 --- a/pkg/driftctl.go +++ b/pkg/driftctl.go @@ -4,21 +4,19 @@ import ( "fmt" "time" - "github.com/snyk/driftctl/enumeration/alerter" - resource2 "github.com/snyk/driftctl/pkg/resource" - "github.com/jmespath/go-jmespath" "github.com/sirupsen/logrus" - "github.com/snyk/driftctl/pkg/memstore" - globaloutput "github.com/snyk/driftctl/pkg/output" - + "github.com/snyk/driftctl/enumeration/alerter" "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/analyser" "github.com/snyk/driftctl/pkg/cmd/scan/output" "github.com/snyk/driftctl/pkg/filter" "github.com/snyk/driftctl/pkg/iac/config" "github.com/snyk/driftctl/pkg/iac/terraform/state/backend" + "github.com/snyk/driftctl/pkg/memstore" "github.com/snyk/driftctl/pkg/middlewares" + globaloutput "github.com/snyk/driftctl/pkg/output" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) type FmtOptions struct { @@ -47,26 +45,26 @@ type ScanOptions struct { type DriftCTL struct { remoteSupplier resource.Supplier - iacSupplier resource2.IaCSupplier + iacSupplier dctlresource.IaCSupplier alerter alerter.AlerterInterface analyzer *analyser.Analyzer resourceFactory resource.ResourceFactory scanProgress globaloutput.Progress iacProgress globaloutput.Progress - resourceSchemaRepository resource.SchemaRepositoryInterface + resourceSchemaRepository dctlresource.SchemaRepositoryInterface opts *ScanOptions store memstore.Store } func NewDriftCTL(remoteSupplier resource.Supplier, - iacSupplier resource2.IaCSupplier, + iacSupplier dctlresource.IaCSupplier, alerter *alerter.Alerter, analyzer *analyser.Analyzer, resFactory resource.ResourceFactory, opts *ScanOptions, scanProgress globaloutput.Progress, iacProgress globaloutput.Progress, - resourceSchemaRepository resource.SchemaRepositoryInterface, + resourceSchemaRepository dctlresource.SchemaRepositoryInterface, store memstore.Store) *DriftCTL { return &DriftCTL{ remoteSupplier, diff --git a/pkg/driftctl_test.go b/pkg/driftctl_test.go index d3ead48ea..14126cb41 100644 --- a/pkg/driftctl_test.go +++ b/pkg/driftctl_test.go @@ -14,7 +14,6 @@ import ( "github.com/snyk/driftctl/pkg/output" dctlresource "github.com/snyk/driftctl/pkg/resource" "github.com/snyk/driftctl/pkg/resource/aws" - "github.com/snyk/driftctl/pkg/resource/github" "github.com/snyk/driftctl/test" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" @@ -31,7 +30,7 @@ type TestCase struct { provider *TestProvider stateResources []*resource.Resource remoteResources []*resource.Resource - mocks func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) + mocks func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) assert func(t *testing.T, result *test.ScanResult, err error) assertStore func(*testing.T, memstore.Store) options *pkg.ScanOptions @@ -48,8 +47,6 @@ func runTest(t *testing.T, cases TestCases) { } } repo := testresource.InitFakeSchemaRepository(c.provider.Name, c.provider.Version) - aws.InitResourcesMetadata(repo) - github.InitResourcesMetadata(repo) t.Run(c.name, func(t *testing.T) { testAlerter := alerter.NewAlerter() @@ -363,7 +360,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { }, { name: "we should ignore default AWS IAM role when strict mode is disabled", - mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { + mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { factory.(*dctlresource.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, @@ -461,7 +458,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { }, { name: "we should not ignore default AWS IAM role when strict mode is enabled", - mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { + mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { factory.(*dctlresource.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, @@ -559,7 +556,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { }, { name: "we should not ignore default AWS IAM role when strict mode is enabled and a filter is specified", - mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { + mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { factory.(*dctlresource.MockResourceFactory).On( "CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, @@ -790,7 +787,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { + mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { factory.(*dctlresource.MockResourceFactory).On( "CreateAbstractResource", aws.AwsS3BucketPolicyResourceType, @@ -877,7 +874,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { + mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { foo := resource.Resource{ Id: "vol-018c5ae89895aca4c", Type: "aws_ebs_volume", @@ -992,7 +989,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { + mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table1080289494", mock.MatchedBy(func(input map[string]interface{}) bool { return matchByAttributes(input, map[string]interface{}{ "destination_cidr_block": "0.0.0.0/0", @@ -1070,7 +1067,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { + mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_sns_topic_policy", "foo", map[string]interface{}{ "id": "foo", "arn": "arn", @@ -1132,7 +1129,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { + mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", map[string]interface{}{ "id": "foo", "queue_url": "foo", @@ -1344,7 +1341,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { + mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { rule1 := resource.Resource{ Type: aws.AwsSecurityGroupRuleResourceType, Id: "sgrule-1707973622", @@ -1553,7 +1550,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo resource.SchemaRepositoryInterface) { + mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "iduser1", map[string]interface{}{ "id": "iduser1", "policy_arn": "policy_arn1", @@ -1784,7 +1781,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { runTest(t, cases) } -func getSchema(repo resource.SchemaRepositoryInterface, resourceType string) *resource.Schema { +func getSchema(repo dctlresource.SchemaRepositoryInterface, resourceType string) *resource.Schema { sch, _ := repo.GetSchema(resourceType) return sch } diff --git a/pkg/middlewares/aws_sns_topic_policy_expander.go b/pkg/middlewares/aws_sns_topic_policy_expander.go index 233198aa9..7b4707c67 100644 --- a/pkg/middlewares/aws_sns_topic_policy_expander.go +++ b/pkg/middlewares/aws_sns_topic_policy_expander.go @@ -4,16 +4,17 @@ import ( "github.com/pkg/errors" "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" "github.com/snyk/driftctl/pkg/resource/aws" ) // Explodes policy found in aws_sns_topic from state resources to aws_sns_topic_policy resources type AwsSNSTopicPolicyExpander struct { resourceFactory resource.ResourceFactory - resourceSchemaRepository resource.SchemaRepositoryInterface + resourceSchemaRepository dctlresource.SchemaRepositoryInterface } -func NewAwsSNSTopicPolicyExpander(resourceFactory resource.ResourceFactory, resourceSchemaRepository resource.SchemaRepositoryInterface) AwsSNSTopicPolicyExpander { +func NewAwsSNSTopicPolicyExpander(resourceFactory resource.ResourceFactory, resourceSchemaRepository dctlresource.SchemaRepositoryInterface) AwsSNSTopicPolicyExpander { return AwsSNSTopicPolicyExpander{ resourceFactory, resourceSchemaRepository, diff --git a/pkg/middlewares/aws_sqs_queue_policy_expander.go b/pkg/middlewares/aws_sqs_queue_policy_expander.go index 814724780..9bd2100cc 100644 --- a/pkg/middlewares/aws_sqs_queue_policy_expander.go +++ b/pkg/middlewares/aws_sqs_queue_policy_expander.go @@ -3,16 +3,17 @@ package middlewares import ( "github.com/sirupsen/logrus" "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" "github.com/snyk/driftctl/pkg/resource/aws" ) // Explodes policy found in aws_sqs_queue.policy from state resources to dedicated resources type AwsSQSQueuePolicyExpander struct { resourceFactory resource.ResourceFactory - resourceSchemaRepository resource.SchemaRepositoryInterface + resourceSchemaRepository dctlresource.SchemaRepositoryInterface } -func NewAwsSQSQueuePolicyExpander(resourceFactory resource.ResourceFactory, resourceSchemaRepository resource.SchemaRepositoryInterface) AwsSQSQueuePolicyExpander { +func NewAwsSQSQueuePolicyExpander(resourceFactory resource.ResourceFactory, resourceSchemaRepository dctlresource.SchemaRepositoryInterface) AwsSQSQueuePolicyExpander { return AwsSQSQueuePolicyExpander{ resourceFactory, resourceSchemaRepository, diff --git a/pkg/resource/aws/aws_ami.go b/pkg/resource/aws/aws_ami.go index b436575e5..6934d4d96 100644 --- a/pkg/resource/aws/aws_ami.go +++ b/pkg/resource/aws/aws_ami.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsAmiResourceType = "aws_ami" -func initAwsAmiMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsAmiMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsAmiResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_apigatewayv2_mapping.go b/pkg/resource/aws/aws_apigatewayv2_mapping.go index dd563a9a2..55269a556 100644 --- a/pkg/resource/aws/aws_apigatewayv2_mapping.go +++ b/pkg/resource/aws/aws_apigatewayv2_mapping.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsApiGatewayV2MappingResourceType = "aws_apigatewayv2_api_mapping" -func initAwsApiGatewayV2MappingMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsApiGatewayV2MappingMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc( AwsApiGatewayV2MappingResourceType, func(res *resource.Resource) map[string]string { diff --git a/pkg/resource/aws/aws_apigatewayv2_model.go b/pkg/resource/aws/aws_apigatewayv2_model.go index 471ae4937..879861eec 100644 --- a/pkg/resource/aws/aws_apigatewayv2_model.go +++ b/pkg/resource/aws/aws_apigatewayv2_model.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsApiGatewayV2ModelResourceType = "aws_apigatewayv2_model" -func initAwsApiGatewayV2ModelMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsApiGatewayV2ModelMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc( AwsApiGatewayV2ModelResourceType, func(res *resource.Resource) map[string]string { diff --git a/pkg/resource/aws/aws_appautoscaling_policy.go b/pkg/resource/aws/aws_appautoscaling_policy.go index 33c6ea0b1..30087e649 100644 --- a/pkg/resource/aws/aws_appautoscaling_policy.go +++ b/pkg/resource/aws/aws_appautoscaling_policy.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsAppAutoscalingPolicyResourceType = "aws_appautoscaling_policy" -func initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsAppAutoscalingPolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingPolicyResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { diff --git a/pkg/resource/aws/aws_appautoscaling_target.go b/pkg/resource/aws/aws_appautoscaling_target.go index 67ce5e847..5819da282 100644 --- a/pkg/resource/aws/aws_appautoscaling_target.go +++ b/pkg/resource/aws/aws_appautoscaling_target.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsAppAutoscalingTargetResourceType = "aws_appautoscaling_target" -func initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsAppAutoscalingTargetMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsAppAutoscalingTargetResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) if v := res.Attributes().GetString("scalable_dimension"); v != nil && *v != "" { diff --git a/pkg/resource/aws/aws_cloudformation_stack.go b/pkg/resource/aws/aws_cloudformation_stack.go index d65c62971..6f47f2e1e 100644 --- a/pkg/resource/aws/aws_cloudformation_stack.go +++ b/pkg/resource/aws/aws_cloudformation_stack.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsCloudformationStackResourceType = "aws_cloudformation_stack" -func initAwsCloudformationStackMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsCloudformationStackMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsCloudformationStackResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_cloudfront_distribution.go b/pkg/resource/aws/aws_cloudfront_distribution.go index 44fbf3af5..5dba03bee 100644 --- a/pkg/resource/aws/aws_cloudfront_distribution.go +++ b/pkg/resource/aws/aws_cloudfront_distribution.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsCloudfrontDistributionResourceType = "aws_cloudfront_distribution" -func initAwsCloudfrontDistributionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsCloudfrontDistributionMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsCloudfrontDistributionResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"etag"}) diff --git a/pkg/resource/aws/aws_db_instance.go b/pkg/resource/aws/aws_db_instance.go index 280681fdc..b9af967e7 100644 --- a/pkg/resource/aws/aws_db_instance.go +++ b/pkg/resource/aws/aws_db_instance.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsDbInstanceResourceType = "aws_db_instance" -func initAwsDbInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsDbInstanceMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsDbInstanceResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"delete_automated_backups"}) diff --git a/pkg/resource/aws/aws_db_subnet_group.go b/pkg/resource/aws/aws_db_subnet_group.go index a716cbaac..c190929a1 100644 --- a/pkg/resource/aws/aws_db_subnet_group.go +++ b/pkg/resource/aws/aws_db_subnet_group.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsDbSubnetGroupResourceType = "aws_db_subnet_group" -func initAwsDbSubnetGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsDbSubnetGroupMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsDbSubnetGroupResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"name_prefix"}) diff --git a/pkg/resource/aws/aws_default_network_acl.go b/pkg/resource/aws/aws_default_network_acl.go index 353b5dddd..3f21c4005 100644 --- a/pkg/resource/aws/aws_default_network_acl.go +++ b/pkg/resource/aws/aws_default_network_acl.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsDefaultNetworkACLResourceType = "aws_default_network_acl" -func initAwsDefaultNetworkACLMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsDefaultNetworkACLMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsDefaultNetworkACLResourceType, func(res *resource.Resource) { res.Attrs.SafeDelete([]string{"default_network_acl_id"}) diff --git a/pkg/resource/aws/aws_default_route_table.go b/pkg/resource/aws/aws_default_route_table.go index 0965c995c..e76780ccb 100644 --- a/pkg/resource/aws/aws_default_route_table.go +++ b/pkg/resource/aws/aws_default_route_table.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsDefaultRouteTableResourceType = "aws_default_route_table" -func initAwsDefaultRouteTableMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsDefaultRouteTableMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsDefaultRouteTableResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetNormalizeFunc(AwsDefaultRouteTableResourceType, func(res *resource.Resource) { val := res.Attrs diff --git a/pkg/resource/aws/aws_default_security_group.go b/pkg/resource/aws/aws_default_security_group.go index 6615025cc..c045dd758 100644 --- a/pkg/resource/aws/aws_default_security_group.go +++ b/pkg/resource/aws/aws_default_security_group.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsDefaultSecurityGroupResourceType = "aws_default_security_group" -func initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsDefaultSecurityGroupMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsDefaultSecurityGroupResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"revoke_rules_on_delete"}) diff --git a/pkg/resource/aws/aws_default_subnet.go b/pkg/resource/aws/aws_default_subnet.go index d0e597de7..b08853d13 100644 --- a/pkg/resource/aws/aws_default_subnet.go +++ b/pkg/resource/aws/aws_default_subnet.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsDefaultSubnetResourceType = "aws_default_subnet" -func initAwsDefaultSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsDefaultSubnetMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsDefaultSubnetResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_default_vpc.go b/pkg/resource/aws/aws_default_vpc.go index 62a02a122..7cfc37335 100644 --- a/pkg/resource/aws/aws_default_vpc.go +++ b/pkg/resource/aws/aws_default_vpc.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsDefaultVpcResourceType = "aws_default_vpc" -func initAwsDefaultVpcMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsDefaultVpcMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsDefaultVpcResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_dynamodb_table.go b/pkg/resource/aws/aws_dynamodb_table.go index eb0d4c7dc..30ae1fbb5 100644 --- a/pkg/resource/aws/aws_dynamodb_table.go +++ b/pkg/resource/aws/aws_dynamodb_table.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsDynamodbTableResourceType = "aws_dynamodb_table" -func initAwsDynamodbTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsDynamodbTableMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsDynamodbTableResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_ebs_encryption_by_default.go b/pkg/resource/aws/aws_ebs_encryption_by_default.go index 502b99f38..ba831bc31 100644 --- a/pkg/resource/aws/aws_ebs_encryption_by_default.go +++ b/pkg/resource/aws/aws_ebs_encryption_by_default.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsEbsEncryptionByDefaultResourceType = "aws_ebs_encryption_by_default" -func initAwsEbsEncryptionByDefaultMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsEbsEncryptionByDefaultMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsEbsEncryptionByDefaultResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_ebs_snapshot.go b/pkg/resource/aws/aws_ebs_snapshot.go index ff870fa8f..4510a1caa 100644 --- a/pkg/resource/aws/aws_ebs_snapshot.go +++ b/pkg/resource/aws/aws_ebs_snapshot.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsEbsSnapshotResourceType = "aws_ebs_snapshot" -func initAwsEbsSnapshotMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsEbsSnapshotMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsEbsSnapshotResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_ebs_volume.go b/pkg/resource/aws/aws_ebs_volume.go index 004e611ac..10d7e03bd 100644 --- a/pkg/resource/aws/aws_ebs_volume.go +++ b/pkg/resource/aws/aws_ebs_volume.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsEbsVolumeResourceType = "aws_ebs_volume" -func initAwsEbsVolumeMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsEbsVolumeMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsEbsVolumeResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"arn"}) diff --git a/pkg/resource/aws/aws_ecr_repository.go b/pkg/resource/aws/aws_ecr_repository.go index faea0a071..300c48db2 100644 --- a/pkg/resource/aws/aws_ecr_repository.go +++ b/pkg/resource/aws/aws_ecr_repository.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsEcrRepositoryResourceType = "aws_ecr_repository" -func initAwsEcrRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsEcrRepositoryMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsEcrRepositoryResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_eip.go b/pkg/resource/aws/aws_eip.go index 06fe011f9..7895aef27 100644 --- a/pkg/resource/aws/aws_eip.go +++ b/pkg/resource/aws/aws_eip.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsEipResourceType = "aws_eip" -func initAwsEipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsEipMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsEipResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_eip_association.go b/pkg/resource/aws/aws_eip_association.go index 60248114b..6a6e742fe 100644 --- a/pkg/resource/aws/aws_eip_association.go +++ b/pkg/resource/aws/aws_eip_association.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsEipAssociationResourceType = "aws_eip_association" -func initAwsEipAssociationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsEipAssociationMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsEipAssociationResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_access_key.go b/pkg/resource/aws/aws_iam_access_key.go index 240512ac6..02b9b8cd7 100644 --- a/pkg/resource/aws/aws_iam_access_key.go +++ b/pkg/resource/aws/aws_iam_access_key.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsIamAccessKeyResourceType = "aws_iam_access_key" -func initAwsIAMAccessKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsIAMAccessKeyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsIamAccessKeyResourceType, func(res *resource.Resource) { val := res.Attrs // As we can't read secrets from aws API once access_key created we need to set diff --git a/pkg/resource/aws/aws_iam_policy.go b/pkg/resource/aws/aws_iam_policy.go index 1718e3b67..6becab4ce 100644 --- a/pkg/resource/aws/aws_iam_policy.go +++ b/pkg/resource/aws/aws_iam_policy.go @@ -3,11 +3,12 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/helpers" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const AwsIamPolicyResourceType = "aws_iam_policy" -func initAwsIAMPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsIAMPolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsIamPolicyResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) diff --git a/pkg/resource/aws/aws_iam_policy_attachment.go b/pkg/resource/aws/aws_iam_policy_attachment.go index 36ad1ce46..3201a4c3a 100644 --- a/pkg/resource/aws/aws_iam_policy_attachment.go +++ b/pkg/resource/aws/aws_iam_policy_attachment.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsIamPolicyAttachmentResourceType = "aws_iam_policy_attachment" -func initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsIAMPolicyAttachmentMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsIamPolicyAttachmentResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"name"}) diff --git a/pkg/resource/aws/aws_iam_role.go b/pkg/resource/aws/aws_iam_role.go index 31c846114..36b6b0cb1 100644 --- a/pkg/resource/aws/aws_iam_role.go +++ b/pkg/resource/aws/aws_iam_role.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsIamRoleResourceType = "aws_iam_role" -func initAwsIAMRoleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsIAMRoleMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsIamRoleResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"force_detach_policies"}) diff --git a/pkg/resource/aws/aws_iam_role_policy.go b/pkg/resource/aws/aws_iam_role_policy.go index c0fb37567..16bcda306 100644 --- a/pkg/resource/aws/aws_iam_role_policy.go +++ b/pkg/resource/aws/aws_iam_role_policy.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsIamRolePolicyResourceType = "aws_iam_role_policy" -func initAwsIAMRolePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsIAMRolePolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.UpdateSchema(AwsIamRolePolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ "policy": func(attributeSchema *resource.AttributeSchema) { attributeSchema.JsonString = true diff --git a/pkg/resource/aws/aws_iam_role_policy_attachment.go b/pkg/resource/aws/aws_iam_role_policy_attachment.go index a9d83f241..d94687b5f 100644 --- a/pkg/resource/aws/aws_iam_role_policy_attachment.go +++ b/pkg/resource/aws/aws_iam_role_policy_attachment.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsIamRolePolicyAttachmentResourceType = "aws_iam_role_policy_attachment" -func initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsIamRolePolicyAttachmentMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsIamRolePolicyAttachmentResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_iam_user.go b/pkg/resource/aws/aws_iam_user.go index 576cd882d..1068bed1e 100644 --- a/pkg/resource/aws/aws_iam_user.go +++ b/pkg/resource/aws/aws_iam_user.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsIamUserResourceType = "aws_iam_user" -func initAwsIAMUserMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsIAMUserMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsIamUserResourceType, func(res *resource.Resource) { val := res.Attrs permissionsBoundary, exist := val.Get("permissions_boundary") diff --git a/pkg/resource/aws/aws_iam_user_policy.go b/pkg/resource/aws/aws_iam_user_policy.go index 9eb7ae9e2..d7aba042d 100644 --- a/pkg/resource/aws/aws_iam_user_policy.go +++ b/pkg/resource/aws/aws_iam_user_policy.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsIamUserPolicyResourceType = "aws_iam_user_policy" -func initAwsIAMUserPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsIAMUserPolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.UpdateSchema(AwsIamUserPolicyResourceType, map[string]func(attributeSchema *resource.AttributeSchema){ "policy": func(attributeSchema *resource.AttributeSchema) { attributeSchema.JsonString = true diff --git a/pkg/resource/aws/aws_iam_user_policy_attachment.go b/pkg/resource/aws/aws_iam_user_policy_attachment.go index 9b7a41d15..e4319c809 100644 --- a/pkg/resource/aws/aws_iam_user_policy_attachment.go +++ b/pkg/resource/aws/aws_iam_user_policy_attachment.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsIamUserPolicyAttachmentResourceType = "aws_iam_user_policy_attachment" -func initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsIamUserPolicyAttachmentMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsIamUserPolicyAttachmentResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_instance.go b/pkg/resource/aws/aws_instance.go index 21fbfff69..d31417bea 100644 --- a/pkg/resource/aws/aws_instance.go +++ b/pkg/resource/aws/aws_instance.go @@ -2,13 +2,13 @@ package aws import ( "github.com/hashicorp/go-version" - "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const AwsInstanceResourceType = "aws_instance" -func initAwsInstanceMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsInstanceMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsInstanceResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_internet_gateway.go b/pkg/resource/aws/aws_internet_gateway.go index 500a664e8..700ce031d 100644 --- a/pkg/resource/aws/aws_internet_gateway.go +++ b/pkg/resource/aws/aws_internet_gateway.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsInternetGatewayResourceType = "aws_internet_gateway" -func initAwsInternetGatewayMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsInternetGatewayMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsInternetGatewayResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_key_pair.go b/pkg/resource/aws/aws_key_pair.go index 387aa690c..0fedadb27 100644 --- a/pkg/resource/aws/aws_key_pair.go +++ b/pkg/resource/aws/aws_key_pair.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsKeyPairResourceType = "aws_key_pair" -func initAwsKeyPairMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsKeyPairMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsKeyPairResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"key_name_prefix"}) diff --git a/pkg/resource/aws/aws_kms_alias.go b/pkg/resource/aws/aws_kms_alias.go index ae291c509..895697d7f 100644 --- a/pkg/resource/aws/aws_kms_alias.go +++ b/pkg/resource/aws/aws_kms_alias.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsKmsAliasResourceType = "aws_kms_alias" -func initAwsKmsAliasMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsKmsAliasMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsKmsAliasResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"name"}) diff --git a/pkg/resource/aws/aws_kms_key.go b/pkg/resource/aws/aws_kms_key.go index e52160a2c..3a4e68002 100644 --- a/pkg/resource/aws/aws_kms_key.go +++ b/pkg/resource/aws/aws_kms_key.go @@ -3,11 +3,12 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/helpers" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const AwsKmsKeyResourceType = "aws_kms_key" -func initAwsKmsKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsKmsKeyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsKmsKeyResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"deletion_window_in_days"}) diff --git a/pkg/resource/aws/aws_lambda_event_source_mapping.go b/pkg/resource/aws/aws_lambda_event_source_mapping.go index b6dc064b3..55b11dba2 100644 --- a/pkg/resource/aws/aws_lambda_event_source_mapping.go +++ b/pkg/resource/aws/aws_lambda_event_source_mapping.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsLambdaEventSourceMappingResourceType = "aws_lambda_event_source_mapping" -func initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsLambdaEventSourceMappingMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsLambdaEventSourceMappingResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"state_transition_reason"}) diff --git a/pkg/resource/aws/aws_lambda_function.go b/pkg/resource/aws/aws_lambda_function.go index 3dd86ac74..0a1fa42f1 100644 --- a/pkg/resource/aws/aws_lambda_function.go +++ b/pkg/resource/aws/aws_lambda_function.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsLambdaFunctionResourceType = "aws_lambda_function" -func initAwsLambdaFunctionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsLambdaFunctionMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsLambdaFunctionResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_launch_template.go b/pkg/resource/aws/aws_launch_template.go index ce931e208..f944f202d 100644 --- a/pkg/resource/aws/aws_launch_template.go +++ b/pkg/resource/aws/aws_launch_template.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsLaunchTemplateResourceType = "aws_launch_template" -func initAwsLaunchTemplateMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsLaunchTemplateMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsLaunchTemplateResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_lb.go b/pkg/resource/aws/aws_lb.go index 791f8068f..e1e9aa900 100644 --- a/pkg/resource/aws/aws_lb.go +++ b/pkg/resource/aws/aws_lb.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsLoadBalancerResourceType = "aws_lb" -func initAwsLoadBalancerMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsLoadBalancerMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsLoadBalancerResourceType, func(res *resource.Resource) map[string]string { return map[string]string{ "Name": *res.Attributes().GetString("name"), diff --git a/pkg/resource/aws/aws_nat_gateway.go b/pkg/resource/aws/aws_nat_gateway.go index c51f3a98b..8120599d6 100644 --- a/pkg/resource/aws/aws_nat_gateway.go +++ b/pkg/resource/aws/aws_nat_gateway.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsNatGatewayResourceType = "aws_nat_gateway" -func initNatGatewayMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initNatGatewayMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsNatGatewayResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_network_acl.go b/pkg/resource/aws/aws_network_acl.go index e2e4650e9..9aacebf70 100644 --- a/pkg/resource/aws/aws_network_acl.go +++ b/pkg/resource/aws/aws_network_acl.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsNetworkACLResourceType = "aws_network_acl" -func initAwsNetworkACLMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsNetworkACLMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsNetworkACLResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_network_acl_rule.go b/pkg/resource/aws/aws_network_acl_rule.go index 2cfd12cb2..69e87d78d 100644 --- a/pkg/resource/aws/aws_network_acl_rule.go +++ b/pkg/resource/aws/aws_network_acl_rule.go @@ -3,6 +3,7 @@ package aws import ( "bytes" "fmt" + dctlresource "github.com/snyk/driftctl/pkg/resource" "strconv" "github.com/hashicorp/terraform/helper/hashcode" @@ -161,7 +162,7 @@ var protocolsNumbers = map[string]int{ "254": 254, } -func initAwsNetworkACLRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsNetworkACLRuleMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) { res.Attrs.DeleteIfDefault("icmp_code") res.Attrs.DeleteIfDefault("icmp_type") diff --git a/pkg/resource/aws/aws_rds_cluster.go b/pkg/resource/aws/aws_rds_cluster.go index 6a520c649..ecf2d1236 100644 --- a/pkg/resource/aws/aws_rds_cluster.go +++ b/pkg/resource/aws/aws_rds_cluster.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsRDSClusterResourceType = "aws_rds_cluster" -func initAwsRDSClusterMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsRDSClusterMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsRDSClusterResourceType, func(res *resource.Resource) { val := res.Attributes() val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_route.go b/pkg/resource/aws/aws_route.go index 0325d335b..64fe1c02e 100644 --- a/pkg/resource/aws/aws_route.go +++ b/pkg/resource/aws/aws_route.go @@ -2,15 +2,15 @@ package aws import ( "fmt" - "github.com/hashicorp/terraform/helper/hashcode" + dctlresource "github.com/snyk/driftctl/pkg/resource" "github.com/snyk/driftctl/enumeration/resource" ) const AwsRouteResourceType = "aws_route" -func initAwsRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsRouteMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsRouteResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_route53_health_check.go b/pkg/resource/aws/aws_route53_health_check.go index e87e5b376..71514c24b 100644 --- a/pkg/resource/aws/aws_route53_health_check.go +++ b/pkg/resource/aws/aws_route53_health_check.go @@ -2,13 +2,13 @@ package aws import ( "fmt" - "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const AwsRoute53HealthCheckResourceType = "aws_route53_health_check" -func initAwsRoute53HealthCheckMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsRoute53HealthCheckMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRoute53HealthCheckResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/pkg/resource/aws/aws_route53_record.go b/pkg/resource/aws/aws_route53_record.go index c4c9e20c4..4ac6c06d2 100644 --- a/pkg/resource/aws/aws_route53_record.go +++ b/pkg/resource/aws/aws_route53_record.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsRoute53RecordResourceType = "aws_route53_record" -func initAwsRoute53RecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsRoute53RecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsRoute53RecordResourceType, func(res *resource.Resource) { val := res.Attrs val.DeleteIfDefault("health_check_id") diff --git a/pkg/resource/aws/aws_route53_zone.go b/pkg/resource/aws/aws_route53_zone.go index 419def8bb..8b40986fa 100644 --- a/pkg/resource/aws/aws_route53_zone.go +++ b/pkg/resource/aws/aws_route53_zone.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsRoute53ZoneResourceType = "aws_route53_zone" -func initAwsRoute53ZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsRoute53ZoneMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsRoute53ZoneResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"force_destroy"}) diff --git a/pkg/resource/aws/aws_route_table.go b/pkg/resource/aws/aws_route_table.go index edef38567..0085d2b87 100644 --- a/pkg/resource/aws/aws_route_table.go +++ b/pkg/resource/aws/aws_route_table.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsRouteTableResourceType = "aws_route_table" -func initAwsRouteTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsRouteTableMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsRouteTableResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetNormalizeFunc(AwsRouteTableResourceType, func(res *resource.Resource) { val := res.Attrs diff --git a/pkg/resource/aws/aws_route_table_association.go b/pkg/resource/aws/aws_route_table_association.go index 1632de70b..6378f5c77 100644 --- a/pkg/resource/aws/aws_route_table_association.go +++ b/pkg/resource/aws/aws_route_table_association.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsRouteTableAssociationResourceType = "aws_route_table_association" -func initAwsRouteTableAssociationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsRouteTableAssociationMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsRouteTableAssociationResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/pkg/resource/aws/aws_s3_bucket.go b/pkg/resource/aws/aws_s3_bucket.go index dc615c1aa..6a2aefad9 100644 --- a/pkg/resource/aws/aws_s3_bucket.go +++ b/pkg/resource/aws/aws_s3_bucket.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsS3BucketResourceType = "aws_s3_bucket" -func initAwsS3BucketMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsS3BucketMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsS3BucketResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"force_destroy"}) diff --git a/pkg/resource/aws/aws_s3_bucket_analytics_configuration.go b/pkg/resource/aws/aws_s3_bucket_analytics_configuration.go index 470d5faaf..2d7a95431 100644 --- a/pkg/resource/aws/aws_s3_bucket_analytics_configuration.go +++ b/pkg/resource/aws/aws_s3_bucket_analytics_configuration.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsS3BucketAnalyticsConfigurationResourceType = "aws_s3_bucket_analytics_configuration" -func initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsS3BucketAnalyticsConfigurationMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsS3BucketAnalyticsConfigurationResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_s3_bucket_inventory.go b/pkg/resource/aws/aws_s3_bucket_inventory.go index 7424fc84e..df4509cb8 100644 --- a/pkg/resource/aws/aws_s3_bucket_inventory.go +++ b/pkg/resource/aws/aws_s3_bucket_inventory.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsS3BucketInventoryResourceType = "aws_s3_bucket_inventory" -func initAwsS3BucketInventoryMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsS3BucketInventoryMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsS3BucketInventoryResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_s3_bucket_metric.go b/pkg/resource/aws/aws_s3_bucket_metric.go index 68e14a8df..634b7fb84 100644 --- a/pkg/resource/aws/aws_s3_bucket_metric.go +++ b/pkg/resource/aws/aws_s3_bucket_metric.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsS3BucketMetricResourceType = "aws_s3_bucket_metric" -func initAwsS3BucketMetricMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsS3BucketMetricMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsS3BucketMetricResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_s3_bucket_notification.go b/pkg/resource/aws/aws_s3_bucket_notification.go index 789ff720f..172e7c909 100644 --- a/pkg/resource/aws/aws_s3_bucket_notification.go +++ b/pkg/resource/aws/aws_s3_bucket_notification.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsS3BucketNotificationResourceType = "aws_s3_bucket_notification" -func initAwsS3BucketNotificationMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsS3BucketNotificationMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsS3BucketNotificationResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_s3_bucket_policy.go b/pkg/resource/aws/aws_s3_bucket_policy.go index 3621b5981..ad7aa68a5 100644 --- a/pkg/resource/aws/aws_s3_bucket_policy.go +++ b/pkg/resource/aws/aws_s3_bucket_policy.go @@ -3,11 +3,12 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/helpers" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const AwsS3BucketPolicyResourceType = "aws_s3_bucket_policy" -func initAwsS3BucketPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsS3BucketPolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsS3BucketPolicyResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) diff --git a/pkg/resource/aws/aws_security_group.go b/pkg/resource/aws/aws_security_group.go index 5ded29397..25b5331d3 100644 --- a/pkg/resource/aws/aws_security_group.go +++ b/pkg/resource/aws/aws_security_group.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsSecurityGroupResourceType = "aws_security_group" -func initAwsSecurityGroupMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsSecurityGroupMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsSecurityGroupResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"revoke_rules_on_delete"}) diff --git a/pkg/resource/aws/aws_security_group_rule.go b/pkg/resource/aws/aws_security_group_rule.go index e4e8ea47d..ebae6ce94 100644 --- a/pkg/resource/aws/aws_security_group_rule.go +++ b/pkg/resource/aws/aws_security_group_rule.go @@ -3,6 +3,7 @@ package aws import ( "bytes" "fmt" + dctlresource "github.com/snyk/driftctl/pkg/resource" "strings" "github.com/hashicorp/terraform/helper/hashcode" @@ -11,7 +12,7 @@ import ( const AwsSecurityGroupRuleResourceType = "aws_security_group_rule" -func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsSecurityGroupRuleMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsSecurityGroupRuleResourceType, func(res *resource.Resource) { val := res.Attrs val.DeleteIfDefault("security_group_id") diff --git a/pkg/resource/aws/aws_sns_topic.go b/pkg/resource/aws/aws_sns_topic.go index 40516244f..ea4ae8730 100644 --- a/pkg/resource/aws/aws_sns_topic.go +++ b/pkg/resource/aws/aws_sns_topic.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsSnsTopicResourceType = "aws_sns_topic" -func initSnsTopicMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initSnsTopicMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicResourceType, func(res *resource.Resource) { val := res.Attrs val.DeleteIfDefault("sqs_success_feedback_sample_rate") diff --git a/pkg/resource/aws/aws_sns_topic_policy.go b/pkg/resource/aws/aws_sns_topic_policy.go index a6f034a25..9b4a76707 100644 --- a/pkg/resource/aws/aws_sns_topic_policy.go +++ b/pkg/resource/aws/aws_sns_topic_policy.go @@ -3,11 +3,12 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/helpers" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const AwsSnsTopicPolicyResourceType = "aws_sns_topic_policy" -func initSnsTopicPolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initSnsTopicPolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicPolicyResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"owner"}) diff --git a/pkg/resource/aws/aws_sns_topic_subscription.go b/pkg/resource/aws/aws_sns_topic_subscription.go index 4e508d257..1075be872 100644 --- a/pkg/resource/aws/aws_sns_topic_subscription.go +++ b/pkg/resource/aws/aws_sns_topic_subscription.go @@ -3,11 +3,12 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/helpers" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const AwsSnsTopicSubscriptionResourceType = "aws_sns_topic_subscription" -func initSnsTopicSubscriptionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initSnsTopicSubscriptionMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsSnsTopicSubscriptionResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["delivery_policy"]) diff --git a/pkg/resource/aws/aws_sqs_queue.go b/pkg/resource/aws/aws_sqs_queue.go index 7c7aa1bf6..da740abb6 100644 --- a/pkg/resource/aws/aws_sqs_queue.go +++ b/pkg/resource/aws/aws_sqs_queue.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsSqsQueueResourceType = "aws_sqs_queue" -func initSqsQueueMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initSqsQueueMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsSqsQueueResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/aws_sqs_queue_policy.go b/pkg/resource/aws/aws_sqs_queue_policy.go index a339ff3ed..a3b9d0ffc 100644 --- a/pkg/resource/aws/aws_sqs_queue_policy.go +++ b/pkg/resource/aws/aws_sqs_queue_policy.go @@ -3,11 +3,12 @@ package aws import ( "github.com/snyk/driftctl/enumeration/resource" "github.com/snyk/driftctl/pkg/helpers" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const AwsSqsQueuePolicyResourceType = "aws_sqs_queue_policy" -func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsSQSQueuePolicyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsSqsQueuePolicyResourceType, func(res *resource.Resource) { val := res.Attrs jsonString, err := helpers.NormalizeJsonString((*val)["policy"]) diff --git a/pkg/resource/aws/aws_subnet.go b/pkg/resource/aws/aws_subnet.go index 6419b157e..298ed4b62 100644 --- a/pkg/resource/aws/aws_subnet.go +++ b/pkg/resource/aws/aws_subnet.go @@ -1,10 +1,13 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsSubnetResourceType = "aws_subnet" -func initAwsSubnetMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsSubnetMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AwsSubnetResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/aws/aws_vpc.go b/pkg/resource/aws/aws_vpc.go index 8d7ae9acb..5f991400c 100644 --- a/pkg/resource/aws/aws_vpc.go +++ b/pkg/resource/aws/aws_vpc.go @@ -1,9 +1,12 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AwsVpcResourceType = "aws_vpc" -func initAwsVpcMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAwsVpcMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetFlags(AwsVpcResourceType, resource.FlagDeepMode) } diff --git a/pkg/resource/aws/metadata_test.go b/pkg/resource/aws/metadata_test.go index aab306ab6..10d53c5f8 100644 --- a/pkg/resource/aws/metadata_test.go +++ b/pkg/resource/aws/metadata_test.go @@ -1,125 +1,126 @@ -package aws +package aws_test import ( "testing" "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/pkg/resource/aws" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" ) func TestAWS_Metadata_Flags(t *testing.T) { testcases := map[string][]resource.Flags{ - AwsAmiResourceType: {resource.FlagDeepMode}, - AwsApiGatewayAccountResourceType: {}, - AwsApiGatewayApiKeyResourceType: {}, - AwsApiGatewayAuthorizerResourceType: {}, - AwsApiGatewayBasePathMappingResourceType: {}, - AwsApiGatewayDeploymentResourceType: {}, - AwsApiGatewayDomainNameResourceType: {}, - AwsApiGatewayGatewayResponseResourceType: {}, - AwsApiGatewayIntegrationResourceType: {}, - AwsApiGatewayIntegrationResponseResourceType: {}, - AwsApiGatewayMethodResourceType: {}, - AwsApiGatewayMethodResponseResourceType: {}, - AwsApiGatewayMethodSettingsResourceType: {}, - AwsApiGatewayModelResourceType: {}, - AwsApiGatewayRequestValidatorResourceType: {}, - AwsApiGatewayResourceResourceType: {}, - AwsApiGatewayRestApiResourceType: {}, - AwsApiGatewayRestApiPolicyResourceType: {}, - AwsApiGatewayStageResourceType: {}, - AwsApiGatewayVpcLinkResourceType: {}, - AwsApiGatewayV2ApiResourceType: {}, - AwsApiGatewayV2RouteResourceType: {}, - AwsApiGatewayV2DeploymentResourceType: {}, - AwsApiGatewayV2VpcLinkResourceType: {}, - AwsApiGatewayV2AuthorizerResourceType: {}, - AwsApiGatewayV2RouteResponseResourceType: {}, - AwsApiGatewayV2DomainNameResourceType: {}, - AwsApiGatewayV2ModelResourceType: {}, - AwsApiGatewayV2StageResourceType: {}, - AwsApiGatewayV2MappingResourceType: {}, - AwsApiGatewayV2IntegrationResourceType: {}, - AwsApiGatewayV2IntegrationResponseResourceType: {}, - AwsAppAutoscalingPolicyResourceType: {resource.FlagDeepMode}, - AwsAppAutoscalingScheduledActionResourceType: {}, - AwsAppAutoscalingTargetResourceType: {resource.FlagDeepMode}, - AwsCloudformationStackResourceType: {resource.FlagDeepMode}, - AwsCloudfrontDistributionResourceType: {resource.FlagDeepMode}, - AwsDbInstanceResourceType: {resource.FlagDeepMode}, - AwsDbSubnetGroupResourceType: {resource.FlagDeepMode}, - AwsDefaultNetworkACLResourceType: {resource.FlagDeepMode}, - AwsDefaultRouteTableResourceType: {resource.FlagDeepMode}, - AwsDefaultSecurityGroupResourceType: {resource.FlagDeepMode}, - AwsDefaultSubnetResourceType: {resource.FlagDeepMode}, - AwsDefaultVpcResourceType: {resource.FlagDeepMode}, - AwsDynamodbTableResourceType: {resource.FlagDeepMode}, - AwsEbsEncryptionByDefaultResourceType: {resource.FlagDeepMode}, - AwsEbsSnapshotResourceType: {resource.FlagDeepMode}, - AwsEbsVolumeResourceType: {resource.FlagDeepMode}, - AwsEcrRepositoryResourceType: {resource.FlagDeepMode}, - AwsEipResourceType: {resource.FlagDeepMode}, - AwsEipAssociationResourceType: {resource.FlagDeepMode}, - AwsElastiCacheClusterResourceType: {}, - AwsIamAccessKeyResourceType: {resource.FlagDeepMode}, - AwsIamPolicyResourceType: {resource.FlagDeepMode}, - AwsIamPolicyAttachmentResourceType: {resource.FlagDeepMode}, - AwsIamRoleResourceType: {resource.FlagDeepMode}, - AwsIamRolePolicyResourceType: {resource.FlagDeepMode}, - AwsIamRolePolicyAttachmentResourceType: {resource.FlagDeepMode}, - AwsIamUserResourceType: {resource.FlagDeepMode}, - AwsIamUserPolicyResourceType: {resource.FlagDeepMode}, - AwsIamUserPolicyAttachmentResourceType: {resource.FlagDeepMode}, - AwsIamGroupPolicyResourceType: {}, - AwsIamGroupPolicyAttachmentResourceType: {}, - AwsInstanceResourceType: {resource.FlagDeepMode}, - AwsInternetGatewayResourceType: {resource.FlagDeepMode}, - AwsKeyPairResourceType: {resource.FlagDeepMode}, - AwsKmsAliasResourceType: {resource.FlagDeepMode}, - AwsKmsKeyResourceType: {resource.FlagDeepMode}, - AwsLambdaEventSourceMappingResourceType: {resource.FlagDeepMode}, - AwsLambdaFunctionResourceType: {resource.FlagDeepMode}, - AwsNatGatewayResourceType: {resource.FlagDeepMode}, - AwsNetworkACLResourceType: {resource.FlagDeepMode}, - AwsRDSClusterResourceType: {resource.FlagDeepMode}, - AwsRDSClusterInstanceResourceType: {}, - AwsRouteResourceType: {resource.FlagDeepMode}, - AwsRoute53HealthCheckResourceType: {resource.FlagDeepMode}, - AwsRoute53RecordResourceType: {resource.FlagDeepMode}, - AwsRoute53ZoneResourceType: {resource.FlagDeepMode}, - AwsRouteTableResourceType: {resource.FlagDeepMode}, - AwsRouteTableAssociationResourceType: {resource.FlagDeepMode}, - AwsS3BucketResourceType: {resource.FlagDeepMode}, - AwsS3BucketAnalyticsConfigurationResourceType: {resource.FlagDeepMode}, - AwsS3BucketInventoryResourceType: {resource.FlagDeepMode}, - AwsS3BucketMetricResourceType: {resource.FlagDeepMode}, - AwsS3BucketNotificationResourceType: {resource.FlagDeepMode}, - AwsS3BucketPolicyResourceType: {resource.FlagDeepMode}, - AwsS3BucketPublicAccessBlockResourceType: {}, - AwsSecurityGroupResourceType: {resource.FlagDeepMode}, - AwsSnsTopicResourceType: {resource.FlagDeepMode}, - AwsSnsTopicPolicyResourceType: {resource.FlagDeepMode}, - AwsSnsTopicSubscriptionResourceType: {resource.FlagDeepMode}, - AwsSqsQueueResourceType: {resource.FlagDeepMode}, - AwsSqsQueuePolicyResourceType: {resource.FlagDeepMode}, - AwsSubnetResourceType: {resource.FlagDeepMode}, - AwsVpcResourceType: {resource.FlagDeepMode}, - AwsSecurityGroupRuleResourceType: {resource.FlagDeepMode}, - AwsNetworkACLRuleResourceType: {resource.FlagDeepMode}, - AwsLaunchTemplateResourceType: {resource.FlagDeepMode}, - AwsLaunchConfigurationResourceType: {}, - AwsLoadBalancerResourceType: {}, - AwsApplicationLoadBalancerResourceType: {}, - AwsClassicLoadBalancerResourceType: {}, - AwsLoadBalancerListenerResourceType: {}, - AwsApplicationLoadBalancerListenerResourceType: {}, - AwsIamGroupResourceType: {}, - AwsEcrRepositoryPolicyResourceType: {}, + aws.AwsAmiResourceType: {resource.FlagDeepMode}, + aws.AwsApiGatewayAccountResourceType: {}, + aws.AwsApiGatewayApiKeyResourceType: {}, + aws.AwsApiGatewayAuthorizerResourceType: {}, + aws.AwsApiGatewayBasePathMappingResourceType: {}, + aws.AwsApiGatewayDeploymentResourceType: {}, + aws.AwsApiGatewayDomainNameResourceType: {}, + aws.AwsApiGatewayGatewayResponseResourceType: {}, + aws.AwsApiGatewayIntegrationResourceType: {}, + aws.AwsApiGatewayIntegrationResponseResourceType: {}, + aws.AwsApiGatewayMethodResourceType: {}, + aws.AwsApiGatewayMethodResponseResourceType: {}, + aws.AwsApiGatewayMethodSettingsResourceType: {}, + aws.AwsApiGatewayModelResourceType: {}, + aws.AwsApiGatewayRequestValidatorResourceType: {}, + aws.AwsApiGatewayResourceResourceType: {}, + aws.AwsApiGatewayRestApiResourceType: {}, + aws.AwsApiGatewayRestApiPolicyResourceType: {}, + aws.AwsApiGatewayStageResourceType: {}, + aws.AwsApiGatewayVpcLinkResourceType: {}, + aws.AwsApiGatewayV2ApiResourceType: {}, + aws.AwsApiGatewayV2RouteResourceType: {}, + aws.AwsApiGatewayV2DeploymentResourceType: {}, + aws.AwsApiGatewayV2VpcLinkResourceType: {}, + aws.AwsApiGatewayV2AuthorizerResourceType: {}, + aws.AwsApiGatewayV2RouteResponseResourceType: {}, + aws.AwsApiGatewayV2DomainNameResourceType: {}, + aws.AwsApiGatewayV2ModelResourceType: {}, + aws.AwsApiGatewayV2StageResourceType: {}, + aws.AwsApiGatewayV2MappingResourceType: {}, + aws.AwsApiGatewayV2IntegrationResourceType: {}, + aws.AwsApiGatewayV2IntegrationResponseResourceType: {}, + aws.AwsAppAutoscalingPolicyResourceType: {resource.FlagDeepMode}, + aws.AwsAppAutoscalingScheduledActionResourceType: {}, + aws.AwsAppAutoscalingTargetResourceType: {resource.FlagDeepMode}, + aws.AwsCloudformationStackResourceType: {resource.FlagDeepMode}, + aws.AwsCloudfrontDistributionResourceType: {resource.FlagDeepMode}, + aws.AwsDbInstanceResourceType: {resource.FlagDeepMode}, + aws.AwsDbSubnetGroupResourceType: {resource.FlagDeepMode}, + aws.AwsDefaultNetworkACLResourceType: {resource.FlagDeepMode}, + aws.AwsDefaultRouteTableResourceType: {resource.FlagDeepMode}, + aws.AwsDefaultSecurityGroupResourceType: {resource.FlagDeepMode}, + aws.AwsDefaultSubnetResourceType: {resource.FlagDeepMode}, + aws.AwsDefaultVpcResourceType: {resource.FlagDeepMode}, + aws.AwsDynamodbTableResourceType: {resource.FlagDeepMode}, + aws.AwsEbsEncryptionByDefaultResourceType: {resource.FlagDeepMode}, + aws.AwsEbsSnapshotResourceType: {resource.FlagDeepMode}, + aws.AwsEbsVolumeResourceType: {resource.FlagDeepMode}, + aws.AwsEcrRepositoryResourceType: {resource.FlagDeepMode}, + aws.AwsEipResourceType: {resource.FlagDeepMode}, + aws.AwsEipAssociationResourceType: {resource.FlagDeepMode}, + aws.AwsElastiCacheClusterResourceType: {}, + aws.AwsIamAccessKeyResourceType: {resource.FlagDeepMode}, + aws.AwsIamPolicyResourceType: {resource.FlagDeepMode}, + aws.AwsIamPolicyAttachmentResourceType: {resource.FlagDeepMode}, + aws.AwsIamRoleResourceType: {resource.FlagDeepMode}, + aws.AwsIamRolePolicyResourceType: {resource.FlagDeepMode}, + aws.AwsIamRolePolicyAttachmentResourceType: {resource.FlagDeepMode}, + aws.AwsIamUserResourceType: {resource.FlagDeepMode}, + aws.AwsIamUserPolicyResourceType: {resource.FlagDeepMode}, + aws.AwsIamUserPolicyAttachmentResourceType: {resource.FlagDeepMode}, + aws.AwsIamGroupPolicyResourceType: {}, + aws.AwsIamGroupPolicyAttachmentResourceType: {}, + aws.AwsInstanceResourceType: {resource.FlagDeepMode}, + aws.AwsInternetGatewayResourceType: {resource.FlagDeepMode}, + aws.AwsKeyPairResourceType: {resource.FlagDeepMode}, + aws.AwsKmsAliasResourceType: {resource.FlagDeepMode}, + aws.AwsKmsKeyResourceType: {resource.FlagDeepMode}, + aws.AwsLambdaEventSourceMappingResourceType: {resource.FlagDeepMode}, + aws.AwsLambdaFunctionResourceType: {resource.FlagDeepMode}, + aws.AwsNatGatewayResourceType: {resource.FlagDeepMode}, + aws.AwsNetworkACLResourceType: {resource.FlagDeepMode}, + aws.AwsRDSClusterResourceType: {resource.FlagDeepMode}, + aws.AwsRDSClusterInstanceResourceType: {}, + aws.AwsRouteResourceType: {resource.FlagDeepMode}, + aws.AwsRoute53HealthCheckResourceType: {resource.FlagDeepMode}, + aws.AwsRoute53RecordResourceType: {resource.FlagDeepMode}, + aws.AwsRoute53ZoneResourceType: {resource.FlagDeepMode}, + aws.AwsRouteTableResourceType: {resource.FlagDeepMode}, + aws.AwsRouteTableAssociationResourceType: {resource.FlagDeepMode}, + aws.AwsS3BucketResourceType: {resource.FlagDeepMode}, + aws.AwsS3BucketAnalyticsConfigurationResourceType: {resource.FlagDeepMode}, + aws.AwsS3BucketInventoryResourceType: {resource.FlagDeepMode}, + aws.AwsS3BucketMetricResourceType: {resource.FlagDeepMode}, + aws.AwsS3BucketNotificationResourceType: {resource.FlagDeepMode}, + aws.AwsS3BucketPolicyResourceType: {resource.FlagDeepMode}, + aws.AwsS3BucketPublicAccessBlockResourceType: {}, + aws.AwsSecurityGroupResourceType: {resource.FlagDeepMode}, + aws.AwsSnsTopicResourceType: {resource.FlagDeepMode}, + aws.AwsSnsTopicPolicyResourceType: {resource.FlagDeepMode}, + aws.AwsSnsTopicSubscriptionResourceType: {resource.FlagDeepMode}, + aws.AwsSqsQueueResourceType: {resource.FlagDeepMode}, + aws.AwsSqsQueuePolicyResourceType: {resource.FlagDeepMode}, + aws.AwsSubnetResourceType: {resource.FlagDeepMode}, + aws.AwsVpcResourceType: {resource.FlagDeepMode}, + aws.AwsSecurityGroupRuleResourceType: {resource.FlagDeepMode}, + aws.AwsNetworkACLRuleResourceType: {resource.FlagDeepMode}, + aws.AwsLaunchTemplateResourceType: {resource.FlagDeepMode}, + aws.AwsLaunchConfigurationResourceType: {}, + aws.AwsLoadBalancerResourceType: {}, + aws.AwsApplicationLoadBalancerResourceType: {}, + aws.AwsClassicLoadBalancerResourceType: {}, + aws.AwsLoadBalancerListenerResourceType: {}, + aws.AwsApplicationLoadBalancerListenerResourceType: {}, + aws.AwsIamGroupResourceType: {}, + aws.AwsEcrRepositoryPolicyResourceType: {}, } schemaRepository := testresource.InitFakeSchemaRepository("aws", "3.19.0") - InitResourcesMetadata(schemaRepository) + aws.InitResourcesMetadata(schemaRepository) for ty, flags := range testcases { t.Run(ty, func(tt *testing.T) { diff --git a/pkg/resource/aws/metadatas.go b/pkg/resource/aws/metadatas.go index 7f3bca99b..512dd2ae2 100644 --- a/pkg/resource/aws/metadatas.go +++ b/pkg/resource/aws/metadatas.go @@ -1,6 +1,8 @@ package aws -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/pkg/resource" +) func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { initAwsAmiMetaData(resourceSchemaRepository) diff --git a/pkg/resource/azurerm/azurerm_container_registry.go b/pkg/resource/azurerm/azurerm_container_registry.go index 4a6d52b65..9239775d5 100644 --- a/pkg/resource/azurerm/azurerm_container_registry.go +++ b/pkg/resource/azurerm/azurerm_container_registry.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzureContainerRegistryResourceType = "azurerm_container_registry" -func initAzureContainerRegistryMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzureContainerRegistryMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureContainerRegistryResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/pkg/resource/azurerm/azurerm_firewall.go b/pkg/resource/azurerm/azurerm_firewall.go index ded79fe2a..ed3f90a20 100644 --- a/pkg/resource/azurerm/azurerm_firewall.go +++ b/pkg/resource/azurerm/azurerm_firewall.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzureFirewallResourceType = "azurerm_firewall" -func initAzureFirewallMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzureFirewallMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureFirewallResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/pkg/resource/azurerm/azurerm_image.go b/pkg/resource/azurerm/azurerm_image.go index 0a650295c..a0823b4f4 100644 --- a/pkg/resource/azurerm/azurerm_image.go +++ b/pkg/resource/azurerm/azurerm_image.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzureImageResourceType = "azurerm_image" -func initAzureImageMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzureImageMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureImageResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) diff --git a/pkg/resource/azurerm/azurerm_lb.go b/pkg/resource/azurerm/azurerm_lb.go index 04a7cc0d5..c715d76e1 100644 --- a/pkg/resource/azurerm/azurerm_lb.go +++ b/pkg/resource/azurerm/azurerm_lb.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzureLoadBalancerResourceType = "azurerm_lb" -func initAzureLoadBalancerMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzureLoadBalancerMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureLoadBalancerResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/pkg/resource/azurerm/azurerm_lb_rule.go b/pkg/resource/azurerm/azurerm_lb_rule.go index 2fe23ae60..762f1cf95 100644 --- a/pkg/resource/azurerm/azurerm_lb_rule.go +++ b/pkg/resource/azurerm/azurerm_lb_rule.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzureLoadBalancerRuleResourceType = "azurerm_lb_rule" -func initAzureLoadBalancerRuleMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzureLoadBalancerRuleMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AzureLoadBalancerRuleResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/azurerm/azurerm_network_security_group.go b/pkg/resource/azurerm/azurerm_network_security_group.go index a86883798..77481d9ce 100644 --- a/pkg/resource/azurerm/azurerm_network_security_group.go +++ b/pkg/resource/azurerm/azurerm_network_security_group.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzureNetworkSecurityGroupResourceType = "azurerm_network_security_group" -func initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzureNetworkSecurityGroupMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AzureNetworkSecurityGroupResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/azurerm/azurerm_postgresql_database.go b/pkg/resource/azurerm/azurerm_postgresql_database.go index 7a5784f95..a47ca8222 100644 --- a/pkg/resource/azurerm/azurerm_postgresql_database.go +++ b/pkg/resource/azurerm/azurerm_postgresql_database.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzurePostgresqlDatabaseResourceType = "azurerm_postgresql_database" -func initAzurePostgresqlDatabaseMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzurePostgresqlDatabaseMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePostgresqlDatabaseResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/pkg/resource/azurerm/azurerm_postgresql_server.go b/pkg/resource/azurerm/azurerm_postgresql_server.go index 167e68c3e..b2570d5d9 100644 --- a/pkg/resource/azurerm/azurerm_postgresql_server.go +++ b/pkg/resource/azurerm/azurerm_postgresql_server.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzurePostgresqlServerResourceType = "azurerm_postgresql_server" -func initAzurePostgresqlServerMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzurePostgresqlServerMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePostgresqlServerResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/pkg/resource/azurerm/azurerm_private_dns_a_record.go b/pkg/resource/azurerm/azurerm_private_dns_a_record.go index e67af833c..8205b956b 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_a_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_a_record.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzurePrivateDNSARecordResourceType = "azurerm_private_dns_a_record" -func initAzurePrivateDNSARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzurePrivateDNSARecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSARecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go b/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go index 0c06bb775..f39f60d4d 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_aaaa_record.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzurePrivateDNSAAAARecordResourceType = "azurerm_private_dns_aaaa_record" -func initAzurePrivateDNSAAAARecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzurePrivateDNSAAAARecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSAAAARecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/azurerm/azurerm_private_dns_cname_record.go b/pkg/resource/azurerm/azurerm_private_dns_cname_record.go index 18a2f9050..3e99dc30c 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_cname_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_cname_record.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzurePrivateDNSCNameRecordResourceType = "azurerm_private_dns_cname_record" -func initAzurePrivateDNSCNameRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzurePrivateDNSCNameRecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSCNameRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/azurerm/azurerm_private_dns_mx_record.go b/pkg/resource/azurerm/azurerm_private_dns_mx_record.go index e2602954a..12a47c1ab 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_mx_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_mx_record.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzurePrivateDNSMXRecordResourceType = "azurerm_private_dns_mx_record" -func initAzurePrivateDNSMXRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzurePrivateDNSMXRecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSMXRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go b/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go index c93a4a3ab..5c48e5d05 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_ptr_record.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzurePrivateDNSPTRRecordResourceType = "azurerm_private_dns_ptr_record" -func initAzurePrivateDNSPTRRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzurePrivateDNSPTRRecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSPTRRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/azurerm/azurerm_private_dns_srv_record.go b/pkg/resource/azurerm/azurerm_private_dns_srv_record.go index 9af2d31bb..17e4e42f8 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_srv_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_srv_record.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzurePrivateDNSSRVRecordResourceType = "azurerm_private_dns_srv_record" -func initAzurePrivateDNSSRVRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzurePrivateDNSSRVRecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSSRVRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/azurerm/azurerm_private_dns_txt_record.go b/pkg/resource/azurerm/azurerm_private_dns_txt_record.go index f351267cf..f840781fe 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_txt_record.go +++ b/pkg/resource/azurerm/azurerm_private_dns_txt_record.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzurePrivateDNSTXTRecordResourceType = "azurerm_private_dns_txt_record" -func initAzurePrivateDNSTXTRecordMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzurePrivateDNSTXTRecordMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSTXTRecordResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/azurerm/azurerm_private_dns_zone.go b/pkg/resource/azurerm/azurerm_private_dns_zone.go index d923825db..e125a7eae 100644 --- a/pkg/resource/azurerm/azurerm_private_dns_zone.go +++ b/pkg/resource/azurerm/azurerm_private_dns_zone.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzurePrivateDNSZoneResourceType = "azurerm_private_dns_zone" -func initAzurePrivateDNSZoneMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzurePrivateDNSZoneMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AzurePrivateDNSZoneResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"number_of_record_sets"}) res.Attributes().SafeDelete([]string{"timeouts"}) diff --git a/pkg/resource/azurerm/azurerm_public_ip.go b/pkg/resource/azurerm/azurerm_public_ip.go index ac3d07102..3d7b75836 100644 --- a/pkg/resource/azurerm/azurerm_public_ip.go +++ b/pkg/resource/azurerm/azurerm_public_ip.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzurePublicIPResourceType = "azurerm_public_ip" -func initAzurePublicIPMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzurePublicIPMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzurePublicIPResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/pkg/resource/azurerm/azurerm_resource_group.go b/pkg/resource/azurerm/azurerm_resource_group.go index f30885cb7..28dc2d05d 100644 --- a/pkg/resource/azurerm/azurerm_resource_group.go +++ b/pkg/resource/azurerm/azurerm_resource_group.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzureResourceGroupResourceType = "azurerm_resource_group" -func initAzureResourceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzureResourceGroupMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureResourceGroupResourceType, func(res *resource.Resource) map[string]string { val := res.Attrs attrs := make(map[string]string) diff --git a/pkg/resource/azurerm/azurerm_route.go b/pkg/resource/azurerm/azurerm_route.go index 35ef2c128..11eecaf25 100644 --- a/pkg/resource/azurerm/azurerm_route.go +++ b/pkg/resource/azurerm/azurerm_route.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzureRouteResourceType = "azurerm_route" -func initAzureRouteMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzureRouteMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureRouteResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) diff --git a/pkg/resource/azurerm/azurerm_route_table.go b/pkg/resource/azurerm/azurerm_route_table.go index acfb26d97..7cd04d30d 100644 --- a/pkg/resource/azurerm/azurerm_route_table.go +++ b/pkg/resource/azurerm/azurerm_route_table.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzureRouteTableResourceType = "azurerm_route_table" -func initAzureRouteTableMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzureRouteTableMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureRouteTableResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) diff --git a/pkg/resource/azurerm/azurerm_ssh_public_key.go b/pkg/resource/azurerm/azurerm_ssh_public_key.go index a82f894a2..30fb3b6a7 100644 --- a/pkg/resource/azurerm/azurerm_ssh_public_key.go +++ b/pkg/resource/azurerm/azurerm_ssh_public_key.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzureSSHPublicKeyResourceType = "azurerm_ssh_public_key" -func initAzureSSHPublicKeyMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzureSSHPublicKeyMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(AzureSSHPublicKeyResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/azurerm/azurerm_virtual_network.go b/pkg/resource/azurerm/azurerm_virtual_network.go index a8e358fae..8424d8375 100644 --- a/pkg/resource/azurerm/azurerm_virtual_network.go +++ b/pkg/resource/azurerm/azurerm_virtual_network.go @@ -1,10 +1,13 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const AzureVirtualNetworkResourceType = "azurerm_virtual_network" -func initAzureVirtualNetworkMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initAzureVirtualNetworkMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(AzureVirtualNetworkResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) diff --git a/pkg/resource/azurerm/metadata.go b/pkg/resource/azurerm/metadata.go index 86f14f31b..a01b75339 100644 --- a/pkg/resource/azurerm/metadata.go +++ b/pkg/resource/azurerm/metadata.go @@ -1,6 +1,8 @@ package azurerm -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/pkg/resource" +) func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { initAzureContainerRegistryMetadata(resourceSchemaRepository) diff --git a/pkg/resource/azurerm/metadata_test.go b/pkg/resource/azurerm/metadata_test.go index 725a4c13d..9bb7c91b0 100644 --- a/pkg/resource/azurerm/metadata_test.go +++ b/pkg/resource/azurerm/metadata_test.go @@ -1,44 +1,45 @@ -package azurerm +package azurerm_test import ( "testing" "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/pkg/resource/azurerm" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" ) func TestAzureMetadata_Flags(t *testing.T) { testcases := map[string][]resource.Flags{ - AzureContainerRegistryResourceType: {}, - AzureFirewallResourceType: {}, - AzurePostgresqlServerResourceType: {}, - AzurePostgresqlDatabaseResourceType: {}, - AzurePublicIPResourceType: {}, - AzureResourceGroupResourceType: {}, - AzureRouteResourceType: {}, - AzureRouteTableResourceType: {}, - AzureStorageAccountResourceType: {}, - AzureStorageContainerResourceType: {}, - AzureSubnetResourceType: {}, - AzureVirtualNetworkResourceType: {}, - AzureNetworkSecurityGroupResourceType: {resource.FlagDeepMode}, - AzureLoadBalancerResourceType: {}, - AzurePrivateDNSZoneResourceType: {resource.FlagDeepMode}, - AzurePrivateDNSARecordResourceType: {resource.FlagDeepMode}, - AzurePrivateDNSAAAARecordResourceType: {resource.FlagDeepMode}, - AzurePrivateDNSCNameRecordResourceType: {resource.FlagDeepMode}, - AzurePrivateDNSPTRRecordResourceType: {resource.FlagDeepMode}, - AzurePrivateDNSMXRecordResourceType: {resource.FlagDeepMode}, - AzurePrivateDNSSRVRecordResourceType: {resource.FlagDeepMode}, - AzurePrivateDNSTXTRecordResourceType: {resource.FlagDeepMode}, - AzureImageResourceType: {}, - AzureSSHPublicKeyResourceType: {resource.FlagDeepMode}, - AzureLoadBalancerRuleResourceType: {resource.FlagDeepMode}, + azurerm.AzureContainerRegistryResourceType: {}, + azurerm.AzureFirewallResourceType: {}, + azurerm.AzurePostgresqlServerResourceType: {}, + azurerm.AzurePostgresqlDatabaseResourceType: {}, + azurerm.AzurePublicIPResourceType: {}, + azurerm.AzureResourceGroupResourceType: {}, + azurerm.AzureRouteResourceType: {}, + azurerm.AzureRouteTableResourceType: {}, + azurerm.AzureStorageAccountResourceType: {}, + azurerm.AzureStorageContainerResourceType: {}, + azurerm.AzureSubnetResourceType: {}, + azurerm.AzureVirtualNetworkResourceType: {}, + azurerm.AzureNetworkSecurityGroupResourceType: {resource.FlagDeepMode}, + azurerm.AzureLoadBalancerResourceType: {}, + azurerm.AzurePrivateDNSZoneResourceType: {resource.FlagDeepMode}, + azurerm.AzurePrivateDNSARecordResourceType: {resource.FlagDeepMode}, + azurerm.AzurePrivateDNSAAAARecordResourceType: {resource.FlagDeepMode}, + azurerm.AzurePrivateDNSCNameRecordResourceType: {resource.FlagDeepMode}, + azurerm.AzurePrivateDNSPTRRecordResourceType: {resource.FlagDeepMode}, + azurerm.AzurePrivateDNSMXRecordResourceType: {resource.FlagDeepMode}, + azurerm.AzurePrivateDNSSRVRecordResourceType: {resource.FlagDeepMode}, + azurerm.AzurePrivateDNSTXTRecordResourceType: {resource.FlagDeepMode}, + azurerm.AzureImageResourceType: {}, + azurerm.AzureSSHPublicKeyResourceType: {resource.FlagDeepMode}, + azurerm.AzureLoadBalancerRuleResourceType: {resource.FlagDeepMode}, } schemaRepository := testresource.InitFakeSchemaRepository("azurerm", "2.71.0") - InitResourcesMetadata(schemaRepository) + azurerm.InitResourcesMetadata(schemaRepository) for ty, flags := range testcases { t.Run(ty, func(tt *testing.T) { diff --git a/pkg/resource/factory.go b/pkg/resource/factory.go index 85ad4f0b3..989a1e1c3 100644 --- a/pkg/resource/factory.go +++ b/pkg/resource/factory.go @@ -1,16 +1,18 @@ package resource -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" +) type ResourceFactory interface { CreateAbstractResource(ty, id string, data map[string]interface{}) *resource.Resource } type DriftctlResourceFactory struct { - resourceSchemaRepository resource.SchemaRepositoryInterface + resourceSchemaRepository SchemaRepositoryInterface } -func NewDriftctlResourceFactory(resourceSchemaRepository resource.SchemaRepositoryInterface) *DriftctlResourceFactory { +func NewDriftctlResourceFactory(resourceSchemaRepository SchemaRepositoryInterface) *DriftctlResourceFactory { return &DriftctlResourceFactory{ resourceSchemaRepository: resourceSchemaRepository, } @@ -28,7 +30,7 @@ func (r *DriftctlResourceFactory) CreateAbstractResource(ty, id string, data map Sch: schema, } - schema, exist := r.resourceSchemaRepository.(*resource.SchemaRepository).GetSchema(ty) + schema, exist := r.resourceSchemaRepository.GetSchema(ty) if exist && schema.NormalizeFunc != nil { schema.NormalizeFunc(&res) } diff --git a/pkg/resource/github/github_branch_protection.go b/pkg/resource/github/github_branch_protection.go index 0a4d87fa0..f20e7e8b1 100644 --- a/pkg/resource/github/github_branch_protection.go +++ b/pkg/resource/github/github_branch_protection.go @@ -2,13 +2,13 @@ package github import ( "encoding/base64" - "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GithubBranchProtectionResourceType = "github_branch_protection" -func initGithubBranchProtectionMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGithubBranchProtectionMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GithubBranchProtectionResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"repository_id"}) // Terraform provider is always returning nil diff --git a/pkg/resource/github/github_membership.go b/pkg/resource/github/github_membership.go index e41974b7a..aca43a561 100644 --- a/pkg/resource/github/github_membership.go +++ b/pkg/resource/github/github_membership.go @@ -2,11 +2,12 @@ package github import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GithubMembershipResourceType = "github_membership" -func initGithubMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGithubMembershipMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GithubMembershipResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"etag"}) diff --git a/pkg/resource/github/github_repository.go b/pkg/resource/github/github_repository.go index c399b374f..a5296ff2b 100644 --- a/pkg/resource/github/github_repository.go +++ b/pkg/resource/github/github_repository.go @@ -2,11 +2,12 @@ package github import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GithubRepositoryResourceType = "github_repository" -func initGithubRepositoryMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGithubRepositoryMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GithubRepositoryResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"auto_init"}) diff --git a/pkg/resource/github/github_team.go b/pkg/resource/github/github_team.go index ececcc696..9bff4ef7f 100644 --- a/pkg/resource/github/github_team.go +++ b/pkg/resource/github/github_team.go @@ -2,11 +2,12 @@ package github import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GithubTeamResourceType = "github_team" -func initGithubTeamMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGithubTeamMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GithubTeamResourceType, func(res *resource.Resource) { val := res.Attrs if defaultMaintainer, exist := val.Get("create_default_maintainer"); !exist || defaultMaintainer == nil { diff --git a/pkg/resource/github/github_team_membership.go b/pkg/resource/github/github_team_membership.go index fbc32ae2f..8b3889085 100644 --- a/pkg/resource/github/github_team_membership.go +++ b/pkg/resource/github/github_team_membership.go @@ -2,11 +2,12 @@ package github import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GithubTeamMembershipResourceType = "github_team_membership" -func initGithubTeamMembershipMetaData(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGithubTeamMembershipMetaData(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GithubTeamMembershipResourceType, func(res *resource.Resource) { val := res.Attrs val.SafeDelete([]string{"etag"}) diff --git a/pkg/resource/github/metadata_test.go b/pkg/resource/github/metadata_test.go index fd0977d8b..34150fdcf 100644 --- a/pkg/resource/github/metadata_test.go +++ b/pkg/resource/github/metadata_test.go @@ -1,24 +1,25 @@ -package github +package github_test import ( "testing" "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/pkg/resource/github" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" ) func TestGitHub_Metadata_Flags(t *testing.T) { testcases := map[string][]resource.Flags{ - GithubBranchProtectionResourceType: {resource.FlagDeepMode}, - GithubMembershipResourceType: {resource.FlagDeepMode}, - GithubTeamMembershipResourceType: {resource.FlagDeepMode}, - GithubRepositoryResourceType: {resource.FlagDeepMode}, - GithubTeamResourceType: {resource.FlagDeepMode}, + github.GithubBranchProtectionResourceType: {resource.FlagDeepMode}, + github.GithubMembershipResourceType: {resource.FlagDeepMode}, + github.GithubTeamMembershipResourceType: {resource.FlagDeepMode}, + github.GithubRepositoryResourceType: {resource.FlagDeepMode}, + github.GithubTeamResourceType: {resource.FlagDeepMode}, } schemaRepository := testresource.InitFakeSchemaRepository("github", "4.4.0") - InitResourcesMetadata(schemaRepository) + github.InitResourcesMetadata(schemaRepository) for ty, flags := range testcases { t.Run(ty, func(tt *testing.T) { diff --git a/pkg/resource/github/metadatas.go b/pkg/resource/github/metadatas.go index 246227851..ea01b024a 100644 --- a/pkg/resource/github/metadatas.go +++ b/pkg/resource/github/metadatas.go @@ -1,6 +1,8 @@ package github -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/pkg/resource" +) func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { initGithubBranchProtectionMetaData(resourceSchemaRepository) diff --git a/pkg/resource/google/google_bigquery_dataset.go b/pkg/resource/google/google_bigquery_dataset.go index c37e423da..4a3bfc5cf 100644 --- a/pkg/resource/google/google_bigquery_dataset.go +++ b/pkg/resource/google/google_bigquery_dataset.go @@ -2,11 +2,12 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GoogleBigqueryDatasetResourceType = "google_bigquery_dataset" -func initGoogleBigqueryDatasetMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleBigqueryDatasetMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleBigqueryDatasetResourceType, func(res *resource.Resource) map[string]string { return map[string]string{ "name": *res.Attrs.GetString("friendly_name"), diff --git a/pkg/resource/google/google_bigquery_table.go b/pkg/resource/google/google_bigquery_table.go index 9c39658d1..eae644ee3 100644 --- a/pkg/resource/google/google_bigquery_table.go +++ b/pkg/resource/google/google_bigquery_table.go @@ -1,10 +1,13 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const GoogleBigqueryTableResourceType = "google_bigquery_table" -func initGoogleBigqueryTableMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleBigqueryTableMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleBigqueryTableResourceType, func(res *resource.Resource) map[string]string { return map[string]string{ "name": *res.Attrs.GetString("friendly_name"), diff --git a/pkg/resource/google/google_compute_address.go b/pkg/resource/google/google_compute_address.go index a37732855..b8d328e41 100644 --- a/pkg/resource/google/google_compute_address.go +++ b/pkg/resource/google/google_compute_address.go @@ -1,10 +1,13 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const GoogleComputeAddressResourceType = "google_compute_address" -func initGoogleComputeAddressMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleComputeAddressMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeAddressResourceType, func(res *resource.Resource) map[string]string { return map[string]string{ "Name": *res.Attributes().GetString("name"), diff --git a/pkg/resource/google/google_compute_disk.go b/pkg/resource/google/google_compute_disk.go index ed40a222e..fe0a70c69 100644 --- a/pkg/resource/google/google_compute_disk.go +++ b/pkg/resource/google/google_compute_disk.go @@ -1,10 +1,13 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const GoogleComputeDiskResourceType = "google_compute_disk" -func initGoogleComputeDiskMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleComputeDiskMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeDiskResourceType, func(res *resource.Resource) map[string]string { return map[string]string{ "Name": *res.Attributes().GetString("name"), diff --git a/pkg/resource/google/google_compute_firewall.go b/pkg/resource/google/google_compute_firewall.go index 7f7d912da..79621aca5 100644 --- a/pkg/resource/google/google_compute_firewall.go +++ b/pkg/resource/google/google_compute_firewall.go @@ -2,11 +2,12 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GoogleComputeFirewallResourceType = "google_compute_firewall" -func initGoogleComputeFirewallMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleComputeFirewallMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GoogleComputeFirewallResourceType, func(res *resource.Resource) { res.Attrs.SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/google/google_compute_global_address.go b/pkg/resource/google/google_compute_global_address.go index 1c3af037c..e04cb330d 100644 --- a/pkg/resource/google/google_compute_global_address.go +++ b/pkg/resource/google/google_compute_global_address.go @@ -1,10 +1,13 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const GoogleComputeGlobalAddressResourceType = "google_compute_global_address" -func initGoogleComputeGlobalAddressMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleComputeGlobalAddressMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeGlobalAddressResourceType, func(res *resource.Resource) map[string]string { return map[string]string{ "Name": *res.Attributes().GetString("name"), diff --git a/pkg/resource/google/google_compute_health_check.go b/pkg/resource/google/google_compute_health_check.go index c33b81731..598cd379d 100644 --- a/pkg/resource/google/google_compute_health_check.go +++ b/pkg/resource/google/google_compute_health_check.go @@ -1,10 +1,13 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const GoogleComputeHealthCheckResourceType = "google_compute_health_check" -func initGoogleComputeHealthCheckMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleComputeHealthCheckMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeHealthCheckResourceType, func(res *resource.Resource) map[string]string { return map[string]string{ "Name": *res.Attributes().GetString("name"), diff --git a/pkg/resource/google/google_compute_image.go b/pkg/resource/google/google_compute_image.go index f52788da5..6159c9182 100644 --- a/pkg/resource/google/google_compute_image.go +++ b/pkg/resource/google/google_compute_image.go @@ -1,10 +1,13 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const GoogleComputeImageResourceType = "google_compute_image" -func initGoogleComputeImageMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleComputeImageMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeImageResourceType, func(res *resource.Resource) map[string]string { return map[string]string{ "Name": *res.Attributes().GetString("name"), diff --git a/pkg/resource/google/google_compute_instance_group.go b/pkg/resource/google/google_compute_instance_group.go index 2d5c288e4..fd43bff13 100644 --- a/pkg/resource/google/google_compute_instance_group.go +++ b/pkg/resource/google/google_compute_instance_group.go @@ -2,11 +2,12 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GoogleComputeInstanceGroupResourceType = "google_compute_instance_group" -func initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleComputeInstanceGroupMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GoogleComputeInstanceGroupResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) }) diff --git a/pkg/resource/google/google_compute_instance_group_manager.go b/pkg/resource/google/google_compute_instance_group_manager.go index 35ab1fbbc..403d5c23c 100644 --- a/pkg/resource/google/google_compute_instance_group_manager.go +++ b/pkg/resource/google/google_compute_instance_group_manager.go @@ -1,10 +1,13 @@ package google -import "github.com/snyk/driftctl/enumeration/resource" +import ( + "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" +) const GoogleComputeInstanceGroupManagerResourceType = "google_compute_instance_group_manager" -func initComputeInstanceGroupManagerMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initComputeInstanceGroupManagerMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetHumanReadableAttributesFunc(GoogleComputeInstanceGroupManagerResourceType, func(res *resource.Resource) map[string]string { attrs := make(map[string]string) if v := res.Attributes().GetString("name"); v != nil && *v != "" { diff --git a/pkg/resource/google/google_compute_network.go b/pkg/resource/google/google_compute_network.go index 0032f5954..d8fd65a4f 100644 --- a/pkg/resource/google/google_compute_network.go +++ b/pkg/resource/google/google_compute_network.go @@ -2,11 +2,12 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GoogleComputeNetworkResourceType = "google_compute_network" -func initGoogleComputeNetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleComputeNetworkMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GoogleComputeNetworkResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"self_link"}) diff --git a/pkg/resource/google/google_compute_subnetwork.go b/pkg/resource/google/google_compute_subnetwork.go index 89b9d3952..2ef023437 100644 --- a/pkg/resource/google/google_compute_subnetwork.go +++ b/pkg/resource/google/google_compute_subnetwork.go @@ -2,11 +2,12 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GoogleComputeSubnetworkResourceType = "google_compute_subnetwork" -func initGoogleComputeSubnetworkMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleComputeSubnetworkMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GoogleComputeSubnetworkResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"timeouts"}) res.Attributes().SafeDelete([]string{"self_link"}) diff --git a/pkg/resource/google/google_project_iam_member.go b/pkg/resource/google/google_project_iam_member.go index f3b06bf26..9a5866e40 100644 --- a/pkg/resource/google/google_project_iam_member.go +++ b/pkg/resource/google/google_project_iam_member.go @@ -2,11 +2,12 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GoogleProjectIamMemberResourceType = "google_project_iam_member" -func initGoogleProjectIAMMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleProjectIAMMemberMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GoogleProjectIamMemberResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"force_destroy"}) res.Attributes().SafeDelete([]string{"etag"}) diff --git a/pkg/resource/google/google_storage_bucket.go b/pkg/resource/google/google_storage_bucket.go index 9ce508f18..1961d9353 100644 --- a/pkg/resource/google/google_storage_bucket.go +++ b/pkg/resource/google/google_storage_bucket.go @@ -2,11 +2,12 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GoogleStorageBucketResourceType = "google_storage_bucket" -func initGoogleStorageBucketMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleStorageBucketMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GoogleStorageBucketResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"force_destroy"}) }) diff --git a/pkg/resource/google/google_storage_bucket_iam_member.go b/pkg/resource/google/google_storage_bucket_iam_member.go index a33c26fc3..247f81c7b 100644 --- a/pkg/resource/google/google_storage_bucket_iam_member.go +++ b/pkg/resource/google/google_storage_bucket_iam_member.go @@ -2,11 +2,12 @@ package google import ( "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const GoogleStorageBucketIamMemberResourceType = "google_storage_bucket_iam_member" -func initGoogleStorageBucketIamBMemberMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { +func initGoogleStorageBucketIamBMemberMetadata(resourceSchemaRepository dctlresource.SchemaRepositoryInterface) { resourceSchemaRepository.SetNormalizeFunc(GoogleStorageBucketIamMemberResourceType, func(res *resource.Resource) { res.Attributes().SafeDelete([]string{"force_destroy"}) res.Attributes().SafeDelete([]string{"etag"}) diff --git a/pkg/resource/google/metadata_test.go b/pkg/resource/google/metadata_test.go index 7181e2126..602c247ce 100644 --- a/pkg/resource/google/metadata_test.go +++ b/pkg/resource/google/metadata_test.go @@ -1,42 +1,43 @@ -package google +package google_test import ( "testing" "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/pkg/resource/google" testresource "github.com/snyk/driftctl/test/resource" "github.com/stretchr/testify/assert" ) func TestGoogle_Metadata_Flags(t *testing.T) { testcases := map[string][]resource.Flags{ - GoogleBigqueryDatasetResourceType: {}, - GoogleComputeFirewallResourceType: {resource.FlagDeepMode}, - GoogleComputeInstanceResourceType: {}, - GoogleComputeInstanceGroupResourceType: {resource.FlagDeepMode}, - GoogleComputeNetworkResourceType: {resource.FlagDeepMode}, - GoogleComputeRouterResourceType: {}, - GoogleDNSManagedZoneResourceType: {}, - GoogleProjectIamBindingResourceType: {}, - GoogleProjectIamMemberResourceType: {resource.FlagDeepMode}, - GoogleProjectIamPolicyResourceType: {}, - GoogleStorageBucketResourceType: {resource.FlagDeepMode}, - GoogleStorageBucketIamBindingResourceType: {}, - GoogleStorageBucketIamMemberResourceType: {resource.FlagDeepMode}, - GoogleStorageBucketIamPolicyResourceType: {}, - GoogleBigqueryTableResourceType: {}, - GoogleComputeDiskResourceType: {}, - GoogleBigTableInstanceResourceType: {}, - GoogleComputeGlobalAddressResourceType: {}, - GoogleCloudRunServiceResourceType: {}, - GoogleComputeNodeGroupResourceType: {}, - GoogleComputeForwardingRuleResourceType: {}, - GoogleComputeInstanceGroupManagerResourceType: {}, - GoogleComputeGlobalForwardingRuleResourceType: {}, + google.GoogleBigqueryDatasetResourceType: {}, + google.GoogleComputeFirewallResourceType: {resource.FlagDeepMode}, + google.GoogleComputeInstanceResourceType: {}, + google.GoogleComputeInstanceGroupResourceType: {resource.FlagDeepMode}, + google.GoogleComputeNetworkResourceType: {resource.FlagDeepMode}, + google.GoogleComputeRouterResourceType: {}, + google.GoogleDNSManagedZoneResourceType: {}, + google.GoogleProjectIamBindingResourceType: {}, + google.GoogleProjectIamMemberResourceType: {resource.FlagDeepMode}, + google.GoogleProjectIamPolicyResourceType: {}, + google.GoogleStorageBucketResourceType: {resource.FlagDeepMode}, + google.GoogleStorageBucketIamBindingResourceType: {}, + google.GoogleStorageBucketIamMemberResourceType: {resource.FlagDeepMode}, + google.GoogleStorageBucketIamPolicyResourceType: {}, + google.GoogleBigqueryTableResourceType: {}, + google.GoogleComputeDiskResourceType: {}, + google.GoogleBigTableInstanceResourceType: {}, + google.GoogleComputeGlobalAddressResourceType: {}, + google.GoogleCloudRunServiceResourceType: {}, + google.GoogleComputeNodeGroupResourceType: {}, + google.GoogleComputeForwardingRuleResourceType: {}, + google.GoogleComputeInstanceGroupManagerResourceType: {}, + google.GoogleComputeGlobalForwardingRuleResourceType: {}, } schemaRepository := testresource.InitFakeSchemaRepository("google", "3.78.0") - InitResourcesMetadata(schemaRepository) + google.InitResourcesMetadata(schemaRepository) for ty, flags := range testcases { t.Run(ty, func(tt *testing.T) { diff --git a/pkg/resource/google/metadatas.go b/pkg/resource/google/metadatas.go index 0666ba742..72c446ee3 100644 --- a/pkg/resource/google/metadatas.go +++ b/pkg/resource/google/metadatas.go @@ -1,7 +1,7 @@ package google import ( - "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/pkg/resource" ) func InitResourcesMetadata(resourceSchemaRepository resource.SchemaRepositoryInterface) { diff --git a/pkg/resource/schemas.go b/pkg/resource/schemas.go new file mode 100644 index 000000000..48c20b270 --- /dev/null +++ b/pkg/resource/schemas.go @@ -0,0 +1,12 @@ +package resource + +import "github.com/snyk/driftctl/enumeration/resource" + +type SchemaRepositoryInterface interface { + GetSchema(resourceType string) (*resource.Schema, bool) + SetFlags(typ string, flags ...resource.Flags) + UpdateSchema(typ string, schemasMutators map[string]func(attributeSchema *resource.AttributeSchema)) + SetNormalizeFunc(typ string, normalizeFunc func(res *resource.Resource)) + SetHumanReadableAttributesFunc(typ string, humanReadableAttributesFunc func(res *resource.Resource) map[string]string) + SetDiscriminantFunc(string, func(*resource.Resource, *resource.Resource) bool) +} diff --git a/pkg/resource/schemas/repository.go b/pkg/resource/schemas/repository.go new file mode 100644 index 000000000..fe09f15b8 --- /dev/null +++ b/pkg/resource/schemas/repository.go @@ -0,0 +1,134 @@ +package schemas + +import ( + "strings" + + "github.com/hashicorp/go-version" + "github.com/hashicorp/terraform/configs/configschema" + "github.com/hashicorp/terraform/providers" + "github.com/pkg/errors" + "github.com/sirupsen/logrus" + "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/pkg/resource/aws" + "github.com/snyk/driftctl/pkg/resource/azurerm" + "github.com/snyk/driftctl/pkg/resource/github" + "github.com/snyk/driftctl/pkg/resource/google" +) + +type SchemaRepository struct { + schemas map[string]*resource.Schema +} + +func NewSchemaRepository() *SchemaRepository { + return &SchemaRepository{ + schemas: make(map[string]*resource.Schema), + } +} + +func (r *SchemaRepository) GetSchema(resourceType string) (*resource.Schema, bool) { + schema, exist := r.schemas[resourceType] + return schema, exist +} + +func (r *SchemaRepository) fetchNestedBlocks(root string, metadata map[string]resource.AttributeSchema, block map[string]*configschema.NestedBlock) { + for s, nestedBlock := range block { + path := s + if root != "" { + path = strings.Join([]string{root, s}, ".") + } + for s2, attr := range nestedBlock.Attributes { + nestedPath := strings.Join([]string{path, s2}, ".") + metadata[nestedPath] = resource.AttributeSchema{ + ConfigSchema: *attr, + } + } + r.fetchNestedBlocks(path, metadata, nestedBlock.BlockTypes) + } +} + +func (r *SchemaRepository) Init(providerName, providerVersion string, schema map[string]providers.Schema) error { + v, err := version.NewVersion(providerVersion) + if err != nil { + return err + } + for typ, sch := range schema { + attributeMetas := map[string]resource.AttributeSchema{} + for s, attribute := range sch.Block.Attributes { + attributeMetas[s] = resource.AttributeSchema{ + ConfigSchema: *attribute, + } + } + + r.fetchNestedBlocks("", attributeMetas, sch.Block.BlockTypes) + + r.schemas[typ] = &resource.Schema{ + ProviderVersion: v, + SchemaVersion: sch.Version, + Attributes: attributeMetas, + } + } + switch providerName { + case "aws": + aws.InitResourcesMetadata(r) + case "github": + github.InitResourcesMetadata(r) + case "google": + google.InitResourcesMetadata(r) + case "azurerm": + azurerm.InitResourcesMetadata(r) + default: + return errors.Errorf("unsupported remote '%s'", providerName) + } + return nil +} + +func (r SchemaRepository) SetFlags(typ string, flags ...resource.Flags) { + metadata, exist := r.GetSchema(typ) + if !exist { + logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set flags, no schema found") + return + } + for _, flag := range flags { + metadata.Flags.AddFlag(flag) + } +} + +func (r *SchemaRepository) UpdateSchema(typ string, schemasMutators map[string]func(attributeSchema *resource.AttributeSchema)) { + for s, f := range schemasMutators { + metadata, exist := r.GetSchema(typ) + if !exist { + logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set metadata, no schema found") + return + } + m := (*metadata).Attributes[s] + f(&m) + (*metadata).Attributes[s] = m + } +} + +func (r *SchemaRepository) SetNormalizeFunc(typ string, normalizeFunc func(res *resource.Resource)) { + metadata, exist := r.GetSchema(typ) + if !exist { + logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set normalize func, no schema found") + return + } + (*metadata).NormalizeFunc = normalizeFunc +} + +func (r *SchemaRepository) SetHumanReadableAttributesFunc(typ string, humanReadableAttributesFunc func(res *resource.Resource) map[string]string) { + metadata, exist := r.GetSchema(typ) + if !exist { + logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to add human readable attributes, no schema found") + return + } + (*metadata).HumanReadableAttributesFunc = humanReadableAttributesFunc +} + +func (r *SchemaRepository) SetDiscriminantFunc(typ string, fn func(self, res *resource.Resource) bool) { + metadata, exist := r.GetSchema(typ) + if !exist { + logrus.WithFields(logrus.Fields{"type": typ}).Warning("Unable to set discriminant function, no schema found") + return + } + (*metadata).DiscriminantFunc = fn +} diff --git a/test/resource/resource.go b/test/resource/resource.go index f720d3925..84a8492f6 100644 --- a/test/resource/resource.go +++ b/test/resource/resource.go @@ -1,22 +1,23 @@ -package resource +package resource_test import ( "github.com/hashicorp/terraform/providers" - "github.com/snyk/driftctl/enumeration/resource" - "github.com/snyk/driftctl/test/schemas" + "github.com/snyk/driftctl/pkg/resource" + "github.com/snyk/driftctl/pkg/resource/schemas" + testschemas "github.com/snyk/driftctl/test/schemas" ) func InitFakeSchemaRepository(provider, version string) resource.SchemaRepositoryInterface { - repo := resource.NewSchemaRepository() + repo := schemas.NewSchemaRepository() schema := make(map[string]providers.Schema) if provider != "" { - s, err := schemas.ReadTestSchema(provider, version) + s, err := testschemas.ReadTestSchema(provider, version) if err != nil { // TODO HANDLER ERROR PROPERLY panic(err) } schema = s } - _ = repo.Init("Fake", "1.0.0", schema) + _ = repo.Init(provider, version, schema) return repo } From 34504d6147872d83c91d30d89e3349f10ca6a095 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Fri, 22 Jul 2022 11:25:58 +0200 Subject: [PATCH 4/9] chore: remove useless factory mock --- pkg/driftctl_test.go | 389 +------------------------------------------ 1 file changed, 2 insertions(+), 387 deletions(-) diff --git a/pkg/driftctl_test.go b/pkg/driftctl_test.go index 14126cb41..040c26a3a 100644 --- a/pkg/driftctl_test.go +++ b/pkg/driftctl_test.go @@ -30,7 +30,6 @@ type TestCase struct { provider *TestProvider stateResources []*resource.Resource remoteResources []*resource.Resource - mocks func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) assert func(t *testing.T, result *test.ScanResult, err error) assertStore func(*testing.T, memstore.Store) options *pkg.ScanOptions @@ -76,11 +75,6 @@ func runTest(t *testing.T, cases TestCases) { var resourceFactory resource.ResourceFactory = dctlresource.NewDriftctlResourceFactory(repo) - if c.mocks != nil { - resourceFactory = &dctlresource.MockResourceFactory{} - c.mocks(resourceFactory, repo) - } - if c.options == nil { c.options = &pkg.ScanOptions{Deep: true} } @@ -360,24 +354,6 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { }, { name: "we should ignore default AWS IAM role when strict mode is disabled", - mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { - factory.(*dctlresource.MockResourceFactory).On( - "CreateAbstractResource", - aws.AwsIamPolicyAttachmentResourceType, - "role-test-1-policy-test-1", - map[string]interface{}{ - "policy_arn": "policy-test-1", - "roles": []interface{}{"role-test-1"}, - }, - ).Once().Return(&resource.Resource{ - Id: "role-test-1-policy-test-1", - Type: aws.AwsIamPolicyAttachmentResourceType, - Attrs: &resource.Attributes{ - "policy_arn": "policy-test-1", - "roles": []interface{}{"role-test-1"}, - }, - }) - }, stateResources: []*resource.Resource{ &resource.Resource{ Id: "fake", @@ -458,24 +434,6 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { }, { name: "we should not ignore default AWS IAM role when strict mode is enabled", - mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { - factory.(*dctlresource.MockResourceFactory).On( - "CreateAbstractResource", - aws.AwsIamPolicyAttachmentResourceType, - "role-test-1-policy-test-1", - map[string]interface{}{ - "policy_arn": "policy-test-1", - "roles": []interface{}{"role-test-1"}, - }, - ).Once().Return(&resource.Resource{ - Id: "role-test-1-policy-test-1", - Type: aws.AwsIamPolicyAttachmentResourceType, - Attrs: &resource.Attributes{ - "policy_arn": "policy-test-1", - "roles": []interface{}{"role-test-1"}, - }, - }) - }, stateResources: []*resource.Resource{ &resource.Resource{ Id: "fake", @@ -556,24 +514,6 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { }, { name: "we should not ignore default AWS IAM role when strict mode is enabled and a filter is specified", - mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { - factory.(*dctlresource.MockResourceFactory).On( - "CreateAbstractResource", - aws.AwsIamPolicyAttachmentResourceType, - "role-test-1-policy-test-1", - map[string]interface{}{ - "policy_arn": "policy-test-1", - "roles": []interface{}{"role-test-1"}, - }, - ).Once().Return(&resource.Resource{ - Id: "role-test-1-policy-test-1", - Type: aws.AwsIamPolicyAttachmentResourceType, - Attrs: &resource.Attributes{ - "policy_arn": "policy-test-1", - "roles": []interface{}{"role-test-1"}, - }, - }) - }, stateResources: []*resource.Resource{ &resource.Resource{ Id: "fake", @@ -787,27 +727,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { - factory.(*dctlresource.MockResourceFactory).On( - "CreateAbstractResource", - aws.AwsS3BucketPolicyResourceType, - "foo", - map[string]interface{}{ - "id": "foo", - "bucket": "foo", - "policy": "{\"Id\":\"foo\"}", - }, - ).Once().Return(&resource.Resource{ - Id: "foo", - Type: aws.AwsS3BucketPolicyResourceType, - Attrs: &resource.Attributes{ - "id": "foo", - "bucket": "foo", - "policy": "{\"Id\":\"foo\"}", - }, - Sch: getSchema(repo, aws.AwsS3BucketPolicyResourceType), - }) - }, assert: func(t *testing.T, result *test.ScanResult, err error) { result.AssertManagedCount(1) result.AssertResourceHasDrift("foo", "aws_s3_bucket_policy", analyser.Change{ @@ -874,45 +793,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { - foo := resource.Resource{ - Id: "vol-018c5ae89895aca4c", - Type: "aws_ebs_volume", - Attrs: &resource.Attributes{ - "encrypted": true, - "multi_attach_enabled": false, - "availability_zone": "us-east-1", - }, - Sch: getSchema(repo, "aws_ebs_volume"), - } - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { - return matchByAttributes(input, map[string]interface{}{ - "id": "vol-018c5ae89895aca4c", - "availability_zone": "us-east-1", - "encrypted": true, - "multi_attach_enabled": false, - }) - })).Times(1).Return(&foo, nil) - - bar := resource.Resource{ - Id: "vol-02862d9b39045a3a4", - Type: "aws_ebs_volume", - Attrs: &resource.Attributes{ - "type": "gp2", - "multi_attach_enabled": false, - "availability_zone": "us-east-1", - }, - Sch: getSchema(repo, "aws_ebs_volume"), - } - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_ebs_volume", mock.Anything, mock.MatchedBy(func(input map[string]interface{}) bool { - return matchByAttributes(input, map[string]interface{}{ - "id": "vol-02862d9b39045a3a4", - "availability_zone": "us-east-1", - "type": "gp2", - "multi_attach_enabled": false, - }) - })).Times(1).Return(&bar, nil) - }, assert: func(t *testing.T, result *test.ScanResult, err error) { result.AssertManagedCount(2) result.AssertResourceHasDrift("vol-02862d9b39045a3a4", "aws_ebs_volume", analyser.Change{ @@ -974,6 +854,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "origin": "CreateRoute", "destination_cidr_block": "0.0.0.0/0", "gateway_id": "igw-07b7844a8fd17a638", + "id": "r-table1080289494", "state": "active", }, }, @@ -985,50 +866,11 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "origin": "CreateRoute", "destination_ipv6_cidr_block": "::/0", "gateway_id": "igw-07b7844a8fd17a638", + "id": "r-table2750132062", "state": "active", }, }, }, - mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table1080289494", mock.MatchedBy(func(input map[string]interface{}) bool { - return matchByAttributes(input, map[string]interface{}{ - "destination_cidr_block": "0.0.0.0/0", - "gateway_id": "igw-07b7844a8fd17a638", - "origin": "CreateRoute", - "route_table_id": "table", - "state": "active", - }) - })).Times(1).Return(&resource.Resource{ - Id: "r-table1080289494", - Type: aws.AwsRouteResourceType, - Attrs: &resource.Attributes{ - "route_table_id": "table", - "origin": "CreateRoute", - "destination_cidr_block": "0.0.0.0/0", - "gateway_id": "igw-07b7844a8fd17a638", - "state": "active", - }, - }, nil) - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_route", "r-table2750132062", mock.MatchedBy(func(input map[string]interface{}) bool { - return matchByAttributes(input, map[string]interface{}{ - "destination_ipv6_cidr_block": "::/0", - "gateway_id": "igw-07b7844a8fd17a638", - "origin": "CreateRoute", - "route_table_id": "table", - "state": "active", - }) - })).Times(1).Return(&resource.Resource{ - Id: "r-table2750132062", - Type: aws.AwsRouteResourceType, - Attrs: &resource.Attributes{ - "route_table_id": "table", - "origin": "CreateRoute", - "destination_ipv6_cidr_block": "::/0", - "gateway_id": "igw-07b7844a8fd17a638", - "state": "active", - }, - }, nil) - }, assert: func(t *testing.T, result *test.ScanResult, err error) { result.AssertManagedCount(2) result.AssertInfrastructureIsInSync() @@ -1067,22 +909,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_sns_topic_policy", "foo", map[string]interface{}{ - "id": "foo", - "arn": "arn", - "policy": "{\"policy\":\"bar\"}", - }).Times(1).Return(&resource.Resource{ - Id: "foo", - Type: aws.AwsSnsTopicPolicyResourceType, - Attrs: &resource.Attributes{ - "id": "foo", - "arn": "arn", - "policy": "{\"policy\":\"bar\"}", - }, - Sch: getSchema(repo, aws.AwsSnsTopicPolicyResourceType), - }, nil) - }, assert: func(t *testing.T, result *test.ScanResult, err error) { result.AssertManagedCount(1) result.AssertResourceHasDrift("foo", "aws_sns_topic_policy", analyser.Change{ @@ -1129,22 +955,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_sqs_queue_policy", "foo", map[string]interface{}{ - "id": "foo", - "queue_url": "foo", - "policy": "{\"policy\":\"bar\"}", - }).Times(1).Return(&resource.Resource{ - Id: "foo", - Type: aws.AwsSqsQueuePolicyResourceType, - Attrs: &resource.Attributes{ - "id": "foo", - "queue_url": "foo", - "policy": "{\"policy\":\"bar\"}", - }, - Sch: getSchema(repo, aws.AwsSqsQueuePolicyResourceType), - }, nil) - }, assert: func(t *testing.T, result *test.ScanResult, err error) { result.AssertManagedCount(1) result.AssertResourceHasDrift("foo", "aws_sqs_queue_policy", analyser.Change{ @@ -1265,8 +1075,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "from_port": float64(0), "to_port": float64(0), "cidr_blocks": []interface{}{"0.0.0.0/0"}, - "ipv6_cidr_blocks": []interface{}{}, - "prefix_list_ids": []interface{}{}, }, }, &resource.Resource{ @@ -1279,9 +1087,7 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "protocol": "-1", "from_port": float64(0), "to_port": float64(0), - "cidr_blocks": []interface{}{}, "ipv6_cidr_blocks": []interface{}{"::/0"}, - "prefix_list_ids": []interface{}{}, }, }, &resource.Resource{ @@ -1295,8 +1101,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "from_port": float64(0), "to_port": float64(0), "cidr_blocks": []interface{}{"5.6.7.0/24"}, - "ipv6_cidr_blocks": []interface{}{}, - "prefix_list_ids": []interface{}{}, }, }, &resource.Resource{ @@ -1310,8 +1114,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) { "from_port": float64(0), "to_port": float64(0), "cidr_blocks": []interface{}{"1.2.0.0/16"}, - "ipv6_cidr_blocks": []interface{}{}, - "prefix_list_ids": []interface{}{}, }, }, &resource.Resource{ @@ -1341,135 +1143,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { - rule1 := resource.Resource{ - Type: aws.AwsSecurityGroupRuleResourceType, - Id: "sgrule-1707973622", - Attrs: &resource.Attributes{ - "id": "sgrule-1707973622", - "type": "egress", - "security_group_id": "sg-0254c038e32f25530", - "protocol": "-1", - "from_port": float64(0), - "to_port": float64(0), - "cidr_blocks": []interface{}{ - "0.0.0.0/0", - }, - "ipv6_cidr_blocks": []interface{}{}, - "prefix_list_ids": []interface{}{}, - }, - } - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule1.Id, - mock.MatchedBy(func(input map[string]interface{}) bool { - return matchByAttributes(input, map[string]interface{}{ - "id": "sgrule-1707973622", - "type": "egress", - "security_group_id": "sg-0254c038e32f25530", - "protocol": "-1", - "from_port": float64(0), - "to_port": float64(0), - "cidr_blocks": []interface{}{"0.0.0.0/0"}, - "ipv6_cidr_blocks": []interface{}{}, - "prefix_list_ids": []interface{}{}, - }) - })).Times(1).Return(&rule1, nil) - - rule2 := resource.Resource{ - Type: aws.AwsSecurityGroupRuleResourceType, - Id: "sgrule-2821752134", - Attrs: &resource.Attributes{ - "id": "sgrule-2821752134", - "type": "egress", - "security_group_id": "sg-0254c038e32f25530", - "protocol": "-1", - "from_port": float64(0), - "to_port": float64(0), - "cidr_blocks": []interface{}{}, - "ipv6_cidr_blocks": []interface{}{ - "::/0", - }, - "prefix_list_ids": []interface{}{}, - }, - } - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule2.Id, - mock.MatchedBy(func(input map[string]interface{}) bool { - return matchByAttributes(input, map[string]interface{}{ - "id": "sgrule-2821752134", - "type": "egress", - "security_group_id": "sg-0254c038e32f25530", - "protocol": "-1", - "from_port": float64(0), - "to_port": float64(0), - "cidr_blocks": []interface{}{}, - "ipv6_cidr_blocks": []interface{}{"::/0"}, - "prefix_list_ids": []interface{}{}, - }) - })).Times(1).Return(&rule2, nil) - - rule3 := resource.Resource{ - Type: aws.AwsSecurityGroupRuleResourceType, - Id: "sgrule-2165103420", - Attrs: &resource.Attributes{ - "id": "sgrule-2165103420", - "type": "ingress", - "security_group_id": "sg-0254c038e32f25530", - "protocol": "-1", - "from_port": float64(0), - "to_port": float64(0), - "cidr_blocks": []interface{}{ - "5.6.7.0/24", - }, - "ipv6_cidr_blocks": []interface{}{}, - "prefix_list_ids": []interface{}{}, - }, - } - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule3.Id, - mock.MatchedBy(func(input map[string]interface{}) bool { - return matchByAttributes(input, map[string]interface{}{ - "id": "sgrule-2165103420", - "type": "ingress", - "security_group_id": "sg-0254c038e32f25530", - "protocol": "-1", - "from_port": float64(0), - "to_port": float64(0), - "cidr_blocks": []interface{}{"5.6.7.0/24"}, - "ipv6_cidr_blocks": []interface{}{}, - "prefix_list_ids": []interface{}{}, - }) - })).Times(1).Return(&rule3, nil) - - rule4 := resource.Resource{ - Type: aws.AwsSecurityGroupRuleResourceType, - Id: "sgrule-2582518759", - Attrs: &resource.Attributes{ - "id": "sgrule-2582518759", - "type": "ingress", - "security_group_id": "sg-0254c038e32f25530", - "protocol": "-1", - "from_port": float64(0), - "to_port": float64(0), - "cidr_blocks": []interface{}{ - "1.2.0.0/16", - }, - "ipv6_cidr_blocks": []interface{}{}, - "prefix_list_ids": []interface{}{}, - }, - } - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", "aws_security_group_rule", rule4.Id, - mock.MatchedBy(func(input map[string]interface{}) bool { - return matchByAttributes(input, map[string]interface{}{ - "id": "sgrule-2582518759", - "type": "ingress", - "security_group_id": "sg-0254c038e32f25530", - "protocol": "-1", - "from_port": float64(0), - "to_port": float64(0), - "cidr_blocks": []interface{}{"1.2.0.0/16"}, - "ipv6_cidr_blocks": []interface{}{}, - "prefix_list_ids": []interface{}{}, - }) - })).Times(1).Return(&rule4, nil) - }, assert: func(t *testing.T, result *test.ScanResult, err error) { result.AssertManagedCount(7) result.AssertInfrastructureIsInSync() @@ -1550,64 +1223,6 @@ func TestDriftctlRun_Middlewares(t *testing.T) { }, }, }, - mocks: func(factory resource.ResourceFactory, repo dctlresource.SchemaRepositoryInterface) { - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "iduser1", map[string]interface{}{ - "id": "iduser1", - "policy_arn": "policy_arn1", - "users": []interface{}{"user1"}, - "groups": []interface{}{}, - "roles": []interface{}{}, - }).Twice().Return(&resource.Resource{ - Id: "id1", - Type: aws.AwsIamPolicyAttachmentResourceType, - Attrs: &resource.Attributes{ - "id": "iduser1", - "policy_arn": "policy_arn1", - "users": []interface{}{"user1"}, - "groups": []interface{}{}, - "roles": []interface{}{}, - }, - }, nil) - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "user1-policy_arn1", map[string]interface{}{ - "policy_arn": "policy_arn1", - "users": []interface{}{"user1"}, - }).Twice().Return(&resource.Resource{ - Id: "user1-policy_arn1", - Type: aws.AwsIamPolicyAttachmentResourceType, - Attrs: &resource.Attributes{ - "policy_arn": "policy_arn1", - "users": []interface{}{"user1"}, - }, - }, nil) - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "idrole1", map[string]interface{}{ - "id": "idrole1", - "policy_arn": "policy_arn1", - "users": []interface{}{}, - "groups": []interface{}{}, - "roles": []interface{}{"role1"}, - }).Twice().Return(&resource.Resource{ - Id: "idrole1", - Type: aws.AwsIamPolicyAttachmentResourceType, - Attrs: &resource.Attributes{ - "id": "idrole1", - "policy_arn": "policy_arn1", - "users": []interface{}{}, - "groups": []interface{}{}, - "roles": []interface{}{"role1"}, - }, - }, nil) - factory.(*dctlresource.MockResourceFactory).On("CreateAbstractResource", aws.AwsIamPolicyAttachmentResourceType, "role1-policy_arn1", map[string]interface{}{ - "policy_arn": "policy_arn1", - "roles": []interface{}{"role1"}, - }).Twice().Return(&resource.Resource{ - Id: "role1-policy_arn1", - Type: aws.AwsIamPolicyAttachmentResourceType, - Attrs: &resource.Attributes{ - "policy_arn": "policy_arn1", - "roles": []interface{}{"role1"}, - }, - }, nil) - }, assert: func(t *testing.T, result *test.ScanResult, err error) { result.AssertManagedCount(2) result.AssertInfrastructureIsInSync() From 60d72cd67e7ae5d4a7ae9348c8234cc09b9ac8b2 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Fri, 22 Jul 2022 11:38:43 +0200 Subject: [PATCH 5/9] chore: add normalization pass for remote resources and fix tests --- pkg/driftctl.go | 14 +++++++++++++- pkg/driftctl_test.go | 27 ++++++++++++++++++++++----- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/pkg/driftctl.go b/pkg/driftctl.go index 3bd515f0f..05e79f8da 100644 --- a/pkg/driftctl.go +++ b/pkg/driftctl.go @@ -213,5 +213,17 @@ func (d DriftCTL) scan() (remoteResources []*resource.Resource, resourcesFromSta return nil, nil, err } - return remoteResources, resourcesFromState, err + // We do a normalization pass to resources from remote because resource in IaC supplier + // are already created using DriftctlFactory.CreateAbstractResource and thus are already normalized + var normalizedRemoteResources []*resource.Resource + for _, res := range remoteResources { + attrs := resource.Attributes{} + if res.Attributes() != nil { + attrs = *res.Attributes() + } + normalizedRes := d.resourceFactory.CreateAbstractResource(res.ResourceType(), res.ResourceId(), attrs) + normalizedRemoteResources = append(normalizedRemoteResources, normalizedRes) + } + + return normalizedRemoteResources, resourcesFromState, err } diff --git a/pkg/driftctl_test.go b/pkg/driftctl_test.go index 040c26a3a..2fe3e51e3 100644 --- a/pkg/driftctl_test.go +++ b/pkg/driftctl_test.go @@ -137,10 +137,22 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { { name: "infrastructure should be in sync", stateResources: []*resource.Resource{ - &resource.Resource{}, + &resource.Resource{ + Id: "id", + Type: "type", + Attrs: &resource.Attributes{ + "foobar": "barfoo", + }, + }, }, remoteResources: []*resource.Resource{ - &resource.Resource{}, + &resource.Resource{ + Id: "id", + Type: "type", + Attrs: &resource.Attributes{ + "foobar": "barfoo", + }, + }, }, assert: func(t *testing.T, result *test.ScanResult, err error) { result.AssertInfrastructureIsInSync() @@ -277,6 +289,7 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { Attrs: &resource.Attributes{ "tags": map[string]string{ "tag1": "deleted", + "tag2": "not_deleted", }, }, }, @@ -286,7 +299,9 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { Id: "fake", Type: "FakeResource", Attrs: &resource.Attributes{ - "tags": map[string]string{}, + "tags": map[string]string{ + "tag2": "not_deleted", + }, }, }, }, @@ -364,7 +379,8 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { Id: "role-policy-test-1", Type: aws.AwsIamPolicyResourceType, Attrs: &resource.Attributes{ - "arn": "policy-test-1", + "arn": "policy-test-1", + "policy": "", }, }, }, @@ -444,7 +460,8 @@ func TestDriftctlRun_BasicBehavior(t *testing.T) { Id: "policy-test-1", Type: aws.AwsIamPolicyResourceType, Attrs: &resource.Attributes{ - "arn": "policy-test-1", + "arn": "policy-test-1", + "policy": "", }, }, }, From e7750bc00cc11555a248a5a4a782ea5bb4b55d06 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Tue, 26 Jul 2022 17:17:48 +0200 Subject: [PATCH 6/9] chore: Add test on driftctl side --- pkg/cmd/scan.go | 2 +- pkg/driftctl_test.go | 179 ++++++++++++++++++ pkg/resource/resource_types.go | 13 ++ .../aws_api_gateway_account/expected.json | 16 ++ .../3.19.0/aws_api_gateway_account/input.json | 16 ++ .../aws_api_gateway_api_key/expected.json | 30 +++ .../3.19.0/aws_api_gateway_api_key/input.json | 30 +++ .../aws_api_gateway_authorizer/expected.json | 32 ++++ .../aws_api_gateway_authorizer/input.json | 32 ++++ .../expected.json | 24 +++ .../input.json | 24 +++ .../aws_api_gateway_domain_name/expected.json | 28 +++ .../aws_api_gateway_domain_name/input.json | 28 +++ .../expected.json | 18 ++ .../input.json | 18 ++ .../aws_api_gateway_integration/expected.json | 22 +++ .../aws_api_gateway_integration/input.json | 22 +++ .../expected.json | 18 ++ .../input.json | 18 ++ .../aws_api_gateway_method/expected.json | 16 ++ .../3.19.0/aws_api_gateway_method/input.json | 16 ++ .../expected.json | 13 ++ .../input.json | 13 ++ .../expected.json | 50 +++++ .../input.json | 50 +++++ .../aws_api_gateway_model/expected.json | 26 +++ .../3.19.0/aws_api_gateway_model/input.json | 26 +++ .../expected.json | 24 +++ .../input.json | 24 +++ .../aws_api_gateway_resource/expected.json | 24 +++ .../aws_api_gateway_resource/input.json | 24 +++ .../aws_api_gateway_rest_api/expected.json | 49 +++++ .../aws_api_gateway_rest_api/input.json | 49 +++++ .../expected.json | 20 ++ .../input.json | 20 ++ .../aws_api_gateway_stage/expected.json | 40 ++++ .../3.19.0/aws_api_gateway_stage/input.json | 40 ++++ .../aws_api_gateway_vpc_link/expected.json | 15 ++ .../aws_api_gateway_vpc_link/input.json | 15 ++ .../3.19.0/aws_apigatewayv2_api/expected.json | 19 ++ .../3.19.0/aws_apigatewayv2_api/input.json | 19 ++ .../expected.json | 13 ++ .../aws_apigatewayv2_api_mapping/input.json | 13 ++ .../aws_apigatewayv2_authorizer/expected.json | 20 ++ .../aws_apigatewayv2_authorizer/input.json | 20 ++ .../aws_apigatewayv2_deployment/expected.json | 12 ++ .../aws_apigatewayv2_deployment/input.json | 12 ++ .../expected.json | 21 ++ .../aws_apigatewayv2_domain_name/input.json | 21 ++ .../expected.json | 24 +++ .../aws_apigatewayv2_integration/input.json | 24 +++ .../expected.json | 14 ++ .../input.json | 14 ++ .../aws_apigatewayv2_model/expected.json | 14 ++ .../3.19.0/aws_apigatewayv2_model/input.json | 14 ++ .../aws_apigatewayv2_route/expected.json | 18 ++ .../3.19.0/aws_apigatewayv2_route/input.json | 18 ++ .../expected.json | 13 ++ .../input.json | 13 ++ .../aws_apigatewayv2_stage/expected.json | 27 +++ .../3.19.0/aws_apigatewayv2_stage/input.json | 27 +++ .../aws_apigatewayv2_vpc_link/expected.json | 21 ++ .../aws_apigatewayv2_vpc_link/input.json | 21 ++ .../aws_appautoscaling_policy/expected.json | 29 +++ .../aws_appautoscaling_policy/input.json | 31 +++ .../expected.json | 21 ++ .../input.json | 21 ++ .../aws_appautoscaling_target/expected.json | 15 ++ .../aws_appautoscaling_target/input.json | 15 ++ .../aws_cloudformation_stack/expected.json | 30 +++ .../aws_cloudformation_stack/input.json | 50 +++++ .../aws_cloudfront_distribution/expected.json | 80 ++++++++ .../aws_cloudfront_distribution/input.json | 102 ++++++++++ .../aws/3.19.0/aws_db_instance/expected.json | 55 ++++++ .../aws/3.19.0/aws_db_instance/input.json | 55 ++++++ .../3.19.0/aws_db_subnet_group/expected.json | 30 +++ .../aws/3.19.0/aws_db_subnet_group/input.json | 30 +++ .../aws_default_network_acl/expected.json | 44 +++++ .../3.19.0/aws_default_network_acl/input.json | 46 +++++ .../aws_default_route_table/expected.json | 13 ++ .../3.19.0/aws_default_route_table/input.json | 13 ++ .../aws/3.19.0/aws_default_vpc/expected.json | 26 +++ .../aws/3.19.0/aws_default_vpc/input.json | 28 +++ .../3.19.0/aws_dynamodb_table/expected.json | 101 ++++++++++ .../aws/3.19.0/aws_dynamodb_table/input.json | 119 ++++++++++++ .../expected.json | 10 + .../aws_ebs_encryption_by_default/input.json | 10 + .../3.19.0/aws_ecr_repository/expected.json | 48 +++++ .../aws/3.19.0/aws_ecr_repository/input.json | 56 ++++++ .../aws_ecr_repository_policy/expected.json | 12 ++ .../aws_ecr_repository_policy/input.json | 12 ++ .../aws_elasticache_cluster/expected.json | 33 ++++ .../3.19.0/aws_elasticache_cluster/input.json | 33 ++++ pkg/test/aws/3.19.0/aws_elb/expected.json | 55 ++++++ pkg/test/aws/3.19.0/aws_elb/input.json | 55 ++++++ .../3.19.0/aws_iam_access_key/expected.json | 38 ++++ .../aws/3.19.0/aws_iam_access_key/input.json | 58 ++++++ .../aws/3.19.0/aws_iam_group/expected.json | 13 ++ pkg/test/aws/3.19.0/aws_iam_group/input.json | 13 ++ .../3.19.0/aws_iam_group_policy/expected.json | 12 ++ .../3.19.0/aws_iam_group_policy/input.json | 12 ++ .../expected.json | 11 ++ .../input.json | 11 ++ .../aws/3.19.0/aws_iam_policy/expected.json | 38 ++++ pkg/test/aws/3.19.0/aws_iam_policy/input.json | 41 ++++ .../aws/3.19.0/aws_iam_role/expected.json | 56 ++++++ pkg/test/aws/3.19.0/aws_iam_role/input.json | 65 +++++++ .../3.19.0/aws_iam_role_policy/expected.json | 56 ++++++ .../aws/3.19.0/aws_iam_role_policy/input.json | 56 ++++++ .../expected.json | 56 ++++++ .../aws_iam_role_policy_attachment/input.json | 56 ++++++ .../aws/3.19.0/aws_iam_user/expected.json | 44 +++++ pkg/test/aws/3.19.0/aws_iam_user/input.json | 50 +++++ .../3.19.0/aws_iam_user_policy/expected.json | 110 +++++++++++ .../aws/3.19.0/aws_iam_user_policy/input.json | 110 +++++++++++ .../expected.json | 110 +++++++++++ .../aws_iam_user_policy_attachment/input.json | 110 +++++++++++ .../3.19.0/aws_internet_gateway/expected.json | 15 ++ .../3.19.0/aws_internet_gateway/input.json | 15 ++ .../aws/3.19.0/aws_kms_alias/expected.json | 32 ++++ pkg/test/aws/3.19.0/aws_kms_alias/input.json | 38 ++++ pkg/test/aws/3.19.0/aws_kms_key/expected.json | 50 +++++ pkg/test/aws/3.19.0/aws_kms_key/input.json | 55 ++++++ .../expected.json | 38 ++++ .../input.json | 38 ++++ .../3.19.0/aws_lambda_function/expected.json | 54 ++++++ .../aws/3.19.0/aws_lambda_function/input.json | 86 +++++++++ .../aws_launch_configuration/expected.json | 21 ++ .../aws_launch_configuration/input.json | 21 ++ .../3.19.0/aws_launch_template/expected.json | 117 ++++++++++++ .../aws/3.19.0/aws_launch_template/input.json | 153 +++++++++++++++ pkg/test/aws/3.19.0/aws_lb/expected.json | 54 ++++++ pkg/test/aws/3.19.0/aws_lb/input.json | 54 ++++++ .../aws/3.19.0/aws_lb_listener/expected.json | 111 +++++++++++ .../aws/3.19.0/aws_lb_listener/input.json | 111 +++++++++++ .../aws/3.19.0/aws_nat_gateway/expected.json | 17 ++ .../aws/3.19.0/aws_nat_gateway/input.json | 17 ++ .../aws/3.19.0/aws_network_acl/expected.json | 54 ++++++ .../aws/3.19.0/aws_network_acl/input.json | 54 ++++++ .../3.19.0/aws_network_acl_rule/expected.json | 32 ++++ .../3.19.0/aws_network_acl_rule/input.json | 32 ++++ .../aws/3.19.0/aws_rds_cluster/expected.json | 84 ++++++++ .../aws/3.19.0/aws_rds_cluster/input.json | 120 ++++++++++++ pkg/test/aws/3.19.0/aws_route/expected.json | 26 +++ pkg/test/aws/3.19.0/aws_route/input.json | 26 +++ .../aws_route53_health_check/expected.json | 47 +++++ .../aws_route53_health_check/input.json | 47 +++++ .../3.19.0/aws_route53_record/expected.json | 86 +++++++++ .../aws/3.19.0/aws_route53_record/input.json | 146 ++++++++++++++ .../aws/3.19.0/aws_route53_zone/expected.json | 19 ++ .../aws/3.19.0/aws_route53_zone/input.json | 19 ++ .../aws/3.19.0/aws_route_table/expected.json | 18 ++ .../aws/3.19.0/aws_route_table/input.json | 18 ++ .../aws/3.19.0/aws_s3_bucket/expected.json | 62 ++++++ pkg/test/aws/3.19.0/aws_s3_bucket/input.json | 64 +++++++ .../3.19.0/aws_s3_bucket_metric/expected.json | 20 ++ .../3.19.0/aws_s3_bucket_metric/input.json | 22 +++ .../aws_s3_bucket_notification/expected.json | 30 +++ .../aws_s3_bucket_notification/input.json | 32 ++++ .../expected.json | 14 ++ .../input.json | 14 ++ .../aws/3.19.0/aws_sns_topic/expected.json | 65 +++++++ pkg/test/aws/3.19.0/aws_sns_topic/input.json | 83 ++++++++ .../3.19.0/aws_sns_topic_policy/expected.json | 20 ++ .../3.19.0/aws_sns_topic_policy/input.json | 20 ++ .../aws_sns_topic_subscription/expected.json | 30 +++ .../aws_sns_topic_subscription/input.json | 34 ++++ .../aws/3.19.0/aws_sqs_queue/expected.json | 42 ++++ pkg/test/aws/3.19.0/aws_sqs_queue/input.json | 46 +++++ .../3.19.0/aws_sqs_queue_policy/expected.json | 29 +++ .../3.19.0/aws_sqs_queue_policy/input.json | 29 +++ pkg/test/aws/3.19.0/aws_subnet/expected.json | 110 +++++++++++ pkg/test/aws/3.19.0/aws_subnet/input.json | 110 +++++++++++ pkg/test/aws/3.19.0/aws_vpc/expected.json | 65 +++++++ pkg/test/aws/3.19.0/aws_vpc/input.json | 74 ++++++++ .../2.71.0/azurerm_image/expected.json | 24 +++ .../azurerm/2.71.0/azurerm_image/input.json | 24 +++ .../azurerm/2.71.0/azurerm_lb/expected.json | 46 +++++ pkg/test/azurerm/2.71.0/azurerm_lb/input.json | 48 +++++ .../2.71.0/azurerm_lb_rule/expected.json | 46 +++++ .../azurerm/2.71.0/azurerm_lb_rule/input.json | 48 +++++ .../expected.json | 39 ++++ .../azurerm_network_security_group/input.json | 49 +++++ .../expected.json | 33 ++++ .../azurerm_private_dns_a_record/input.json | 37 ++++ .../expected.json | 34 ++++ .../input.json | 34 ++++ .../expected.json | 28 +++ .../input.json | 32 ++++ .../expected.json | 42 ++++ .../azurerm_private_dns_mx_record/input.json | 46 +++++ .../expected.json | 33 ++++ .../azurerm_private_dns_ptr_record/input.json | 37 ++++ .../expected.json | 48 +++++ .../azurerm_private_dns_srv_record/input.json | 52 +++++ .../expected.json | 39 ++++ .../azurerm_private_dns_txt_record/input.json | 43 +++++ .../azurerm_private_dns_zone/expected.json | 27 +++ .../azurerm_private_dns_zone/input.json | 27 +++ .../azurerm_ssh_public_key/expected.json | 24 +++ .../2.71.0/azurerm_ssh_public_key/input.json | 28 +++ .../github_branch_protection/expected.json | 137 ++++++++++++++ .../4.4.0/github_branch_protection/input.json | 152 +++++++++++++++ .../4.4.0/github_membership/expected.json | 20 ++ .../github/4.4.0/github_membership/input.json | 22 +++ .../4.4.0/github_repository/expected.json | 80 ++++++++ .../github/4.4.0/github_repository/input.json | 94 +++++++++ .../github/4.4.0/github_team/expected.json | 24 +++ pkg/test/github/4.4.0/github_team/input.json | 24 +++ .../github_team_membership/expected.json | 22 +++ .../4.4.0/github_team_membership/input.json | 24 +++ .../google_bigquery_dataset/expected.json | 51 +++++ .../3.78.0/google_bigquery_dataset/input.json | 51 +++++ .../google_bigquery_table/expected.json | 26 +++ .../3.78.0/google_bigquery_table/input.json | 26 +++ .../google_bigtable_instance/expected.json | 23 +++ .../google_bigtable_instance/input.json | 23 +++ .../google_bigtable_table/expected.json | 12 ++ .../3.78.0/google_bigtable_table/input.json | 12 ++ .../expected.json | 26 +++ .../google_cloudfunctions_function/input.json | 26 +++ .../google_compute_address/expected.json | 22 +++ .../3.78.0/google_compute_address/input.json | 22 +++ .../3.78.0/google_compute_disk/expected.json | 26 +++ .../3.78.0/google_compute_disk/input.json | 26 +++ .../google_compute_firewall/expected.json | 98 ++++++++++ .../3.78.0/google_compute_firewall/input.json | 128 +++++++++++++ .../expected.json | 29 +++ .../google_compute_forwarding_rule/input.json | 29 +++ .../expected.json | 20 ++ .../google_compute_global_address/input.json | 20 ++ .../expected.json | 19 ++ .../input.json | 19 ++ .../google_compute_health_check/expected.json | 35 ++++ .../google_compute_health_check/input.json | 35 ++++ .../3.78.0/google_compute_image/expected.json | 28 +++ .../3.78.0/google_compute_image/input.json | 28 +++ .../google_compute_instance/expected.json | 30 +++ .../3.78.0/google_compute_instance/input.json | 36 ++++ .../expected.json | 30 +++ .../google_compute_instance_group/input.json | 36 ++++ .../expected.json | 70 +++++++ .../input.json | 70 +++++++ .../google_compute_network/expected.json | 41 ++++ .../3.78.0/google_compute_network/input.json | 53 ++++++ .../google_compute_node_group/expected.json | 54 ++++++ .../google_compute_node_group/input.json | 54 ++++++ .../google_compute_router/expected.json | 101 ++++++++++ .../3.78.0/google_compute_router/input.json | 101 ++++++++++ .../google_compute_subnetwork/expected.json | 71 +++++++ .../google_compute_subnetwork/input.json | 83 ++++++++ .../google_dns_managed_zone/expected.json | 24 +++ .../3.78.0/google_dns_managed_zone/input.json | 24 +++ .../expected.json | 81 ++++++++ .../google_sql_database_instance/input.json | 81 ++++++++ .../google_storage_bucket/expected.json | 53 ++++++ .../3.78.0/google_storage_bucket/input.json | 80 ++++++++ 257 files changed, 10499 insertions(+), 1 deletion(-) create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_account/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_account/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_api_key/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_api_key/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_authorizer/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_authorizer/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_base_path_mapping/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_base_path_mapping/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_domain_name/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_domain_name/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_gateway_response/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_gateway_response/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_integration/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_integration/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_integration_response/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_integration_response/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_method/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_method/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_method_response/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_method_response/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_method_settings/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_method_settings/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_model/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_model/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_request_validator/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_request_validator/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_resource/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_resource/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_rest_api/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_rest_api/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_rest_api_policy/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_rest_api_policy/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_stage/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_stage/input.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_vpc_link/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_api_gateway_vpc_link/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_api/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_api/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_api_mapping/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_api_mapping/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_authorizer/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_authorizer/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_deployment/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_deployment/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_domain_name/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_domain_name/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_integration/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_integration/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_integration_response/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_integration_response/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_model/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_model/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_route/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_route/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_route_response/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_route_response/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_stage/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_stage/input.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_vpc_link/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_apigatewayv2_vpc_link/input.json create mode 100755 pkg/test/aws/3.19.0/aws_appautoscaling_policy/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_appautoscaling_policy/input.json create mode 100755 pkg/test/aws/3.19.0/aws_appautoscaling_scheduled_action/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_appautoscaling_scheduled_action/input.json create mode 100755 pkg/test/aws/3.19.0/aws_appautoscaling_target/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_appautoscaling_target/input.json create mode 100755 pkg/test/aws/3.19.0/aws_cloudformation_stack/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_cloudformation_stack/input.json create mode 100755 pkg/test/aws/3.19.0/aws_cloudfront_distribution/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_cloudfront_distribution/input.json create mode 100755 pkg/test/aws/3.19.0/aws_db_instance/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_db_instance/input.json create mode 100755 pkg/test/aws/3.19.0/aws_db_subnet_group/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_db_subnet_group/input.json create mode 100755 pkg/test/aws/3.19.0/aws_default_network_acl/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_default_network_acl/input.json create mode 100755 pkg/test/aws/3.19.0/aws_default_route_table/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_default_route_table/input.json create mode 100755 pkg/test/aws/3.19.0/aws_default_vpc/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_default_vpc/input.json create mode 100755 pkg/test/aws/3.19.0/aws_dynamodb_table/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_dynamodb_table/input.json create mode 100755 pkg/test/aws/3.19.0/aws_ebs_encryption_by_default/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_ebs_encryption_by_default/input.json create mode 100755 pkg/test/aws/3.19.0/aws_ecr_repository/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_ecr_repository/input.json create mode 100755 pkg/test/aws/3.19.0/aws_ecr_repository_policy/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_ecr_repository_policy/input.json create mode 100755 pkg/test/aws/3.19.0/aws_elasticache_cluster/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_elasticache_cluster/input.json create mode 100755 pkg/test/aws/3.19.0/aws_elb/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_elb/input.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_access_key/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_access_key/input.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_group/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_group/input.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_group_policy/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_group_policy/input.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_group_policy_attachment/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_group_policy_attachment/input.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_policy/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_policy/input.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_role/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_role/input.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_role_policy/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_role_policy/input.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_role_policy_attachment/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_role_policy_attachment/input.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_user/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_user/input.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_user_policy/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_user_policy/input.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_user_policy_attachment/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_iam_user_policy_attachment/input.json create mode 100755 pkg/test/aws/3.19.0/aws_internet_gateway/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_internet_gateway/input.json create mode 100755 pkg/test/aws/3.19.0/aws_kms_alias/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_kms_alias/input.json create mode 100755 pkg/test/aws/3.19.0/aws_kms_key/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_kms_key/input.json create mode 100755 pkg/test/aws/3.19.0/aws_lambda_event_source_mapping/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_lambda_event_source_mapping/input.json create mode 100755 pkg/test/aws/3.19.0/aws_lambda_function/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_lambda_function/input.json create mode 100755 pkg/test/aws/3.19.0/aws_launch_configuration/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_launch_configuration/input.json create mode 100755 pkg/test/aws/3.19.0/aws_launch_template/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_launch_template/input.json create mode 100755 pkg/test/aws/3.19.0/aws_lb/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_lb/input.json create mode 100755 pkg/test/aws/3.19.0/aws_lb_listener/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_lb_listener/input.json create mode 100755 pkg/test/aws/3.19.0/aws_nat_gateway/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_nat_gateway/input.json create mode 100755 pkg/test/aws/3.19.0/aws_network_acl/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_network_acl/input.json create mode 100755 pkg/test/aws/3.19.0/aws_network_acl_rule/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_network_acl_rule/input.json create mode 100755 pkg/test/aws/3.19.0/aws_rds_cluster/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_rds_cluster/input.json create mode 100755 pkg/test/aws/3.19.0/aws_route/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_route/input.json create mode 100755 pkg/test/aws/3.19.0/aws_route53_health_check/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_route53_health_check/input.json create mode 100755 pkg/test/aws/3.19.0/aws_route53_record/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_route53_record/input.json create mode 100755 pkg/test/aws/3.19.0/aws_route53_zone/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_route53_zone/input.json create mode 100755 pkg/test/aws/3.19.0/aws_route_table/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_route_table/input.json create mode 100755 pkg/test/aws/3.19.0/aws_s3_bucket/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_s3_bucket/input.json create mode 100755 pkg/test/aws/3.19.0/aws_s3_bucket_metric/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_s3_bucket_metric/input.json create mode 100755 pkg/test/aws/3.19.0/aws_s3_bucket_notification/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_s3_bucket_notification/input.json create mode 100755 pkg/test/aws/3.19.0/aws_s3_bucket_public_access_block/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_s3_bucket_public_access_block/input.json create mode 100755 pkg/test/aws/3.19.0/aws_sns_topic/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_sns_topic/input.json create mode 100755 pkg/test/aws/3.19.0/aws_sns_topic_policy/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_sns_topic_policy/input.json create mode 100755 pkg/test/aws/3.19.0/aws_sns_topic_subscription/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_sns_topic_subscription/input.json create mode 100755 pkg/test/aws/3.19.0/aws_sqs_queue/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_sqs_queue/input.json create mode 100755 pkg/test/aws/3.19.0/aws_sqs_queue_policy/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_sqs_queue_policy/input.json create mode 100755 pkg/test/aws/3.19.0/aws_subnet/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_subnet/input.json create mode 100755 pkg/test/aws/3.19.0/aws_vpc/expected.json create mode 100755 pkg/test/aws/3.19.0/aws_vpc/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_image/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_image/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_lb/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_lb/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_lb_rule/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_lb_rule/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_network_security_group/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_network_security_group/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_a_record/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_a_record/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_aaaa_record/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_aaaa_record/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_cname_record/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_cname_record/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_mx_record/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_mx_record/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_ptr_record/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_ptr_record/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_srv_record/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_srv_record/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_txt_record/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_txt_record/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_zone/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_private_dns_zone/input.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_ssh_public_key/expected.json create mode 100755 pkg/test/azurerm/2.71.0/azurerm_ssh_public_key/input.json create mode 100755 pkg/test/github/4.4.0/github_branch_protection/expected.json create mode 100755 pkg/test/github/4.4.0/github_branch_protection/input.json create mode 100755 pkg/test/github/4.4.0/github_membership/expected.json create mode 100755 pkg/test/github/4.4.0/github_membership/input.json create mode 100755 pkg/test/github/4.4.0/github_repository/expected.json create mode 100755 pkg/test/github/4.4.0/github_repository/input.json create mode 100755 pkg/test/github/4.4.0/github_team/expected.json create mode 100755 pkg/test/github/4.4.0/github_team/input.json create mode 100755 pkg/test/github/4.4.0/github_team_membership/expected.json create mode 100755 pkg/test/github/4.4.0/github_team_membership/input.json create mode 100755 pkg/test/google/3.78.0/google_bigquery_dataset/expected.json create mode 100755 pkg/test/google/3.78.0/google_bigquery_dataset/input.json create mode 100755 pkg/test/google/3.78.0/google_bigquery_table/expected.json create mode 100755 pkg/test/google/3.78.0/google_bigquery_table/input.json create mode 100755 pkg/test/google/3.78.0/google_bigtable_instance/expected.json create mode 100755 pkg/test/google/3.78.0/google_bigtable_instance/input.json create mode 100755 pkg/test/google/3.78.0/google_bigtable_table/expected.json create mode 100755 pkg/test/google/3.78.0/google_bigtable_table/input.json create mode 100755 pkg/test/google/3.78.0/google_cloudfunctions_function/expected.json create mode 100755 pkg/test/google/3.78.0/google_cloudfunctions_function/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_address/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_address/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_disk/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_disk/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_firewall/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_firewall/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_forwarding_rule/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_forwarding_rule/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_global_address/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_global_address/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_global_forwarding_rule/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_global_forwarding_rule/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_health_check/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_health_check/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_image/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_image/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_instance/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_instance/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_instance_group/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_instance_group/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_instance_group_manager/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_instance_group_manager/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_network/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_network/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_node_group/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_node_group/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_router/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_router/input.json create mode 100755 pkg/test/google/3.78.0/google_compute_subnetwork/expected.json create mode 100755 pkg/test/google/3.78.0/google_compute_subnetwork/input.json create mode 100755 pkg/test/google/3.78.0/google_dns_managed_zone/expected.json create mode 100755 pkg/test/google/3.78.0/google_dns_managed_zone/input.json create mode 100755 pkg/test/google/3.78.0/google_sql_database_instance/expected.json create mode 100755 pkg/test/google/3.78.0/google_sql_database_instance/input.json create mode 100755 pkg/test/google/3.78.0/google_storage_bucket/expected.json create mode 100755 pkg/test/google/3.78.0/google_storage_bucket/input.json diff --git a/pkg/cmd/scan.go b/pkg/cmd/scan.go index 657d83642..d05e41c82 100644 --- a/pkg/cmd/scan.go +++ b/pkg/cmd/scan.go @@ -297,7 +297,7 @@ func scanRun(opts *pkg.ScanOptions) error { } providerName := common.RemoteParameter(opts.To).GetProviderAddress().Type - err = resourceSchemaRepository.Init(providerName, opts.ProviderVersion, providerLibrary.Provider(opts.To).Schema()) + err = resourceSchemaRepository.Init(providerName, opts.ProviderVersion, providerLibrary.Provider(providerName).Schema()) if err != nil { return err } diff --git a/pkg/driftctl_test.go b/pkg/driftctl_test.go index 2fe3e51e3..300d02fe0 100644 --- a/pkg/driftctl_test.go +++ b/pkg/driftctl_test.go @@ -1,7 +1,11 @@ package pkg_test import ( + "encoding/json" + "io/ioutil" + "path" "reflect" + "strings" "testing" "github.com/r3labs/diff/v2" @@ -1413,6 +1417,181 @@ func TestDriftctlRun_Middlewares(t *testing.T) { runTest(t, cases) } +type normalizationTestCase struct { + Resource string + ProviderName string + ProviderVersion string +} + +func TestDriftctlRun_TestResourcesNormalization(t *testing.T) { + + readResourceFile := func(ty, path string) ([]*resource.Resource, error) { + results := []*resource.Resource{} + file, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + err = json.Unmarshal(file, &results) + if err != nil { + return nil, err + } + for _, res := range results { + res.Type = ty + } + return results, nil + } + + defaultProviderVersions := map[string]string{ + "aws": "3.19.0", + "github": "4.4.0", + "google": "3.78.0", + "azurerm": "2.71.0", + } + + cases := []normalizationTestCase{} + for _, res := range dctlresource.GetSupportedTypes() { + + providerName := strings.SplitN(res, "_", 2)[0] + providerVersion, exist := defaultProviderVersions[providerName] + if !exist { + t.Fatal("Provider not supported for normalisation test of " + res) + } + + cases = append(cases, normalizationTestCase{ + Resource: res, + ProviderVersion: providerVersion, + ProviderName: providerName, + }) + } + + for _, c := range cases { + t.Run(c.Resource, func(t *testing.T) { + + folder := path.Join(c.ProviderName, c.ProviderVersion, c.Resource) + + // _ = os.MkdirAll(path.Join("test", folder), os.ModePerm) + // wd, _ := os.Getwd() + // globPath := path.Join(wd, fmt.Sprintf("../enumeration/remote/test/%s*", c.Resource)) + // matches, err := filepath.Glob(globPath) + // if err != nil { + // t.Fatal(err) + // } + // if len(matches) > 0 { + // fileToCopy, err := ioutil.ReadFile(path.Join(matches[0], "results.golden.json")) + // if err != nil { + // t.Fatal(err) + // } + // + // tmpInputRes := []*resource.Resource{} + // var tmpAttributtes []resource.Attributes + // err = json.Unmarshal(fileToCopy, &tmpAttributtes) + // if err != nil { + // t.Fatal(err) + // } + // for _, attrs := range tmpAttributtes { + // attrs := attrs + // res := &resource.Resource{ + // Type: c.Resource, + // Id: attrs["id"].(string), + // Attrs: &attrs, + // } + // tmpInputRes = append(tmpInputRes, res) + // } + // resourcesToCopy, err := json.MarshalIndent(tmpInputRes, "", " ") + // if err != nil { + // t.Fatal(err) + // } + // err = ioutil.WriteFile(path.Join("test", folder, "input.json"), resourcesToCopy, os.ModePerm) + // if err != nil { + // t.Fatal(err) + // } + // } + + // wd, _ := os.Getwd() + // globPath := path.Join(wd, fmt.Sprintf("iac/terraform/state/test/%s*", c.Resource)) + // matches, err := filepath.Glob(globPath) + // if err != nil { + // t.Fatal(err) + // } + // if len(matches) > 0 { + // fileToCopy, err := ioutil.ReadFile(path.Join(matches[0], "results.golden.json")) + // if err != nil { + // t.Fatal(err) + // } + // err = ioutil.WriteFile(path.Join("test", folder, "expected.json"), fileToCopy, os.ModePerm) + // if err != nil { + // t.Fatal(err) + // } + // } + + inputFilePath := path.Join("test", folder, "input.json") + inputResources, err := readResourceFile(c.Resource, inputFilePath) + if err != nil { + t.Skip(err) + } + + expectedFilePath := path.Join("test", folder, "expected.json") + expectedResources, err := readResourceFile(c.Resource, expectedFilePath) + if err != nil { + t.Fatal(err) + } + + options := &pkg.ScanOptions{ + Deep: true, + } + + repo := testresource.InitFakeSchemaRepository(c.ProviderName, c.ProviderVersion) + resourceFactory := dctlresource.NewDriftctlResourceFactory(repo) + testAlerter := alerter.NewAlerter() + store := memstore.New() + + scanProgress := &output.MockProgress{} + scanProgress.On("Start").Return().Once() + scanProgress.On("Stop").Return().Once() + iacProgress := &output.MockProgress{} + iacProgress.On("Start").Return().Once() + iacProgress.On("Stop").Return().Once() + + testFilter := &filter.MockFilter{} + testFilter.On("IsResourceIgnored", mock.MatchedBy(func(res *resource.Resource) bool { + return res.ResourceType() == c.Resource + })).Return(false) + testFilter.On("IsResourceIgnored", mock.MatchedBy(func(res *resource.Resource) bool { + return res.ResourceType() != c.Resource + })).Return(true) + testFilter.On("IsFieldIgnored", mock.Anything, mock.Anything).Return(false) + analyzer := analyser.NewAnalyzer(testAlerter, analyser.AnalyzerOptions{Deep: options.Deep}, testFilter) + + stateSupplier := &dctlresource.MockIaCSupplier{} + stateSupplier.On("Resources").Return(expectedResources, nil) + stateSupplier.On("SourceCount").Return(uint(1)) + remoteSupplier := &resource.MockSupplier{} + remoteSupplier.On("Resources").Return(inputResources, nil) + + driftctl := pkg.NewDriftCTL( + remoteSupplier, + stateSupplier, + testAlerter, + analyzer, + resourceFactory, + options, + scanProgress, + iacProgress, + repo, + store, + ) + + analysis, err := driftctl.Run() + if err != nil { + t.Fatal(err) + } + results := test.NewScanResult(t, analysis) + results.AssertInfrastructureIsInSync() + }) + } + +} + func getSchema(repo dctlresource.SchemaRepositoryInterface, resourceType string) *resource.Schema { sch, _ := repo.GetSchema(resourceType) return sch diff --git a/pkg/resource/resource_types.go b/pkg/resource/resource_types.go index 46c054feb..6461f84f8 100644 --- a/pkg/resource/resource_types.go +++ b/pkg/resource/resource_types.go @@ -1,5 +1,7 @@ package resource +import "sort" + type ResourceType string var supportedTypes = map[string]ResourceTypeMeta{ @@ -256,6 +258,17 @@ func IsResourceTypeSupported(ty string) bool { return exist } +func GetSupportedTypes() []string { + types := make([]string, 0, len(supportedTypes)) + for k, _ := range supportedTypes { + types = append(types, k) + } + + sort.Strings(types) + + return types +} + func (ty ResourceType) String() string { return string(ty) } diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_account/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_account/expected.json new file mode 100755 index 000000000..ae4ba32f5 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_account/expected.json @@ -0,0 +1,16 @@ +[ + { + "Id": "api-gateway-account", + "Type": "aws_api_gateway_account", + "Attrs": { + "cloudwatch_role_arn": "arn:aws:iam::047081014315:role/api_gateway_cloudwatch_global", + "id": "api-gateway-account", + "throttle_settings": [ + { + "burst_limit": 5000, + "rate_limit": 10000 + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_account/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_account/input.json new file mode 100755 index 000000000..ae4ba32f5 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_account/input.json @@ -0,0 +1,16 @@ +[ + { + "Id": "api-gateway-account", + "Type": "aws_api_gateway_account", + "Attrs": { + "cloudwatch_role_arn": "arn:aws:iam::047081014315:role/api_gateway_cloudwatch_global", + "id": "api-gateway-account", + "throttle_settings": [ + { + "burst_limit": 5000, + "rate_limit": 10000 + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_api_key/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_api_key/expected.json new file mode 100755 index 000000000..fa42bcd15 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_api_key/expected.json @@ -0,0 +1,30 @@ +[ + { + "Id": "9ge737dd45", + "Type": "aws_api_gateway_api_key", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/apikeys/9ge737dd45", + "created_date": "2021-09-27T09:10:54Z", + "description": "Foo Api Key", + "enabled": false, + "id": "9ge737dd45", + "last_updated_date": "2021-09-27T09:10:54Z", + "name": "foo", + "value": "nHt1Wqv9538R7HUN5LtH11DyaluIiGwM39svyqqi" + } + }, + { + "Id": "fuwnl8lrva", + "Type": "aws_api_gateway_api_key", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/apikeys/fuwnl8lrva", + "created_date": "2021-09-27T09:10:54Z", + "description": "Bar Api Key", + "enabled": false, + "id": "fuwnl8lrva", + "last_updated_date": "2021-09-27T09:10:54Z", + "name": "bar", + "value": "pmqQupx2Eu2KG4bh8UPTP5gpPTYC5dlF6VcrygNy" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_api_key/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_api_key/input.json new file mode 100755 index 000000000..fa42bcd15 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_api_key/input.json @@ -0,0 +1,30 @@ +[ + { + "Id": "9ge737dd45", + "Type": "aws_api_gateway_api_key", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/apikeys/9ge737dd45", + "created_date": "2021-09-27T09:10:54Z", + "description": "Foo Api Key", + "enabled": false, + "id": "9ge737dd45", + "last_updated_date": "2021-09-27T09:10:54Z", + "name": "foo", + "value": "nHt1Wqv9538R7HUN5LtH11DyaluIiGwM39svyqqi" + } + }, + { + "Id": "fuwnl8lrva", + "Type": "aws_api_gateway_api_key", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/apikeys/fuwnl8lrva", + "created_date": "2021-09-27T09:10:54Z", + "description": "Bar Api Key", + "enabled": false, + "id": "fuwnl8lrva", + "last_updated_date": "2021-09-27T09:10:54Z", + "name": "bar", + "value": "pmqQupx2Eu2KG4bh8UPTP5gpPTYC5dlF6VcrygNy" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_authorizer/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_authorizer/expected.json new file mode 100755 index 000000000..ae098f88e --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_authorizer/expected.json @@ -0,0 +1,32 @@ +[ + { + "Id": "ypcpde", + "Type": "aws_api_gateway_authorizer", + "Attrs": { + "authorizer_credentials": "arn:aws:iam::047081014315:role/api_gateway_auth_invocation", + "authorizer_result_ttl_in_seconds": 300, + "authorizer_uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:047081014315:function:api_gateway_authorizer/invocations", + "id": "ypcpde", + "identity_source": "method.request.header.Authorization", + "identity_validation_expression": "", + "name": "bar", + "rest_api_id": "1jitcobwol", + "type": "TOKEN" + } + }, + { + "Id": "bwhebj", + "Type": "aws_api_gateway_authorizer", + "Attrs": { + "authorizer_credentials": "arn:aws:iam::047081014315:role/api_gateway_auth_invocation", + "authorizer_result_ttl_in_seconds": 300, + "authorizer_uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:047081014315:function:api_gateway_authorizer/invocations", + "id": "bwhebj", + "identity_source": "method.request.header.Authorization", + "identity_validation_expression": "", + "name": "foo", + "rest_api_id": "1jitcobwol", + "type": "TOKEN" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_authorizer/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_authorizer/input.json new file mode 100755 index 000000000..ae098f88e --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_authorizer/input.json @@ -0,0 +1,32 @@ +[ + { + "Id": "ypcpde", + "Type": "aws_api_gateway_authorizer", + "Attrs": { + "authorizer_credentials": "arn:aws:iam::047081014315:role/api_gateway_auth_invocation", + "authorizer_result_ttl_in_seconds": 300, + "authorizer_uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:047081014315:function:api_gateway_authorizer/invocations", + "id": "ypcpde", + "identity_source": "method.request.header.Authorization", + "identity_validation_expression": "", + "name": "bar", + "rest_api_id": "1jitcobwol", + "type": "TOKEN" + } + }, + { + "Id": "bwhebj", + "Type": "aws_api_gateway_authorizer", + "Attrs": { + "authorizer_credentials": "arn:aws:iam::047081014315:role/api_gateway_auth_invocation", + "authorizer_result_ttl_in_seconds": 300, + "authorizer_uri": "arn:aws:apigateway:us-east-1:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-1:047081014315:function:api_gateway_authorizer/invocations", + "id": "bwhebj", + "identity_source": "method.request.header.Authorization", + "identity_validation_expression": "", + "name": "foo", + "rest_api_id": "1jitcobwol", + "type": "TOKEN" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_base_path_mapping/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_base_path_mapping/expected.json new file mode 100755 index 000000000..b650a6664 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_base_path_mapping/expected.json @@ -0,0 +1,24 @@ +[ + { + "Id": "example-driftctl.com/foo", + "Type": "aws_api_gateway_base_path_mapping", + "Attrs": { + "api_id": "zetudukz30", + "base_path": "foo", + "domain_name": "example-driftctl.com", + "id": "example-driftctl.com/foo", + "stage_name": "foo" + } + }, + { + "Id": "example-driftctl.com/", + "Type": "aws_api_gateway_base_path_mapping", + "Attrs": { + "api_id": "zetudukz30", + "base_path": "", + "domain_name": "example-driftctl.com", + "id": "example-driftctl.com/", + "stage_name": "foo" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_base_path_mapping/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_base_path_mapping/input.json new file mode 100755 index 000000000..b650a6664 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_base_path_mapping/input.json @@ -0,0 +1,24 @@ +[ + { + "Id": "example-driftctl.com/foo", + "Type": "aws_api_gateway_base_path_mapping", + "Attrs": { + "api_id": "zetudukz30", + "base_path": "foo", + "domain_name": "example-driftctl.com", + "id": "example-driftctl.com/foo", + "stage_name": "foo" + } + }, + { + "Id": "example-driftctl.com/", + "Type": "aws_api_gateway_base_path_mapping", + "Attrs": { + "api_id": "zetudukz30", + "base_path": "", + "domain_name": "example-driftctl.com", + "id": "example-driftctl.com/", + "stage_name": "foo" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_domain_name/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_domain_name/expected.json new file mode 100755 index 000000000..6dcac7ffb --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_domain_name/expected.json @@ -0,0 +1,28 @@ +[ + { + "Id": "example-driftctl.com", + "Type": "aws_api_gateway_domain_name", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/domainnames/example-driftctl.com", + "certificate_arn": "", + "certificate_name": "", + "certificate_upload_date": "2021-10-05T10:12:49Z", + "cloudfront_domain_name": "", + "cloudfront_zone_id": "Z2FDTNDATAQYW2", + "domain_name": "example-driftctl.com", + "endpoint_configuration": [ + { + "types": [ + "REGIONAL" + ] + } + ], + "id": "example-driftctl.com", + "regional_certificate_arn": "arn:aws:acm:us-east-1:047081014315:certificate/9759296d-8303-4f62-b6f0-f84ed1530047", + "regional_certificate_name": "", + "regional_domain_name": "d-r6fst05lt4.execute-api.us-east-1.amazonaws.com", + "regional_zone_id": "Z1UJRXOUMOOFQ8", + "security_policy": "TLS_1_0" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_domain_name/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_domain_name/input.json new file mode 100755 index 000000000..6dcac7ffb --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_domain_name/input.json @@ -0,0 +1,28 @@ +[ + { + "Id": "example-driftctl.com", + "Type": "aws_api_gateway_domain_name", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/domainnames/example-driftctl.com", + "certificate_arn": "", + "certificate_name": "", + "certificate_upload_date": "2021-10-05T10:12:49Z", + "cloudfront_domain_name": "", + "cloudfront_zone_id": "Z2FDTNDATAQYW2", + "domain_name": "example-driftctl.com", + "endpoint_configuration": [ + { + "types": [ + "REGIONAL" + ] + } + ], + "id": "example-driftctl.com", + "regional_certificate_arn": "arn:aws:acm:us-east-1:047081014315:certificate/9759296d-8303-4f62-b6f0-f84ed1530047", + "regional_certificate_name": "", + "regional_domain_name": "d-r6fst05lt4.execute-api.us-east-1.amazonaws.com", + "regional_zone_id": "Z1UJRXOUMOOFQ8", + "security_policy": "TLS_1_0" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_gateway_response/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_gateway_response/expected.json new file mode 100755 index 000000000..859a3bb9e --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_gateway_response/expected.json @@ -0,0 +1,18 @@ +[ + { + "Id": "aggr-vryjzimtj1-UNAUTHORIZED", + "Type": "aws_api_gateway_gateway_response", + "Attrs": { + "id": "aggr-vryjzimtj1-UNAUTHORIZED", + "response_parameters": { + "gatewayresponse.header.Authorization": "'Basic'" + }, + "response_templates": { + "application/json": "{\"message\":$context.error.messageString}" + }, + "response_type": "UNAUTHORIZED", + "rest_api_id": "vryjzimtj1", + "status_code": "401" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_gateway_response/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_gateway_response/input.json new file mode 100755 index 000000000..859a3bb9e --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_gateway_response/input.json @@ -0,0 +1,18 @@ +[ + { + "Id": "aggr-vryjzimtj1-UNAUTHORIZED", + "Type": "aws_api_gateway_gateway_response", + "Attrs": { + "id": "aggr-vryjzimtj1-UNAUTHORIZED", + "response_parameters": { + "gatewayresponse.header.Authorization": "'Basic'" + }, + "response_templates": { + "application/json": "{\"message\":$context.error.messageString}" + }, + "response_type": "UNAUTHORIZED", + "rest_api_id": "vryjzimtj1", + "status_code": "401" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_integration/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_integration/expected.json new file mode 100755 index 000000000..010690425 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_integration/expected.json @@ -0,0 +1,22 @@ +[ + { + "Id": "agi-u7jce3lokk-z9ag20-GET", + "Type": "aws_api_gateway_integration", + "Attrs": { + "cache_namespace": "z9ag20", + "connection_id": "", + "connection_type": "INTERNET", + "content_handling": "", + "credentials": "", + "http_method": "GET", + "id": "agi-u7jce3lokk-z9ag20-GET", + "integration_http_method": "", + "passthrough_behavior": "WHEN_NO_MATCH", + "resource_id": "z9ag20", + "rest_api_id": "u7jce3lokk", + "timeout_milliseconds": 29000, + "type": "MOCK", + "uri": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_integration/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_integration/input.json new file mode 100755 index 000000000..010690425 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_integration/input.json @@ -0,0 +1,22 @@ +[ + { + "Id": "agi-u7jce3lokk-z9ag20-GET", + "Type": "aws_api_gateway_integration", + "Attrs": { + "cache_namespace": "z9ag20", + "connection_id": "", + "connection_type": "INTERNET", + "content_handling": "", + "credentials": "", + "http_method": "GET", + "id": "agi-u7jce3lokk-z9ag20-GET", + "integration_http_method": "", + "passthrough_behavior": "WHEN_NO_MATCH", + "resource_id": "z9ag20", + "rest_api_id": "u7jce3lokk", + "timeout_milliseconds": 29000, + "type": "MOCK", + "uri": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_integration_response/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_integration_response/expected.json new file mode 100755 index 000000000..acf8d902d --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_integration_response/expected.json @@ -0,0 +1,18 @@ +[ + { + "Id": "agir-u7jce3lokk-z9ag20-GET-200", + "Type": "aws_api_gateway_integration_response", + "Attrs": { + "content_handling": "", + "http_method": "GET", + "id": "agir-u7jce3lokk-z9ag20-GET-200", + "resource_id": "z9ag20", + "response_templates": { + "application/xml": "#set($inputRoot = $input.path('$'))\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cmessage\u003e\n $inputRoot.body\n\u003c/message\u003e\n" + }, + "rest_api_id": "u7jce3lokk", + "selection_pattern": "", + "status_code": "200" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_integration_response/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_integration_response/input.json new file mode 100755 index 000000000..acf8d902d --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_integration_response/input.json @@ -0,0 +1,18 @@ +[ + { + "Id": "agir-u7jce3lokk-z9ag20-GET-200", + "Type": "aws_api_gateway_integration_response", + "Attrs": { + "content_handling": "", + "http_method": "GET", + "id": "agir-u7jce3lokk-z9ag20-GET-200", + "resource_id": "z9ag20", + "response_templates": { + "application/xml": "#set($inputRoot = $input.path('$'))\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cmessage\u003e\n $inputRoot.body\n\u003c/message\u003e\n" + }, + "rest_api_id": "u7jce3lokk", + "selection_pattern": "", + "status_code": "200" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_method/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_method/expected.json new file mode 100755 index 000000000..c9d8f0e48 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_method/expected.json @@ -0,0 +1,16 @@ +[ + { + "Id": "agm-vryjzimtj1-hl7ksq-GET", + "Type": "aws_api_gateway_method", + "Attrs": { + "api_key_required": false, + "authorization": "NONE", + "authorizer_id": "", + "http_method": "GET", + "id": "agm-vryjzimtj1-hl7ksq-GET", + "request_validator_id": "", + "resource_id": "hl7ksq", + "rest_api_id": "vryjzimtj1" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_method/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_method/input.json new file mode 100755 index 000000000..c9d8f0e48 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_method/input.json @@ -0,0 +1,16 @@ +[ + { + "Id": "agm-vryjzimtj1-hl7ksq-GET", + "Type": "aws_api_gateway_method", + "Attrs": { + "api_key_required": false, + "authorization": "NONE", + "authorizer_id": "", + "http_method": "GET", + "id": "agm-vryjzimtj1-hl7ksq-GET", + "request_validator_id": "", + "resource_id": "hl7ksq", + "rest_api_id": "vryjzimtj1" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_method_response/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_method_response/expected.json new file mode 100755 index 000000000..3cfdfbe6f --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_method_response/expected.json @@ -0,0 +1,13 @@ +[ + { + "Id": "agmr-vryjzimtj1-oy4dqf-GET-200", + "Type": "aws_api_gateway_method_response", + "Attrs": { + "http_method": "GET", + "id": "agmr-vryjzimtj1-oy4dqf-GET-200", + "resource_id": "oy4dqf", + "rest_api_id": "vryjzimtj1", + "status_code": "200" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_method_response/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_method_response/input.json new file mode 100755 index 000000000..3cfdfbe6f --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_method_response/input.json @@ -0,0 +1,13 @@ +[ + { + "Id": "agmr-vryjzimtj1-oy4dqf-GET-200", + "Type": "aws_api_gateway_method_response", + "Attrs": { + "http_method": "GET", + "id": "agmr-vryjzimtj1-oy4dqf-GET-200", + "resource_id": "oy4dqf", + "rest_api_id": "vryjzimtj1", + "status_code": "200" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_method_settings/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_method_settings/expected.json new file mode 100755 index 000000000..7657790b7 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_method_settings/expected.json @@ -0,0 +1,50 @@ +[ + { + "Id": "vryjzimtj1-foo-foo/GET", + "Type": "aws_api_gateway_method_settings", + "Attrs": { + "id": "vryjzimtj1-foo-foo/GET", + "method_path": "foo/GET", + "rest_api_id": "vryjzimtj1", + "settings": [ + { + "cache_data_encrypted": false, + "cache_ttl_in_seconds": 300, + "caching_enabled": false, + "data_trace_enabled": false, + "logging_level": "INFO", + "metrics_enabled": true, + "require_authorization_for_cache_control": true, + "throttling_burst_limit": -1, + "throttling_rate_limit": -1, + "unauthorized_cache_control_header_strategy": "SUCCEED_WITH_RESPONSE_HEADER" + } + ], + "stage_name": "foo" + } + }, + { + "Id": "vryjzimtj1-foo-*/*", + "Type": "aws_api_gateway_method_settings", + "Attrs": { + "id": "vryjzimtj1-foo-*/*", + "method_path": "*/*", + "rest_api_id": "vryjzimtj1", + "settings": [ + { + "cache_data_encrypted": false, + "cache_ttl_in_seconds": 300, + "caching_enabled": false, + "data_trace_enabled": false, + "logging_level": "ERROR", + "metrics_enabled": true, + "require_authorization_for_cache_control": true, + "throttling_burst_limit": -1, + "throttling_rate_limit": -1, + "unauthorized_cache_control_header_strategy": "SUCCEED_WITH_RESPONSE_HEADER" + } + ], + "stage_name": "foo" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_method_settings/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_method_settings/input.json new file mode 100755 index 000000000..7657790b7 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_method_settings/input.json @@ -0,0 +1,50 @@ +[ + { + "Id": "vryjzimtj1-foo-foo/GET", + "Type": "aws_api_gateway_method_settings", + "Attrs": { + "id": "vryjzimtj1-foo-foo/GET", + "method_path": "foo/GET", + "rest_api_id": "vryjzimtj1", + "settings": [ + { + "cache_data_encrypted": false, + "cache_ttl_in_seconds": 300, + "caching_enabled": false, + "data_trace_enabled": false, + "logging_level": "INFO", + "metrics_enabled": true, + "require_authorization_for_cache_control": true, + "throttling_burst_limit": -1, + "throttling_rate_limit": -1, + "unauthorized_cache_control_header_strategy": "SUCCEED_WITH_RESPONSE_HEADER" + } + ], + "stage_name": "foo" + } + }, + { + "Id": "vryjzimtj1-foo-*/*", + "Type": "aws_api_gateway_method_settings", + "Attrs": { + "id": "vryjzimtj1-foo-*/*", + "method_path": "*/*", + "rest_api_id": "vryjzimtj1", + "settings": [ + { + "cache_data_encrypted": false, + "cache_ttl_in_seconds": 300, + "caching_enabled": false, + "data_trace_enabled": false, + "logging_level": "ERROR", + "metrics_enabled": true, + "require_authorization_for_cache_control": true, + "throttling_burst_limit": -1, + "throttling_rate_limit": -1, + "unauthorized_cache_control_header_strategy": "SUCCEED_WITH_RESPONSE_HEADER" + } + ], + "stage_name": "foo" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_model/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_model/expected.json new file mode 100755 index 000000000..8a7f87fcc --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_model/expected.json @@ -0,0 +1,26 @@ +[ + { + "Id": "85v536", + "Type": "aws_api_gateway_model", + "Attrs": { + "content_type": "application/json", + "description": "a JSON schema", + "id": "85v536", + "name": "bar", + "rest_api_id": "zetudukz30", + "schema": "{\n \"type\": \"object\"\n}\n" + } + }, + { + "Id": "g68a4s", + "Type": "aws_api_gateway_model", + "Attrs": { + "content_type": "application/json", + "description": "a JSON schema", + "id": "g68a4s", + "name": "foo", + "rest_api_id": "vryjzimtj1", + "schema": "{\n \"type\": \"object\"\n}\n" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_model/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_model/input.json new file mode 100755 index 000000000..8a7f87fcc --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_model/input.json @@ -0,0 +1,26 @@ +[ + { + "Id": "85v536", + "Type": "aws_api_gateway_model", + "Attrs": { + "content_type": "application/json", + "description": "a JSON schema", + "id": "85v536", + "name": "bar", + "rest_api_id": "zetudukz30", + "schema": "{\n \"type\": \"object\"\n}\n" + } + }, + { + "Id": "g68a4s", + "Type": "aws_api_gateway_model", + "Attrs": { + "content_type": "application/json", + "description": "a JSON schema", + "id": "g68a4s", + "name": "foo", + "rest_api_id": "vryjzimtj1", + "schema": "{\n \"type\": \"object\"\n}\n" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_request_validator/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_request_validator/expected.json new file mode 100755 index 000000000..49305671c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_request_validator/expected.json @@ -0,0 +1,24 @@ +[ + { + "Id": "tak8bq", + "Type": "aws_api_gateway_request_validator", + "Attrs": { + "id": "tak8bq", + "name": "bar", + "rest_api_id": "zetudukz30", + "validate_request_body": true, + "validate_request_parameters": true + } + }, + { + "Id": "ywlcuf", + "Type": "aws_api_gateway_request_validator", + "Attrs": { + "id": "ywlcuf", + "name": "foo", + "rest_api_id": "vryjzimtj1", + "validate_request_body": true, + "validate_request_parameters": true + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_request_validator/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_request_validator/input.json new file mode 100755 index 000000000..49305671c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_request_validator/input.json @@ -0,0 +1,24 @@ +[ + { + "Id": "tak8bq", + "Type": "aws_api_gateway_request_validator", + "Attrs": { + "id": "tak8bq", + "name": "bar", + "rest_api_id": "zetudukz30", + "validate_request_body": true, + "validate_request_parameters": true + } + }, + { + "Id": "ywlcuf", + "Type": "aws_api_gateway_request_validator", + "Attrs": { + "id": "ywlcuf", + "name": "foo", + "rest_api_id": "vryjzimtj1", + "validate_request_body": true, + "validate_request_parameters": true + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_resource/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_resource/expected.json new file mode 100755 index 000000000..011bb8082 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_resource/expected.json @@ -0,0 +1,24 @@ +[ + { + "Id": "21zk4y", + "Type": "aws_api_gateway_resource", + "Attrs": { + "id": "21zk4y", + "parent_id": "pe75h6tq6i", + "path": "/bar", + "path_part": "bar", + "rest_api_id": "3of73v5ob4" + } + }, + { + "Id": "wijcbm", + "Type": "aws_api_gateway_resource", + "Attrs": { + "id": "wijcbm", + "parent_id": "2ltv32p058", + "path": "/foo", + "path_part": "foo", + "rest_api_id": "1jitcobwol" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_resource/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_resource/input.json new file mode 100755 index 000000000..011bb8082 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_resource/input.json @@ -0,0 +1,24 @@ +[ + { + "Id": "21zk4y", + "Type": "aws_api_gateway_resource", + "Attrs": { + "id": "21zk4y", + "parent_id": "pe75h6tq6i", + "path": "/bar", + "path_part": "bar", + "rest_api_id": "3of73v5ob4" + } + }, + { + "Id": "wijcbm", + "Type": "aws_api_gateway_resource", + "Attrs": { + "id": "wijcbm", + "parent_id": "2ltv32p058", + "path": "/foo", + "path_part": "foo", + "rest_api_id": "1jitcobwol" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_rest_api/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_rest_api/expected.json new file mode 100755 index 000000000..f61a9c984 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_rest_api/expected.json @@ -0,0 +1,49 @@ +[ + { + "Id": "3of73v5ob4", + "Type": "aws_api_gateway_rest_api", + "Attrs": { + "api_key_source": "HEADER", + "arn": "arn:aws:apigateway:us-east-1::/restapis/3of73v5ob4", + "body": "{\"info\":{\"title\":\"example\",\"version\":\"1.0\"},\"openapi\":\"3.0.1\",\"paths\":{\"/path1\":{\"get\":{\"x-amazon-apigateway-integration\":{\"httpMethod\":\"GET\",\"payloadFormatVersion\":\"1.0\",\"type\":\"HTTP_PROXY\",\"uri\":\"https://ip-ranges.amazonaws.com/ip-ranges.json\"}}}}}", + "created_date": "2021-09-14T13:08:52Z", + "description": "This is bar API", + "endpoint_configuration": [ + { + "types": [ + "EDGE" + ] + } + ], + "execution_arn": "arn:aws:execute-api:us-east-1:047081014315:3of73v5ob4", + "id": "3of73v5ob4", + "minimum_compression_size": -1, + "name": "bar", + "policy": "", + "root_resource_id": "pe75h6tq6i" + } + }, + { + "Id": "1jitcobwol", + "Type": "aws_api_gateway_rest_api", + "Attrs": { + "api_key_source": "HEADER", + "arn": "arn:aws:apigateway:us-east-1::/restapis/1jitcobwol", + "created_date": "2021-09-14T13:07:37Z", + "description": "This is foo API", + "endpoint_configuration": [ + { + "types": [ + "EDGE" + ] + } + ], + "execution_arn": "arn:aws:execute-api:us-east-1:047081014315:1jitcobwol", + "id": "1jitcobwol", + "minimum_compression_size": -1, + "name": "foo", + "policy": "", + "root_resource_id": "2ltv32p058" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_rest_api/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_rest_api/input.json new file mode 100755 index 000000000..acc6041f2 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_rest_api/input.json @@ -0,0 +1,49 @@ +[ + { + "Id": "3of73v5ob4", + "Type": "aws_api_gateway_rest_api", + "Attrs": { + "api_key_source": "HEADER", + "arn": "arn:aws:apigateway:us-east-1::/restapis/3of73v5ob4", + "body": "{\"info\":{\"title\":\"example\",\"version\":\"1.0\"},\"openapi\":\"3.0.1\",\"paths\":{\"/path1\":{\"get\":{\"x-amazon-apigateway-integration\":{\"httpMethod\":\"GET\",\"payloadFormatVersion\":\"1.0\",\"type\":\"HTTP_PROXY\",\"uri\":\"https://ip-ranges.amazonaws.com/ip-ranges.json\"}}}}}", + "created_date": "2021-09-14T13:08:52Z", + "description": "This is bar API", + "endpoint_configuration": [ + { + "types": [ + "EDGE" + ] + } + ], + "execution_arn": "arn:aws:execute-api:us-east-1:047081014315:3of73v5ob4", + "id": "3of73v5ob4", + "minimum_compression_size": -1, + "name": "bar", + "policy": "", + "root_resource_id": "pe75h6tq6i" + } + }, + { + "Id": "1jitcobwol", + "Type": "aws_api_gateway_rest_api", + "Attrs": { + "api_key_source": "HEADER", + "arn": "arn:aws:apigateway:us-east-1::/restapis/1jitcobwol", + "created_date": "2021-09-14T13:07:37Z", + "description": "This is foo API", + "endpoint_configuration": [ + { + "types": [ + "EDGE" + ] + } + ], + "execution_arn": "arn:aws:execute-api:us-east-1:047081014315:1jitcobwol", + "id": "1jitcobwol", + "minimum_compression_size": -1, + "name": "foo", + "policy": "", + "root_resource_id": "2ltv32p058" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_rest_api_policy/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_rest_api_policy/expected.json new file mode 100755 index 000000000..53e10f181 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_rest_api_policy/expected.json @@ -0,0 +1,20 @@ +[ + { + "Id": "c3n3aqga5d", + "Type": "aws_api_gateway_rest_api_policy", + "Attrs": { + "id": "c3n3aqga5d", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:047081014315:c3n3aqga5d/*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":\"123.123.123.123/32\"}}}]}", + "rest_api_id": "c3n3aqga5d" + } + }, + { + "Id": "uwk4xvbm04", + "Type": "aws_api_gateway_rest_api_policy", + "Attrs": { + "id": "uwk4xvbm04", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:047081014315:uwk4xvbm04/*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":\"12.12.12.12/32\"}}}]}", + "rest_api_id": "uwk4xvbm04" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_rest_api_policy/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_rest_api_policy/input.json new file mode 100755 index 000000000..53e10f181 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_rest_api_policy/input.json @@ -0,0 +1,20 @@ +[ + { + "Id": "c3n3aqga5d", + "Type": "aws_api_gateway_rest_api_policy", + "Attrs": { + "id": "c3n3aqga5d", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:047081014315:c3n3aqga5d/*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":\"123.123.123.123/32\"}}}]}", + "rest_api_id": "c3n3aqga5d" + } + }, + { + "Id": "uwk4xvbm04", + "Type": "aws_api_gateway_rest_api_policy", + "Attrs": { + "id": "uwk4xvbm04", + "policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":\"execute-api:Invoke\",\"Resource\":\"arn:aws:execute-api:us-east-1:047081014315:uwk4xvbm04/*\",\"Condition\":{\"IpAddress\":{\"aws:SourceIp\":\"12.12.12.12/32\"}}}]}", + "rest_api_id": "uwk4xvbm04" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_stage/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_stage/expected.json new file mode 100755 index 000000000..ab3f4faa4 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_stage/expected.json @@ -0,0 +1,40 @@ +[ + { + "Id": "ags-3of73v5ob4-baz", + "Type": "aws_api_gateway_stage", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/restapis/3of73v5ob4/stages/baz", + "cache_cluster_enabled": false, + "cache_cluster_size": "", + "client_certificate_id": "", + "deployment_id": "i5bl4e", + "description": "", + "documentation_version": "", + "execution_arn": "arn:aws:execute-api:us-east-1:047081014315:3of73v5ob4/baz", + "id": "ags-3of73v5ob4-baz", + "invoke_url": "https://3of73v5ob4.execute-api.us-east-1.amazonaws.com/baz", + "rest_api_id": "3of73v5ob4", + "stage_name": "baz", + "xray_tracing_enabled": false + } + }, + { + "Id": "ags-3of73v5ob4-foo", + "Type": "aws_api_gateway_stage", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/restapis/3of73v5ob4/stages/foo", + "cache_cluster_enabled": false, + "cache_cluster_size": "", + "client_certificate_id": "", + "deployment_id": "i5bl4e", + "description": "", + "documentation_version": "", + "execution_arn": "arn:aws:execute-api:us-east-1:047081014315:3of73v5ob4/foo", + "id": "ags-3of73v5ob4-foo", + "invoke_url": "https://3of73v5ob4.execute-api.us-east-1.amazonaws.com/foo", + "rest_api_id": "3of73v5ob4", + "stage_name": "foo", + "xray_tracing_enabled": false + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_stage/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_stage/input.json new file mode 100755 index 000000000..ab3f4faa4 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_stage/input.json @@ -0,0 +1,40 @@ +[ + { + "Id": "ags-3of73v5ob4-baz", + "Type": "aws_api_gateway_stage", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/restapis/3of73v5ob4/stages/baz", + "cache_cluster_enabled": false, + "cache_cluster_size": "", + "client_certificate_id": "", + "deployment_id": "i5bl4e", + "description": "", + "documentation_version": "", + "execution_arn": "arn:aws:execute-api:us-east-1:047081014315:3of73v5ob4/baz", + "id": "ags-3of73v5ob4-baz", + "invoke_url": "https://3of73v5ob4.execute-api.us-east-1.amazonaws.com/baz", + "rest_api_id": "3of73v5ob4", + "stage_name": "baz", + "xray_tracing_enabled": false + } + }, + { + "Id": "ags-3of73v5ob4-foo", + "Type": "aws_api_gateway_stage", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/restapis/3of73v5ob4/stages/foo", + "cache_cluster_enabled": false, + "cache_cluster_size": "", + "client_certificate_id": "", + "deployment_id": "i5bl4e", + "description": "", + "documentation_version": "", + "execution_arn": "arn:aws:execute-api:us-east-1:047081014315:3of73v5ob4/foo", + "id": "ags-3of73v5ob4-foo", + "invoke_url": "https://3of73v5ob4.execute-api.us-east-1.amazonaws.com/foo", + "rest_api_id": "3of73v5ob4", + "stage_name": "foo", + "xray_tracing_enabled": false + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_vpc_link/expected.json b/pkg/test/aws/3.19.0/aws_api_gateway_vpc_link/expected.json new file mode 100755 index 000000000..ab5eec4b4 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_vpc_link/expected.json @@ -0,0 +1,15 @@ +[ + { + "Id": "ipu24n", + "Type": "aws_api_gateway_vpc_link", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/vpclinks/ipu24n", + "description": "Description", + "id": "ipu24n", + "name": "foo", + "target_arns": [ + "arn:aws:elasticloadbalancing:us-east-1:047081014315:loadbalancer/net/example/ffbc3a2463857d4e" + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_api_gateway_vpc_link/input.json b/pkg/test/aws/3.19.0/aws_api_gateway_vpc_link/input.json new file mode 100755 index 000000000..ab5eec4b4 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_api_gateway_vpc_link/input.json @@ -0,0 +1,15 @@ +[ + { + "Id": "ipu24n", + "Type": "aws_api_gateway_vpc_link", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-1::/vpclinks/ipu24n", + "description": "Description", + "id": "ipu24n", + "name": "foo", + "target_arns": [ + "arn:aws:elasticloadbalancing:us-east-1:047081014315:loadbalancer/net/example/ffbc3a2463857d4e" + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_api/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_api/expected.json new file mode 100755 index 000000000..4f8895e38 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_api/expected.json @@ -0,0 +1,19 @@ +[ + { + "Id": "f5vdrg12tk", + "Type": "aws_apigatewayv2_api", + "Attrs": { + "api_endpoint": "wss://f5vdrg12tk.execute-api.us-east-2.amazonaws.com", + "api_key_selection_expression": "$request.header.x-api-key", + "arn": "arn:aws:apigateway:us-east-2::/apis/f5vdrg12tk", + "description": "", + "disable_execute_api_endpoint": false, + "execution_arn": "arn:aws:execute-api:us-east-2:070182406464:f5vdrg12tk", + "id": "f5vdrg12tk", + "name": "example-websocket-api", + "protocol_type": "WEBSOCKET", + "route_selection_expression": "$request.body.action", + "version": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_api/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_api/input.json new file mode 100755 index 000000000..4f8895e38 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_api/input.json @@ -0,0 +1,19 @@ +[ + { + "Id": "f5vdrg12tk", + "Type": "aws_apigatewayv2_api", + "Attrs": { + "api_endpoint": "wss://f5vdrg12tk.execute-api.us-east-2.amazonaws.com", + "api_key_selection_expression": "$request.header.x-api-key", + "arn": "arn:aws:apigateway:us-east-2::/apis/f5vdrg12tk", + "description": "", + "disable_execute_api_endpoint": false, + "execution_arn": "arn:aws:execute-api:us-east-2:070182406464:f5vdrg12tk", + "id": "f5vdrg12tk", + "name": "example-websocket-api", + "protocol_type": "WEBSOCKET", + "route_selection_expression": "$request.body.action", + "version": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_api_mapping/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_api_mapping/expected.json new file mode 100755 index 000000000..839c9a0b5 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_api_mapping/expected.json @@ -0,0 +1,13 @@ +[ + { + "Id": "f02opk", + "Type": "aws_apigatewayv2_api_mapping", + "Attrs": { + "api_id": "wbachnbphj", + "api_mapping_key": "", + "domain_name": "driftctl.example.com", + "id": "f02opk", + "stage": "example-stage" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_api_mapping/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_api_mapping/input.json new file mode 100755 index 000000000..839c9a0b5 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_api_mapping/input.json @@ -0,0 +1,13 @@ +[ + { + "Id": "f02opk", + "Type": "aws_apigatewayv2_api_mapping", + "Attrs": { + "api_id": "wbachnbphj", + "api_mapping_key": "", + "domain_name": "driftctl.example.com", + "id": "f02opk", + "stage": "example-stage" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_authorizer/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_authorizer/expected.json new file mode 100755 index 000000000..d68e566af --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_authorizer/expected.json @@ -0,0 +1,20 @@ +[ + { + "Id": "xaappu", + "Type": "aws_apigatewayv2_authorizer", + "Attrs": { + "api_id": "bmyl5c6huh", + "authorizer_credentials_arn": "", + "authorizer_payload_format_version": "", + "authorizer_result_ttl_in_seconds": 0, + "authorizer_type": "REQUEST", + "authorizer_uri": "arn:aws:apigateway:us-east-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-2:047081014315:function:api_gateway_authorizer/invocations", + "enable_simple_responses": false, + "id": "xaappu", + "identity_sources": [ + "route.request.header.Auth" + ], + "name": "foo" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_authorizer/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_authorizer/input.json new file mode 100755 index 000000000..d68e566af --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_authorizer/input.json @@ -0,0 +1,20 @@ +[ + { + "Id": "xaappu", + "Type": "aws_apigatewayv2_authorizer", + "Attrs": { + "api_id": "bmyl5c6huh", + "authorizer_credentials_arn": "", + "authorizer_payload_format_version": "", + "authorizer_result_ttl_in_seconds": 0, + "authorizer_type": "REQUEST", + "authorizer_uri": "arn:aws:apigateway:us-east-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-east-2:047081014315:function:api_gateway_authorizer/invocations", + "enable_simple_responses": false, + "id": "xaappu", + "identity_sources": [ + "route.request.header.Auth" + ], + "name": "foo" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_deployment/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_deployment/expected.json new file mode 100755 index 000000000..fc0bc3517 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_deployment/expected.json @@ -0,0 +1,12 @@ +[ + { + "Id": "dcab", + "Type": "aws_apigatewayv2_deployment", + "Attrs": { + "api_id": "abcd", + "auto_deployed": false, + "description": "Example deployment", + "id": "dcab" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_deployment/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_deployment/input.json new file mode 100755 index 000000000..fc0bc3517 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_deployment/input.json @@ -0,0 +1,12 @@ +[ + { + "Id": "dcab", + "Type": "aws_apigatewayv2_deployment", + "Attrs": { + "api_id": "abcd", + "auto_deployed": false, + "description": "Example deployment", + "id": "dcab" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_domain_name/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_domain_name/expected.json new file mode 100755 index 000000000..f87380c79 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_domain_name/expected.json @@ -0,0 +1,21 @@ +[ + { + "Id": "driftctl.example.com", + "Type": "aws_apigatewayv2_domain_name", + "Attrs": { + "api_mapping_selection_expression": "$request.basepath", + "arn": "arn:aws:apigateway:us-east-2::/domainnames/driftctl.example.com", + "domain_name": "driftctl.example.com", + "domain_name_configuration": [ + { + "certificate_arn": "arn:aws:acm:us-east-2:047081014315:certificate/c49d9c11-1308-4594-bd78-7853466ae7bc", + "endpoint_type": "REGIONAL", + "hosted_zone_id": "ZOJJZC49E0EPZ", + "security_policy": "TLS_1_2", + "target_domain_name": "d-db4yiff8oa.execute-api.us-east-2.amazonaws.com" + } + ], + "id": "driftctl.example.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_domain_name/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_domain_name/input.json new file mode 100755 index 000000000..f87380c79 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_domain_name/input.json @@ -0,0 +1,21 @@ +[ + { + "Id": "driftctl.example.com", + "Type": "aws_apigatewayv2_domain_name", + "Attrs": { + "api_mapping_selection_expression": "$request.basepath", + "arn": "arn:aws:apigateway:us-east-2::/domainnames/driftctl.example.com", + "domain_name": "driftctl.example.com", + "domain_name_configuration": [ + { + "certificate_arn": "arn:aws:acm:us-east-2:047081014315:certificate/c49d9c11-1308-4594-bd78-7853466ae7bc", + "endpoint_type": "REGIONAL", + "hosted_zone_id": "ZOJJZC49E0EPZ", + "security_policy": "TLS_1_2", + "target_domain_name": "d-db4yiff8oa.execute-api.us-east-2.amazonaws.com" + } + ], + "id": "driftctl.example.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_integration/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_integration/expected.json new file mode 100755 index 000000000..6f1949fbe --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_integration/expected.json @@ -0,0 +1,24 @@ +[ + { + "Id": "fmezvlh", + "Type": "aws_apigatewayv2_integration", + "Attrs": { + "api_id": "yw28nwdf34", + "connection_id": "", + "connection_type": "INTERNET", + "content_handling_strategy": "", + "credentials_arn": "", + "description": "", + "id": "fmezvlh", + "integration_method": "", + "integration_response_selection_expression": "${integration.response.statuscode}", + "integration_subtype": "", + "integration_type": "MOCK", + "integration_uri": "", + "passthrough_behavior": "WHEN_NO_MATCH", + "payload_format_version": "1.0", + "template_selection_expression": "", + "timeout_milliseconds": 29000 + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_integration/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_integration/input.json new file mode 100755 index 000000000..6f1949fbe --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_integration/input.json @@ -0,0 +1,24 @@ +[ + { + "Id": "fmezvlh", + "Type": "aws_apigatewayv2_integration", + "Attrs": { + "api_id": "yw28nwdf34", + "connection_id": "", + "connection_type": "INTERNET", + "content_handling_strategy": "", + "credentials_arn": "", + "description": "", + "id": "fmezvlh", + "integration_method": "", + "integration_response_selection_expression": "${integration.response.statuscode}", + "integration_subtype": "", + "integration_type": "MOCK", + "integration_uri": "", + "passthrough_behavior": "WHEN_NO_MATCH", + "payload_format_version": "1.0", + "template_selection_expression": "", + "timeout_milliseconds": 29000 + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_integration_response/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_integration_response/expected.json new file mode 100755 index 000000000..1ff3574f6 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_integration_response/expected.json @@ -0,0 +1,14 @@ +[ + { + "Id": "sf67ti7", + "Type": "aws_apigatewayv2_integration_response", + "Attrs": { + "api_id": "yw28nwdf34", + "content_handling_strategy": "", + "id": "sf67ti7", + "integration_id": "fmezvlh", + "integration_response_key": "/200/", + "template_selection_expression": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_integration_response/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_integration_response/input.json new file mode 100755 index 000000000..1ff3574f6 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_integration_response/input.json @@ -0,0 +1,14 @@ +[ + { + "Id": "sf67ti7", + "Type": "aws_apigatewayv2_integration_response", + "Attrs": { + "api_id": "yw28nwdf34", + "content_handling_strategy": "", + "id": "sf67ti7", + "integration_id": "fmezvlh", + "integration_response_key": "/200/", + "template_selection_expression": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_model/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_model/expected.json new file mode 100755 index 000000000..e767143f7 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_model/expected.json @@ -0,0 +1,14 @@ +[ + { + "Id": "vdw6up", + "Type": "aws_apigatewayv2_model", + "Attrs": { + "api_id": "ci51xtkpsg", + "content_type": "application/json", + "description": "", + "id": "vdw6up", + "name": "example", + "schema": "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n \"title\": \"ExampleModel\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": { \"type\": \"string\" }\n }\n}\n" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_model/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_model/input.json new file mode 100755 index 000000000..e767143f7 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_model/input.json @@ -0,0 +1,14 @@ +[ + { + "Id": "vdw6up", + "Type": "aws_apigatewayv2_model", + "Attrs": { + "api_id": "ci51xtkpsg", + "content_type": "application/json", + "description": "", + "id": "vdw6up", + "name": "example", + "schema": "{\n \"$schema\": \"http://json-schema.org/draft-04/schema#\",\n \"title\": \"ExampleModel\",\n \"type\": \"object\",\n \"properties\": {\n \"id\": { \"type\": \"string\" }\n }\n}\n" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_route/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_route/expected.json new file mode 100755 index 000000000..c46fe0ea6 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_route/expected.json @@ -0,0 +1,18 @@ +[ + { + "Id": "dcab", + "Type": "aws_apigatewayv2_route", + "Attrs": { + "api_id": "abcd", + "api_key_required": false, + "authorization_type": "NONE", + "authorizer_id": "", + "id": "dcab", + "model_selection_expression": "", + "operation_name": "", + "route_key": "$default", + "route_response_selection_expression": "", + "target": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_route/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_route/input.json new file mode 100755 index 000000000..c46fe0ea6 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_route/input.json @@ -0,0 +1,18 @@ +[ + { + "Id": "dcab", + "Type": "aws_apigatewayv2_route", + "Attrs": { + "api_id": "abcd", + "api_key_required": false, + "authorization_type": "NONE", + "authorizer_id": "", + "id": "dcab", + "model_selection_expression": "", + "operation_name": "", + "route_key": "$default", + "route_response_selection_expression": "", + "target": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_route_response/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_route_response/expected.json new file mode 100755 index 000000000..92236e839 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_route_response/expected.json @@ -0,0 +1,13 @@ +[ + { + "Id": "nbw7vw", + "Type": "aws_apigatewayv2_route_response", + "Attrs": { + "api_id": "77ooqulkke", + "id": "nbw7vw", + "model_selection_expression": "", + "route_id": "liqc5u4", + "route_response_key": "$default" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_route_response/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_route_response/input.json new file mode 100755 index 000000000..92236e839 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_route_response/input.json @@ -0,0 +1,13 @@ +[ + { + "Id": "nbw7vw", + "Type": "aws_apigatewayv2_route_response", + "Attrs": { + "api_id": "77ooqulkke", + "id": "nbw7vw", + "model_selection_expression": "", + "route_id": "liqc5u4", + "route_response_key": "$default" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_stage/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_stage/expected.json new file mode 100755 index 000000000..63018f464 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_stage/expected.json @@ -0,0 +1,27 @@ +[ + { + "Id": "example-stage", + "Type": "aws_apigatewayv2_stage", + "Attrs": { + "api_id": "hn5fxpwfae", + "arn": "arn:aws:apigateway:us-east-1::/apis/hn5fxpwfae/stages/example-stage", + "auto_deploy": false, + "client_certificate_id": "", + "default_route_settings": [ + { + "data_trace_enabled": false, + "detailed_metrics_enabled": false, + "logging_level": "", + "throttling_burst_limit": 0, + "throttling_rate_limit": 0 + } + ], + "deployment_id": "", + "description": "", + "execution_arn": "arn:aws:execute-api:us-east-1:929327065333:hn5fxpwfae/example-stage", + "id": "example-stage", + "invoke_url": "https://hn5fxpwfae.execute-api.us-east-1.amazonaws.com/example-stage", + "name": "example-stage" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_stage/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_stage/input.json new file mode 100755 index 000000000..63018f464 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_stage/input.json @@ -0,0 +1,27 @@ +[ + { + "Id": "example-stage", + "Type": "aws_apigatewayv2_stage", + "Attrs": { + "api_id": "hn5fxpwfae", + "arn": "arn:aws:apigateway:us-east-1::/apis/hn5fxpwfae/stages/example-stage", + "auto_deploy": false, + "client_certificate_id": "", + "default_route_settings": [ + { + "data_trace_enabled": false, + "detailed_metrics_enabled": false, + "logging_level": "", + "throttling_burst_limit": 0, + "throttling_rate_limit": 0 + } + ], + "deployment_id": "", + "description": "", + "execution_arn": "arn:aws:execute-api:us-east-1:929327065333:hn5fxpwfae/example-stage", + "id": "example-stage", + "invoke_url": "https://hn5fxpwfae.execute-api.us-east-1.amazonaws.com/example-stage", + "name": "example-stage" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_vpc_link/expected.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_vpc_link/expected.json new file mode 100755 index 000000000..81682f82b --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_vpc_link/expected.json @@ -0,0 +1,21 @@ +[ + { + "Id": "b8r351", + "Type": "aws_apigatewayv2_vpc_link", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-2::/vpclinks/b8r351", + "id": "b8r351", + "name": "foo", + "security_group_ids": [ + "sg-055d40d3b933c2c4b" + ], + "subnet_ids": [ + "subnet-06e2e690aa9cfcb4e", + "subnet-0b536f373c65d780a" + ], + "tags": { + "Usage": "example" + } + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_apigatewayv2_vpc_link/input.json b/pkg/test/aws/3.19.0/aws_apigatewayv2_vpc_link/input.json new file mode 100755 index 000000000..81682f82b --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_apigatewayv2_vpc_link/input.json @@ -0,0 +1,21 @@ +[ + { + "Id": "b8r351", + "Type": "aws_apigatewayv2_vpc_link", + "Attrs": { + "arn": "arn:aws:apigateway:us-east-2::/vpclinks/b8r351", + "id": "b8r351", + "name": "foo", + "security_group_ids": [ + "sg-055d40d3b933c2c4b" + ], + "subnet_ids": [ + "subnet-06e2e690aa9cfcb4e", + "subnet-0b536f373c65d780a" + ], + "tags": { + "Usage": "example" + } + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_appautoscaling_policy/expected.json b/pkg/test/aws/3.19.0/aws_appautoscaling_policy/expected.json new file mode 100755 index 000000000..63fdee704 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_appautoscaling_policy/expected.json @@ -0,0 +1,29 @@ +[ + { + "Id": "DynamoDBReadCapacityUtilization:table/GameScores", + "Type": "aws_appautoscaling_policy", + "Attrs": { + "arn": "arn:aws:autoscaling:us-east-1:533948124879:scalingPolicy:012b61a9-c500-41a0-84a4-019976bd10fc:resource/dynamodb/table/GameScores:policyName/DynamoDBReadCapacityUtilization:table/GameScores", + "id": "DynamoDBReadCapacityUtilization:table/GameScores", + "name": "DynamoDBReadCapacityUtilization:table/GameScores", + "policy_type": "TargetTrackingScaling", + "resource_id": "table/GameScores", + "scalable_dimension": "dynamodb:table:ReadCapacityUnits", + "service_namespace": "dynamodb", + "target_tracking_scaling_policy_configuration": [ + { + "disable_scale_in": false, + "predefined_metric_specification": [ + { + "predefined_metric_type": "DynamoDBReadCapacityUtilization", + "resource_label": "" + } + ], + "scale_in_cooldown": 0, + "scale_out_cooldown": 0, + "target_value": 70 + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_appautoscaling_policy/input.json b/pkg/test/aws/3.19.0/aws_appautoscaling_policy/input.json new file mode 100755 index 000000000..14db041ec --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_appautoscaling_policy/input.json @@ -0,0 +1,31 @@ +[ + { + "Id": "DynamoDBReadCapacityUtilization:table/GameScores", + "Type": "aws_appautoscaling_policy", + "Attrs": { + "arn": "arn:aws:autoscaling:us-east-1:533948124879:scalingPolicy:012b61a9-c500-41a0-84a4-019976bd10fc:resource/dynamodb/table/GameScores:policyName/DynamoDBReadCapacityUtilization:table/GameScores", + "id": "DynamoDBReadCapacityUtilization:table/GameScores", + "name": "DynamoDBReadCapacityUtilization:table/GameScores", + "policy_type": "TargetTrackingScaling", + "resource_id": "table/GameScores", + "scalable_dimension": "dynamodb:table:ReadCapacityUnits", + "service_namespace": "dynamodb", + "step_scaling_policy_configuration": [], + "target_tracking_scaling_policy_configuration": [ + { + "customized_metric_specification": [], + "disable_scale_in": false, + "predefined_metric_specification": [ + { + "predefined_metric_type": "DynamoDBReadCapacityUtilization", + "resource_label": "" + } + ], + "scale_in_cooldown": 0, + "scale_out_cooldown": 0, + "target_value": 70 + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_appautoscaling_scheduled_action/expected.json b/pkg/test/aws/3.19.0/aws_appautoscaling_scheduled_action/expected.json new file mode 100755 index 000000000..0ff10f10c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_appautoscaling_scheduled_action/expected.json @@ -0,0 +1,21 @@ +[ + { + "Id": "dynamodb-dynamodb-table/GameScores", + "Type": "aws_appautoscaling_scheduled_action", + "Attrs": { + "arn": "arn:aws:autoscaling:us-east-1:533948124879:scheduledAction:cf26c451-97f8-49f9-9cdd-515135e7d0f3:resource/dynamodb/table/GameScores:scheduledActionName/dynamodb", + "id": "dynamodb-dynamodb-table/GameScores", + "name": "dynamodb", + "resource_id": "table/GameScores", + "scalable_dimension": "dynamodb:table:ReadCapacityUnits", + "scalable_target_action": [ + { + "max_capacity": 200, + "min_capacity": 1 + } + ], + "schedule": "at(2006-01-02T15:04:05)", + "service_namespace": "dynamodb" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_appautoscaling_scheduled_action/input.json b/pkg/test/aws/3.19.0/aws_appautoscaling_scheduled_action/input.json new file mode 100755 index 000000000..0ff10f10c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_appautoscaling_scheduled_action/input.json @@ -0,0 +1,21 @@ +[ + { + "Id": "dynamodb-dynamodb-table/GameScores", + "Type": "aws_appautoscaling_scheduled_action", + "Attrs": { + "arn": "arn:aws:autoscaling:us-east-1:533948124879:scheduledAction:cf26c451-97f8-49f9-9cdd-515135e7d0f3:resource/dynamodb/table/GameScores:scheduledActionName/dynamodb", + "id": "dynamodb-dynamodb-table/GameScores", + "name": "dynamodb", + "resource_id": "table/GameScores", + "scalable_dimension": "dynamodb:table:ReadCapacityUnits", + "scalable_target_action": [ + { + "max_capacity": 200, + "min_capacity": 1 + } + ], + "schedule": "at(2006-01-02T15:04:05)", + "service_namespace": "dynamodb" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_appautoscaling_target/expected.json b/pkg/test/aws/3.19.0/aws_appautoscaling_target/expected.json new file mode 100755 index 000000000..99885d6a3 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_appautoscaling_target/expected.json @@ -0,0 +1,15 @@ +[ + { + "Id": "table/GameScores", + "Type": "aws_appautoscaling_target", + "Attrs": { + "id": "table/GameScores", + "max_capacity": 100, + "min_capacity": 5, + "resource_id": "table/GameScores", + "role_arn": "arn:aws:iam::533948124879:role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_DynamoDBTable", + "scalable_dimension": "dynamodb:table:ReadCapacityUnits", + "service_namespace": "dynamodb" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_appautoscaling_target/input.json b/pkg/test/aws/3.19.0/aws_appautoscaling_target/input.json new file mode 100755 index 000000000..2e88ee801 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_appautoscaling_target/input.json @@ -0,0 +1,15 @@ +[ + { + "Id": "table/GameScores", + "Type": "aws_appautoscaling_target", + "Attrs": { + "id": "table/GameScores", + "max_capacity": 100, + "min_capacity": 5, + "resource_id": "table/GameScores", + "role_arn": "arn:aws:iam::533948124879:role/aws-service-role/dynamodb.application-autoscaling.amazonaws.com/AWSServiceRoleForApplicationAutoScaling_DynamoDBTable", + "scalable_dimension": "dynamodb:table:ReadCapacityUnits", + "service_namespace": "dynamodb" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_cloudformation_stack/expected.json b/pkg/test/aws/3.19.0/aws_cloudformation_stack/expected.json new file mode 100755 index 000000000..17dd12def --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_cloudformation_stack/expected.json @@ -0,0 +1,30 @@ +[ + { + "Id": "arn:aws:cloudformation:us-east-1:047081014315:stack/bar-stack/c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab", + "Type": "aws_cloudformation_stack", + "Attrs": { + "capabilities": [ + "CAPABILITY_NAMED_IAM" + ], + "disable_rollback": false, + "iam_role_arn": "", + "id": "arn:aws:cloudformation:us-east-1:047081014315:stack/bar-stack/c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab", + "name": "bar-stack", + "template_body": "Resources:\n myUser:\n Type: AWS::IAM::User\n Properties:\n UserName: \"bar_cfn\"\n" + } + }, + { + "Id": "arn:aws:cloudformation:us-east-1:047081014315:stack/foo-stack/c7aa0ab0-0f21-11ec-ba25-129d8c0b3757", + "Type": "aws_cloudformation_stack", + "Attrs": { + "disable_rollback": false, + "iam_role_arn": "", + "id": "arn:aws:cloudformation:us-east-1:047081014315:stack/foo-stack/c7aa0ab0-0f21-11ec-ba25-129d8c0b3757", + "name": "foo-stack", + "parameters": { + "VPCCidr": "10.0.0.0/16" + }, + "template_body": "{\"Parameters\":{\"VPCCidr\":{\"Default\":\"10.0.0.0/16\",\"Description\":\"Enter the CIDR block for the VPC. Default is 10.0.0.0/16.\",\"Type\":\"String\"}},\"Resources\":{\"myVpc\":{\"Properties\":{\"CidrBlock\":{\"Ref\":\"VPCCidr\"},\"Tags\":[{\"Key\":\"Name\",\"Value\":\"Primary_CF_VPC\"}]},\"Type\":\"AWS::EC2::VPC\"}}}" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_cloudformation_stack/input.json b/pkg/test/aws/3.19.0/aws_cloudformation_stack/input.json new file mode 100755 index 000000000..782a640ca --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_cloudformation_stack/input.json @@ -0,0 +1,50 @@ +[ + { + "Id": "arn:aws:cloudformation:us-east-1:047081014315:stack/foo-stack/c7aa0ab0-0f21-11ec-ba25-129d8c0b3757", + "Type": "aws_cloudformation_stack", + "Attrs": { + "capabilities": null, + "disable_rollback": false, + "iam_role_arn": "", + "id": "arn:aws:cloudformation:us-east-1:047081014315:stack/foo-stack/c7aa0ab0-0f21-11ec-ba25-129d8c0b3757", + "name": "foo-stack", + "notification_arns": null, + "on_failure": null, + "outputs": {}, + "parameters": { + "VPCCidr": "10.0.0.0/16" + }, + "policy_body": null, + "policy_url": null, + "tags": {}, + "template_body": "{\"Parameters\":{\"VPCCidr\":{\"Default\":\"10.0.0.0/16\",\"Description\":\"Enter the CIDR block for the VPC. Default is 10.0.0.0/16.\",\"Type\":\"String\"}},\"Resources\":{\"myVpc\":{\"Properties\":{\"CidrBlock\":{\"Ref\":\"VPCCidr\"},\"Tags\":[{\"Key\":\"Name\",\"Value\":\"Primary_CF_VPC\"}]},\"Type\":\"AWS::EC2::VPC\"}}}", + "template_url": null, + "timeout_in_minutes": null, + "timeouts": {} + } + }, + { + "Id": "arn:aws:cloudformation:us-east-1:047081014315:stack/bar-stack/c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab", + "Type": "aws_cloudformation_stack", + "Attrs": { + "capabilities": [ + "CAPABILITY_NAMED_IAM" + ], + "disable_rollback": false, + "iam_role_arn": "", + "id": "arn:aws:cloudformation:us-east-1:047081014315:stack/bar-stack/c7a96e70-0f21-11ec-bd2a-0a2d95c2b2ab", + "name": "bar-stack", + "notification_arns": null, + "on_failure": null, + "outputs": {}, + "parameters": {}, + "policy_body": null, + "policy_url": null, + "tags": {}, + "template_body": "Resources:\n myUser:\n Type: AWS::IAM::User\n Properties:\n UserName: \"bar_cfn\"\n", + "template_url": null, + "timeout_in_minutes": null, + "timeouts": {} + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_cloudfront_distribution/expected.json b/pkg/test/aws/3.19.0/aws_cloudfront_distribution/expected.json new file mode 100755 index 000000000..198df0876 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_cloudfront_distribution/expected.json @@ -0,0 +1,80 @@ +[ + { + "Id": "E1M9CNS0XSHI19", + "Type": "aws_cloudfront_distribution", + "Attrs": { + "arn": "arn:aws:cloudfront::047081014315:distribution/E1M9CNS0XSHI19", + "caller_reference": "terraform-20210216101734792900000001", + "default_cache_behavior": [ + { + "allowed_methods": [ + "GET", + "HEAD" + ], + "cached_methods": [ + "GET", + "HEAD" + ], + "compress": false, + "default_ttl": 86400, + "field_level_encryption_id": "", + "forwarded_values": [ + { + "cookies": [ + { + "forward": "none" + } + ], + "query_string": false + } + ], + "max_ttl": 31536000, + "min_ttl": 0, + "smooth_streaming": false, + "target_origin_id": "S3-foo-cloudfront", + "viewer_protocol_policy": "allow-all" + } + ], + "default_root_object": "", + "domain_name": "d1g0dw0i1wvlgd.cloudfront.net", + "enabled": false, + "hosted_zone_id": "Z2FDTNDATAQYW2", + "http_version": "http2", + "id": "E1M9CNS0XSHI19", + "in_progress_validation_batches": 0, + "is_ipv6_enabled": false, + "origin": [ + { + "domain_name": "foo-cloudfront.s3.eu-west-3.amazonaws.com", + "origin_id": "S3-foo-cloudfront", + "origin_path": "" + } + ], + "price_class": "PriceClass_All", + "restrictions": [ + { + "geo_restriction": [ + { + "restriction_type": "none" + } + ] + } + ], + "trusted_signers": [ + { + "enabled": false + } + ], + "viewer_certificate": [ + { + "acm_certificate_arn": "", + "cloudfront_default_certificate": true, + "iam_certificate_id": "", + "minimum_protocol_version": "TLSv1", + "ssl_support_method": "" + } + ], + "web_acl_id": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_cloudfront_distribution/input.json b/pkg/test/aws/3.19.0/aws_cloudfront_distribution/input.json new file mode 100755 index 000000000..cf4767e0c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_cloudfront_distribution/input.json @@ -0,0 +1,102 @@ +[ + { + "Id": "E1M9CNS0XSHI19", + "Type": "aws_cloudfront_distribution", + "Attrs": { + "aliases": [], + "arn": "arn:aws:cloudfront::047081014315:distribution/E1M9CNS0XSHI19", + "caller_reference": "terraform-20210216101734792900000001", + "comment": null, + "custom_error_response": [], + "default_cache_behavior": [ + { + "allowed_methods": [ + "GET", + "HEAD" + ], + "cached_methods": [ + "GET", + "HEAD" + ], + "compress": false, + "default_ttl": 86400, + "field_level_encryption_id": "", + "forwarded_values": [ + { + "cookies": [ + { + "forward": "none", + "whitelisted_names": [] + } + ], + "headers": [], + "query_string": false, + "query_string_cache_keys": [] + } + ], + "lambda_function_association": [], + "max_ttl": 31536000, + "min_ttl": 0, + "smooth_streaming": false, + "target_origin_id": "S3-foo-cloudfront", + "trusted_signers": [], + "viewer_protocol_policy": "allow-all" + } + ], + "default_root_object": "", + "domain_name": "d1g0dw0i1wvlgd.cloudfront.net", + "enabled": false, + "etag": "E2CKBANLXUPWGQ", + "hosted_zone_id": "Z2FDTNDATAQYW2", + "http_version": "http2", + "id": "E1M9CNS0XSHI19", + "in_progress_validation_batches": 0, + "is_ipv6_enabled": false, + "last_modified_time": "2021-02-16 10:17:35.404 +0000 UTC", + "logging_config": [], + "ordered_cache_behavior": [], + "origin": [ + { + "custom_header": [], + "custom_origin_config": [], + "domain_name": "foo-cloudfront.s3.eu-west-3.amazonaws.com", + "origin_id": "S3-foo-cloudfront", + "origin_path": "", + "s3_origin_config": [] + } + ], + "origin_group": null, + "price_class": "PriceClass_All", + "restrictions": [ + { + "geo_restriction": [ + { + "locations": [], + "restriction_type": "none" + } + ] + } + ], + "retain_on_delete": null, + "status": "Deployed", + "tags": {}, + "trusted_signers": [ + { + "enabled": false, + "items": [] + } + ], + "viewer_certificate": [ + { + "acm_certificate_arn": "", + "cloudfront_default_certificate": true, + "iam_certificate_id": "", + "minimum_protocol_version": "TLSv1", + "ssl_support_method": "" + } + ], + "wait_for_deployment": null, + "web_acl_id": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_db_instance/expected.json b/pkg/test/aws/3.19.0/aws_db_instance/expected.json new file mode 100755 index 000000000..c30c015a4 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_db_instance/expected.json @@ -0,0 +1,55 @@ +[ + { + "Id": "terraform-20201015115018309600000001", + "Type": "aws_db_instance", + "Attrs": { + "address": "terraform-20201015115018309600000001.c4j6qwp34sb1.eu-west-3.rds.amazonaws.com", + "allocated_storage": 20, + "arn": "arn:aws:rds:eu-west-3:929327065333:db:terraform-20201015115018309600000001", + "auto_minor_version_upgrade": true, + "availability_zone": "eu-west-3c", + "backup_retention_period": 0, + "backup_window": "09:16-09:46", + "ca_cert_identifier": "rds-ca-2019", + "copy_tags_to_snapshot": false, + "db_subnet_group_name": "default", + "deletion_protection": false, + "domain": "", + "domain_iam_role_name": "", + "endpoint": "terraform-20201015115018309600000001.c4j6qwp34sb1.eu-west-3.rds.amazonaws.com:3306", + "engine": "mysql", + "engine_version": "5.7.26", + "hosted_zone_id": "ZMESEXB7ZGGQ3", + "iam_database_authentication_enabled": false, + "id": "terraform-20201015115018309600000001", + "identifier": "terraform-20201015115018309600000001", + "instance_class": "db.t2.micro", + "iops": 0, + "kms_key_id": "", + "license_model": "general-public-license", + "maintenance_window": "thu:05:32-thu:06:02", + "max_allocated_storage": 0, + "monitoring_interval": 0, + "monitoring_role_arn": "", + "multi_az": false, + "name": "mydb", + "option_group_name": "default:mysql-5-7", + "parameter_group_name": "default.mysql5.7", + "performance_insights_enabled": false, + "performance_insights_kms_key_id": "", + "performance_insights_retention_period": 0, + "port": 3306, + "publicly_accessible": false, + "replicate_source_db": "", + "resource_id": "db-PVD6KZ2WX76FJ7CJXVUNMEM2VQ", + "status": "available", + "storage_encrypted": false, + "storage_type": "gp2", + "timezone": "", + "username": "foo", + "vpc_security_group_ids": [ + "sg-a74815c8" + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_db_instance/input.json b/pkg/test/aws/3.19.0/aws_db_instance/input.json new file mode 100755 index 000000000..c30c015a4 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_db_instance/input.json @@ -0,0 +1,55 @@ +[ + { + "Id": "terraform-20201015115018309600000001", + "Type": "aws_db_instance", + "Attrs": { + "address": "terraform-20201015115018309600000001.c4j6qwp34sb1.eu-west-3.rds.amazonaws.com", + "allocated_storage": 20, + "arn": "arn:aws:rds:eu-west-3:929327065333:db:terraform-20201015115018309600000001", + "auto_minor_version_upgrade": true, + "availability_zone": "eu-west-3c", + "backup_retention_period": 0, + "backup_window": "09:16-09:46", + "ca_cert_identifier": "rds-ca-2019", + "copy_tags_to_snapshot": false, + "db_subnet_group_name": "default", + "deletion_protection": false, + "domain": "", + "domain_iam_role_name": "", + "endpoint": "terraform-20201015115018309600000001.c4j6qwp34sb1.eu-west-3.rds.amazonaws.com:3306", + "engine": "mysql", + "engine_version": "5.7.26", + "hosted_zone_id": "ZMESEXB7ZGGQ3", + "iam_database_authentication_enabled": false, + "id": "terraform-20201015115018309600000001", + "identifier": "terraform-20201015115018309600000001", + "instance_class": "db.t2.micro", + "iops": 0, + "kms_key_id": "", + "license_model": "general-public-license", + "maintenance_window": "thu:05:32-thu:06:02", + "max_allocated_storage": 0, + "monitoring_interval": 0, + "monitoring_role_arn": "", + "multi_az": false, + "name": "mydb", + "option_group_name": "default:mysql-5-7", + "parameter_group_name": "default.mysql5.7", + "performance_insights_enabled": false, + "performance_insights_kms_key_id": "", + "performance_insights_retention_period": 0, + "port": 3306, + "publicly_accessible": false, + "replicate_source_db": "", + "resource_id": "db-PVD6KZ2WX76FJ7CJXVUNMEM2VQ", + "status": "available", + "storage_encrypted": false, + "storage_type": "gp2", + "timezone": "", + "username": "foo", + "vpc_security_group_ids": [ + "sg-a74815c8" + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_db_subnet_group/expected.json b/pkg/test/aws/3.19.0/aws_db_subnet_group/expected.json new file mode 100755 index 000000000..7d44f07dc --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_db_subnet_group/expected.json @@ -0,0 +1,30 @@ +[ + { + "Id": "bar", + "Type": "aws_db_subnet_group", + "Attrs": { + "arn": "arn:aws:rds:eu-west-3:929327065333:subgrp:bar", + "description": "Managed by Terraform", + "id": "bar", + "name": "bar", + "subnet_ids": [ + "subnet-63c5f90a", + "subnet-d81e8695" + ] + } + }, + { + "Id": "foo", + "Type": "aws_db_subnet_group", + "Attrs": { + "arn": "arn:aws:rds:eu-west-3:929327065333:subgrp:foo", + "description": "Managed by Terraform", + "id": "foo", + "name": "foo", + "subnet_ids": [ + "subnet-49f9ae32", + "subnet-63c5f90a" + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_db_subnet_group/input.json b/pkg/test/aws/3.19.0/aws_db_subnet_group/input.json new file mode 100755 index 000000000..7d44f07dc --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_db_subnet_group/input.json @@ -0,0 +1,30 @@ +[ + { + "Id": "bar", + "Type": "aws_db_subnet_group", + "Attrs": { + "arn": "arn:aws:rds:eu-west-3:929327065333:subgrp:bar", + "description": "Managed by Terraform", + "id": "bar", + "name": "bar", + "subnet_ids": [ + "subnet-63c5f90a", + "subnet-d81e8695" + ] + } + }, + { + "Id": "foo", + "Type": "aws_db_subnet_group", + "Attrs": { + "arn": "arn:aws:rds:eu-west-3:929327065333:subgrp:foo", + "description": "Managed by Terraform", + "id": "foo", + "name": "foo", + "subnet_ids": [ + "subnet-49f9ae32", + "subnet-63c5f90a" + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_default_network_acl/expected.json b/pkg/test/aws/3.19.0/aws_default_network_acl/expected.json new file mode 100755 index 000000000..f9aae659c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_default_network_acl/expected.json @@ -0,0 +1,44 @@ +[ + { + "Id": "acl-e88ee595", + "Type": "aws_default_network_acl", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:929327065333:network-acl/acl-e88ee595", + "egress": [ + { + "action": "allow", + "cidr_block": "0.0.0.0/0", + "from_port": 0, + "icmp_code": 0, + "icmp_type": 0, + "ipv6_cidr_block": "", + "protocol": "17", + "rule_no": 100, + "to_port": 0 + } + ], + "id": "acl-e88ee595", + "ingress": [ + { + "action": "allow", + "cidr_block": "0.0.0.0/0", + "from_port": 0, + "protocol": "tcp", + "rule_no": 100, + "to_port": 0 + }, + { + "action": "deny", + "cidr_block": "0.0.0.0/0", + "from_port": 80, + "ipv6_cidr_block": "", + "protocol": "tcp", + "rule_no": 90, + "to_port": 80 + } + ], + "owner_id": "929327065333", + "vpc_id": "vpc-41d1d13b" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_default_network_acl/input.json b/pkg/test/aws/3.19.0/aws_default_network_acl/input.json new file mode 100755 index 000000000..7c99fd165 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_default_network_acl/input.json @@ -0,0 +1,46 @@ +[ + { + "Id": "acl-e88ee595", + "Type": "aws_default_network_acl", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:929327065333:network-acl/acl-e88ee595", + "default_network_acl_id": null, + "egress": [ + { + "action": "allow", + "cidr_block": "0.0.0.0/0", + "from_port": 0, + "icmp_code": 0, + "icmp_type": 0, + "ipv6_cidr_block": "", + "protocol": "17", + "rule_no": 100, + "to_port": 0 + } + ], + "id": "acl-e88ee595", + "ingress": [ + { + "action": "allow", + "cidr_block": "0.0.0.0/0", + "from_port": 0, + "protocol": "tcp", + "rule_no": 100, + "to_port": 0 + }, + { + "action": "deny", + "cidr_block": "0.0.0.0/0", + "from_port": 80, + "ipv6_cidr_block": "", + "protocol": "tcp", + "rule_no": 90, + "to_port": 80 + } + ], + "owner_id": "929327065333", + "tags": {}, + "vpc_id": "vpc-41d1d13b" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_default_route_table/expected.json b/pkg/test/aws/3.19.0/aws_default_route_table/expected.json new file mode 100755 index 000000000..4935ee008 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_default_route_table/expected.json @@ -0,0 +1,13 @@ +[ + { + "Id": "rtb-03fda555c6c35a1e5", + "Type": "aws_default_route_table", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:282061376516:route-table/rtb-03fda555c6c35a1e5", + "default_route_table_id": "rtb-03fda555c6c35a1e5", + "id": "rtb-03fda555c6c35a1e5", + "owner_id": "282061376516", + "vpc_id": "vpc-092fed41ffac6df72" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_default_route_table/input.json b/pkg/test/aws/3.19.0/aws_default_route_table/input.json new file mode 100755 index 000000000..4935ee008 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_default_route_table/input.json @@ -0,0 +1,13 @@ +[ + { + "Id": "rtb-03fda555c6c35a1e5", + "Type": "aws_default_route_table", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:282061376516:route-table/rtb-03fda555c6c35a1e5", + "default_route_table_id": "rtb-03fda555c6c35a1e5", + "id": "rtb-03fda555c6c35a1e5", + "owner_id": "282061376516", + "vpc_id": "vpc-092fed41ffac6df72" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_default_vpc/expected.json b/pkg/test/aws/3.19.0/aws_default_vpc/expected.json new file mode 100755 index 000000000..001f38b21 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_default_vpc/expected.json @@ -0,0 +1,26 @@ +[ + { + "Id": "vpc-a8c5d4c1", + "Type": "aws_default_vpc", + "Attrs": { + "arn": "arn:aws:ec2:eu-west-3:929327065333:vpc/vpc-a8c5d4c1", + "assign_generated_ipv6_cidr_block": false, + "cidr_block": "172.31.0.0/16", + "default_network_acl_id": "acl-3d435954", + "default_route_table_id": "rtb-b0ba5bd8", + "default_security_group_id": "sg-a74815c8", + "dhcp_options_id": "dopt-9becf2f2", + "enable_dns_hostnames": true, + "enable_dns_support": true, + "id": "vpc-a8c5d4c1", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-b0ba5bd8", + "owner_id": "929327065333", + "tags": { + "Name": "Default VPC" + } + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_default_vpc/input.json b/pkg/test/aws/3.19.0/aws_default_vpc/input.json new file mode 100755 index 000000000..329367e2c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_default_vpc/input.json @@ -0,0 +1,28 @@ +[ + { + "Id": "vpc-a8c5d4c1", + "Type": "aws_default_vpc", + "Attrs": { + "arn": "arn:aws:ec2:eu-west-3:929327065333:vpc/vpc-a8c5d4c1", + "assign_generated_ipv6_cidr_block": false, + "cidr_block": "172.31.0.0/16", + "default_network_acl_id": "acl-3d435954", + "default_route_table_id": "rtb-b0ba5bd8", + "default_security_group_id": "sg-a74815c8", + "dhcp_options_id": "dopt-9becf2f2", + "enable_classiclink": null, + "enable_classiclink_dns_support": null, + "enable_dns_hostnames": true, + "enable_dns_support": true, + "id": "vpc-a8c5d4c1", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-b0ba5bd8", + "owner_id": "929327065333", + "tags": { + "Name": "Default VPC" + } + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_dynamodb_table/expected.json b/pkg/test/aws/3.19.0/aws_dynamodb_table/expected.json new file mode 100755 index 000000000..f40734ec2 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_dynamodb_table/expected.json @@ -0,0 +1,101 @@ +[ + { + "Id": "GameScores", + "Type": "aws_dynamodb_table", + "Attrs": { + "arn": "arn:aws:dynamodb:us-east-1:526954929923:table/GameScores", + "attribute": [ + { + "name": "GameTitle", + "type": "S" + }, + { + "name": "TopScore", + "type": "N" + }, + { + "name": "UserId", + "type": "S" + } + ], + "billing_mode": "PROVISIONED", + "global_secondary_index": [ + { + "hash_key": "GameTitle", + "name": "GameTitleIndex", + "non_key_attributes": [ + "UserId" + ], + "projection_type": "INCLUDE", + "range_key": "TopScore", + "read_capacity": 10, + "write_capacity": 10 + } + ], + "hash_key": "UserId", + "id": "GameScores", + "name": "GameScores", + "point_in_time_recovery": [ + { + "enabled": false + } + ], + "range_key": "GameTitle", + "read_capacity": 20, + "stream_arn": "", + "stream_enabled": false, + "stream_label": "", + "stream_view_type": "", + "tags": { + "Environment": "production", + "Name": "dynamodb-table-1" + }, + "ttl": [ + { + "attribute_name": "TimeToExist", + "enabled": true + } + ], + "write_capacity": 20 + } + }, + { + "Id": "example", + "Type": "aws_dynamodb_table", + "Attrs": { + "arn": "arn:aws:dynamodb:us-east-1:526954929923:table/example", + "attribute": [ + { + "name": "TestTableHashKey", + "type": "S" + } + ], + "billing_mode": "PAY_PER_REQUEST", + "hash_key": "TestTableHashKey", + "id": "example", + "name": "example", + "point_in_time_recovery": [ + { + "enabled": false + } + ], + "read_capacity": 0, + "replica": [ + { + "region_name": "us-east-2" + } + ], + "stream_arn": "arn:aws:dynamodb:us-east-1:526954929923:table/example/stream/2021-02-11T09:50:20.750", + "stream_enabled": true, + "stream_label": "2021-02-11T09:50:20.750", + "stream_view_type": "NEW_AND_OLD_IMAGES", + "ttl": [ + { + "attribute_name": "", + "enabled": false + } + ], + "write_capacity": 0 + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_dynamodb_table/input.json b/pkg/test/aws/3.19.0/aws_dynamodb_table/input.json new file mode 100755 index 000000000..f365523d7 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_dynamodb_table/input.json @@ -0,0 +1,119 @@ +[ + { + "Id": "GameScores", + "Type": "aws_dynamodb_table", + "Attrs": { + "arn": "arn:aws:dynamodb:us-east-1:526954929923:table/GameScores", + "attribute": [ + { + "name": "GameTitle", + "type": "S" + }, + { + "name": "TopScore", + "type": "N" + }, + { + "name": "UserId", + "type": "S" + } + ], + "billing_mode": "PROVISIONED", + "global_secondary_index": [ + { + "hash_key": "GameTitle", + "name": "GameTitleIndex", + "non_key_attributes": [ + "UserId" + ], + "projection_type": "INCLUDE", + "range_key": "TopScore", + "read_capacity": 10, + "write_capacity": 10 + } + ], + "hash_key": "UserId", + "id": "GameScores", + "local_secondary_index": [], + "name": "GameScores", + "point_in_time_recovery": [ + { + "enabled": false + } + ], + "range_key": "GameTitle", + "read_capacity": 20, + "replica": [], + "server_side_encryption": [], + "stream_arn": "", + "stream_enabled": false, + "stream_label": "", + "stream_view_type": "", + "tags": { + "Environment": "production", + "Name": "dynamodb-table-1" + }, + "timeouts": { + "create": null, + "delete": null, + "update": null + }, + "ttl": [ + { + "attribute_name": "TimeToExist", + "enabled": true + } + ], + "write_capacity": 20 + } + }, + { + "Id": "example", + "Type": "aws_dynamodb_table", + "Attrs": { + "arn": "arn:aws:dynamodb:us-east-1:526954929923:table/example", + "attribute": [ + { + "name": "TestTableHashKey", + "type": "S" + } + ], + "billing_mode": "PAY_PER_REQUEST", + "global_secondary_index": [], + "hash_key": "TestTableHashKey", + "id": "example", + "local_secondary_index": [], + "name": "example", + "point_in_time_recovery": [ + { + "enabled": false + } + ], + "range_key": null, + "read_capacity": 0, + "replica": [ + { + "region_name": "us-east-2" + } + ], + "server_side_encryption": [], + "stream_arn": "arn:aws:dynamodb:us-east-1:526954929923:table/example/stream/2021-02-11T09:50:20.750", + "stream_enabled": true, + "stream_label": "2021-02-11T09:50:20.750", + "stream_view_type": "NEW_AND_OLD_IMAGES", + "tags": {}, + "timeouts": { + "create": null, + "delete": null, + "update": null + }, + "ttl": [ + { + "attribute_name": "", + "enabled": false + } + ], + "write_capacity": 0 + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_ebs_encryption_by_default/expected.json b/pkg/test/aws/3.19.0/aws_ebs_encryption_by_default/expected.json new file mode 100755 index 000000000..b6cb773b1 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_ebs_encryption_by_default/expected.json @@ -0,0 +1,10 @@ +[ + { + "Id": "ebs_encryption_default", + "Type": "aws_ebs_encryption_by_default", + "Attrs": { + "enabled": false, + "id": "ebs_encryption_default" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_ebs_encryption_by_default/input.json b/pkg/test/aws/3.19.0/aws_ebs_encryption_by_default/input.json new file mode 100755 index 000000000..b6cb773b1 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_ebs_encryption_by_default/input.json @@ -0,0 +1,10 @@ +[ + { + "Id": "ebs_encryption_default", + "Type": "aws_ebs_encryption_by_default", + "Attrs": { + "enabled": false, + "id": "ebs_encryption_default" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_ecr_repository/expected.json b/pkg/test/aws/3.19.0/aws_ecr_repository/expected.json new file mode 100755 index 000000000..a8643c184 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_ecr_repository/expected.json @@ -0,0 +1,48 @@ +[ + { + "Id": "bar", + "Type": "aws_ecr_repository", + "Attrs": { + "arn": "arn:aws:ecr:eu-west-3:726421854799:repository/bar", + "encryption_configuration": [ + { + "encryption_type": "AES256", + "kms_key": "" + } + ], + "id": "bar", + "image_scanning_configuration": [ + { + "scan_on_push": true + } + ], + "image_tag_mutability": "MUTABLE", + "name": "bar", + "registry_id": "726421854799", + "repository_url": "726421854799.dkr.ecr.eu-west-3.amazonaws.com/bar" + } + }, + { + "Id": "test_ecr", + "Type": "aws_ecr_repository", + "Attrs": { + "arn": "arn:aws:ecr:eu-west-3:726421854799:repository/test_ecr", + "encryption_configuration": [ + { + "encryption_type": "AES256", + "kms_key": "" + } + ], + "id": "test_ecr", + "image_scanning_configuration": [ + { + "scan_on_push": false + } + ], + "image_tag_mutability": "MUTABLE", + "name": "test_ecr", + "registry_id": "726421854799", + "repository_url": "726421854799.dkr.ecr.eu-west-3.amazonaws.com/test_ecr" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_ecr_repository/input.json b/pkg/test/aws/3.19.0/aws_ecr_repository/input.json new file mode 100755 index 000000000..e67ccba41 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_ecr_repository/input.json @@ -0,0 +1,56 @@ +[ + { + "Id": "bar", + "Type": "aws_ecr_repository", + "Attrs": { + "arn": "arn:aws:ecr:eu-west-3:726421854799:repository/bar", + "encryption_configuration": [ + { + "encryption_type": "AES256", + "kms_key": "" + } + ], + "id": "bar", + "image_scanning_configuration": [ + { + "scan_on_push": true + } + ], + "image_tag_mutability": "MUTABLE", + "name": "bar", + "registry_id": "726421854799", + "repository_url": "726421854799.dkr.ecr.eu-west-3.amazonaws.com/bar", + "tags": {}, + "timeouts": { + "delete": null + } + } + }, + { + "Id": "test_ecr", + "Type": "aws_ecr_repository", + "Attrs": { + "arn": "arn:aws:ecr:eu-west-3:726421854799:repository/test_ecr", + "encryption_configuration": [ + { + "encryption_type": "AES256", + "kms_key": "" + } + ], + "id": "test_ecr", + "image_scanning_configuration": [ + { + "scan_on_push": false + } + ], + "image_tag_mutability": "MUTABLE", + "name": "test_ecr", + "registry_id": "726421854799", + "repository_url": "726421854799.dkr.ecr.eu-west-3.amazonaws.com/test_ecr", + "tags": {}, + "timeouts": { + "delete": null + } + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_ecr_repository_policy/expected.json b/pkg/test/aws/3.19.0/aws_ecr_repository_policy/expected.json new file mode 100755 index 000000000..12afd35ec --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_ecr_repository_policy/expected.json @@ -0,0 +1,12 @@ +[ + { + "Id": "bar", + "Type": "aws_ecr_repository_policy", + "Attrs": { + "id": "bar", + "policy": "{\n \"Version\" : \"2008-10-17\",\n \"Statement\" : [ {\n \"Sid\" : \"new policy\",\n \"Effect\" : \"Allow\",\n \"Principal\" : \"*\",\n \"Action\" : [ \"ecr:GetDownloadUrlForLayer\", \"ecr:BatchGetImage\", \"ecr:BatchCheckLayerAvailability\", \"ecr:PutImage\", \"ecr:InitiateLayerUpload\", \"ecr:UploadLayerPart\", \"ecr:CompleteLayerUpload\", \"ecr:DescribeRepositories\", \"ecr:GetRepositoryPolicy\", \"ecr:ListImages\", \"ecr:DeleteRepository\", \"ecr:BatchDeleteImage\", \"ecr:SetRepositoryPolicy\", \"ecr:DeleteRepositoryPolicy\" ]\n } ]\n}", + "registry_id": "586583619100", + "repository": "bar" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_ecr_repository_policy/input.json b/pkg/test/aws/3.19.0/aws_ecr_repository_policy/input.json new file mode 100755 index 000000000..12afd35ec --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_ecr_repository_policy/input.json @@ -0,0 +1,12 @@ +[ + { + "Id": "bar", + "Type": "aws_ecr_repository_policy", + "Attrs": { + "id": "bar", + "policy": "{\n \"Version\" : \"2008-10-17\",\n \"Statement\" : [ {\n \"Sid\" : \"new policy\",\n \"Effect\" : \"Allow\",\n \"Principal\" : \"*\",\n \"Action\" : [ \"ecr:GetDownloadUrlForLayer\", \"ecr:BatchGetImage\", \"ecr:BatchCheckLayerAvailability\", \"ecr:PutImage\", \"ecr:InitiateLayerUpload\", \"ecr:UploadLayerPart\", \"ecr:CompleteLayerUpload\", \"ecr:DescribeRepositories\", \"ecr:GetRepositoryPolicy\", \"ecr:ListImages\", \"ecr:DeleteRepository\", \"ecr:BatchDeleteImage\", \"ecr:SetRepositoryPolicy\", \"ecr:DeleteRepositoryPolicy\" ]\n } ]\n}", + "registry_id": "586583619100", + "repository": "bar" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_elasticache_cluster/expected.json b/pkg/test/aws/3.19.0/aws_elasticache_cluster/expected.json new file mode 100755 index 000000000..87d88cc39 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_elasticache_cluster/expected.json @@ -0,0 +1,33 @@ +[ + { + "Id": "cluster-example", + "Type": "aws_elasticache_cluster", + "Attrs": { + "arn": "arn:aws:elasticache:us-east-2:047081014315:cluster:cluster-example", + "availability_zone": "us-east-2b", + "az_mode": "single-az", + "cache_nodes": [ + { + "address": "cluster-example.jkdpui.0001.use2.cache.amazonaws.com", + "availability_zone": "us-east-2b", + "id": "0001", + "port": 11211 + } + ], + "cluster_address": "cluster-example.jkdpui.cfg.use2.cache.amazonaws.com", + "cluster_id": "cluster-example", + "configuration_endpoint": "cluster-example.jkdpui.cfg.use2.cache.amazonaws.com:11211", + "engine": "memcached", + "engine_version": "1.6.6", + "id": "cluster-example", + "maintenance_window": "fri:02:30-fri:03:30", + "node_type": "cache.t2.micro", + "num_cache_nodes": 1, + "parameter_group_name": "default.memcached1.6", + "port": 11211, + "snapshot_retention_limit": 0, + "snapshot_window": "", + "subnet_group_name": "default" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_elasticache_cluster/input.json b/pkg/test/aws/3.19.0/aws_elasticache_cluster/input.json new file mode 100755 index 000000000..87d88cc39 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_elasticache_cluster/input.json @@ -0,0 +1,33 @@ +[ + { + "Id": "cluster-example", + "Type": "aws_elasticache_cluster", + "Attrs": { + "arn": "arn:aws:elasticache:us-east-2:047081014315:cluster:cluster-example", + "availability_zone": "us-east-2b", + "az_mode": "single-az", + "cache_nodes": [ + { + "address": "cluster-example.jkdpui.0001.use2.cache.amazonaws.com", + "availability_zone": "us-east-2b", + "id": "0001", + "port": 11211 + } + ], + "cluster_address": "cluster-example.jkdpui.cfg.use2.cache.amazonaws.com", + "cluster_id": "cluster-example", + "configuration_endpoint": "cluster-example.jkdpui.cfg.use2.cache.amazonaws.com:11211", + "engine": "memcached", + "engine_version": "1.6.6", + "id": "cluster-example", + "maintenance_window": "fri:02:30-fri:03:30", + "node_type": "cache.t2.micro", + "num_cache_nodes": 1, + "parameter_group_name": "default.memcached1.6", + "port": 11211, + "snapshot_retention_limit": 0, + "snapshot_window": "", + "subnet_group_name": "default" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_elb/expected.json b/pkg/test/aws/3.19.0/aws_elb/expected.json new file mode 100755 index 000000000..6da86a92c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_elb/expected.json @@ -0,0 +1,55 @@ +[ + { + "Id": "foobar-terraform-elb", + "Type": "aws_elb", + "Attrs": { + "arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/foobar-terraform-elb", + "availability_zones": [ + "us-east-1a", + "us-east-1b" + ], + "connection_draining": true, + "connection_draining_timeout": 400, + "cross_zone_load_balancing": true, + "dns_name": "foobar-terraform-elb-862208417.us-east-1.elb.amazonaws.com", + "health_check": [ + { + "healthy_threshold": 10, + "interval": 30, + "target": "TCP:8000", + "timeout": 5, + "unhealthy_threshold": 2 + } + ], + "id": "foobar-terraform-elb", + "idle_timeout": 400, + "instances": [ + "i-0197bcecd8741f8f2" + ], + "internal": false, + "listener": [ + { + "instance_port": 8000, + "instance_protocol": "http", + "lb_port": 80, + "lb_protocol": "http", + "ssl_certificate_id": "" + } + ], + "name": "foobar-terraform-elb", + "security_groups": [ + "sg-06d494bd7e90d1978" + ], + "source_security_group": "533948124879/default_elb_9cdec3e4-c42b-3ae8-a684-6161437e15d0", + "source_security_group_id": "sg-06d494bd7e90d1978", + "subnets": [ + "subnet-86cffacb", + "subnet-a18debfe" + ], + "tags": { + "Name": "foobar-terraform-elb" + }, + "zone_id": "Z35SXDOTRQ7X7K" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_elb/input.json b/pkg/test/aws/3.19.0/aws_elb/input.json new file mode 100755 index 000000000..6da86a92c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_elb/input.json @@ -0,0 +1,55 @@ +[ + { + "Id": "foobar-terraform-elb", + "Type": "aws_elb", + "Attrs": { + "arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/foobar-terraform-elb", + "availability_zones": [ + "us-east-1a", + "us-east-1b" + ], + "connection_draining": true, + "connection_draining_timeout": 400, + "cross_zone_load_balancing": true, + "dns_name": "foobar-terraform-elb-862208417.us-east-1.elb.amazonaws.com", + "health_check": [ + { + "healthy_threshold": 10, + "interval": 30, + "target": "TCP:8000", + "timeout": 5, + "unhealthy_threshold": 2 + } + ], + "id": "foobar-terraform-elb", + "idle_timeout": 400, + "instances": [ + "i-0197bcecd8741f8f2" + ], + "internal": false, + "listener": [ + { + "instance_port": 8000, + "instance_protocol": "http", + "lb_port": 80, + "lb_protocol": "http", + "ssl_certificate_id": "" + } + ], + "name": "foobar-terraform-elb", + "security_groups": [ + "sg-06d494bd7e90d1978" + ], + "source_security_group": "533948124879/default_elb_9cdec3e4-c42b-3ae8-a684-6161437e15d0", + "source_security_group_id": "sg-06d494bd7e90d1978", + "subnets": [ + "subnet-86cffacb", + "subnet-a18debfe" + ], + "tags": { + "Name": "foobar-terraform-elb" + }, + "zone_id": "Z35SXDOTRQ7X7K" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_access_key/expected.json b/pkg/test/aws/3.19.0/aws_iam_access_key/expected.json new file mode 100755 index 000000000..1d1e7c18c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_access_key/expected.json @@ -0,0 +1,38 @@ +[ + { + "Id": "AKIA5QYBVVD223VWU32A", + "Type": "aws_iam_access_key", + "Attrs": { + "id": "AKIA5QYBVVD223VWU32A", + "status": "Active", + "user": "test-driftctl" + } + }, + { + "Id": "AKIA5QYBVVD2QYI36UZP", + "Type": "aws_iam_access_key", + "Attrs": { + "id": "AKIA5QYBVVD2QYI36UZP", + "status": "Active", + "user": "test-driftctl" + } + }, + { + "Id": "AKIA5QYBVVD26EJME25D", + "Type": "aws_iam_access_key", + "Attrs": { + "id": "AKIA5QYBVVD26EJME25D", + "status": "Active", + "user": "test-driftctl2" + } + }, + { + "Id": "AKIA5QYBVVD2SWDFVVMG", + "Type": "aws_iam_access_key", + "Attrs": { + "id": "AKIA5QYBVVD2SWDFVVMG", + "status": "Active", + "user": "test-driftctl2" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_access_key/input.json b/pkg/test/aws/3.19.0/aws_iam_access_key/input.json new file mode 100755 index 000000000..cadfebfe1 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_access_key/input.json @@ -0,0 +1,58 @@ +[ + { + "Id": "AKIA5QYBVVD223VWU32A", + "Type": "aws_iam_access_key", + "Attrs": { + "encrypted_secret": null, + "id": "AKIA5QYBVVD223VWU32A", + "key_fingerprint": null, + "pgp_key": null, + "secret": null, + "ses_smtp_password_v4": null, + "status": "Active", + "user": "test-driftctl" + } + }, + { + "Id": "AKIA5QYBVVD2QYI36UZP", + "Type": "aws_iam_access_key", + "Attrs": { + "encrypted_secret": null, + "id": "AKIA5QYBVVD2QYI36UZP", + "key_fingerprint": null, + "pgp_key": null, + "secret": null, + "ses_smtp_password_v4": null, + "status": "Active", + "user": "test-driftctl" + } + }, + { + "Id": "AKIA5QYBVVD26EJME25D", + "Type": "aws_iam_access_key", + "Attrs": { + "encrypted_secret": null, + "id": "AKIA5QYBVVD26EJME25D", + "key_fingerprint": null, + "pgp_key": null, + "secret": null, + "ses_smtp_password_v4": null, + "status": "Active", + "user": "test-driftctl2" + } + }, + { + "Id": "AKIA5QYBVVD2SWDFVVMG", + "Type": "aws_iam_access_key", + "Attrs": { + "encrypted_secret": null, + "id": "AKIA5QYBVVD2SWDFVVMG", + "key_fingerprint": null, + "pgp_key": null, + "secret": null, + "ses_smtp_password_v4": null, + "status": "Active", + "user": "test-driftctl2" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_group/expected.json b/pkg/test/aws/3.19.0/aws_iam_group/expected.json new file mode 100755 index 000000000..c4516ffb0 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_group/expected.json @@ -0,0 +1,13 @@ +[ + { + "Id": "developers", + "Type": "aws_iam_group", + "Attrs": { + "arn": "arn:aws:iam::533948124879:group/users/developers", + "id": "developers", + "name": "developers", + "path": "/users/", + "unique_id": "AGPAXYUOJZ3HYXMHVQXQK" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_group/input.json b/pkg/test/aws/3.19.0/aws_iam_group/input.json new file mode 100755 index 000000000..c4516ffb0 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_group/input.json @@ -0,0 +1,13 @@ +[ + { + "Id": "developers", + "Type": "aws_iam_group", + "Attrs": { + "arn": "arn:aws:iam::533948124879:group/users/developers", + "id": "developers", + "name": "developers", + "path": "/users/", + "unique_id": "AGPAXYUOJZ3HYXMHVQXQK" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_group_policy/expected.json b/pkg/test/aws/3.19.0/aws_iam_group_policy/expected.json new file mode 100755 index 000000000..b003d51c7 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_group_policy/expected.json @@ -0,0 +1,12 @@ +[ + { + "Id": "developers:my_developer_policy", + "Type": "aws_iam_group_policy", + "Attrs": { + "group": "developers", + "id": "developers:my_developer_policy", + "name": "my_developer_policy", + "policy": "{\"Statement\":[{\"Action\":[\"ec2:Describe*\"],\"Effect\":\"Allow\",\"Resource\":\"*\"}],\"Version\":\"2012-10-17\"}" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_group_policy/input.json b/pkg/test/aws/3.19.0/aws_iam_group_policy/input.json new file mode 100755 index 000000000..b003d51c7 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_group_policy/input.json @@ -0,0 +1,12 @@ +[ + { + "Id": "developers:my_developer_policy", + "Type": "aws_iam_group_policy", + "Attrs": { + "group": "developers", + "id": "developers:my_developer_policy", + "name": "my_developer_policy", + "policy": "{\"Statement\":[{\"Action\":[\"ec2:Describe*\"],\"Effect\":\"Allow\",\"Resource\":\"*\"}],\"Version\":\"2012-10-17\"}" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_group_policy_attachment/expected.json b/pkg/test/aws/3.19.0/aws_iam_group_policy_attachment/expected.json new file mode 100755 index 000000000..efee38c1e --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_group_policy_attachment/expected.json @@ -0,0 +1,11 @@ +[ + { + "Id": "test-group-20220509135152620300000001", + "Type": "aws_iam_group_policy_attachment", + "Attrs": { + "group": "test-group", + "id": "test-group-20220509135152620300000001", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_group_policy_attachment/input.json b/pkg/test/aws/3.19.0/aws_iam_group_policy_attachment/input.json new file mode 100755 index 000000000..efee38c1e --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_group_policy_attachment/input.json @@ -0,0 +1,11 @@ +[ + { + "Id": "test-group-20220509135152620300000001", + "Type": "aws_iam_group_policy_attachment", + "Attrs": { + "group": "test-group", + "id": "test-group-20220509135152620300000001", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_policy/expected.json b/pkg/test/aws/3.19.0/aws_iam_policy/expected.json new file mode 100755 index 000000000..5075f731b --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_policy/expected.json @@ -0,0 +1,38 @@ +[ + { + "Id": "arn:aws:iam::929327065333:policy/policy-0", + "Type": "aws_iam_policy", + "Attrs": { + "arn": "arn:aws:iam::929327065333:policy/policy-0", + "description": "", + "id": "arn:aws:iam::929327065333:policy/policy-0", + "name": "policy-0", + "path": "/", + "policy": "{\"Statement\":[{\"Action\":\"ec2:*\",\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"EC2Admin\"}],\"Version\":\"2012-10-17\"}" + } + }, + { + "Id": "arn:aws:iam::929327065333:policy/policy-1", + "Type": "aws_iam_policy", + "Attrs": { + "arn": "arn:aws:iam::929327065333:policy/policy-1", + "description": "", + "id": "arn:aws:iam::929327065333:policy/policy-1", + "name": "policy-1", + "path": "/", + "policy": "{\"Statement\":[{\"Action\":\"ec2:*\",\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"EC2Admin\"}],\"Version\":\"2012-10-17\"}" + } + }, + { + "Id": "arn:aws:iam::929327065333:policy/policy-2", + "Type": "aws_iam_policy", + "Attrs": { + "arn": "arn:aws:iam::929327065333:policy/policy-2", + "description": "", + "id": "arn:aws:iam::929327065333:policy/policy-2", + "name": "policy-2", + "path": "/", + "policy": "{\"Statement\":[{\"Action\":\"ec2:*\",\"Effect\":\"Allow\",\"Resource\":\"*\",\"Sid\":\"EC2Admin\"}],\"Version\":\"2012-10-17\"}" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_policy/input.json b/pkg/test/aws/3.19.0/aws_iam_policy/input.json new file mode 100755 index 000000000..cfbb67eb2 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_policy/input.json @@ -0,0 +1,41 @@ +[ + { + "Id": "arn:aws:iam::929327065333:policy/policy-0", + "Type": "aws_iam_policy", + "Attrs": { + "arn": "arn:aws:iam::929327065333:policy/policy-0", + "description": "", + "id": "arn:aws:iam::929327065333:policy/policy-0", + "name": "policy-0", + "name_prefix": null, + "path": "/", + "policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"EC2Admin\",\n \"Effect\": \"Allow\",\n \"Action\": \"ec2:*\",\n \"Resource\": \"*\"\n }\n ]\n}\n" + } + }, + { + "Id": "arn:aws:iam::929327065333:policy/policy-1", + "Type": "aws_iam_policy", + "Attrs": { + "arn": "arn:aws:iam::929327065333:policy/policy-1", + "description": "", + "id": "arn:aws:iam::929327065333:policy/policy-1", + "name": "policy-1", + "name_prefix": null, + "path": "/", + "policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"EC2Admin\",\n \"Effect\": \"Allow\",\n \"Action\": \"ec2:*\",\n \"Resource\": \"*\"\n }\n ]\n}\n" + } + }, + { + "Id": "arn:aws:iam::929327065333:policy/policy-2", + "Type": "aws_iam_policy", + "Attrs": { + "arn": "arn:aws:iam::929327065333:policy/policy-2", + "description": "", + "id": "arn:aws:iam::929327065333:policy/policy-2", + "name": "policy-2", + "name_prefix": null, + "path": "/", + "policy": "{\n \"Version\": \"2012-10-17\",\n \"Statement\": [\n {\n \"Sid\": \"EC2Admin\",\n \"Effect\": \"Allow\",\n \"Action\": \"ec2:*\",\n \"Resource\": \"*\"\n }\n ]\n}\n" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_role/expected.json b/pkg/test/aws/3.19.0/aws_iam_role/expected.json new file mode 100755 index 000000000..2f2c3693a --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_role/expected.json @@ -0,0 +1,56 @@ +[ + { + "Id": "test_role_0", + "Type": "aws_iam_role", + "Attrs": { + "arn": "arn:aws:iam::929327065333:role/test/test_role_0", + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}", + "create_date": "2020-11-04T10:09:37Z", + "description": "test", + "id": "test_role_0", + "max_session_duration": 3600, + "name": "test_role_0", + "path": "/test/", + "tags": { + "foo": "bar0" + }, + "unique_id": "AROA5QYBVVD24YSTJXHHO" + } + }, + { + "Id": "test_role_1", + "Type": "aws_iam_role", + "Attrs": { + "arn": "arn:aws:iam::929327065333:role/test/test_role_1", + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}", + "create_date": "2020-11-04T10:09:37Z", + "description": "", + "id": "test_role_1", + "max_session_duration": 3600, + "name": "test_role_1", + "path": "/test/", + "tags": { + "foo": "bar1" + }, + "unique_id": "AROA5QYBVVD2UGXJCEDXF" + } + }, + { + "Id": "test_role_2", + "Type": "aws_iam_role", + "Attrs": { + "arn": "arn:aws:iam::929327065333:role/test/test_role_2", + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}", + "create_date": "2020-11-04T10:09:37Z", + "description": "", + "id": "test_role_2", + "max_session_duration": 3600, + "name": "test_role_2", + "path": "/test/", + "tags": { + "foo": "bar2" + }, + "unique_id": "AROA5QYBVVD2WGP2ZEG73" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_role/input.json b/pkg/test/aws/3.19.0/aws_iam_role/input.json new file mode 100755 index 000000000..ee7d6740b --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_role/input.json @@ -0,0 +1,65 @@ +[ + { + "Id": "test_role_0", + "Type": "aws_iam_role", + "Attrs": { + "arn": "arn:aws:iam::929327065333:role/test/test_role_0", + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}", + "create_date": "2020-11-04T10:09:37Z", + "description": "test", + "force_detach_policies": null, + "id": "test_role_0", + "max_session_duration": 3600, + "name": "test_role_0", + "name_prefix": null, + "path": "/test/", + "permissions_boundary": null, + "tags": { + "foo": "bar0" + }, + "unique_id": "AROA5QYBVVD24YSTJXHHO" + } + }, + { + "Id": "test_role_1", + "Type": "aws_iam_role", + "Attrs": { + "arn": "arn:aws:iam::929327065333:role/test/test_role_1", + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}", + "create_date": "2020-11-04T10:09:37Z", + "description": "", + "force_detach_policies": null, + "id": "test_role_1", + "max_session_duration": 3600, + "name": "test_role_1", + "name_prefix": null, + "path": "/test/", + "permissions_boundary": null, + "tags": { + "foo": "bar1" + }, + "unique_id": "AROA5QYBVVD2UGXJCEDXF" + } + }, + { + "Id": "test_role_2", + "Type": "aws_iam_role", + "Attrs": { + "arn": "arn:aws:iam::929327065333:role/test/test_role_2", + "assume_role_policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Sid\":\"\",\"Effect\":\"Allow\",\"Principal\":{\"Service\":\"ec2.amazonaws.com\"},\"Action\":\"sts:AssumeRole\"}]}", + "create_date": "2020-11-04T10:09:37Z", + "description": "", + "force_detach_policies": null, + "id": "test_role_2", + "max_session_duration": 3600, + "name": "test_role_2", + "name_prefix": null, + "path": "/test/", + "permissions_boundary": null, + "tags": { + "foo": "bar2" + }, + "unique_id": "AROA5QYBVVD2WGP2ZEG73" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_role_policy/expected.json b/pkg/test/aws/3.19.0/aws_iam_role_policy/expected.json new file mode 100755 index 000000000..31bd3f50b --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_role_policy/expected.json @@ -0,0 +1,56 @@ +[ + { + "Id": "test-policy2-test-role2", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy2-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy2", + "role": "test-role2" + } + }, + { + "Id": "test-policy3-test-role2", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy3-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy3", + "role": "test-role2" + } + }, + { + "Id": "test-policy-test-role2", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy", + "role": "test-role2" + } + }, + { + "Id": "test-policy3-test-role", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy3-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy3", + "role": "test-role" + } + }, + { + "Id": "test-policy-test-role", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy", + "role": "test-role" + } + }, + { + "Id": "test-policy2-test-role", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy2-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy2", + "role": "test-role" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_role_policy/input.json b/pkg/test/aws/3.19.0/aws_iam_role_policy/input.json new file mode 100755 index 000000000..31bd3f50b --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_role_policy/input.json @@ -0,0 +1,56 @@ +[ + { + "Id": "test-policy2-test-role2", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy2-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy2", + "role": "test-role2" + } + }, + { + "Id": "test-policy3-test-role2", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy3-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy3", + "role": "test-role2" + } + }, + { + "Id": "test-policy-test-role2", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy", + "role": "test-role2" + } + }, + { + "Id": "test-policy3-test-role", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy3-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy3", + "role": "test-role" + } + }, + { + "Id": "test-policy-test-role", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy", + "role": "test-role" + } + }, + { + "Id": "test-policy2-test-role", + "Type": "aws_iam_role_policy", + "Attrs": { + "id": "test-policy2-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy2", + "role": "test-role" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_role_policy_attachment/expected.json b/pkg/test/aws/3.19.0/aws_iam_role_policy_attachment/expected.json new file mode 100755 index 000000000..1bbc6f085 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_role_policy_attachment/expected.json @@ -0,0 +1,56 @@ +[ + { + "Id": "test-policy2-test-role2", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy2-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy2", + "role": "test-role2" + } + }, + { + "Id": "test-policy3-test-role2", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy3-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy3", + "role": "test-role2" + } + }, + { + "Id": "test-policy-test-role2", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy", + "role": "test-role2" + } + }, + { + "Id": "test-policy3-test-role", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy3-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy3", + "role": "test-role" + } + }, + { + "Id": "test-policy-test-role", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy", + "role": "test-role" + } + }, + { + "Id": "test-policy2-test-role", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy2-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy2", + "role": "test-role" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_role_policy_attachment/input.json b/pkg/test/aws/3.19.0/aws_iam_role_policy_attachment/input.json new file mode 100755 index 000000000..1bbc6f085 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_role_policy_attachment/input.json @@ -0,0 +1,56 @@ +[ + { + "Id": "test-policy2-test-role2", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy2-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy2", + "role": "test-role2" + } + }, + { + "Id": "test-policy3-test-role2", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy3-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy3", + "role": "test-role2" + } + }, + { + "Id": "test-policy-test-role2", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy-test-role2", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy", + "role": "test-role2" + } + }, + { + "Id": "test-policy3-test-role", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy3-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy3", + "role": "test-role" + } + }, + { + "Id": "test-policy-test-role", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy", + "role": "test-role" + } + }, + { + "Id": "test-policy2-test-role", + "Type": "aws_iam_role_policy_attachment", + "Attrs": { + "id": "test-policy2-test-role", + "policy_arn": "arn:aws:iam::929327065333:policy/test-policy2", + "role": "test-role" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_user/expected.json b/pkg/test/aws/3.19.0/aws_iam_user/expected.json new file mode 100755 index 000000000..8c96abeb3 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_user/expected.json @@ -0,0 +1,44 @@ +[ + { + "Id": "test-driftctl-2", + "Type": "aws_iam_user", + "Attrs": { + "arn": "arn:aws:iam::929327065333:user/test/test-driftctl-2", + "id": "test-driftctl-2", + "name": "test-driftctl-2", + "path": "/test/", + "tags": { + "foo": "bar" + }, + "unique_id": "AIDA5QYBVVD23ZWIILRUW" + } + }, + { + "Id": "test-driftctl-0", + "Type": "aws_iam_user", + "Attrs": { + "arn": "arn:aws:iam::929327065333:user/test/test-driftctl-0", + "id": "test-driftctl-0", + "name": "test-driftctl-0", + "path": "/test/", + "tags": { + "foo": "bar" + }, + "unique_id": "AIDA5QYBVVD2ZWIW56NWS" + } + }, + { + "Id": "test-driftctl-1", + "Type": "aws_iam_user", + "Attrs": { + "arn": "arn:aws:iam::929327065333:user/test/test-driftctl-1", + "id": "test-driftctl-1", + "name": "test-driftctl-1", + "path": "/test/", + "tags": { + "foo": "bar" + }, + "unique_id": "AIDA5QYBVVD2UMP6CZEGZ" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_user/input.json b/pkg/test/aws/3.19.0/aws_iam_user/input.json new file mode 100755 index 000000000..4220a0f14 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_user/input.json @@ -0,0 +1,50 @@ +[ + { + "Id": "test-driftctl-2", + "Type": "aws_iam_user", + "Attrs": { + "arn": "arn:aws:iam::929327065333:user/test/test-driftctl-2", + "force_destroy": null, + "id": "test-driftctl-2", + "name": "test-driftctl-2", + "path": "/test/", + "permissions_boundary": null, + "tags": { + "foo": "bar" + }, + "unique_id": "AIDA5QYBVVD23ZWIILRUW" + } + }, + { + "Id": "test-driftctl-0", + "Type": "aws_iam_user", + "Attrs": { + "arn": "arn:aws:iam::929327065333:user/test/test-driftctl-0", + "force_destroy": null, + "id": "test-driftctl-0", + "name": "test-driftctl-0", + "path": "/test/", + "permissions_boundary": null, + "tags": { + "foo": "bar" + }, + "unique_id": "AIDA5QYBVVD2ZWIW56NWS" + } + }, + { + "Id": "test-driftctl-1", + "Type": "aws_iam_user", + "Attrs": { + "arn": "arn:aws:iam::929327065333:user/test/test-driftctl-1", + "force_destroy": null, + "id": "test-driftctl-1", + "name": "test-driftctl-1", + "path": "/test/", + "permissions_boundary": null, + "tags": { + "foo": "bar" + }, + "unique_id": "AIDA5QYBVVD2UMP6CZEGZ" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_user_policy/expected.json b/pkg/test/aws/3.19.0/aws_iam_user_policy/expected.json new file mode 100755 index 000000000..c4bc9248d --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_user_policy/expected.json @@ -0,0 +1,110 @@ +[ + { + "Id": "test3-loadbalancer2", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test3-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer2" + } + }, + { + "Id": "test4-loadbalancer2", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test4-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer2" + } + }, + { + "Id": "test-loadbalancer", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer" + } + }, + { + "Id": "test3-loadbalancer", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test3-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer" + } + }, + { + "Id": "test-loadbalancer3", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer3" + } + }, + { + "Id": "test-loadbalancer2", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer2" + } + }, + { + "Id": "test4-loadbalancer", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test4-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer" + } + }, + { + "Id": "test2-loadbalancer2", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test2-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer2" + } + }, + { + "Id": "test2-loadbalancer", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test2-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer" + } + }, + { + "Id": "test4-loadbalancer3", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test4-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer3" + } + }, + { + "Id": "test3-loadbalancer3", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test3-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer3" + } + }, + { + "Id": "test2-loadbalancer3", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test2-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer3" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_user_policy/input.json b/pkg/test/aws/3.19.0/aws_iam_user_policy/input.json new file mode 100755 index 000000000..c4bc9248d --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_user_policy/input.json @@ -0,0 +1,110 @@ +[ + { + "Id": "test3-loadbalancer2", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test3-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer2" + } + }, + { + "Id": "test4-loadbalancer2", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test4-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer2" + } + }, + { + "Id": "test-loadbalancer", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer" + } + }, + { + "Id": "test3-loadbalancer", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test3-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer" + } + }, + { + "Id": "test-loadbalancer3", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer3" + } + }, + { + "Id": "test-loadbalancer2", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer2" + } + }, + { + "Id": "test4-loadbalancer", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test4-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer" + } + }, + { + "Id": "test2-loadbalancer2", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test2-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer2" + } + }, + { + "Id": "test2-loadbalancer", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test2-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer" + } + }, + { + "Id": "test4-loadbalancer3", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test4-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer3" + } + }, + { + "Id": "test3-loadbalancer3", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test3-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer3" + } + }, + { + "Id": "test2-loadbalancer3", + "Type": "aws_iam_user_policy", + "Attrs": { + "id": "test2-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer3" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_user_policy_attachment/expected.json b/pkg/test/aws/3.19.0/aws_iam_user_policy_attachment/expected.json new file mode 100755 index 000000000..17f4c7019 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_user_policy_attachment/expected.json @@ -0,0 +1,110 @@ +[ + { + "Id": "test3-loadbalancer2", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test3-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer2" + } + }, + { + "Id": "test4-loadbalancer2", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test4-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer2" + } + }, + { + "Id": "test-loadbalancer", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer" + } + }, + { + "Id": "test3-loadbalancer", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test3-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer" + } + }, + { + "Id": "test-loadbalancer3", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer3" + } + }, + { + "Id": "test-loadbalancer2", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer2" + } + }, + { + "Id": "test4-loadbalancer", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test4-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer" + } + }, + { + "Id": "test2-loadbalancer2", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test2-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer2" + } + }, + { + "Id": "test2-loadbalancer", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test2-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer" + } + }, + { + "Id": "test4-loadbalancer3", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test4-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer3" + } + }, + { + "Id": "test3-loadbalancer3", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test3-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer3" + } + }, + { + "Id": "test2-loadbalancer3", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test2-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer3" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_iam_user_policy_attachment/input.json b/pkg/test/aws/3.19.0/aws_iam_user_policy_attachment/input.json new file mode 100755 index 000000000..17f4c7019 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_iam_user_policy_attachment/input.json @@ -0,0 +1,110 @@ +[ + { + "Id": "test3-loadbalancer2", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test3-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer2" + } + }, + { + "Id": "test4-loadbalancer2", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test4-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer2" + } + }, + { + "Id": "test-loadbalancer", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer" + } + }, + { + "Id": "test3-loadbalancer", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test3-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer" + } + }, + { + "Id": "test-loadbalancer3", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer3" + } + }, + { + "Id": "test-loadbalancer2", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test", + "user": "loadbalancer2" + } + }, + { + "Id": "test4-loadbalancer", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test4-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer" + } + }, + { + "Id": "test2-loadbalancer2", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test2-loadbalancer2", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer2" + } + }, + { + "Id": "test2-loadbalancer", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test2-loadbalancer", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer" + } + }, + { + "Id": "test4-loadbalancer3", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test4-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test4", + "user": "loadbalancer3" + } + }, + { + "Id": "test3-loadbalancer3", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test3-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test3", + "user": "loadbalancer3" + } + }, + { + "Id": "test2-loadbalancer3", + "Type": "aws_iam_user_policy_attachment", + "Attrs": { + "id": "test2-loadbalancer3", + "policy_arn": "arn:aws:iam::726421854799:policy/test2", + "user": "loadbalancer3" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_internet_gateway/expected.json b/pkg/test/aws/3.19.0/aws_internet_gateway/expected.json new file mode 100755 index 000000000..616ceb483 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_internet_gateway/expected.json @@ -0,0 +1,15 @@ +[ + { + "Id": "igw-0184eb41aadc62d1c", + "Type": "aws_internet_gateway", + "Attrs": { + "arn": "arn:aws:ec2:eu-west-3:047081014315:internet-gateway/igw-0184eb41aadc62d1c", + "id": "igw-0184eb41aadc62d1c", + "owner_id": "047081014315", + "tags": { + "Name": "main" + }, + "vpc_id": "vpc-0f3ac2b7909b6bedd" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_internet_gateway/input.json b/pkg/test/aws/3.19.0/aws_internet_gateway/input.json new file mode 100755 index 000000000..616ceb483 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_internet_gateway/input.json @@ -0,0 +1,15 @@ +[ + { + "Id": "igw-0184eb41aadc62d1c", + "Type": "aws_internet_gateway", + "Attrs": { + "arn": "arn:aws:ec2:eu-west-3:047081014315:internet-gateway/igw-0184eb41aadc62d1c", + "id": "igw-0184eb41aadc62d1c", + "owner_id": "047081014315", + "tags": { + "Name": "main" + }, + "vpc_id": "vpc-0f3ac2b7909b6bedd" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_kms_alias/expected.json b/pkg/test/aws/3.19.0/aws_kms_alias/expected.json new file mode 100755 index 000000000..68ab4ae84 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_kms_alias/expected.json @@ -0,0 +1,32 @@ +[ + { + "Id": "alias/baz20210225124429210500000001", + "Type": "aws_kms_alias", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:alias/baz20210225124429210500000001", + "id": "alias/baz20210225124429210500000001", + "target_key_arn": "arn:aws:kms:eu-west-3:047081014315:key/341b2d76-feab-4911-b5de-fbdd92b21aa7", + "target_key_id": "341b2d76-feab-4911-b5de-fbdd92b21aa7" + } + }, + { + "Id": "alias/foo", + "Type": "aws_kms_alias", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:alias/foo", + "id": "alias/foo", + "target_key_arn": "arn:aws:kms:eu-west-3:047081014315:key/341b2d76-feab-4911-b5de-fbdd92b21aa7", + "target_key_id": "341b2d76-feab-4911-b5de-fbdd92b21aa7" + } + }, + { + "Id": "alias/bar", + "Type": "aws_kms_alias", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:alias/bar", + "id": "alias/bar", + "target_key_arn": "arn:aws:kms:eu-west-3:047081014315:key/341b2d76-feab-4911-b5de-fbdd92b21aa7", + "target_key_id": "341b2d76-feab-4911-b5de-fbdd92b21aa7" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_kms_alias/input.json b/pkg/test/aws/3.19.0/aws_kms_alias/input.json new file mode 100755 index 000000000..e2aa45b92 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_kms_alias/input.json @@ -0,0 +1,38 @@ +[ + { + "Id": "alias/baz20210225124429210500000001", + "Type": "aws_kms_alias", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:alias/baz20210225124429210500000001", + "id": "alias/baz20210225124429210500000001", + "name": null, + "name_prefix": null, + "target_key_arn": "arn:aws:kms:eu-west-3:047081014315:key/341b2d76-feab-4911-b5de-fbdd92b21aa7", + "target_key_id": "341b2d76-feab-4911-b5de-fbdd92b21aa7" + } + }, + { + "Id": "alias/foo", + "Type": "aws_kms_alias", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:alias/foo", + "id": "alias/foo", + "name": null, + "name_prefix": null, + "target_key_arn": "arn:aws:kms:eu-west-3:047081014315:key/341b2d76-feab-4911-b5de-fbdd92b21aa7", + "target_key_id": "341b2d76-feab-4911-b5de-fbdd92b21aa7" + } + }, + { + "Id": "alias/bar", + "Type": "aws_kms_alias", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:alias/bar", + "id": "alias/bar", + "name": null, + "name_prefix": null, + "target_key_arn": "arn:aws:kms:eu-west-3:047081014315:key/341b2d76-feab-4911-b5de-fbdd92b21aa7", + "target_key_id": "341b2d76-feab-4911-b5de-fbdd92b21aa7" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_kms_key/expected.json b/pkg/test/aws/3.19.0/aws_kms_key/expected.json new file mode 100755 index 000000000..005444075 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_kms_key/expected.json @@ -0,0 +1,50 @@ +[ + { + "Id": "8ee21d91-c000-428c-8032-235aac55da36", + "Type": "aws_kms_key", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:key/8ee21d91-c000-428c-8032-235aac55da36", + "customer_master_key_spec": "RSA_2048", + "description": "Bar", + "enable_key_rotation": false, + "id": "8ee21d91-c000-428c-8032-235aac55da36", + "is_enabled": true, + "key_id": "8ee21d91-c000-428c-8032-235aac55da36", + "key_usage": "SIGN_VERIFY", + "policy": "{\"Id\":\"key-consolepolicy-3\",\"Statement\":[{\"Action\":\"kms:*\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::047081014315:root\"},\"Resource\":\"*\",\"Sid\":\"Enable IAM User Permissions\"},{\"Action\":[\"kms:DescribeKey\",\"kms:GetPublicKey\",\"kms:Sign\",\"kms:Verify\"],\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::047081014315:user/admin\"},\"Resource\":\"*\",\"Sid\":\"Allow use of the key\"},{\"Action\":[\"kms:CreateGrant\",\"kms:ListGrants\",\"kms:RevokeGrant\"],\"Condition\":{\"Bool\":{\"kms:GrantIsForAWSResource\":\"true\"}},\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::047081014315:user/admin\"},\"Resource\":\"*\",\"Sid\":\"Allow attachment of persistent resources\"}],\"Version\":\"2012-10-17\"}" + } + }, + { + "Id": "5d765f32-bfdc-4610-b6ab-f82db5d0601b", + "Type": "aws_kms_key", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:key/5d765f32-bfdc-4610-b6ab-f82db5d0601b", + "customer_master_key_spec": "SYMMETRIC_DEFAULT", + "description": "Baz", + "enable_key_rotation": false, + "id": "5d765f32-bfdc-4610-b6ab-f82db5d0601b", + "is_enabled": false, + "key_id": "5d765f32-bfdc-4610-b6ab-f82db5d0601b", + "key_usage": "ENCRYPT_DECRYPT", + "policy": "{\"Id\":\"key-default-1\",\"Statement\":[{\"Action\":\"kms:*\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::047081014315:root\"},\"Resource\":\"*\",\"Sid\":\"Enable IAM User Permissions\"}],\"Version\":\"2012-10-17\"}", + "tags": { + "Foo": "true" + } + } + }, + { + "Id": "89d2c023-ea53-40a5-b20a-d84905c622d7", + "Type": "aws_kms_key", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:key/89d2c023-ea53-40a5-b20a-d84905c622d7", + "customer_master_key_spec": "RSA_4096", + "description": "Foo", + "enable_key_rotation": false, + "id": "89d2c023-ea53-40a5-b20a-d84905c622d7", + "is_enabled": true, + "key_id": "89d2c023-ea53-40a5-b20a-d84905c622d7", + "key_usage": "ENCRYPT_DECRYPT", + "policy": "{\"Id\":\"key-default-1\",\"Statement\":[{\"Action\":\"kms:*\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::047081014315:root\"},\"Resource\":\"*\",\"Sid\":\"Enable IAM User Permissions\"}],\"Version\":\"2012-10-17\"}" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_kms_key/input.json b/pkg/test/aws/3.19.0/aws_kms_key/input.json new file mode 100755 index 000000000..a0c5dc9e0 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_kms_key/input.json @@ -0,0 +1,55 @@ +[ + { + "Id": "8ee21d91-c000-428c-8032-235aac55da36", + "Type": "aws_kms_key", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:key/8ee21d91-c000-428c-8032-235aac55da36", + "customer_master_key_spec": "RSA_2048", + "deletion_window_in_days": null, + "description": "Bar", + "enable_key_rotation": false, + "id": "8ee21d91-c000-428c-8032-235aac55da36", + "is_enabled": true, + "key_id": "8ee21d91-c000-428c-8032-235aac55da36", + "key_usage": "SIGN_VERIFY", + "policy": "{\"Id\":\"key-consolepolicy-3\",\"Statement\":[{\"Action\":\"kms:*\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::047081014315:root\"},\"Resource\":\"*\",\"Sid\":\"Enable IAM User Permissions\"},{\"Action\":[\"kms:DescribeKey\",\"kms:GetPublicKey\",\"kms:Sign\",\"kms:Verify\"],\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::047081014315:user/admin\"},\"Resource\":\"*\",\"Sid\":\"Allow use of the key\"},{\"Action\":[\"kms:CreateGrant\",\"kms:ListGrants\",\"kms:RevokeGrant\"],\"Condition\":{\"Bool\":{\"kms:GrantIsForAWSResource\":\"true\"}},\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::047081014315:user/admin\"},\"Resource\":\"*\",\"Sid\":\"Allow attachment of persistent resources\"}],\"Version\":\"2012-10-17\"}", + "tags": {} + } + }, + { + "Id": "5d765f32-bfdc-4610-b6ab-f82db5d0601b", + "Type": "aws_kms_key", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:key/5d765f32-bfdc-4610-b6ab-f82db5d0601b", + "customer_master_key_spec": "SYMMETRIC_DEFAULT", + "deletion_window_in_days": null, + "description": "Baz", + "enable_key_rotation": false, + "id": "5d765f32-bfdc-4610-b6ab-f82db5d0601b", + "is_enabled": false, + "key_id": "5d765f32-bfdc-4610-b6ab-f82db5d0601b", + "key_usage": "ENCRYPT_DECRYPT", + "policy": "{\"Id\":\"key-default-1\",\"Statement\":[{\"Action\":\"kms:*\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::047081014315:root\"},\"Resource\":\"*\",\"Sid\":\"Enable IAM User Permissions\"}],\"Version\":\"2012-10-17\"}", + "tags": { + "Foo": "true" + } + } + }, + { + "Id": "89d2c023-ea53-40a5-b20a-d84905c622d7", + "Type": "aws_kms_key", + "Attrs": { + "arn": "arn:aws:kms:eu-west-3:047081014315:key/89d2c023-ea53-40a5-b20a-d84905c622d7", + "customer_master_key_spec": "RSA_4096", + "deletion_window_in_days": null, + "description": "Foo", + "enable_key_rotation": false, + "id": "89d2c023-ea53-40a5-b20a-d84905c622d7", + "is_enabled": true, + "key_id": "89d2c023-ea53-40a5-b20a-d84905c622d7", + "key_usage": "ENCRYPT_DECRYPT", + "policy": "{\"Id\":\"key-default-1\",\"Statement\":[{\"Action\":\"kms:*\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::047081014315:root\"},\"Resource\":\"*\",\"Sid\":\"Enable IAM User Permissions\"}],\"Version\":\"2012-10-17\"}", + "tags": {} + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_lambda_event_source_mapping/expected.json b/pkg/test/aws/3.19.0/aws_lambda_event_source_mapping/expected.json new file mode 100755 index 000000000..a53e63767 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_lambda_event_source_mapping/expected.json @@ -0,0 +1,38 @@ +[ + { + "Id": "13ff66f8-37eb-4ad6-a0a8-594fea72df4f", + "Type": "aws_lambda_event_source_mapping", + "Attrs": { + "batch_size": 1, + "bisect_batch_on_function_error": false, + "enabled": true, + "event_source_arn": "arn:aws:sqs:us-east-1:526954929923:queue1", + "function_arn": "arn:aws:lambda:us-east-1:526954929923:function:lambda_function_name", + "function_name": "arn:aws:lambda:us-east-1:526954929923:function:lambda_function_name", + "id": "13ff66f8-37eb-4ad6-a0a8-594fea72df4f", + "maximum_batching_window_in_seconds": 0, + "maximum_record_age_in_seconds": 0, + "maximum_retry_attempts": 0, + "parallelization_factor": 0, + "uuid": "13ff66f8-37eb-4ad6-a0a8-594fea72df4f" + } + }, + { + "Id": "4ad7e2b3-79e9-4713-9d9d-5af2c01d9058", + "Type": "aws_lambda_event_source_mapping", + "Attrs": { + "batch_size": 1, + "bisect_batch_on_function_error": false, + "enabled": true, + "event_source_arn": "arn:aws:sqs:us-east-1:526954929923:queue2", + "function_arn": "arn:aws:lambda:us-east-1:526954929923:function:lambda_function_name", + "function_name": "arn:aws:lambda:us-east-1:526954929923:function:lambda_function_name", + "id": "4ad7e2b3-79e9-4713-9d9d-5af2c01d9058", + "maximum_batching_window_in_seconds": 0, + "maximum_record_age_in_seconds": 0, + "maximum_retry_attempts": 0, + "parallelization_factor": 0, + "uuid": "4ad7e2b3-79e9-4713-9d9d-5af2c01d9058" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_lambda_event_source_mapping/input.json b/pkg/test/aws/3.19.0/aws_lambda_event_source_mapping/input.json new file mode 100755 index 000000000..a53e63767 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_lambda_event_source_mapping/input.json @@ -0,0 +1,38 @@ +[ + { + "Id": "13ff66f8-37eb-4ad6-a0a8-594fea72df4f", + "Type": "aws_lambda_event_source_mapping", + "Attrs": { + "batch_size": 1, + "bisect_batch_on_function_error": false, + "enabled": true, + "event_source_arn": "arn:aws:sqs:us-east-1:526954929923:queue1", + "function_arn": "arn:aws:lambda:us-east-1:526954929923:function:lambda_function_name", + "function_name": "arn:aws:lambda:us-east-1:526954929923:function:lambda_function_name", + "id": "13ff66f8-37eb-4ad6-a0a8-594fea72df4f", + "maximum_batching_window_in_seconds": 0, + "maximum_record_age_in_seconds": 0, + "maximum_retry_attempts": 0, + "parallelization_factor": 0, + "uuid": "13ff66f8-37eb-4ad6-a0a8-594fea72df4f" + } + }, + { + "Id": "4ad7e2b3-79e9-4713-9d9d-5af2c01d9058", + "Type": "aws_lambda_event_source_mapping", + "Attrs": { + "batch_size": 1, + "bisect_batch_on_function_error": false, + "enabled": true, + "event_source_arn": "arn:aws:sqs:us-east-1:526954929923:queue2", + "function_arn": "arn:aws:lambda:us-east-1:526954929923:function:lambda_function_name", + "function_name": "arn:aws:lambda:us-east-1:526954929923:function:lambda_function_name", + "id": "4ad7e2b3-79e9-4713-9d9d-5af2c01d9058", + "maximum_batching_window_in_seconds": 0, + "maximum_record_age_in_seconds": 0, + "maximum_retry_attempts": 0, + "parallelization_factor": 0, + "uuid": "4ad7e2b3-79e9-4713-9d9d-5af2c01d9058" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_lambda_function/expected.json b/pkg/test/aws/3.19.0/aws_lambda_function/expected.json new file mode 100755 index 000000000..dee65a96d --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_lambda_function/expected.json @@ -0,0 +1,54 @@ +[ + { + "Id": "bar", + "Type": "aws_lambda_function", + "Attrs": { + "arn": "arn:aws:lambda:eu-west-3:047081014315:function:bar", + "description": "", + "function_name": "bar", + "handler": "lambda.handler", + "id": "bar", + "invoke_arn": "arn:aws:apigateway:eu-west-3:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-3:047081014315:function:bar/invocations", + "kms_key_arn": "", + "memory_size": 128, + "qualified_arn": "arn:aws:lambda:eu-west-3:047081014315:function:bar:$LATEST", + "reserved_concurrent_executions": -1, + "role": "arn:aws:iam::047081014315:role/iam_for_lambda", + "runtime": "nodejs12.x", + "source_code_hash": "PoaAEeOCmEFZojnrhEJvNzs+jg7/w1lL9GiFYvlM6aw=", + "timeout": 3, + "tracing_config": [ + { + "mode": "PassThrough" + } + ], + "version": "$LATEST" + } + }, + { + "Id": "foo", + "Type": "aws_lambda_function", + "Attrs": { + "arn": "arn:aws:lambda:eu-west-3:047081014315:function:foo", + "description": "", + "function_name": "foo", + "handler": "lambda.handler", + "id": "foo", + "invoke_arn": "arn:aws:apigateway:eu-west-3:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-3:047081014315:function:foo/invocations", + "kms_key_arn": "", + "memory_size": 128, + "qualified_arn": "arn:aws:lambda:eu-west-3:047081014315:function:foo:$LATEST", + "reserved_concurrent_executions": -1, + "role": "arn:aws:iam::047081014315:role/iam_for_lambda", + "runtime": "nodejs12.x", + "source_code_hash": "PoaAEeOCmEFZojnrhEJvNzs+jg7/w1lL9GiFYvlM6aw=", + "timeout": 3, + "tracing_config": [ + { + "mode": "PassThrough" + } + ], + "version": "$LATEST" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_lambda_function/input.json b/pkg/test/aws/3.19.0/aws_lambda_function/input.json new file mode 100755 index 000000000..e763195eb --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_lambda_function/input.json @@ -0,0 +1,86 @@ +[ + { + "Id": "bar", + "Type": "aws_lambda_function", + "Attrs": { + "arn": "arn:aws:lambda:eu-west-3:047081014315:function:bar", + "dead_letter_config": [], + "description": "", + "environment": [], + "file_system_config": [], + "filename": null, + "function_name": "bar", + "handler": "lambda.handler", + "id": "bar", + "invoke_arn": "arn:aws:apigateway:eu-west-3:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-3:047081014315:function:bar/invocations", + "kms_key_arn": "", + "last_modified": "2020-10-16T09:04:42.050+0000", + "layers": [], + "memory_size": 128, + "publish": null, + "qualified_arn": "arn:aws:lambda:eu-west-3:047081014315:function:bar:$LATEST", + "reserved_concurrent_executions": -1, + "role": "arn:aws:iam::047081014315:role/iam_for_lambda", + "runtime": "nodejs12.x", + "s3_bucket": null, + "s3_key": null, + "s3_object_version": null, + "source_code_hash": "PoaAEeOCmEFZojnrhEJvNzs+jg7/w1lL9GiFYvlM6aw=", + "source_code_size": 352, + "tags": {}, + "timeout": 3, + "timeouts": { + "create": null + }, + "tracing_config": [ + { + "mode": "PassThrough" + } + ], + "version": "$LATEST", + "vpc_config": [] + } + }, + { + "Id": "foo", + "Type": "aws_lambda_function", + "Attrs": { + "arn": "arn:aws:lambda:eu-west-3:047081014315:function:foo", + "dead_letter_config": [], + "description": "", + "environment": [], + "file_system_config": [], + "filename": null, + "function_name": "foo", + "handler": "lambda.handler", + "id": "foo", + "invoke_arn": "arn:aws:apigateway:eu-west-3:lambda:path/2015-03-31/functions/arn:aws:lambda:eu-west-3:047081014315:function:foo/invocations", + "kms_key_arn": "", + "last_modified": "2020-10-16T09:04:36.176+0000", + "layers": [], + "memory_size": 128, + "publish": null, + "qualified_arn": "arn:aws:lambda:eu-west-3:047081014315:function:foo:$LATEST", + "reserved_concurrent_executions": -1, + "role": "arn:aws:iam::047081014315:role/iam_for_lambda", + "runtime": "nodejs12.x", + "s3_bucket": null, + "s3_key": null, + "s3_object_version": null, + "source_code_hash": "PoaAEeOCmEFZojnrhEJvNzs+jg7/w1lL9GiFYvlM6aw=", + "source_code_size": 352, + "tags": {}, + "timeout": 3, + "timeouts": { + "create": null + }, + "tracing_config": [ + { + "mode": "PassThrough" + } + ], + "version": "$LATEST", + "vpc_config": [] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_launch_configuration/expected.json b/pkg/test/aws/3.19.0/aws_launch_configuration/expected.json new file mode 100755 index 000000000..11447a7a2 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_launch_configuration/expected.json @@ -0,0 +1,21 @@ +[ + { + "Id": "web_config", + "Type": "aws_launch_configuration", + "Attrs": { + "arn": "arn:aws:autoscaling:us-east-1:533948124879:launchConfiguration:2cbee675-0d59-454b-866d-e9476e69381d:launchConfigurationName/web_config", + "associate_public_ip_address": false, + "ebs_optimized": false, + "enable_monitoring": true, + "iam_instance_profile": "", + "id": "web_config", + "image_id": "ami-022d4249382309a48", + "instance_type": "t3.micro", + "key_name": "", + "name": "web_config", + "name_prefix": "", + "spot_price": "", + "vpc_classic_link_id": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_launch_configuration/input.json b/pkg/test/aws/3.19.0/aws_launch_configuration/input.json new file mode 100755 index 000000000..11447a7a2 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_launch_configuration/input.json @@ -0,0 +1,21 @@ +[ + { + "Id": "web_config", + "Type": "aws_launch_configuration", + "Attrs": { + "arn": "arn:aws:autoscaling:us-east-1:533948124879:launchConfiguration:2cbee675-0d59-454b-866d-e9476e69381d:launchConfigurationName/web_config", + "associate_public_ip_address": false, + "ebs_optimized": false, + "enable_monitoring": true, + "iam_instance_profile": "", + "id": "web_config", + "image_id": "ami-022d4249382309a48", + "instance_type": "t3.micro", + "key_name": "", + "name": "web_config", + "name_prefix": "", + "spot_price": "", + "vpc_classic_link_id": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_launch_template/expected.json b/pkg/test/aws/3.19.0/aws_launch_template/expected.json new file mode 100755 index 000000000..e06d46452 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_launch_template/expected.json @@ -0,0 +1,117 @@ +[ + { + "Id": "lt-00b2d18c6cee7fe23", + "Type": "aws_launch_template", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:533948124879:launch-template/lt-00b2d18c6cee7fe23", + "default_version": 1, + "description": "", + "disable_api_termination": false, + "ebs_optimized": "", + "id": "lt-00b2d18c6cee7fe23", + "image_id": "ami-000b3a073fc20e415", + "instance_initiated_shutdown_behavior": "", + "instance_type": "t3.micro", + "kernel_id": "", + "key_name": "", + "latest_version": 1, + "name": "test-template-2", + "ram_disk_id": "", + "user_data": "" + } + }, + { + "Id": "lt-0ed993d09ce6afc67", + "Type": "aws_launch_template", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:533948124879:launch-template/lt-0ed993d09ce6afc67", + "block_device_mappings": [ + { + "device_name": "/dev/sda1", + "ebs": [ + { + "delete_on_termination": "", + "encrypted": "", + "iops": 0, + "kms_key_id": "", + "snapshot_id": "", + "volume_size": 20, + "volume_type": "" + } + ], + "no_device": "", + "virtual_name": "" + } + ], + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open" + } + ], + "cpu_options": [ + { + "core_count": 4, + "threads_per_core": 2 + } + ], + "default_version": 1, + "description": "", + "disable_api_termination": true, + "ebs_optimized": "true", + "id": "lt-0ed993d09ce6afc67", + "image_id": "ami-000b3a073fc20e415", + "instance_initiated_shutdown_behavior": "terminate", + "instance_type": "", + "kernel_id": "", + "key_name": "", + "latest_version": 1, + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_put_response_hop_limit": 1, + "http_tokens": "required" + } + ], + "monitoring": [ + { + "enabled": true + } + ], + "name": "test-template", + "network_interfaces": [ + { + "associate_public_ip_address": "true", + "delete_on_termination": "", + "description": "", + "device_index": 0, + "ipv4_address_count": 0, + "ipv6_address_count": 0, + "network_interface_id": "", + "private_ip_address": "", + "subnet_id": "" + } + ], + "placement": [ + { + "affinity": "", + "availability_zone": "us-west-2a", + "group_name": "", + "host_id": "", + "partition_number": 0, + "spread_domain": "", + "tenancy": "" + } + ], + "ram_disk_id": "", + "tag_specifications": [ + { + "resource_type": "instance", + "tags": { + "Name": "test" + } + } + ], + "user_data": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_launch_template/input.json b/pkg/test/aws/3.19.0/aws_launch_template/input.json new file mode 100755 index 000000000..b09193230 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_launch_template/input.json @@ -0,0 +1,153 @@ +[ + { + "Id": "lt-00b2d18c6cee7fe23", + "Type": "aws_launch_template", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:533948124879:launch-template/lt-00b2d18c6cee7fe23", + "block_device_mappings": [], + "capacity_reservation_specification": [], + "cpu_options": [], + "credit_specification": [], + "default_version": 1, + "description": "", + "disable_api_termination": false, + "ebs_optimized": "", + "elastic_gpu_specifications": [], + "elastic_inference_accelerator": [], + "hibernation_options": [], + "iam_instance_profile": [], + "id": "lt-00b2d18c6cee7fe23", + "image_id": "ami-000b3a073fc20e415", + "instance_initiated_shutdown_behavior": "", + "instance_market_options": [], + "instance_type": "t3.micro", + "kernel_id": "", + "key_name": "", + "latest_version": 1, + "license_specification": [], + "metadata_options": [], + "monitoring": [], + "name": "test-template-2", + "name_prefix": null, + "network_interfaces": [], + "placement": [], + "ram_disk_id": "", + "security_group_names": [], + "tag_specifications": [], + "tags": {}, + "update_default_version": null, + "user_data": "", + "vpc_security_group_ids": [] + } + }, + { + "Id": "lt-0ed993d09ce6afc67", + "Type": "aws_launch_template", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:533948124879:launch-template/lt-0ed993d09ce6afc67", + "block_device_mappings": [ + { + "device_name": "/dev/sda1", + "ebs": [ + { + "delete_on_termination": "", + "encrypted": "", + "iops": 0, + "kms_key_id": "", + "snapshot_id": "", + "volume_size": 20, + "volume_type": "" + } + ], + "no_device": "", + "virtual_name": "" + } + ], + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_options": [ + { + "core_count": 4, + "threads_per_core": 2 + } + ], + "credit_specification": null, + "default_version": 1, + "description": "", + "disable_api_termination": true, + "ebs_optimized": "true", + "elastic_gpu_specifications": [], + "elastic_inference_accelerator": [], + "hibernation_options": [], + "iam_instance_profile": [], + "id": "lt-0ed993d09ce6afc67", + "image_id": "ami-000b3a073fc20e415", + "instance_initiated_shutdown_behavior": "terminate", + "instance_market_options": [], + "instance_type": "", + "kernel_id": "", + "key_name": "", + "latest_version": 1, + "license_specification": [], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_put_response_hop_limit": 1, + "http_tokens": "required" + } + ], + "monitoring": [ + { + "enabled": true + } + ], + "name": "test-template", + "name_prefix": null, + "network_interfaces": [ + { + "associate_public_ip_address": "true", + "delete_on_termination": "", + "description": "", + "device_index": 0, + "ipv4_address_count": 0, + "ipv4_addresses": [], + "ipv6_address_count": 0, + "ipv6_addresses": [], + "network_interface_id": "", + "private_ip_address": "", + "security_groups": [], + "subnet_id": "" + } + ], + "placement": [ + { + "affinity": "", + "availability_zone": "us-west-2a", + "group_name": "", + "host_id": "", + "partition_number": 0, + "spread_domain": "", + "tenancy": "" + } + ], + "ram_disk_id": "", + "security_group_names": [], + "tag_specifications": [ + { + "resource_type": "instance", + "tags": { + "Name": "test" + } + } + ], + "tags": {}, + "update_default_version": null, + "user_data": "", + "vpc_security_group_ids": [] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_lb/expected.json b/pkg/test/aws/3.19.0/aws_lb/expected.json new file mode 100755 index 000000000..db336fb3c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_lb/expected.json @@ -0,0 +1,54 @@ +[ + { + "Id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/35be57d467ff22b9", + "Type": "aws_alb", + "Attrs": { + "access_logs": [ + { + "bucket": "", + "enabled": false, + "prefix": "" + } + ], + "arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/35be57d467ff22b9", + "arn_suffix": "app/test-lb-tf/35be57d467ff22b9", + "customer_owned_ipv4_pool": "", + "dns_name": "test-lb-tf-278241463.us-east-1.elb.amazonaws.com", + "drop_invalid_header_fields": false, + "enable_deletion_protection": false, + "enable_http2": true, + "id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/35be57d467ff22b9", + "idle_timeout": 60, + "internal": false, + "ip_address_type": "ipv4", + "load_balancer_type": "application", + "name": "test-lb-tf", + "security_groups": [ + "sg-06fecfaa711e65b6c" + ], + "subnet_mapping": [ + { + "allocation_id": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-003713513d37c0905" + }, + { + "allocation_id": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-063162f23053ebfdd" + } + ], + "subnets": [ + "subnet-003713513d37c0905", + "subnet-063162f23053ebfdd" + ], + "tags": { + "Environment": "dev" + }, + "vpc_id": "vpc-0ae1f138a09749ef1", + "zone_id": "Z35SXDOTRQ7X7K" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_lb/input.json b/pkg/test/aws/3.19.0/aws_lb/input.json new file mode 100755 index 000000000..db336fb3c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_lb/input.json @@ -0,0 +1,54 @@ +[ + { + "Id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/35be57d467ff22b9", + "Type": "aws_alb", + "Attrs": { + "access_logs": [ + { + "bucket": "", + "enabled": false, + "prefix": "" + } + ], + "arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/35be57d467ff22b9", + "arn_suffix": "app/test-lb-tf/35be57d467ff22b9", + "customer_owned_ipv4_pool": "", + "dns_name": "test-lb-tf-278241463.us-east-1.elb.amazonaws.com", + "drop_invalid_header_fields": false, + "enable_deletion_protection": false, + "enable_http2": true, + "id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/35be57d467ff22b9", + "idle_timeout": 60, + "internal": false, + "ip_address_type": "ipv4", + "load_balancer_type": "application", + "name": "test-lb-tf", + "security_groups": [ + "sg-06fecfaa711e65b6c" + ], + "subnet_mapping": [ + { + "allocation_id": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-003713513d37c0905" + }, + { + "allocation_id": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-063162f23053ebfdd" + } + ], + "subnets": [ + "subnet-003713513d37c0905", + "subnet-063162f23053ebfdd" + ], + "tags": { + "Environment": "dev" + }, + "vpc_id": "vpc-0ae1f138a09749ef1", + "zone_id": "Z35SXDOTRQ7X7K" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_lb_listener/expected.json b/pkg/test/aws/3.19.0/aws_lb_listener/expected.json new file mode 100755 index 000000000..03fe964c1 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_lb_listener/expected.json @@ -0,0 +1,111 @@ +[ + { + "Id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:listener/app/test-lb-tf/168f3e312968e275/21a7de7e81a06bda", + "Type": "aws_lb_listener", + "Attrs": { + "arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:listener/app/test-lb-tf/168f3e312968e275/21a7de7e81a06bda", + "default_action": [ + { + "order": 1, + "target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:targetgroup/tf-example-lb-tg/9e43d546683d8b35", + "type": "forward" + } + ], + "id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:listener/app/test-lb-tf/168f3e312968e275/21a7de7e81a06bda", + "load_balancer_arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/168f3e312968e275", + "port": 80, + "protocol": "HTTP", + "ssl_policy": "" + } + }, + { + "Id": "sg-0d8b60865ca657bb3", + "Type": "aws_security_group", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:533948124879:security-group/sg-0d8b60865ca657bb3", + "description": "Allow TLS inbound traffic", + "id": "sg-0d8b60865ca657bb3", + "name": "allow_tls_lb", + "name_prefix": "", + "owner_id": "533948124879", + "vpc_id": "vpc-069eb1208f4f62f3c" + } + }, + { + "Id": "subnet-09b8c4d89ed5f3aeb", + "Type": "aws_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:533948124879:subnet/subnet-09b8c4d89ed5f3aeb", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1a", + "availability_zone_id": "use1-az4", + "cidr_block": "10.100.0.0/24", + "id": "subnet-09b8c4d89ed5f3aeb", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "533948124879", + "vpc_id": "vpc-069eb1208f4f62f3c" + } + }, + { + "Id": "igw-00e1a78d127606c92", + "Type": "aws_internet_gateway", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:533948124879:internet-gateway/igw-00e1a78d127606c92", + "id": "igw-00e1a78d127606c92", + "owner_id": "533948124879", + "vpc_id": "vpc-069eb1208f4f62f3c" + } + }, + { + "Id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/168f3e312968e275", + "Type": "aws_lb", + "Attrs": { + "access_logs": [ + { + "bucket": "", + "enabled": false, + "prefix": "" + } + ], + "arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/168f3e312968e275", + "arn_suffix": "app/test-lb-tf/168f3e312968e275", + "customer_owned_ipv4_pool": "", + "dns_name": "test-lb-tf-2047934243.us-east-1.elb.amazonaws.com", + "drop_invalid_header_fields": false, + "enable_deletion_protection": false, + "enable_http2": true, + "id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/168f3e312968e275", + "idle_timeout": 60, + "internal": false, + "ip_address_type": "ipv4", + "load_balancer_type": "application", + "name": "test-lb-tf", + "security_groups": [ + "sg-0d8b60865ca657bb3" + ], + "subnet_mapping": [ + { + "allocation_id": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-00499e85b962e382f" + }, + { + "allocation_id": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-09b8c4d89ed5f3aeb" + } + ], + "subnets": [ + "subnet-00499e85b962e382f", + "subnet-09b8c4d89ed5f3aeb" + ], + "vpc_id": "vpc-069eb1208f4f62f3c", + "zone_id": "Z35SXDOTRQ7X7K" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_lb_listener/input.json b/pkg/test/aws/3.19.0/aws_lb_listener/input.json new file mode 100755 index 000000000..03fe964c1 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_lb_listener/input.json @@ -0,0 +1,111 @@ +[ + { + "Id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:listener/app/test-lb-tf/168f3e312968e275/21a7de7e81a06bda", + "Type": "aws_lb_listener", + "Attrs": { + "arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:listener/app/test-lb-tf/168f3e312968e275/21a7de7e81a06bda", + "default_action": [ + { + "order": 1, + "target_group_arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:targetgroup/tf-example-lb-tg/9e43d546683d8b35", + "type": "forward" + } + ], + "id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:listener/app/test-lb-tf/168f3e312968e275/21a7de7e81a06bda", + "load_balancer_arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/168f3e312968e275", + "port": 80, + "protocol": "HTTP", + "ssl_policy": "" + } + }, + { + "Id": "sg-0d8b60865ca657bb3", + "Type": "aws_security_group", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:533948124879:security-group/sg-0d8b60865ca657bb3", + "description": "Allow TLS inbound traffic", + "id": "sg-0d8b60865ca657bb3", + "name": "allow_tls_lb", + "name_prefix": "", + "owner_id": "533948124879", + "vpc_id": "vpc-069eb1208f4f62f3c" + } + }, + { + "Id": "subnet-09b8c4d89ed5f3aeb", + "Type": "aws_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:533948124879:subnet/subnet-09b8c4d89ed5f3aeb", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1a", + "availability_zone_id": "use1-az4", + "cidr_block": "10.100.0.0/24", + "id": "subnet-09b8c4d89ed5f3aeb", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "533948124879", + "vpc_id": "vpc-069eb1208f4f62f3c" + } + }, + { + "Id": "igw-00e1a78d127606c92", + "Type": "aws_internet_gateway", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:533948124879:internet-gateway/igw-00e1a78d127606c92", + "id": "igw-00e1a78d127606c92", + "owner_id": "533948124879", + "vpc_id": "vpc-069eb1208f4f62f3c" + } + }, + { + "Id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/168f3e312968e275", + "Type": "aws_lb", + "Attrs": { + "access_logs": [ + { + "bucket": "", + "enabled": false, + "prefix": "" + } + ], + "arn": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/168f3e312968e275", + "arn_suffix": "app/test-lb-tf/168f3e312968e275", + "customer_owned_ipv4_pool": "", + "dns_name": "test-lb-tf-2047934243.us-east-1.elb.amazonaws.com", + "drop_invalid_header_fields": false, + "enable_deletion_protection": false, + "enable_http2": true, + "id": "arn:aws:elasticloadbalancing:us-east-1:533948124879:loadbalancer/app/test-lb-tf/168f3e312968e275", + "idle_timeout": 60, + "internal": false, + "ip_address_type": "ipv4", + "load_balancer_type": "application", + "name": "test-lb-tf", + "security_groups": [ + "sg-0d8b60865ca657bb3" + ], + "subnet_mapping": [ + { + "allocation_id": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-00499e85b962e382f" + }, + { + "allocation_id": "", + "outpost_id": "", + "private_ipv4_address": "", + "subnet_id": "subnet-09b8c4d89ed5f3aeb" + } + ], + "subnets": [ + "subnet-00499e85b962e382f", + "subnet-09b8c4d89ed5f3aeb" + ], + "vpc_id": "vpc-069eb1208f4f62f3c", + "zone_id": "Z35SXDOTRQ7X7K" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_nat_gateway/expected.json b/pkg/test/aws/3.19.0/aws_nat_gateway/expected.json new file mode 100755 index 000000000..854309171 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_nat_gateway/expected.json @@ -0,0 +1,17 @@ +[ + { + "Id": "nat-0a5408508b19ef490", + "Type": "aws_nat_gateway", + "Attrs": { + "allocation_id": "eipalloc-0f3e9fff457bb770b", + "id": "nat-0a5408508b19ef490", + "network_interface_id": "eni-0a5125861e3328c7d", + "private_ip": "172.31.84.248", + "public_ip": "54.87.245.115", + "subnet_id": "subnet-44fe0c65", + "tags": { + "Name": "nat1" + } + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_nat_gateway/input.json b/pkg/test/aws/3.19.0/aws_nat_gateway/input.json new file mode 100755 index 000000000..854309171 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_nat_gateway/input.json @@ -0,0 +1,17 @@ +[ + { + "Id": "nat-0a5408508b19ef490", + "Type": "aws_nat_gateway", + "Attrs": { + "allocation_id": "eipalloc-0f3e9fff457bb770b", + "id": "nat-0a5408508b19ef490", + "network_interface_id": "eni-0a5125861e3328c7d", + "private_ip": "172.31.84.248", + "public_ip": "54.87.245.115", + "subnet_id": "subnet-44fe0c65", + "tags": { + "Name": "nat1" + } + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_network_acl/expected.json b/pkg/test/aws/3.19.0/aws_network_acl/expected.json new file mode 100755 index 000000000..4e2b6712c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_network_acl/expected.json @@ -0,0 +1,54 @@ +[ + { + "Id": "acl-01b7bc85a61d92e70", + "Type": "aws_network_acl", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:929327065333:network-acl/acl-01b7bc85a61d92e70", + "id": "acl-01b7bc85a61d92e70", + "owner_id": "929327065333", + "tags": { + "Name": "test2" + }, + "vpc_id": "vpc-41d1d13b" + } + }, + { + "Id": "acl-069e079b416dd581e", + "Type": "aws_network_acl", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:929327065333:network-acl/acl-069e079b416dd581e", + "egress": [ + { + "action": "allow", + "cidr_block": "172.31.0.0/16", + "from_port": 80, + "icmp_code": 0, + "icmp_type": 0, + "ipv6_cidr_block": "", + "protocol": "udp", + "rule_no": 100, + "to_port": 80 + } + ], + "id": "acl-069e079b416dd581e", + "ingress": [ + { + "action": "allow", + "cidr_block": "172.31.0.0/16", + "from_port": 80, + "icmp_code": 0, + "icmp_type": 0, + "ipv6_cidr_block": "", + "protocol": "udp", + "rule_no": 100, + "to_port": 80 + } + ], + "owner_id": "929327065333", + "tags": { + "Name": "test" + }, + "vpc_id": "vpc-41d1d13b" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_network_acl/input.json b/pkg/test/aws/3.19.0/aws_network_acl/input.json new file mode 100755 index 000000000..4e2b6712c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_network_acl/input.json @@ -0,0 +1,54 @@ +[ + { + "Id": "acl-01b7bc85a61d92e70", + "Type": "aws_network_acl", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:929327065333:network-acl/acl-01b7bc85a61d92e70", + "id": "acl-01b7bc85a61d92e70", + "owner_id": "929327065333", + "tags": { + "Name": "test2" + }, + "vpc_id": "vpc-41d1d13b" + } + }, + { + "Id": "acl-069e079b416dd581e", + "Type": "aws_network_acl", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:929327065333:network-acl/acl-069e079b416dd581e", + "egress": [ + { + "action": "allow", + "cidr_block": "172.31.0.0/16", + "from_port": 80, + "icmp_code": 0, + "icmp_type": 0, + "ipv6_cidr_block": "", + "protocol": "udp", + "rule_no": 100, + "to_port": 80 + } + ], + "id": "acl-069e079b416dd581e", + "ingress": [ + { + "action": "allow", + "cidr_block": "172.31.0.0/16", + "from_port": 80, + "icmp_code": 0, + "icmp_type": 0, + "ipv6_cidr_block": "", + "protocol": "udp", + "rule_no": 100, + "to_port": 80 + } + ], + "owner_id": "929327065333", + "tags": { + "Name": "test" + }, + "vpc_id": "vpc-41d1d13b" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_network_acl_rule/expected.json b/pkg/test/aws/3.19.0/aws_network_acl_rule/expected.json new file mode 100755 index 000000000..e3288c169 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_network_acl_rule/expected.json @@ -0,0 +1,32 @@ +[ + { + "Id": "nacl-2880546575", + "Type": "aws_network_acl_rule", + "Attrs": { + "cidr_block": "172.31.0.0/16", + "egress": true, + "from_port": 80, + "id": "nacl-2880546575", + "network_acl_id": "acl-01b7bc85a61d92e70", + "protocol": "17", + "rule_action": "allow", + "rule_number": 100, + "to_port": 80 + } + }, + { + "Id": "nacl-1525104124", + "Type": "aws_network_acl_rule", + "Attrs": { + "cidr_block": "172.31.0.0/16", + "egress": false, + "from_port": 80, + "id": "nacl-1525104124", + "network_acl_id": "acl-01b7bc85a61d92e70", + "protocol": "6", + "rule_action": "allow", + "rule_number": 100, + "to_port": 80 + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_network_acl_rule/input.json b/pkg/test/aws/3.19.0/aws_network_acl_rule/input.json new file mode 100755 index 000000000..e3288c169 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_network_acl_rule/input.json @@ -0,0 +1,32 @@ +[ + { + "Id": "nacl-2880546575", + "Type": "aws_network_acl_rule", + "Attrs": { + "cidr_block": "172.31.0.0/16", + "egress": true, + "from_port": 80, + "id": "nacl-2880546575", + "network_acl_id": "acl-01b7bc85a61d92e70", + "protocol": "17", + "rule_action": "allow", + "rule_number": 100, + "to_port": 80 + } + }, + { + "Id": "nacl-1525104124", + "Type": "aws_network_acl_rule", + "Attrs": { + "cidr_block": "172.31.0.0/16", + "egress": false, + "from_port": 80, + "id": "nacl-1525104124", + "network_acl_id": "acl-01b7bc85a61d92e70", + "protocol": "6", + "rule_action": "allow", + "rule_number": 100, + "to_port": 80 + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_rds_cluster/expected.json b/pkg/test/aws/3.19.0/aws_rds_cluster/expected.json new file mode 100755 index 000000000..79c746aa4 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_rds_cluster/expected.json @@ -0,0 +1,84 @@ +[ + { + "Id": "aurora-cluster-demo", + "Type": "aws_rds_cluster", + "Attrs": { + "arn": "arn:aws:rds:us-east-1:533948124879:cluster:aurora-cluster-demo", + "availability_zones": [ + "us-east-1a", + "us-east-1b", + "us-east-1d" + ], + "backtrack_window": 0, + "backup_retention_period": 5, + "cluster_identifier": "aurora-cluster-demo", + "cluster_resource_id": "cluster-TISYDSSX4J5R6ZGUTV6LLJW73E", + "copy_tags_to_snapshot": false, + "database_name": "mydb", + "db_cluster_parameter_group_name": "default.aurora-postgresql11", + "db_subnet_group_name": "default", + "deletion_protection": false, + "enable_http_endpoint": false, + "endpoint": "aurora-cluster-demo.cluster-cd539r6quiux.us-east-1.rds.amazonaws.com", + "engine": "aurora-postgresql", + "engine_mode": "provisioned", + "engine_version": "11.9", + "global_cluster_identifier": "", + "hosted_zone_id": "Z2R2ITUGPM61AM", + "iam_database_authentication_enabled": false, + "id": "aurora-cluster-demo", + "kms_key_id": "", + "master_username": "foo", + "port": 5432, + "preferred_backup_window": "07:00-09:00", + "preferred_maintenance_window": "fri:03:03-fri:03:33", + "reader_endpoint": "aurora-cluster-demo.cluster-ro-cd539r6quiux.us-east-1.rds.amazonaws.com", + "replication_source_identifier": "", + "storage_encrypted": false, + "vpc_security_group_ids": [ + "sg-49e38646" + ] + } + }, + { + "Id": "aurora-cluster-demo-2", + "Type": "aws_rds_cluster", + "Attrs": { + "arn": "arn:aws:rds:us-east-1:533948124879:cluster:aurora-cluster-demo", + "availability_zones": [ + "us-east-1a", + "us-east-1b", + "us-east-1d" + ], + "backtrack_window": 0, + "backup_retention_period": 5, + "cluster_identifier": "aurora-cluster-demo-2", + "cluster_resource_id": "cluster-TISYDSSX4J5R6ZGUTV6LLJW73E", + "copy_tags_to_snapshot": false, + "database_name": "", + "db_cluster_parameter_group_name": "default.aurora-postgresql11", + "db_subnet_group_name": "default", + "deletion_protection": false, + "enable_http_endpoint": false, + "endpoint": "aurora-cluster-demo.cluster-cd539r6quiux.us-east-1.rds.amazonaws.com", + "engine": "aurora-postgresql", + "engine_mode": "provisioned", + "engine_version": "11.9", + "global_cluster_identifier": "", + "hosted_zone_id": "Z2R2ITUGPM61AM", + "iam_database_authentication_enabled": false, + "id": "aurora-cluster-demo-2", + "kms_key_id": "", + "master_username": "foo", + "port": 5432, + "preferred_backup_window": "07:00-09:00", + "preferred_maintenance_window": "fri:03:03-fri:03:33", + "reader_endpoint": "aurora-cluster-demo.cluster-ro-cd539r6quiux.us-east-1.rds.amazonaws.com", + "replication_source_identifier": "", + "storage_encrypted": false, + "vpc_security_group_ids": [ + "sg-49e38646" + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_rds_cluster/input.json b/pkg/test/aws/3.19.0/aws_rds_cluster/input.json new file mode 100755 index 000000000..be2e7f9e1 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_rds_cluster/input.json @@ -0,0 +1,120 @@ +[ + { + "Id": "aurora-cluster-demo", + "Type": "aws_rds_cluster", + "Attrs": { + "allow_major_version_upgrade": null, + "apply_immediately": null, + "arn": "arn:aws:rds:us-east-1:533948124879:cluster:aurora-cluster-demo", + "availability_zones": [ + "us-east-1a", + "us-east-1b", + "us-east-1d" + ], + "backtrack_window": 0, + "backup_retention_period": 5, + "cluster_identifier": "aurora-cluster-demo", + "cluster_identifier_prefix": null, + "cluster_members": [ + "aurora-cluster-demo-0" + ], + "cluster_resource_id": "cluster-TISYDSSX4J5R6ZGUTV6LLJW73E", + "copy_tags_to_snapshot": false, + "database_name": "mydb", + "db_cluster_parameter_group_name": "default.aurora-postgresql11", + "db_subnet_group_name": "default", + "deletion_protection": false, + "enable_http_endpoint": false, + "enabled_cloudwatch_logs_exports": [], + "endpoint": "aurora-cluster-demo.cluster-cd539r6quiux.us-east-1.rds.amazonaws.com", + "engine": "aurora-postgresql", + "engine_mode": "provisioned", + "engine_version": "11.9", + "final_snapshot_identifier": null, + "global_cluster_identifier": "", + "hosted_zone_id": "Z2R2ITUGPM61AM", + "iam_database_authentication_enabled": false, + "iam_roles": [], + "id": "aurora-cluster-demo", + "kms_key_id": "", + "master_password": null, + "master_username": "foo", + "port": 5432, + "preferred_backup_window": "07:00-09:00", + "preferred_maintenance_window": "fri:03:03-fri:03:33", + "reader_endpoint": "aurora-cluster-demo.cluster-ro-cd539r6quiux.us-east-1.rds.amazonaws.com", + "replication_source_identifier": "", + "restore_to_point_in_time": null, + "s3_import": null, + "scaling_configuration": [], + "skip_final_snapshot": null, + "snapshot_identifier": null, + "source_region": null, + "storage_encrypted": false, + "tags": {}, + "timeouts": {}, + "vpc_security_group_ids": [ + "sg-49e38646" + ] + } + }, + { + "Id": "aurora-cluster-demo-2", + "Type": "aws_rds_cluster", + "Attrs": { + "allow_major_version_upgrade": null, + "apply_immediately": null, + "arn": "arn:aws:rds:us-east-1:533948124879:cluster:aurora-cluster-demo", + "availability_zones": [ + "us-east-1a", + "us-east-1b", + "us-east-1d" + ], + "backtrack_window": 0, + "backup_retention_period": 5, + "cluster_identifier": "aurora-cluster-demo-2", + "cluster_identifier_prefix": null, + "cluster_members": [ + "aurora-cluster-demo-0" + ], + "cluster_resource_id": "cluster-TISYDSSX4J5R6ZGUTV6LLJW73E", + "copy_tags_to_snapshot": false, + "database_name": "", + "db_cluster_parameter_group_name": "default.aurora-postgresql11", + "db_subnet_group_name": "default", + "deletion_protection": false, + "enable_http_endpoint": false, + "enabled_cloudwatch_logs_exports": [], + "endpoint": "aurora-cluster-demo.cluster-cd539r6quiux.us-east-1.rds.amazonaws.com", + "engine": "aurora-postgresql", + "engine_mode": "provisioned", + "engine_version": "11.9", + "final_snapshot_identifier": null, + "global_cluster_identifier": "", + "hosted_zone_id": "Z2R2ITUGPM61AM", + "iam_database_authentication_enabled": false, + "iam_roles": [], + "id": "aurora-cluster-demo-2", + "kms_key_id": "", + "master_password": null, + "master_username": "foo", + "port": 5432, + "preferred_backup_window": "07:00-09:00", + "preferred_maintenance_window": "fri:03:03-fri:03:33", + "reader_endpoint": "aurora-cluster-demo.cluster-ro-cd539r6quiux.us-east-1.rds.amazonaws.com", + "replication_source_identifier": "", + "restore_to_point_in_time": null, + "s3_import": null, + "scaling_configuration": [], + "skip_final_snapshot": null, + "snapshot_identifier": null, + "source_region": null, + "storage_encrypted": false, + "tags": {}, + "timeouts": {}, + "vpc_security_group_ids": [ + "sg-49e38646" + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_route/expected.json b/pkg/test/aws/3.19.0/aws_route/expected.json new file mode 100755 index 000000000..480325b4c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_route/expected.json @@ -0,0 +1,26 @@ +[ + { + "Id": "r-rtb-0232602f0f07748fc243279527", + "Type": "aws_route", + "Attrs": { + "destination_cidr_block": "1.1.1.1/32", + "gateway_id": "igw-0125fbf19e83d008b", + "id": "r-rtb-0232602f0f07748fc243279527", + "origin": "CreateRoute", + "route_table_id": "rtb-0232602f0f07748fc", + "state": "active" + } + }, + { + "Id": "r-rtb-0232602f0f07748fc2750132062", + "Type": "aws_route", + "Attrs": { + "destination_ipv6_cidr_block": "::/0", + "gateway_id": "igw-0125fbf19e83d008b", + "id": "r-rtb-0232602f0f07748fc2750132062", + "origin": "CreateRoute", + "route_table_id": "rtb-0232602f0f07748fc", + "state": "active" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_route/input.json b/pkg/test/aws/3.19.0/aws_route/input.json new file mode 100755 index 000000000..480325b4c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_route/input.json @@ -0,0 +1,26 @@ +[ + { + "Id": "r-rtb-0232602f0f07748fc243279527", + "Type": "aws_route", + "Attrs": { + "destination_cidr_block": "1.1.1.1/32", + "gateway_id": "igw-0125fbf19e83d008b", + "id": "r-rtb-0232602f0f07748fc243279527", + "origin": "CreateRoute", + "route_table_id": "rtb-0232602f0f07748fc", + "state": "active" + } + }, + { + "Id": "r-rtb-0232602f0f07748fc2750132062", + "Type": "aws_route", + "Attrs": { + "destination_ipv6_cidr_block": "::/0", + "gateway_id": "igw-0125fbf19e83d008b", + "id": "r-rtb-0232602f0f07748fc2750132062", + "origin": "CreateRoute", + "route_table_id": "rtb-0232602f0f07748fc", + "state": "active" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_route53_health_check/expected.json b/pkg/test/aws/3.19.0/aws_route53_health_check/expected.json new file mode 100755 index 000000000..8583d482e --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_route53_health_check/expected.json @@ -0,0 +1,47 @@ +[ + { + "Id": "70994c67-b616-4caa-89bc-557153b65845", + "Type": "aws_route53_health_check", + "Attrs": { + "child_health_threshold": 0, + "disabled": false, + "enable_sni": false, + "failure_threshold": 5, + "fqdn": "moadib.net", + "id": "70994c67-b616-4caa-89bc-557153b65845", + "insufficient_data_health_status": "", + "invert_healthcheck": false, + "ip_address": "", + "measure_latency": false, + "port": 80, + "request_interval": 30, + "resource_path": "/", + "search_string": "", + "tags": { + "Name": "tf-test-health-check" + }, + "type": "HTTP" + } + }, + { + "Id": "45b0a22b-c9db-4271-96b3-23ac49debbf3", + "Type": "aws_route53_health_check", + "Attrs": { + "child_health_threshold": 0, + "disabled": false, + "enable_sni": true, + "failure_threshold": 5, + "fqdn": "moadib.net", + "id": "45b0a22b-c9db-4271-96b3-23ac49debbf3", + "insufficient_data_health_status": "", + "invert_healthcheck": false, + "ip_address": "", + "measure_latency": false, + "port": 443, + "request_interval": 30, + "resource_path": "/", + "search_string": "MoAdiB", + "type": "HTTPS_STR_MATCH" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_route53_health_check/input.json b/pkg/test/aws/3.19.0/aws_route53_health_check/input.json new file mode 100755 index 000000000..8583d482e --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_route53_health_check/input.json @@ -0,0 +1,47 @@ +[ + { + "Id": "70994c67-b616-4caa-89bc-557153b65845", + "Type": "aws_route53_health_check", + "Attrs": { + "child_health_threshold": 0, + "disabled": false, + "enable_sni": false, + "failure_threshold": 5, + "fqdn": "moadib.net", + "id": "70994c67-b616-4caa-89bc-557153b65845", + "insufficient_data_health_status": "", + "invert_healthcheck": false, + "ip_address": "", + "measure_latency": false, + "port": 80, + "request_interval": 30, + "resource_path": "/", + "search_string": "", + "tags": { + "Name": "tf-test-health-check" + }, + "type": "HTTP" + } + }, + { + "Id": "45b0a22b-c9db-4271-96b3-23ac49debbf3", + "Type": "aws_route53_health_check", + "Attrs": { + "child_health_threshold": 0, + "disabled": false, + "enable_sni": true, + "failure_threshold": 5, + "fqdn": "moadib.net", + "id": "45b0a22b-c9db-4271-96b3-23ac49debbf3", + "insufficient_data_health_status": "", + "invert_healthcheck": false, + "ip_address": "", + "measure_latency": false, + "port": 443, + "request_interval": 30, + "resource_path": "/", + "search_string": "MoAdiB", + "type": "HTTPS_STR_MATCH" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_route53_record/expected.json b/pkg/test/aws/3.19.0/aws_route53_record/expected.json new file mode 100755 index 000000000..4e1b21b4c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_route53_record/expected.json @@ -0,0 +1,86 @@ +[ + { + "Id": "Z06486383UC8WYSBZTWFM_test1.foo-2.com_A", + "Type": "aws_route53_record", + "Attrs": { + "fqdn": "test1.foo-2.com", + "id": "Z06486383UC8WYSBZTWFM_test1.foo-2.com_A", + "records": [ + "192.0.1.3" + ], + "ttl": 300, + "type": "A", + "zone_id": "Z06486383UC8WYSBZTWFM" + } + }, + { + "Id": "Z06486383UC8WYSBZTWFM_test0.foo-2.com_TXT", + "Type": "aws_route53_record", + "Attrs": { + "fqdn": "test0.foo-2.com", + "id": "Z06486383UC8WYSBZTWFM_test0_TXT", + "records": [ + "test0" + ], + "ttl": 300, + "type": "TXT", + "zone_id": "Z06486383UC8WYSBZTWFM" + } + }, + { + "Id": "Z06486383UC8WYSBZTWFM__test2.foo-2.com_A", + "Type": "aws_route53_record", + "Attrs": { + "fqdn": "_test2.foo-2.com", + "id": "Z06486383UC8WYSBZTWFM__test2.foo-2.com_A", + "records": [ + "192.0.1.4" + ], + "ttl": 300, + "type": "A", + "zone_id": "Z06486383UC8WYSBZTWFM" + } + }, + { + "Id": "Z06486383UC8WYSBZTWFM_test0_A", + "Type": "aws_route53_record", + "Attrs": { + "fqdn": "test0.foo-2.com", + "id": "Z06486383UC8WYSBZTWFM_test0_A", + "records": [ + "192.0.1.2" + ], + "ttl": 300, + "type": "A", + "zone_id": "Z06486383UC8WYSBZTWFM" + } + }, + { + "Id": "Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT", + "Type": "aws_route53_record", + "Attrs": { + "fqdn": "test1.foo-2.com", + "id": "Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT", + "records": [ + "test1.foo-2.com" + ], + "ttl": 300, + "type": "TXT", + "zone_id": "Z06486383UC8WYSBZTWFM" + } + }, + { + "Id": "Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT", + "Type": "aws_route53_record", + "Attrs": { + "fqdn": "_test2.foo-2.com", + "id": "Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT", + "records": [ + "_test2.foo-2.com" + ], + "ttl": 300, + "type": "TXT", + "zone_id": "Z06486383UC8WYSBZTWFM" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_route53_record/input.json b/pkg/test/aws/3.19.0/aws_route53_record/input.json new file mode 100755 index 000000000..533edd144 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_route53_record/input.json @@ -0,0 +1,146 @@ +[ + { + "Id": "Z06486383UC8WYSBZTWFM_test1.foo-2.com_A", + "Type": "aws_route53_record", + "Attrs": { + "alias": null, + "allow_overwrite": null, + "failover_routing_policy": null, + "fqdn": "test1.foo-2.com", + "geolocation_routing_policy": null, + "health_check_id": "", + "id": "Z06486383UC8WYSBZTWFM_test1.foo-2.com_A", + "latency_routing_policy": null, + "multivalue_answer_routing_policy": null, + "name": "test1.foo-2.com", + "records": [ + "192.0.1.3" + ], + "set_identifier": "", + "ttl": 300, + "type": "A", + "weighted_routing_policy": null, + "zone_id": "Z06486383UC8WYSBZTWFM" + } + }, + { + "Id": "Z06486383UC8WYSBZTWFM_test0.foo-2.com_TXT", + "Type": "aws_route53_record", + "Attrs": { + "alias": null, + "allow_overwrite": null, + "failover_routing_policy": null, + "fqdn": "test0.foo-2.com", + "geolocation_routing_policy": null, + "health_check_id": "", + "id": "Z06486383UC8WYSBZTWFM_test0_TXT", + "latency_routing_policy": null, + "multivalue_answer_routing_policy": null, + "name": "test0", + "records": [ + "test0" + ], + "set_identifier": "", + "ttl": 300, + "type": "TXT", + "weighted_routing_policy": null, + "zone_id": "Z06486383UC8WYSBZTWFM" + } + }, + { + "Id": "Z06486383UC8WYSBZTWFM__test2.foo-2.com_A", + "Type": "aws_route53_record", + "Attrs": { + "alias": null, + "allow_overwrite": null, + "failover_routing_policy": null, + "fqdn": "_test2.foo-2.com", + "geolocation_routing_policy": null, + "health_check_id": "", + "id": "Z06486383UC8WYSBZTWFM__test2.foo-2.com_A", + "latency_routing_policy": null, + "multivalue_answer_routing_policy": null, + "name": "_test2.foo-2.com", + "records": [ + "192.0.1.4" + ], + "set_identifier": "", + "ttl": 300, + "type": "A", + "weighted_routing_policy": null, + "zone_id": "Z06486383UC8WYSBZTWFM" + } + }, + { + "Id": "Z06486383UC8WYSBZTWFM_test0.foo-2.com_A", + "Type": "aws_route53_record", + "Attrs": { + "alias": null, + "allow_overwrite": null, + "failover_routing_policy": null, + "fqdn": "test0.foo-2.com", + "geolocation_routing_policy": null, + "health_check_id": "", + "id": "Z06486383UC8WYSBZTWFM_test0.foo-2.com_A", + "latency_routing_policy": null, + "multivalue_answer_routing_policy": null, + "name": "test0", + "records": [ + "192.0.1.2" + ], + "set_identifier": "", + "ttl": 300, + "type": "A", + "weighted_routing_policy": null, + "zone_id": "Z06486383UC8WYSBZTWFM" + } + }, + { + "Id": "Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT", + "Type": "aws_route53_record", + "Attrs": { + "alias": null, + "allow_overwrite": null, + "failover_routing_policy": null, + "fqdn": "test1.foo-2.com", + "geolocation_routing_policy": null, + "health_check_id": "", + "id": "Z06486383UC8WYSBZTWFM_test1.foo-2.com_TXT", + "latency_routing_policy": null, + "multivalue_answer_routing_policy": null, + "name": "test1.foo-2.com", + "records": [ + "test1.foo-2.com" + ], + "set_identifier": "", + "ttl": 300, + "type": "TXT", + "weighted_routing_policy": null, + "zone_id": "Z06486383UC8WYSBZTWFM" + } + }, + { + "Id": "Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT", + "Type": "aws_route53_record", + "Attrs": { + "alias": null, + "allow_overwrite": null, + "failover_routing_policy": null, + "fqdn": "_test2.foo-2.com", + "geolocation_routing_policy": null, + "health_check_id": "", + "id": "Z06486383UC8WYSBZTWFM__test2.foo-2.com_TXT", + "latency_routing_policy": null, + "multivalue_answer_routing_policy": null, + "name": "_test2.foo-2.com", + "records": [ + "_test2.foo-2.com" + ], + "set_identifier": "", + "ttl": 300, + "type": "TXT", + "weighted_routing_policy": null, + "zone_id": "Z06486383UC8WYSBZTWFM" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_route53_zone/expected.json b/pkg/test/aws/3.19.0/aws_route53_zone/expected.json new file mode 100755 index 000000000..a73728d70 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_route53_zone/expected.json @@ -0,0 +1,19 @@ +[ + { + "Id": "Z09368953G729AFEX5048", + "Type": "aws_route53_zone", + "Attrs": { + "comment": "Managed by Terraform", + "delegation_set_id": "", + "id": "Z09368953G729AFEX5048", + "name": "elie.ski", + "name_servers": [ + "ns-1504.awsdns-60.org", + "ns-180.awsdns-22.com", + "ns-1890.awsdns-44.co.uk", + "ns-759.awsdns-30.net" + ], + "zone_id": "Z09368953G729AFEX5048" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_route53_zone/input.json b/pkg/test/aws/3.19.0/aws_route53_zone/input.json new file mode 100755 index 000000000..a73728d70 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_route53_zone/input.json @@ -0,0 +1,19 @@ +[ + { + "Id": "Z09368953G729AFEX5048", + "Type": "aws_route53_zone", + "Attrs": { + "comment": "Managed by Terraform", + "delegation_set_id": "", + "id": "Z09368953G729AFEX5048", + "name": "elie.ski", + "name_servers": [ + "ns-1504.awsdns-60.org", + "ns-180.awsdns-22.com", + "ns-1890.awsdns-44.co.uk", + "ns-759.awsdns-30.net" + ], + "zone_id": "Z09368953G729AFEX5048" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_route_table/expected.json b/pkg/test/aws/3.19.0/aws_route_table/expected.json new file mode 100755 index 000000000..dabf6deec --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_route_table/expected.json @@ -0,0 +1,18 @@ +[ + { + "Id": "rtb-0a946227959883445", + "Type": "aws_route_table", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:282061376516:route-table/rtb-0a946227959883445", + "id": "rtb-0a946227959883445", + "owner_id": "282061376516", + "tags": { + "Name": "rr" + }, + "tags_all": { + "Name": "rr" + }, + "vpc_id": "vpc-0b76cbfa2bd868650" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_route_table/input.json b/pkg/test/aws/3.19.0/aws_route_table/input.json new file mode 100755 index 000000000..dabf6deec --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_route_table/input.json @@ -0,0 +1,18 @@ +[ + { + "Id": "rtb-0a946227959883445", + "Type": "aws_route_table", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:282061376516:route-table/rtb-0a946227959883445", + "id": "rtb-0a946227959883445", + "owner_id": "282061376516", + "tags": { + "Name": "rr" + }, + "tags_all": { + "Name": "rr" + }, + "vpc_id": "vpc-0b76cbfa2bd868650" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_s3_bucket/expected.json b/pkg/test/aws/3.19.0/aws_s3_bucket/expected.json new file mode 100755 index 000000000..a6defd37d --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_s3_bucket/expected.json @@ -0,0 +1,62 @@ +[ + { + "Id": "bucket-martin-test-drift2:Analytics2_Bucket2", + "Type": "aws_s3_bucket", + "Attrs": { + "bucket": "bucket-martin-test-drift2", + "id": "bucket-martin-test-drift2:Analytics2_Bucket2", + "name": "Analytics2_Bucket2", + "storage_class_analysis": [ + { + "data_export": [ + { + "destination": [ + { + "s3_bucket_destination": [ + { + "bucket_account_id": "", + "bucket_arn": "arn:aws:s3:::bucket-martin-test-drift2", + "format": "CSV", + "prefix": "" + } + ] + } + ], + "output_schema_version": "V_1" + } + ] + } + ] + } + }, + { + "Id": "bucket-martin-test-drift2:Analytics_Bucket2", + "Type": "aws_s3_bucket", + "Attrs": { + "bucket": "bucket-martin-test-drift2", + "id": "bucket-martin-test-drift2:Analytics_Bucket2", + "name": "Analytics_Bucket2", + "storage_class_analysis": [ + { + "data_export": [ + { + "destination": [ + { + "s3_bucket_destination": [ + { + "bucket_account_id": "", + "bucket_arn": "arn:aws:s3:::bucket-martin-test-drift2", + "format": "CSV", + "prefix": "" + } + ] + } + ], + "output_schema_version": "V_1" + } + ] + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_s3_bucket/input.json b/pkg/test/aws/3.19.0/aws_s3_bucket/input.json new file mode 100755 index 000000000..255fed9b3 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_s3_bucket/input.json @@ -0,0 +1,64 @@ +[ + { + "Id": "bucket-martin-test-drift2:Analytics2_Bucket2", + "Type": "aws_s3_bucket", + "Attrs": { + "bucket": "bucket-martin-test-drift2", + "filter": [], + "id": "bucket-martin-test-drift2:Analytics2_Bucket2", + "name": "Analytics2_Bucket2", + "storage_class_analysis": [ + { + "data_export": [ + { + "destination": [ + { + "s3_bucket_destination": [ + { + "bucket_account_id": "", + "bucket_arn": "arn:aws:s3:::bucket-martin-test-drift2", + "format": "CSV", + "prefix": "" + } + ] + } + ], + "output_schema_version": "V_1" + } + ] + } + ] + } + }, + { + "Id": "bucket-martin-test-drift2:Analytics_Bucket2", + "Type": "aws_s3_bucket", + "Attrs": { + "bucket": "bucket-martin-test-drift2", + "filter": [], + "id": "bucket-martin-test-drift2:Analytics_Bucket2", + "name": "Analytics_Bucket2", + "storage_class_analysis": [ + { + "data_export": [ + { + "destination": [ + { + "s3_bucket_destination": [ + { + "bucket_account_id": "", + "bucket_arn": "arn:aws:s3:::bucket-martin-test-drift2", + "format": "CSV", + "prefix": "" + } + ] + } + ], + "output_schema_version": "V_1" + } + ] + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_s3_bucket_metric/expected.json b/pkg/test/aws/3.19.0/aws_s3_bucket_metric/expected.json new file mode 100755 index 000000000..faf98d23b --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_s3_bucket_metric/expected.json @@ -0,0 +1,20 @@ +[ + { + "Id": "bucket-martin-test-drift2:Metrics2_Bucket2", + "Type": "aws_s3_bucket_metric", + "Attrs": { + "bucket": "bucket-martin-test-drift2", + "id": "bucket-martin-test-drift2:Metrics2_Bucket2", + "name": "Metrics2_Bucket2" + } + }, + { + "Id": "bucket-martin-test-drift2:Metrics_Bucket2", + "Type": "aws_s3_bucket_metric", + "Attrs": { + "bucket": "bucket-martin-test-drift2", + "id": "bucket-martin-test-drift2:Metrics_Bucket2", + "name": "Metrics_Bucket2" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_s3_bucket_metric/input.json b/pkg/test/aws/3.19.0/aws_s3_bucket_metric/input.json new file mode 100755 index 000000000..a2460e3ee --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_s3_bucket_metric/input.json @@ -0,0 +1,22 @@ +[ + { + "Id": "bucket-martin-test-drift2:Metrics2_Bucket2", + "Type": "aws_s3_bucket_metric", + "Attrs": { + "bucket": "bucket-martin-test-drift2", + "filter": null, + "id": "bucket-martin-test-drift2:Metrics2_Bucket2", + "name": "Metrics2_Bucket2" + } + }, + { + "Id": "bucket-martin-test-drift2:Metrics_Bucket2", + "Type": "aws_s3_bucket_metric", + "Attrs": { + "bucket": "bucket-martin-test-drift2", + "filter": null, + "id": "bucket-martin-test-drift2:Metrics_Bucket2", + "name": "Metrics_Bucket2" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_s3_bucket_notification/expected.json b/pkg/test/aws/3.19.0/aws_s3_bucket_notification/expected.json new file mode 100755 index 000000000..bf15a6499 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_s3_bucket_notification/expected.json @@ -0,0 +1,30 @@ +[ + { + "Id": "bucket-martin-test-drift2", + "Type": "aws_s3_bucket_notification", + "Attrs": { + "bucket": "bucket-martin-test-drift2", + "id": "bucket-martin-test-drift2", + "lambda_function": [ + { + "events": [ + "s3:ObjectCreated:*" + ], + "filter_prefix": "AWSLogs/", + "filter_suffix": ".log", + "id": "tf-s3-lambda-20201103165354926600000001", + "lambda_function_arn": "arn:aws:lambda:eu-west-3:526954929923:function:example_lambda_name1" + }, + { + "events": [ + "s3:ObjectCreated:*" + ], + "filter_prefix": "OtherLogs/", + "filter_suffix": ".log", + "id": "tf-s3-lambda-20201103165354926600000002", + "lambda_function_arn": "arn:aws:lambda:eu-west-3:526954929923:function:example_lambda_name2" + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_s3_bucket_notification/input.json b/pkg/test/aws/3.19.0/aws_s3_bucket_notification/input.json new file mode 100755 index 000000000..e4fbf49b0 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_s3_bucket_notification/input.json @@ -0,0 +1,32 @@ +[ + { + "Id": "bucket-martin-test-drift2", + "Type": "aws_s3_bucket_notification", + "Attrs": { + "bucket": "bucket-martin-test-drift2", + "id": "bucket-martin-test-drift2", + "lambda_function": [ + { + "events": [ + "s3:ObjectCreated:*" + ], + "filter_prefix": "AWSLogs/", + "filter_suffix": ".log", + "id": "tf-s3-lambda-20201103165354926600000001", + "lambda_function_arn": "arn:aws:lambda:eu-west-3:526954929923:function:example_lambda_name1" + }, + { + "events": [ + "s3:ObjectCreated:*" + ], + "filter_prefix": "OtherLogs/", + "filter_suffix": ".log", + "id": "tf-s3-lambda-20201103165354926600000002", + "lambda_function_arn": "arn:aws:lambda:eu-west-3:526954929923:function:example_lambda_name2" + } + ], + "queue": [], + "topic": [] + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_s3_bucket_public_access_block/expected.json b/pkg/test/aws/3.19.0/aws_s3_bucket_public_access_block/expected.json new file mode 100755 index 000000000..c8a39cda7 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_s3_bucket_public_access_block/expected.json @@ -0,0 +1,14 @@ +[ + { + "Id": "elie-dev-driftctl", + "Type": "aws_s3_bucket_public_access_block", + "Attrs": { + "block_public_acls": true, + "block_public_policy": true, + "bucket": "elie-dev-driftctl", + "id": "elie-dev-driftctl", + "ignore_public_acls": false, + "restrict_public_buckets": false + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_s3_bucket_public_access_block/input.json b/pkg/test/aws/3.19.0/aws_s3_bucket_public_access_block/input.json new file mode 100755 index 000000000..c8a39cda7 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_s3_bucket_public_access_block/input.json @@ -0,0 +1,14 @@ +[ + { + "Id": "elie-dev-driftctl", + "Type": "aws_s3_bucket_public_access_block", + "Attrs": { + "block_public_acls": true, + "block_public_policy": true, + "bucket": "elie-dev-driftctl", + "id": "elie-dev-driftctl", + "ignore_public_acls": false, + "restrict_public_buckets": false + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_sns_topic/expected.json b/pkg/test/aws/3.19.0/aws_sns_topic/expected.json new file mode 100755 index 000000000..5b45d05f0 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_sns_topic/expected.json @@ -0,0 +1,65 @@ +[ + { + "Id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic2", + "Type": "aws_sns_topic", + "Attrs": { + "application_failure_feedback_role_arn": "", + "application_success_feedback_role_arn": "", + "arn": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic2", + "delivery_policy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false,\"defaultThrottlePolicy\":{\"maxReceivesPerSecond\":1}}}", + "display_name": "", + "http_failure_feedback_role_arn": "", + "http_success_feedback_role_arn": "", + "id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic2", + "kms_master_key_id": "", + "lambda_failure_feedback_role_arn": "", + "lambda_success_feedback_role_arn": "", + "name": "user-updates-topic2", + "policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:eu-west-3:526954929923:user-updates-topic2\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"526954929923\"}}}]}", + "sqs_failure_feedback_role_arn": "", + "sqs_success_feedback_role_arn": "" + } + }, + { + "Id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic3", + "Type": "aws_sns_topic", + "Attrs": { + "application_failure_feedback_role_arn": "", + "application_success_feedback_role_arn": "", + "arn": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic3", + "delivery_policy": "", + "display_name": "", + "http_failure_feedback_role_arn": "", + "http_success_feedback_role_arn": "", + "id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic3", + "kms_master_key_id": "", + "lambda_failure_feedback_role_arn": "", + "lambda_success_feedback_role_arn": "", + "name": "user-updates-topic3", + "policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:eu-west-3:526954929923:user-updates-topic3\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"526954929923\"}}}]}", + "sqs_failure_feedback_role_arn": "", + "sqs_success_feedback_role_arn": "" + } + }, + { + "Id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic", + "Type": "aws_sns_topic", + "Attrs": { + "application_failure_feedback_role_arn": "", + "application_success_feedback_role_arn": "", + "arn": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic", + "delivery_policy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false,\"defaultThrottlePolicy\":{\"maxReceivesPerSecond\":1}}}", + "display_name": "", + "http_failure_feedback_role_arn": "", + "http_success_feedback_role_arn": "", + "id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic", + "kms_master_key_id": "", + "lambda_failure_feedback_role_arn": "", + "lambda_success_feedback_role_arn": "", + "name": "user-updates-topic", + "policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:eu-west-3:526954929923:user-updates-topic\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"526954929923\"}}}]}", + "sqs_failure_feedback_role_arn": "", + "sqs_success_feedback_role_arn": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_sns_topic/input.json b/pkg/test/aws/3.19.0/aws_sns_topic/input.json new file mode 100755 index 000000000..edab1d84c --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_sns_topic/input.json @@ -0,0 +1,83 @@ +[ + { + "Id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic2", + "Type": "aws_sns_topic", + "Attrs": { + "application_failure_feedback_role_arn": "", + "application_success_feedback_role_arn": "", + "application_success_feedback_sample_rate": null, + "arn": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic2", + "delivery_policy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false,\"defaultThrottlePolicy\":{\"maxReceivesPerSecond\":1}}}", + "display_name": "", + "http_failure_feedback_role_arn": "", + "http_success_feedback_role_arn": "", + "http_success_feedback_sample_rate": null, + "id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic2", + "kms_master_key_id": "", + "lambda_failure_feedback_role_arn": "", + "lambda_success_feedback_role_arn": "", + "lambda_success_feedback_sample_rate": null, + "name": "user-updates-topic2", + "name_prefix": null, + "policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:eu-west-3:526954929923:user-updates-topic2\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"526954929923\"}}}]}", + "sqs_failure_feedback_role_arn": "", + "sqs_success_feedback_role_arn": "", + "sqs_success_feedback_sample_rate": null, + "tags": {} + } + }, + { + "Id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic3", + "Type": "aws_sns_topic", + "Attrs": { + "application_failure_feedback_role_arn": "", + "application_success_feedback_role_arn": "", + "application_success_feedback_sample_rate": null, + "arn": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic3", + "delivery_policy": "", + "display_name": "", + "http_failure_feedback_role_arn": "", + "http_success_feedback_role_arn": "", + "http_success_feedback_sample_rate": null, + "id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic3", + "kms_master_key_id": "", + "lambda_failure_feedback_role_arn": "", + "lambda_success_feedback_role_arn": "", + "lambda_success_feedback_sample_rate": null, + "name": "user-updates-topic3", + "name_prefix": null, + "policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:eu-west-3:526954929923:user-updates-topic3\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"526954929923\"}}}]}", + "sqs_failure_feedback_role_arn": "", + "sqs_success_feedback_role_arn": "", + "sqs_success_feedback_sample_rate": null, + "tags": {} + } + }, + { + "Id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic", + "Type": "aws_sns_topic", + "Attrs": { + "application_failure_feedback_role_arn": "", + "application_success_feedback_role_arn": "", + "application_success_feedback_sample_rate": null, + "arn": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic", + "delivery_policy": "{\"http\":{\"defaultHealthyRetryPolicy\":{\"minDelayTarget\":20,\"maxDelayTarget\":20,\"numRetries\":3,\"numMaxDelayRetries\":0,\"numNoDelayRetries\":0,\"numMinDelayRetries\":0,\"backoffFunction\":\"linear\"},\"disableSubscriptionOverrides\":false,\"defaultThrottlePolicy\":{\"maxReceivesPerSecond\":1}}}", + "display_name": "", + "http_failure_feedback_role_arn": "", + "http_success_feedback_role_arn": "", + "http_success_feedback_sample_rate": null, + "id": "arn:aws:sns:eu-west-3:526954929923:user-updates-topic", + "kms_master_key_id": "", + "lambda_failure_feedback_role_arn": "", + "lambda_success_feedback_role_arn": "", + "lambda_success_feedback_sample_rate": null, + "name": "user-updates-topic", + "name_prefix": null, + "policy": "{\"Version\":\"2008-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:GetTopicAttributes\",\"SNS:SetTopicAttributes\",\"SNS:AddPermission\",\"SNS:RemovePermission\",\"SNS:DeleteTopic\",\"SNS:Subscribe\",\"SNS:ListSubscriptionsByTopic\",\"SNS:Publish\",\"SNS:Receive\"],\"Resource\":\"arn:aws:sns:eu-west-3:526954929923:user-updates-topic\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":\"526954929923\"}}}]}", + "sqs_failure_feedback_role_arn": "", + "sqs_success_feedback_role_arn": "", + "sqs_success_feedback_sample_rate": null, + "tags": {} + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_sns_topic_policy/expected.json b/pkg/test/aws/3.19.0/aws_sns_topic_policy/expected.json new file mode 100755 index 000000000..d24c53b02 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_sns_topic_policy/expected.json @@ -0,0 +1,20 @@ +[ + { + "Id": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy2", + "Type": "aws_sns_topic_policy", + "Attrs": { + "arn": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy2", + "id": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy2", + "policy": "{\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Action\":[\"SNS:Subscribe\",\"SNS:SetTopicAttributes\",\"SNS:RemovePermission\",\"SNS:Receive\",\"SNS:Publish\",\"SNS:ListSubscriptionsByTopic\",\"SNS:GetTopicAttributes\",\"SNS:DeleteTopic\",\"SNS:AddPermission\"],\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":[]}},\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Resource\":\"arn:aws:sns:us-east-1:526954929923:my-topic-with-policy\",\"Sid\":\"__default_statement_ID\"}],\"Version\":\"2012-10-17\"}" + } + }, + { + "Id": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy", + "Type": "aws_sns_topic_policy", + "Attrs": { + "arn": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy", + "id": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy", + "policy": "{\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Action\":[\"SNS:Subscribe\",\"SNS:SetTopicAttributes\",\"SNS:RemovePermission\",\"SNS:Receive\",\"SNS:Publish\",\"SNS:ListSubscriptionsByTopic\",\"SNS:GetTopicAttributes\",\"SNS:DeleteTopic\",\"SNS:AddPermission\"],\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":[]}},\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Resource\":\"arn:aws:sns:us-east-1:526954929923:my-topic-with-policy\",\"Sid\":\"__default_statement_ID\"}],\"Version\":\"2012-10-17\"}" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_sns_topic_policy/input.json b/pkg/test/aws/3.19.0/aws_sns_topic_policy/input.json new file mode 100755 index 000000000..e06f97bcf --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_sns_topic_policy/input.json @@ -0,0 +1,20 @@ +[ + { + "Id": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy2", + "Type": "aws_sns_topic_policy", + "Attrs": { + "arn": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy2", + "id": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy2", + "policy": "{\"Version\":\"2012-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:Subscribe\",\"SNS:SetTopicAttributes\",\"SNS:RemovePermission\",\"SNS:Receive\",\"SNS:Publish\",\"SNS:ListSubscriptionsByTopic\",\"SNS:GetTopicAttributes\",\"SNS:DeleteTopic\",\"SNS:AddPermission\"],\"Resource\":\"arn:aws:sns:us-east-1:526954929923:my-topic-with-policy\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":[]}}}]}" + } + }, + { + "Id": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy", + "Type": "aws_sns_topic_policy", + "Attrs": { + "arn": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy", + "id": "arn:aws:sns:us-east-1:526954929923:my-topic-with-policy", + "policy": "{\"Version\":\"2012-10-17\",\"Id\":\"__default_policy_ID\",\"Statement\":[{\"Sid\":\"__default_statement_ID\",\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"*\"},\"Action\":[\"SNS:Subscribe\",\"SNS:SetTopicAttributes\",\"SNS:RemovePermission\",\"SNS:Receive\",\"SNS:Publish\",\"SNS:ListSubscriptionsByTopic\",\"SNS:GetTopicAttributes\",\"SNS:DeleteTopic\",\"SNS:AddPermission\"],\"Resource\":\"arn:aws:sns:us-east-1:526954929923:my-topic-with-policy\",\"Condition\":{\"StringEquals\":{\"AWS:SourceOwner\":[]}}}]}" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_sns_topic_subscription/expected.json b/pkg/test/aws/3.19.0/aws_sns_topic_subscription/expected.json new file mode 100755 index 000000000..98d871620 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_sns_topic_subscription/expected.json @@ -0,0 +1,30 @@ +[ + { + "Id": "arn:aws:sns:us-east-1:526954929923:user-updates-topic2:c0f794c5-a009-4db4-9147-4c55959787fa", + "Type": "aws_sns_topic_subscription", + "Attrs": { + "arn": "arn:aws:sns:us-east-1:526954929923:user-updates-topic2:c0f794c5-a009-4db4-9147-4c55959787fa", + "delivery_policy": "", + "endpoint": "arn:aws:sqs:us-east-1:526954929923:user-updates-queue", + "filter_policy": "", + "id": "arn:aws:sns:us-east-1:526954929923:user-updates-topic2:c0f794c5-a009-4db4-9147-4c55959787fa", + "protocol": "sqs", + "raw_message_delivery": false, + "topic_arn": "arn:aws:sns:us-east-1:526954929923:user-updates-topic2" + } + }, + { + "Id": "arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e", + "Type": "aws_sns_topic_subscription", + "Attrs": { + "arn": "arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e", + "delivery_policy": "", + "endpoint": "arn:aws:sqs:us-east-1:526954929923:user-updates-queue", + "filter_policy": "", + "id": "arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e", + "protocol": "sqs", + "raw_message_delivery": false, + "topic_arn": "arn:aws:sns:us-east-1:526954929923:user-updates-topic" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_sns_topic_subscription/input.json b/pkg/test/aws/3.19.0/aws_sns_topic_subscription/input.json new file mode 100755 index 000000000..b5c997a37 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_sns_topic_subscription/input.json @@ -0,0 +1,34 @@ +[ + { + "Id": "arn:aws:sns:us-east-1:526954929923:user-updates-topic2:c0f794c5-a009-4db4-9147-4c55959787fa", + "Type": "aws_sns_topic_subscription", + "Attrs": { + "arn": "arn:aws:sns:us-east-1:526954929923:user-updates-topic2:c0f794c5-a009-4db4-9147-4c55959787fa", + "confirmation_timeout_in_minutes": null, + "delivery_policy": "", + "endpoint": "arn:aws:sqs:us-east-1:526954929923:user-updates-queue", + "endpoint_auto_confirms": null, + "filter_policy": "", + "id": "arn:aws:sns:us-east-1:526954929923:user-updates-topic2:c0f794c5-a009-4db4-9147-4c55959787fa", + "protocol": "sqs", + "raw_message_delivery": false, + "topic_arn": "arn:aws:sns:us-east-1:526954929923:user-updates-topic2" + } + }, + { + "Id": "arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e", + "Type": "aws_sns_topic_subscription", + "Attrs": { + "arn": "arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e", + "confirmation_timeout_in_minutes": null, + "delivery_policy": "", + "endpoint": "arn:aws:sqs:us-east-1:526954929923:user-updates-queue", + "endpoint_auto_confirms": null, + "filter_policy": "", + "id": "arn:aws:sns:us-east-1:526954929923:user-updates-topic:b6e66147-2b31-4486-8d4b-2a2272264c8e", + "protocol": "sqs", + "raw_message_delivery": false, + "topic_arn": "arn:aws:sns:us-east-1:526954929923:user-updates-topic" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_sqs_queue/expected.json b/pkg/test/aws/3.19.0/aws_sqs_queue/expected.json new file mode 100755 index 000000000..dc5710742 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_sqs_queue/expected.json @@ -0,0 +1,42 @@ +[ + { + "Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo", + "Type": "aws_sqs_queue", + "Attrs": { + "arn": "arn:aws:sqs:eu-west-3:047081014315:foo", + "content_based_deduplication": false, + "delay_seconds": 0, + "fifo_queue": false, + "id": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo", + "kms_data_key_reuse_period_seconds": 300, + "kms_master_key_id": "", + "max_message_size": 262144, + "message_retention_seconds": 345600, + "name": "foo", + "policy": "", + "receive_wait_time_seconds": 0, + "redrive_policy": "", + "visibility_timeout_seconds": 30 + } + }, + { + "Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo", + "Type": "aws_sqs_queue", + "Attrs": { + "arn": "arn:aws:sqs:eu-west-3:047081014315:bar.fifo", + "content_based_deduplication": true, + "delay_seconds": 0, + "fifo_queue": true, + "id": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo", + "kms_data_key_reuse_period_seconds": 300, + "kms_master_key_id": "", + "max_message_size": 262144, + "message_retention_seconds": 345600, + "name": "bar.fifo", + "policy": "", + "receive_wait_time_seconds": 0, + "redrive_policy": "", + "visibility_timeout_seconds": 30 + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_sqs_queue/input.json b/pkg/test/aws/3.19.0/aws_sqs_queue/input.json new file mode 100755 index 000000000..51d2984e7 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_sqs_queue/input.json @@ -0,0 +1,46 @@ +[ + { + "Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo", + "Type": "aws_sqs_queue", + "Attrs": { + "arn": "arn:aws:sqs:eu-west-3:047081014315:foo", + "content_based_deduplication": false, + "delay_seconds": 0, + "fifo_queue": false, + "id": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo", + "kms_data_key_reuse_period_seconds": 300, + "kms_master_key_id": "", + "max_message_size": 262144, + "message_retention_seconds": 345600, + "name": "foo", + "name_prefix": null, + "policy": "", + "receive_wait_time_seconds": 0, + "redrive_policy": "", + "tags": {}, + "visibility_timeout_seconds": 30 + } + }, + { + "Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo", + "Type": "aws_sqs_queue", + "Attrs": { + "arn": "arn:aws:sqs:eu-west-3:047081014315:bar.fifo", + "content_based_deduplication": true, + "delay_seconds": 0, + "fifo_queue": true, + "id": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo", + "kms_data_key_reuse_period_seconds": 300, + "kms_master_key_id": "", + "max_message_size": 262144, + "message_retention_seconds": 345600, + "name": "bar.fifo", + "name_prefix": null, + "policy": "", + "receive_wait_time_seconds": 0, + "redrive_policy": "", + "tags": {}, + "visibility_timeout_seconds": 30 + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_sqs_queue_policy/expected.json b/pkg/test/aws/3.19.0/aws_sqs_queue_policy/expected.json new file mode 100755 index 000000000..e7aaac065 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_sqs_queue_policy/expected.json @@ -0,0 +1,29 @@ +[ + { + "Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo", + "Type": "aws_sqs_queue_policy", + "Attrs": { + "id": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo", + "policy": "{\"Id\":\"Policy1611769532425\",\"Statement\":[{\"Action\":\"sqs:SendMessage\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Resource\":\"arn:aws:sqs:eu-west-3:047081014315:foo\",\"Sid\":\"Stmt1611769527792\"}],\"Version\":\"2012-10-17\"}", + "queue_url": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo" + } + }, + { + "Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/baz", + "Type": "aws_sqs_queue_policy", + "Attrs": { + "id": "https://sqs.eu-west-3.amazonaws.com/047081014315/baz", + "policy": "{\"Id\":\"MYSQSPOLICY\",\"Statement\":[{\"Action\":\"sqs:SendMessage\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Resource\":\"arn:aws:sqs:eu-west-3:047081014315:baz\",\"Sid\":\"Stmt1611769527792\"}],\"Version\":\"2012-10-17\"}", + "queue_url": "https://sqs.eu-west-3.amazonaws.com/047081014315/baz" + } + }, + { + "Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo", + "Type": "aws_sqs_queue_policy", + "Attrs": { + "id": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo", + "policy": "", + "queue_url": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_sqs_queue_policy/input.json b/pkg/test/aws/3.19.0/aws_sqs_queue_policy/input.json new file mode 100755 index 000000000..0ebfe6f6b --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_sqs_queue_policy/input.json @@ -0,0 +1,29 @@ +[ + { + "Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo", + "Type": "aws_sqs_queue_policy", + "Attrs": { + "id": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo", + "policy": "{\"Version\":\"2012-10-17\",\"Id\":\"Policy1611769532425\",\"Statement\":[{\"Sid\":\"Stmt1611769527792\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"sqs:SendMessage\",\"Resource\":\"arn:aws:sqs:eu-west-3:047081014315:foo\"}]}", + "queue_url": "https://sqs.eu-west-3.amazonaws.com/047081014315/foo" + } + }, + { + "Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/baz", + "Type": "aws_sqs_queue_policy", + "Attrs": { + "id": "https://sqs.eu-west-3.amazonaws.com/047081014315/baz", + "policy": "{\"Version\":\"2012-10-17\",\"Id\":\"MYSQSPOLICY\",\"Statement\":[{\"Sid\":\"Stmt1611769527792\",\"Effect\":\"Allow\",\"Principal\":\"*\",\"Action\":\"sqs:SendMessage\",\"Resource\":\"arn:aws:sqs:eu-west-3:047081014315:baz\"}]}", + "queue_url": "https://sqs.eu-west-3.amazonaws.com/047081014315/baz" + } + }, + { + "Id": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo", + "Type": "aws_sqs_queue_policy", + "Attrs": { + "id": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo", + "policy": "", + "queue_url": "https://sqs.eu-west-3.amazonaws.com/047081014315/bar.fifo" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_subnet/expected.json b/pkg/test/aws/3.19.0/aws_subnet/expected.json new file mode 100755 index 000000000..70a910c7e --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_subnet/expected.json @@ -0,0 +1,110 @@ +[ + { + "Id": "subnet-03258f7d55e1df8ed", + "Type": "aws_default_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-03258f7d55e1df8ed", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1a", + "availability_zone_id": "use1-az1", + "cidr_block": "172.31.0.0/20", + "id": "subnet-03258f7d55e1df8ed", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": true, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-075959b9534907185" + } + }, + { + "Id": "subnet-03a8928df96cbc112", + "Type": "aws_default_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-03a8928df96cbc112", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1b", + "availability_zone_id": "use1-az2", + "cidr_block": "172.31.80.0/20", + "id": "subnet-03a8928df96cbc112", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": true, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-075959b9534907185" + } + }, + { + "Id": "subnet-00242cc446a0e7583", + "Type": "aws_default_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-00242cc446a0e7583", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1c", + "availability_zone_id": "use1-az4", + "cidr_block": "172.31.16.0/20", + "id": "subnet-00242cc446a0e7583", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": true, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-075959b9534907185" + } + }, + { + "Id": "subnet-03c1a726f076cec6b", + "Type": "aws_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-03c1a726f076cec6b", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1c", + "availability_zone_id": "use1-az4", + "cidr_block": "10.0.0.0/24", + "id": "subnet-03c1a726f076cec6b", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-0ad2f4ae7212c2bff" + } + }, + { + "Id": "subnet-02fb51b19c891f0e9", + "Type": "aws_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-02fb51b19c891f0e9", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1d", + "availability_zone_id": "use1-az6", + "cidr_block": "10.0.1.0/24", + "id": "subnet-02fb51b19c891f0e9", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-0ad2f4ae7212c2bff" + } + }, + { + "Id": "subnet-09631aa1f17d607c4", + "Type": "aws_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-09631aa1f17d607c4", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1a", + "availability_zone_id": "use1-az1", + "cidr_block": "10.0.2.0/24", + "id": "subnet-09631aa1f17d607c4", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-0ad2f4ae7212c2bff" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_subnet/input.json b/pkg/test/aws/3.19.0/aws_subnet/input.json new file mode 100755 index 000000000..70a910c7e --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_subnet/input.json @@ -0,0 +1,110 @@ +[ + { + "Id": "subnet-03258f7d55e1df8ed", + "Type": "aws_default_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-03258f7d55e1df8ed", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1a", + "availability_zone_id": "use1-az1", + "cidr_block": "172.31.0.0/20", + "id": "subnet-03258f7d55e1df8ed", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": true, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-075959b9534907185" + } + }, + { + "Id": "subnet-03a8928df96cbc112", + "Type": "aws_default_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-03a8928df96cbc112", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1b", + "availability_zone_id": "use1-az2", + "cidr_block": "172.31.80.0/20", + "id": "subnet-03a8928df96cbc112", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": true, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-075959b9534907185" + } + }, + { + "Id": "subnet-00242cc446a0e7583", + "Type": "aws_default_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-00242cc446a0e7583", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1c", + "availability_zone_id": "use1-az4", + "cidr_block": "172.31.16.0/20", + "id": "subnet-00242cc446a0e7583", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": true, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-075959b9534907185" + } + }, + { + "Id": "subnet-03c1a726f076cec6b", + "Type": "aws_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-03c1a726f076cec6b", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1c", + "availability_zone_id": "use1-az4", + "cidr_block": "10.0.0.0/24", + "id": "subnet-03c1a726f076cec6b", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-0ad2f4ae7212c2bff" + } + }, + { + "Id": "subnet-02fb51b19c891f0e9", + "Type": "aws_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-02fb51b19c891f0e9", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1d", + "availability_zone_id": "use1-az6", + "cidr_block": "10.0.1.0/24", + "id": "subnet-02fb51b19c891f0e9", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-0ad2f4ae7212c2bff" + } + }, + { + "Id": "subnet-09631aa1f17d607c4", + "Type": "aws_subnet", + "Attrs": { + "arn": "arn:aws:ec2:us-east-1:526954929923:subnet/subnet-09631aa1f17d607c4", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1a", + "availability_zone_id": "use1-az1", + "cidr_block": "10.0.2.0/24", + "id": "subnet-09631aa1f17d607c4", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "526954929923", + "vpc_id": "vpc-0ad2f4ae7212c2bff" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_vpc/expected.json b/pkg/test/aws/3.19.0/aws_vpc/expected.json new file mode 100755 index 000000000..14efc77c2 --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_vpc/expected.json @@ -0,0 +1,65 @@ +[ + { + "Id": "vpc-02c50896b59598761", + "Type": "aws_vpc", + "Attrs": { + "arn": "arn:aws:ec2:eu-west-3:929327065333:vpc/vpc-02c50896b59598761", + "assign_generated_ipv6_cidr_block": false, + "cidr_block": "10.0.0.0/16", + "default_network_acl_id": "acl-0acd66b145f6f2102", + "default_route_table_id": "rtb-0bbd95c413323e90a", + "default_security_group_id": "sg-038e08bdd892ccae1", + "dhcp_options_id": "dopt-9becf2f2", + "enable_dns_hostnames": false, + "enable_dns_support": true, + "id": "vpc-02c50896b59598761", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-0bbd95c413323e90a", + "owner_id": "929327065333" + } + }, + { + "Id": "vpc-0768e1fd0029e3fc3", + "Type": "aws_vpc", + "Attrs": { + "arn": "arn:aws:ec2:eu-west-3:929327065333:vpc/vpc-0768e1fd0029e3fc3", + "assign_generated_ipv6_cidr_block": false, + "cidr_block": "10.1.0.0/16", + "default_network_acl_id": "acl-0d17964d633baf4b3", + "default_route_table_id": "rtb-05ef1030c15a0527c", + "default_security_group_id": "sg-00914edefc3bf8bc5", + "dhcp_options_id": "dopt-9becf2f2", + "enable_dns_hostnames": false, + "enable_dns_support": true, + "id": "vpc-0768e1fd0029e3fc3", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-05ef1030c15a0527c", + "owner_id": "929327065333" + } + }, + { + "Id": "vpc-020b072316a95b97f", + "Type": "aws_vpc", + "Attrs": { + "arn": "arn:aws:ec2:eu-west-3:929327065333:vpc/vpc-020b072316a95b97f", + "assign_generated_ipv6_cidr_block": false, + "cidr_block": "10.2.0.0/16", + "default_network_acl_id": "acl-0ff5d175a1aa8f51a", + "default_route_table_id": "rtb-04d42e3cb1ec4f500", + "default_security_group_id": "sg-048230c519e0c2345", + "dhcp_options_id": "dopt-9becf2f2", + "enable_dns_hostnames": false, + "enable_dns_support": true, + "id": "vpc-020b072316a95b97f", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-04d42e3cb1ec4f500", + "owner_id": "929327065333" + } + } +] \ No newline at end of file diff --git a/pkg/test/aws/3.19.0/aws_vpc/input.json b/pkg/test/aws/3.19.0/aws_vpc/input.json new file mode 100755 index 000000000..fdae3c95a --- /dev/null +++ b/pkg/test/aws/3.19.0/aws_vpc/input.json @@ -0,0 +1,74 @@ +[ + { + "Id": "vpc-02c50896b59598761", + "Type": "aws_vpc", + "Attrs": { + "arn": "arn:aws:ec2:eu-west-3:929327065333:vpc/vpc-02c50896b59598761", + "assign_generated_ipv6_cidr_block": false, + "cidr_block": "10.0.0.0/16", + "default_network_acl_id": "acl-0acd66b145f6f2102", + "default_route_table_id": "rtb-0bbd95c413323e90a", + "default_security_group_id": "sg-038e08bdd892ccae1", + "dhcp_options_id": "dopt-9becf2f2", + "enable_classiclink": null, + "enable_classiclink_dns_support": null, + "enable_dns_hostnames": false, + "enable_dns_support": true, + "id": "vpc-02c50896b59598761", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-0bbd95c413323e90a", + "owner_id": "929327065333", + "tags": {} + } + }, + { + "Id": "vpc-0768e1fd0029e3fc3", + "Type": "aws_vpc", + "Attrs": { + "arn": "arn:aws:ec2:eu-west-3:929327065333:vpc/vpc-0768e1fd0029e3fc3", + "assign_generated_ipv6_cidr_block": false, + "cidr_block": "10.1.0.0/16", + "default_network_acl_id": "acl-0d17964d633baf4b3", + "default_route_table_id": "rtb-05ef1030c15a0527c", + "default_security_group_id": "sg-00914edefc3bf8bc5", + "dhcp_options_id": "dopt-9becf2f2", + "enable_classiclink": null, + "enable_classiclink_dns_support": null, + "enable_dns_hostnames": false, + "enable_dns_support": true, + "id": "vpc-0768e1fd0029e3fc3", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-05ef1030c15a0527c", + "owner_id": "929327065333", + "tags": {} + } + }, + { + "Id": "vpc-020b072316a95b97f", + "Type": "aws_vpc", + "Attrs": { + "arn": "arn:aws:ec2:eu-west-3:929327065333:vpc/vpc-020b072316a95b97f", + "assign_generated_ipv6_cidr_block": false, + "cidr_block": "10.2.0.0/16", + "default_network_acl_id": "acl-0ff5d175a1aa8f51a", + "default_route_table_id": "rtb-04d42e3cb1ec4f500", + "default_security_group_id": "sg-048230c519e0c2345", + "dhcp_options_id": "dopt-9becf2f2", + "enable_classiclink": null, + "enable_classiclink_dns_support": null, + "enable_dns_hostnames": false, + "enable_dns_support": true, + "id": "vpc-020b072316a95b97f", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-04d42e3cb1ec4f500", + "owner_id": "929327065333", + "tags": {} + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_image/expected.json b/pkg/test/azurerm/2.71.0/azurerm_image/expected.json new file mode 100755 index 000000000..4ce7cc48c --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_image/expected.json @@ -0,0 +1,24 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/tfvmex-resources/providers/Microsoft.Compute/images/acctest2", + "Type": "azurerm_image", + "Attrs": { + "hyper_v_generation": "V1", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/tfvmex-resources/providers/Microsoft.Compute/images/acctest2", + "location": "westeurope", + "name": "acctest2", + "os_disk": [ + { + "blob_uri": "", + "caching": "None", + "managed_disk_id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/tfvmex-resources/providers/Microsoft.Compute/disks/acctestmd", + "os_state": "Generalized", + "os_type": "Linux", + "size_gb": 30 + } + ], + "resource_group_name": "tfvmex-resources", + "zone_resilient": false + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_image/input.json b/pkg/test/azurerm/2.71.0/azurerm_image/input.json new file mode 100755 index 000000000..4ce7cc48c --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_image/input.json @@ -0,0 +1,24 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/tfvmex-resources/providers/Microsoft.Compute/images/acctest2", + "Type": "azurerm_image", + "Attrs": { + "hyper_v_generation": "V1", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/tfvmex-resources/providers/Microsoft.Compute/images/acctest2", + "location": "westeurope", + "name": "acctest2", + "os_disk": [ + { + "blob_uri": "", + "caching": "None", + "managed_disk_id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/tfvmex-resources/providers/Microsoft.Compute/disks/acctestmd", + "os_state": "Generalized", + "os_type": "Linux", + "size_gb": 30 + } + ], + "resource_group_name": "tfvmex-resources", + "zone_resilient": false + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_lb/expected.json b/pkg/test/azurerm/2.71.0/azurerm_lb/expected.json new file mode 100755 index 000000000..ecd494a55 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_lb/expected.json @@ -0,0 +1,46 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule2", + "Type": "azurerm_lb", + "Attrs": { + "backend_address_pool_id": "", + "backend_port": 80, + "disable_outbound_snat": false, + "enable_floating_ip": false, + "enable_tcp_reset": false, + "frontend_ip_configuration_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress", + "frontend_ip_configuration_name": "PublicIPAddress", + "frontend_port": 80, + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule2", + "idle_timeout_in_minutes": 4, + "load_distribution": "Default", + "loadbalancer_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer", + "name": "LBRule2", + "probe_id": "", + "protocol": "Tcp", + "resource_group_name": "raphael-dev" + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule", + "Type": "azurerm_lb", + "Attrs": { + "backend_address_pool_id": "", + "backend_port": 3389, + "disable_outbound_snat": false, + "enable_floating_ip": false, + "enable_tcp_reset": false, + "frontend_ip_configuration_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress", + "frontend_ip_configuration_name": "PublicIPAddress", + "frontend_port": 3389, + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule", + "idle_timeout_in_minutes": 4, + "load_distribution": "Default", + "loadbalancer_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer", + "name": "LBRule", + "probe_id": "", + "protocol": "Tcp", + "resource_group_name": "raphael-dev" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_lb/input.json b/pkg/test/azurerm/2.71.0/azurerm_lb/input.json new file mode 100755 index 000000000..cd7f0fd0f --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_lb/input.json @@ -0,0 +1,48 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule2", + "Type": "azurerm_lb", + "Attrs": { + "backend_address_pool_id": "", + "backend_port": 80, + "disable_outbound_snat": false, + "enable_floating_ip": false, + "enable_tcp_reset": false, + "frontend_ip_configuration_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress", + "frontend_ip_configuration_name": "PublicIPAddress", + "frontend_port": 80, + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule2", + "idle_timeout_in_minutes": 4, + "load_distribution": "Default", + "loadbalancer_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer", + "name": "LBRule2", + "probe_id": "", + "protocol": "Tcp", + "resource_group_name": "raphael-dev", + "timeouts": {} + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule", + "Type": "azurerm_lb", + "Attrs": { + "backend_address_pool_id": "", + "backend_port": 3389, + "disable_outbound_snat": false, + "enable_floating_ip": false, + "enable_tcp_reset": false, + "frontend_ip_configuration_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress", + "frontend_ip_configuration_name": "PublicIPAddress", + "frontend_port": 3389, + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule", + "idle_timeout_in_minutes": 4, + "load_distribution": "Default", + "loadbalancer_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer", + "name": "LBRule", + "probe_id": "", + "protocol": "Tcp", + "resource_group_name": "raphael-dev", + "timeouts": {} + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_lb_rule/expected.json b/pkg/test/azurerm/2.71.0/azurerm_lb_rule/expected.json new file mode 100755 index 000000000..806c3f7e4 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_lb_rule/expected.json @@ -0,0 +1,46 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule2", + "Type": "azurerm_lb_rule", + "Attrs": { + "backend_address_pool_id": "", + "backend_port": 80, + "disable_outbound_snat": false, + "enable_floating_ip": false, + "enable_tcp_reset": false, + "frontend_ip_configuration_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress", + "frontend_ip_configuration_name": "PublicIPAddress", + "frontend_port": 80, + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule2", + "idle_timeout_in_minutes": 4, + "load_distribution": "Default", + "loadbalancer_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer", + "name": "LBRule2", + "probe_id": "", + "protocol": "Tcp", + "resource_group_name": "raphael-dev" + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule", + "Type": "azurerm_lb_rule", + "Attrs": { + "backend_address_pool_id": "", + "backend_port": 3389, + "disable_outbound_snat": false, + "enable_floating_ip": false, + "enable_tcp_reset": false, + "frontend_ip_configuration_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress", + "frontend_ip_configuration_name": "PublicIPAddress", + "frontend_port": 3389, + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule", + "idle_timeout_in_minutes": 4, + "load_distribution": "Default", + "loadbalancer_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer", + "name": "LBRule", + "probe_id": "", + "protocol": "Tcp", + "resource_group_name": "raphael-dev" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_lb_rule/input.json b/pkg/test/azurerm/2.71.0/azurerm_lb_rule/input.json new file mode 100755 index 000000000..845cc412b --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_lb_rule/input.json @@ -0,0 +1,48 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule2", + "Type": "azurerm_lb_rule", + "Attrs": { + "backend_address_pool_id": "", + "backend_port": 80, + "disable_outbound_snat": false, + "enable_floating_ip": false, + "enable_tcp_reset": false, + "frontend_ip_configuration_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress", + "frontend_ip_configuration_name": "PublicIPAddress", + "frontend_port": 80, + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule2", + "idle_timeout_in_minutes": 4, + "load_distribution": "Default", + "loadbalancer_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer", + "name": "LBRule2", + "probe_id": "", + "protocol": "Tcp", + "resource_group_name": "raphael-dev", + "timeouts": {} + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule", + "Type": "azurerm_lb_rule", + "Attrs": { + "backend_address_pool_id": "", + "backend_port": 3389, + "disable_outbound_snat": false, + "enable_floating_ip": false, + "enable_tcp_reset": false, + "frontend_ip_configuration_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/frontendIPConfigurations/PublicIPAddress", + "frontend_ip_configuration_name": "PublicIPAddress", + "frontend_port": 3389, + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer/loadBalancingRules/LBRule", + "idle_timeout_in_minutes": 4, + "load_distribution": "Default", + "loadbalancer_id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/raphael-dev/providers/Microsoft.Network/loadBalancers/TestLoadBalancer", + "name": "LBRule", + "probe_id": "", + "protocol": "Tcp", + "resource_group_name": "raphael-dev", + "timeouts": {} + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_network_security_group/expected.json b/pkg/test/azurerm/2.71.0/azurerm_network_security_group/expected.json new file mode 100755 index 000000000..cfcbbe383 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_network_security_group/expected.json @@ -0,0 +1,39 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/example-resources/providers/Microsoft.Network/networkSecurityGroups/acceptanceTestSecurityGroup2", + "Type": "azurerm_network_security_group", + "Attrs": { + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/example-resources/providers/Microsoft.Network/networkSecurityGroups/acceptanceTestSecurityGroup2", + "location": "westeurope", + "name": "acceptanceTestSecurityGroup2", + "resource_group_name": "example-resources" + } + }, + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/example-resources/providers/Microsoft.Network/networkSecurityGroups/acceptanceTestSecurityGroup1", + "Type": "azurerm_network_security_group", + "Attrs": { + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/example-resources/providers/Microsoft.Network/networkSecurityGroups/acceptanceTestSecurityGroup1", + "location": "westeurope", + "name": "acceptanceTestSecurityGroup1", + "resource_group_name": "example-resources", + "security_rule": [ + { + "access": "Allow", + "description": "", + "destination_address_prefix": "*", + "destination_port_range": "*", + "direction": "Inbound", + "name": "test123", + "priority": 100, + "protocol": "Tcp", + "source_address_prefix": "*", + "source_port_range": "*" + } + ], + "tags": { + "environment": "Production" + } + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_network_security_group/input.json b/pkg/test/azurerm/2.71.0/azurerm_network_security_group/input.json new file mode 100755 index 000000000..039b39814 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_network_security_group/input.json @@ -0,0 +1,49 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/example-resources/providers/Microsoft.Network/networkSecurityGroups/acceptanceTestSecurityGroup2", + "Type": "azurerm_network_security_group", + "Attrs": { + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/example-resources/providers/Microsoft.Network/networkSecurityGroups/acceptanceTestSecurityGroup2", + "location": "westeurope", + "name": "acceptanceTestSecurityGroup2", + "resource_group_name": "example-resources", + "security_rule": [], + "tags": {}, + "timeouts": {} + } + }, + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/example-resources/providers/Microsoft.Network/networkSecurityGroups/acceptanceTestSecurityGroup1", + "Type": "azurerm_network_security_group", + "Attrs": { + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/example-resources/providers/Microsoft.Network/networkSecurityGroups/acceptanceTestSecurityGroup1", + "location": "westeurope", + "name": "acceptanceTestSecurityGroup1", + "resource_group_name": "example-resources", + "security_rule": [ + { + "access": "Allow", + "description": "", + "destination_address_prefix": "*", + "destination_address_prefixes": [], + "destination_application_security_group_ids": [], + "destination_port_range": "*", + "destination_port_ranges": [], + "direction": "Inbound", + "name": "test123", + "priority": 100, + "protocol": "Tcp", + "source_address_prefix": "*", + "source_address_prefixes": [], + "source_application_security_group_ids": [], + "source_port_range": "*", + "source_port_ranges": [] + } + ], + "tags": { + "environment": "Production" + }, + "timeouts": {} + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_a_record/expected.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_a_record/expected.json new file mode 100755 index 000000000..9f1308d5f --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_a_record/expected.json @@ -0,0 +1,33 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/A/test", + "Type": "azurerm_private_dns_a_record", + "Attrs": { + "fqdn": "test.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/A/test", + "name": "test", + "records": [ + "10.0.180.17", + "10.0.180.20" + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/A/othertest", + "Type": "azurerm_private_dns_a_record", + "Attrs": { + "fqdn": "othertest.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/A/othertest", + "name": "othertest", + "records": [ + "10.0.180.20" + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_a_record/input.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_a_record/input.json new file mode 100755 index 000000000..0807260a7 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_a_record/input.json @@ -0,0 +1,37 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/A/test", + "Type": "azurerm_private_dns_a_record", + "Attrs": { + "fqdn": "test.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/A/test", + "name": "test", + "records": [ + "10.0.180.17", + "10.0.180.20" + ], + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/A/othertest", + "Type": "azurerm_private_dns_a_record", + "Attrs": { + "fqdn": "othertest.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/A/othertest", + "name": "othertest", + "records": [ + "10.0.180.20" + ], + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_aaaa_record/expected.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_aaaa_record/expected.json new file mode 100755 index 000000000..08faf011f --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_aaaa_record/expected.json @@ -0,0 +1,34 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/AAAA/othertest", + "Type": "azurerm_private_dns_aaaa_record", + "Attrs": { + "fqdn": "othertest.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/AAAA/othertest", + "name": "othertest", + "records": [ + "fd5d:70bc:930e:d008:0000:0000:0000:7334", + "fd5d:70bc:930e:d008::7335" + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/AAAA/test", + "Type": "azurerm_private_dns_aaaa_record", + "Attrs": { + "fqdn": "test.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/AAAA/test", + "name": "test", + "records": [ + "fd5d:70bc:930e:d008:0000:0000:0000:7334", + "fd5d:70bc:930e:d008::7335" + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_aaaa_record/input.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_aaaa_record/input.json new file mode 100755 index 000000000..08faf011f --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_aaaa_record/input.json @@ -0,0 +1,34 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/AAAA/othertest", + "Type": "azurerm_private_dns_aaaa_record", + "Attrs": { + "fqdn": "othertest.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/AAAA/othertest", + "name": "othertest", + "records": [ + "fd5d:70bc:930e:d008:0000:0000:0000:7334", + "fd5d:70bc:930e:d008::7335" + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/AAAA/test", + "Type": "azurerm_private_dns_aaaa_record", + "Attrs": { + "fqdn": "test.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/AAAA/test", + "name": "test", + "records": [ + "fd5d:70bc:930e:d008:0000:0000:0000:7334", + "fd5d:70bc:930e:d008::7335" + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_cname_record/expected.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_cname_record/expected.json new file mode 100755 index 000000000..3ce1ad9e2 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_cname_record/expected.json @@ -0,0 +1,28 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/CNAME/test", + "Type": "azurerm_private_dns_cname_record", + "Attrs": { + "fqdn": "test.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/CNAME/test", + "name": "test", + "record": "test.com", + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/CNAME/othertest", + "Type": "azurerm_private_dns_cname_record", + "Attrs": { + "fqdn": "othertest.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/CNAME/othertest", + "name": "othertest", + "record": "othertest.com", + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_cname_record/input.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_cname_record/input.json new file mode 100755 index 000000000..7e99c132d --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_cname_record/input.json @@ -0,0 +1,32 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/CNAME/test", + "Type": "azurerm_private_dns_cname_record", + "Attrs": { + "fqdn": "test.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/CNAME/test", + "name": "test", + "record": "test.com", + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/CNAME/othertest", + "Type": "azurerm_private_dns_cname_record", + "Attrs": { + "fqdn": "othertest.thisisatestusingtf.com.", + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/CNAME/othertest", + "name": "othertest", + "record": "othertest.com", + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_mx_record/expected.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_mx_record/expected.json new file mode 100755 index 000000000..1831ce887 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_mx_record/expected.json @@ -0,0 +1,42 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/MX/testmx", + "Type": "azurerm_private_dns_mx_record", + "Attrs": { + "fqdn": "testmx.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/MX/testmx", + "name": "testmx", + "record": [ + { + "exchange": "bkpmx.thisisatestusingtf.com", + "preference": 30 + } + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/MX/othertestmx", + "Type": "azurerm_private_dns_mx_record", + "Attrs": { + "fqdn": "othertestmx.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/MX/othertestmx", + "name": "othertestmx", + "record": [ + { + "exchange": "backupmx.thisisatestusingtf.com", + "preference": 20 + }, + { + "exchange": "mx.thisisatestusingtf.com", + "preference": 10 + } + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_mx_record/input.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_mx_record/input.json new file mode 100755 index 000000000..80223c196 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_mx_record/input.json @@ -0,0 +1,46 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/MX/testmx", + "Type": "azurerm_private_dns_mx_record", + "Attrs": { + "fqdn": "testmx.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/MX/testmx", + "name": "testmx", + "record": [ + { + "exchange": "bkpmx.thisisatestusingtf.com", + "preference": 30 + } + ], + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/MX/othertestmx", + "Type": "azurerm_private_dns_mx_record", + "Attrs": { + "fqdn": "othertestmx.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/MX/othertestmx", + "name": "othertestmx", + "record": [ + { + "exchange": "backupmx.thisisatestusingtf.com", + "preference": 20 + }, + { + "exchange": "mx.thisisatestusingtf.com", + "preference": 10 + } + ], + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_ptr_record/expected.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_ptr_record/expected.json new file mode 100755 index 000000000..b2a7011bd --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_ptr_record/expected.json @@ -0,0 +1,33 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/PTR/testptr", + "Type": "azurerm_private_dns_ptr_record", + "Attrs": { + "fqdn": "testptr.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/PTR/testptr", + "name": "testptr", + "records": [ + "ptr3.thisisatestusingtf.com" + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/PTR/othertestptr", + "Type": "azurerm_private_dns_ptr_record", + "Attrs": { + "fqdn": "othertestptr.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/PTR/othertestptr", + "name": "othertestptr", + "records": [ + "ptr1.thisisatestusingtf.com", + "ptr2.thisisatestusingtf.com" + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_ptr_record/input.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_ptr_record/input.json new file mode 100755 index 000000000..83e704e5e --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_ptr_record/input.json @@ -0,0 +1,37 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/PTR/testptr", + "Type": "azurerm_private_dns_ptr_record", + "Attrs": { + "fqdn": "testptr.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/PTR/testptr", + "name": "testptr", + "records": [ + "ptr3.thisisatestusingtf.com" + ], + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/PTR/othertestptr", + "Type": "azurerm_private_dns_ptr_record", + "Attrs": { + "fqdn": "othertestptr.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/PTR/othertestptr", + "name": "othertestptr", + "records": [ + "ptr1.thisisatestusingtf.com", + "ptr2.thisisatestusingtf.com" + ], + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_srv_record/expected.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_srv_record/expected.json new file mode 100755 index 000000000..7391421b7 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_srv_record/expected.json @@ -0,0 +1,48 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/SRV/othertestptr", + "Type": "azurerm_private_dns_srv_record", + "Attrs": { + "fqdn": "othertestptr.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/SRV/othertestptr", + "name": "othertestptr", + "record": [ + { + "port": 8080, + "priority": 10, + "target": "srv2.thisisatestusingtf.com", + "weight": 10 + }, + { + "port": 8080, + "priority": 1, + "target": "srv1.thisisatestusingtf.com", + "weight": 5 + } + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/SRV/testptr", + "Type": "azurerm_private_dns_srv_record", + "Attrs": { + "fqdn": "testptr.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/SRV/testptr", + "name": "testptr", + "record": [ + { + "port": 8080, + "priority": 20, + "target": "srv3.thisisatestusingtf.com", + "weight": 15 + } + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_srv_record/input.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_srv_record/input.json new file mode 100755 index 000000000..f2af32b51 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_srv_record/input.json @@ -0,0 +1,52 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/SRV/othertestptr", + "Type": "azurerm_private_dns_srv_record", + "Attrs": { + "fqdn": "othertestptr.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/SRV/othertestptr", + "name": "othertestptr", + "record": [ + { + "port": 8080, + "priority": 10, + "target": "srv2.thisisatestusingtf.com", + "weight": 10 + }, + { + "port": 8080, + "priority": 1, + "target": "srv1.thisisatestusingtf.com", + "weight": 5 + } + ], + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/SRV/testptr", + "Type": "azurerm_private_dns_srv_record", + "Attrs": { + "fqdn": "testptr.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/SRV/testptr", + "name": "testptr", + "record": [ + { + "port": 8080, + "priority": 20, + "target": "srv3.thisisatestusingtf.com", + "weight": 15 + } + ], + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_txt_record/expected.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_txt_record/expected.json new file mode 100755 index 000000000..e4d917487 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_txt_record/expected.json @@ -0,0 +1,39 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/TXT/testtxt", + "Type": "azurerm_private_dns_txt_record", + "Attrs": { + "fqdn": "testtxt.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/TXT/testtxt", + "name": "testtxt", + "record": [ + { + "value": "this is value line 3" + } + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/TXT/othertesttxt", + "Type": "azurerm_private_dns_txt_record", + "Attrs": { + "fqdn": "othertesttxt.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/TXT/othertesttxt", + "name": "othertesttxt", + "record": [ + { + "value": "this is value line 1" + }, + { + "value": "this is value line 2" + } + ], + "resource_group_name": "martin-dev", + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_txt_record/input.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_txt_record/input.json new file mode 100755 index 000000000..967963de8 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_txt_record/input.json @@ -0,0 +1,43 @@ +[ + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/TXT/testtxt", + "Type": "azurerm_private_dns_txt_record", + "Attrs": { + "fqdn": "testtxt.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/TXT/testtxt", + "name": "testtxt", + "record": [ + { + "value": "this is value line 3" + } + ], + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + }, + { + "Id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/TXT/othertesttxt", + "Type": "azurerm_private_dns_txt_record", + "Attrs": { + "fqdn": "othertesttxt.thisisatestusingtf.com.", + "id": "/subscriptions/8cb43347-a79f-4bb2-a8b4-c838b41fa5a5/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com/TXT/othertesttxt", + "name": "othertesttxt", + "record": [ + { + "value": "this is value line 1" + }, + { + "value": "this is value line 2" + } + ], + "resource_group_name": "martin-dev", + "tags": {}, + "timeouts": {}, + "ttl": 300, + "zone_name": "thisisatestusingtf.com" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_zone/expected.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_zone/expected.json new file mode 100755 index 000000000..3fea9498b --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_zone/expected.json @@ -0,0 +1,27 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com", + "Type": "azurerm_private_dns_zone", + "Attrs": { + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com", + "max_number_of_record_sets": 25000, + "max_number_of_virtual_network_links": 1000, + "max_number_of_virtual_network_links_with_registration": 100, + "name": "thisisatestusingtf.com", + "resource_group_name": "martin-dev", + "soa_record": [ + { + "email": "azureprivatedns-host.microsoft.com", + "expire_time": 2419200, + "fqdn": "thisisatestusingtf.com.", + "host_name": "azureprivatedns.net", + "minimum_ttl": 10, + "refresh_time": 3600, + "retry_time": 300, + "serial_number": 1, + "ttl": 3600 + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_private_dns_zone/input.json b/pkg/test/azurerm/2.71.0/azurerm_private_dns_zone/input.json new file mode 100755 index 000000000..3fea9498b --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_private_dns_zone/input.json @@ -0,0 +1,27 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com", + "Type": "azurerm_private_dns_zone", + "Attrs": { + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/martin-dev/providers/Microsoft.Network/privateDnsZones/thisisatestusingtf.com", + "max_number_of_record_sets": 25000, + "max_number_of_virtual_network_links": 1000, + "max_number_of_virtual_network_links_with_registration": 100, + "name": "thisisatestusingtf.com", + "resource_group_name": "martin-dev", + "soa_record": [ + { + "email": "azureprivatedns-host.microsoft.com", + "expire_time": 2419200, + "fqdn": "thisisatestusingtf.com.", + "host_name": "azureprivatedns.net", + "minimum_ttl": 10, + "refresh_time": 3600, + "retry_time": 300, + "serial_number": 1, + "ttl": 3600 + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_ssh_public_key/expected.json b/pkg/test/azurerm/2.71.0/azurerm_ssh_public_key/expected.json new file mode 100755 index 000000000..6449f7c88 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_ssh_public_key/expected.json @@ -0,0 +1,24 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/TESTRESGROUP/providers/Microsoft.Compute/sshPublicKeys/example-key2", + "Type": "azurerm_ssh_public_key", + "Attrs": { + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/TESTRESGROUP/providers/Microsoft.Compute/sshPublicKeys/example-key2", + "location": "westeurope", + "name": "example-key2", + "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCjeC5sO1EdEfZOrdVCpuOgXcXsKZg9zgfJbHgQgX1R2Nd8mNQrUjpsB4XLHNZ3T6UYrsSh7oxYC3UFu6peO4LmA2WTe2wCWVFn9WW/Lo99WcA/G/fGj6s5HK5CHFVPXnNxM47QJMNm5BWOM55+EWP839SHLH9Fk63H575x7jxZvBvaV0uL84XuVpiEBKhnpQfT4cJGoGLOGgjM+TpHyosbKldu5q2UTF9nOGpmLuku41oihqiPPSJnJRv3TDKFi4mIl9Iz5HJINWvLl1kdCfyjPcHcH5GO0tuA9rP5AbsmG5EAGOKtuFipYA4MyY9SYriZ2V1vpgefUS9lilg9hIPEj/8ZPTxf62XeyC1dQ3cOz6yPWR2sODyVECVf6mrmhZPTjVX+DorByX2uBzLDzF9jGMFMJRhxi0yVpXsqBrP+ps9G+s7oNUDp771d1Bix+gm5EyebEbdiQuf0/8wDlhY5jYAFJW1xkPKXcjJdM1FuVVS1B8zhvRVEJZUngruVfh/7jJUOWNS44F7rVz5a4r/vs84ObFIMeYdFn+uxgUqOlNMAvXLvJ2GzlPXInXW90Uv+JJ5msny/5ygGfHr2D6xOf6P7r7oSalXwjd9BcRS6/4GQAY6LVfPwrpnrpyJBiK/FhEbR+ctfDo81eKhmp0EyxvSJGW46/26/kqHvchf+rQ== ?\n", + "resource_group_name": "TESTRESGROUP" + } + }, + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/TESTRESGROUP/providers/Microsoft.Compute/sshPublicKeys/example-key", + "Type": "azurerm_ssh_public_key", + "Attrs": { + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/TESTRESGROUP/providers/Microsoft.Compute/sshPublicKeys/example-key", + "location": "westeurope", + "name": "example-key", + "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCjeC5sO1EdEfZOrdVCpuOgXcXsKZg9zgfJbHgQgX1R2Nd8mNQrUjpsB4XLHNZ3T6UYrsSh7oxYC3UFu6peO4LmA2WTe2wCWVFn9WW/Lo99WcA/G/fGj6s5HK5CHFVPXnNxM47QJMNm5BWOM55+EWP839SHLH9Fk63H575x7jxZvBvaV0uL84XuVpiEBKhnpQfT4cJGoGLOGgjM+TpHyosbKldu5q2UTF9nOGpmLuku41oihqiPPSJnJRv3TDKFi4mIl9Iz5HJINWvLl1kdCfyjPcHcH5GO0tuA9rP5AbsmG5EAGOKtuFipYA4MyY9SYriZ2V1vpgefUS9lilg9hIPEj/8ZPTxf62XeyC1dQ3cOz6yPWR2sODyVECVf6mrmhZPTjVX+DorByX2uBzLDzF9jGMFMJRhxi0yVpXsqBrP+ps9G+s7oNUDp771d1Bix+gm5EyebEbdiQuf0/8wDlhY5jYAFJW1xkPKXcjJdM1FuVVS1B8zhvRVEJZUngruVfh/7jJUOWNS44F7rVz5a4r/vs84ObFIMeYdFn+uxgUqOlNMAvXLvJ2GzlPXInXW90Uv+JJ5msny/5ygGfHr2D6xOf6P7r7oSalXwjd9BcRS6/4GQAY6LVfPwrpnrpyJBiK/FhEbR+ctfDo81eKhmp0EyxvSJGW46/26/kqHvchf+rQ== ?\n", + "resource_group_name": "TESTRESGROUP" + } + } +] \ No newline at end of file diff --git a/pkg/test/azurerm/2.71.0/azurerm_ssh_public_key/input.json b/pkg/test/azurerm/2.71.0/azurerm_ssh_public_key/input.json new file mode 100755 index 000000000..e69ac9df5 --- /dev/null +++ b/pkg/test/azurerm/2.71.0/azurerm_ssh_public_key/input.json @@ -0,0 +1,28 @@ +[ + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/TESTRESGROUP/providers/Microsoft.Compute/sshPublicKeys/example-key2", + "Type": "azurerm_ssh_public_key", + "Attrs": { + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/TESTRESGROUP/providers/Microsoft.Compute/sshPublicKeys/example-key2", + "location": "westeurope", + "name": "example-key2", + "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCjeC5sO1EdEfZOrdVCpuOgXcXsKZg9zgfJbHgQgX1R2Nd8mNQrUjpsB4XLHNZ3T6UYrsSh7oxYC3UFu6peO4LmA2WTe2wCWVFn9WW/Lo99WcA/G/fGj6s5HK5CHFVPXnNxM47QJMNm5BWOM55+EWP839SHLH9Fk63H575x7jxZvBvaV0uL84XuVpiEBKhnpQfT4cJGoGLOGgjM+TpHyosbKldu5q2UTF9nOGpmLuku41oihqiPPSJnJRv3TDKFi4mIl9Iz5HJINWvLl1kdCfyjPcHcH5GO0tuA9rP5AbsmG5EAGOKtuFipYA4MyY9SYriZ2V1vpgefUS9lilg9hIPEj/8ZPTxf62XeyC1dQ3cOz6yPWR2sODyVECVf6mrmhZPTjVX+DorByX2uBzLDzF9jGMFMJRhxi0yVpXsqBrP+ps9G+s7oNUDp771d1Bix+gm5EyebEbdiQuf0/8wDlhY5jYAFJW1xkPKXcjJdM1FuVVS1B8zhvRVEJZUngruVfh/7jJUOWNS44F7rVz5a4r/vs84ObFIMeYdFn+uxgUqOlNMAvXLvJ2GzlPXInXW90Uv+JJ5msny/5ygGfHr2D6xOf6P7r7oSalXwjd9BcRS6/4GQAY6LVfPwrpnrpyJBiK/FhEbR+ctfDo81eKhmp0EyxvSJGW46/26/kqHvchf+rQ== ?\n", + "resource_group_name": "TESTRESGROUP", + "tags": {}, + "timeouts": {} + } + }, + { + "Id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/TESTRESGROUP/providers/Microsoft.Compute/sshPublicKeys/example-key", + "Type": "azurerm_ssh_public_key", + "Attrs": { + "id": "/subscriptions/7bfb2c5c-7308-46ed-8ae4-fffa356eb406/resourceGroups/TESTRESGROUP/providers/Microsoft.Compute/sshPublicKeys/example-key", + "location": "westeurope", + "name": "example-key", + "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCjeC5sO1EdEfZOrdVCpuOgXcXsKZg9zgfJbHgQgX1R2Nd8mNQrUjpsB4XLHNZ3T6UYrsSh7oxYC3UFu6peO4LmA2WTe2wCWVFn9WW/Lo99WcA/G/fGj6s5HK5CHFVPXnNxM47QJMNm5BWOM55+EWP839SHLH9Fk63H575x7jxZvBvaV0uL84XuVpiEBKhnpQfT4cJGoGLOGgjM+TpHyosbKldu5q2UTF9nOGpmLuku41oihqiPPSJnJRv3TDKFi4mIl9Iz5HJINWvLl1kdCfyjPcHcH5GO0tuA9rP5AbsmG5EAGOKtuFipYA4MyY9SYriZ2V1vpgefUS9lilg9hIPEj/8ZPTxf62XeyC1dQ3cOz6yPWR2sODyVECVf6mrmhZPTjVX+DorByX2uBzLDzF9jGMFMJRhxi0yVpXsqBrP+ps9G+s7oNUDp771d1Bix+gm5EyebEbdiQuf0/8wDlhY5jYAFJW1xkPKXcjJdM1FuVVS1B8zhvRVEJZUngruVfh/7jJUOWNS44F7rVz5a4r/vs84ObFIMeYdFn+uxgUqOlNMAvXLvJ2GzlPXInXW90Uv+JJ5msny/5ygGfHr2D6xOf6P7r7oSalXwjd9BcRS6/4GQAY6LVfPwrpnrpyJBiK/FhEbR+ctfDo81eKhmp0EyxvSJGW46/26/kqHvchf+rQ== ?\n", + "resource_group_name": "TESTRESGROUP", + "tags": {}, + "timeouts": {} + } + } +] \ No newline at end of file diff --git a/pkg/test/github/4.4.0/github_branch_protection/expected.json b/pkg/test/github/4.4.0/github_branch_protection/expected.json new file mode 100755 index 000000000..bc9927faa --- /dev/null +++ b/pkg/test/github/4.4.0/github_branch_protection/expected.json @@ -0,0 +1,137 @@ +[ + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": true, + "allows_force_pushes": true, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=", + "pattern": "main", + "push_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "require_signed_commits": false, + "required_pull_request_reviews": [ + { + "dismiss_stale_reviews": true, + "dismissal_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "require_code_owner_reviews": false, + "required_approving_review_count": 1 + } + ], + "required_status_checks": [ + { + "contexts": [ + "ci/travis" + ], + "strict": false + } + ] + } + }, + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": true, + "allows_force_pushes": true, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=", + "pattern": "main", + "push_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "require_signed_commits": false, + "required_pull_request_reviews": [ + { + "dismiss_stale_reviews": true, + "dismissal_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "require_code_owner_reviews": false, + "required_approving_review_count": 1 + } + ], + "required_status_checks": [ + { + "contexts": [ + "ci/travis" + ], + "strict": false + } + ] + } + }, + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": true, + "allows_force_pushes": true, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=", + "pattern": "main", + "push_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "require_signed_commits": false, + "required_pull_request_reviews": [ + { + "dismiss_stale_reviews": true, + "dismissal_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "require_code_owner_reviews": false, + "required_approving_review_count": 1 + } + ], + "required_status_checks": [ + { + "contexts": [ + "ci/travis" + ], + "strict": false + } + ] + } + }, + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzc=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": false, + "allows_force_pushes": false, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzc=", + "pattern": "toto", + "require_signed_commits": false + } + }, + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": false, + "allows_force_pushes": false, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=", + "pattern": "toto", + "require_signed_commits": false + } + }, + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0ODA=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": false, + "allows_force_pushes": false, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0ODA=", + "pattern": "toto", + "require_signed_commits": false + } + } +] \ No newline at end of file diff --git a/pkg/test/github/4.4.0/github_branch_protection/input.json b/pkg/test/github/4.4.0/github_branch_protection/input.json new file mode 100755 index 000000000..e36263683 --- /dev/null +++ b/pkg/test/github/4.4.0/github_branch_protection/input.json @@ -0,0 +1,152 @@ +[ + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": true, + "allows_force_pushes": true, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzI=", + "pattern": "main", + "push_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "repository_id": null, + "require_signed_commits": false, + "required_pull_request_reviews": [ + { + "dismiss_stale_reviews": true, + "dismissal_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "require_code_owner_reviews": false, + "required_approving_review_count": 1 + } + ], + "required_status_checks": [ + { + "contexts": [ + "ci/travis" + ], + "strict": false + } + ] + } + }, + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": true, + "allows_force_pushes": true, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzE=", + "pattern": "main", + "push_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "repository_id": null, + "require_signed_commits": false, + "required_pull_request_reviews": [ + { + "dismiss_stale_reviews": true, + "dismissal_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "require_code_owner_reviews": false, + "required_approving_review_count": 1 + } + ], + "required_status_checks": [ + { + "contexts": [ + "ci/travis" + ], + "strict": false + } + ] + } + }, + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": true, + "allows_force_pushes": true, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0NzQ=", + "pattern": "main", + "push_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "repository_id": null, + "require_signed_commits": false, + "required_pull_request_reviews": [ + { + "dismiss_stale_reviews": true, + "dismissal_restrictions": [ + "MDQ6VXNlcjYxNTQ5ODc=" + ], + "require_code_owner_reviews": false, + "required_approving_review_count": 1 + } + ], + "required_status_checks": [ + { + "contexts": [ + "ci/travis" + ], + "strict": false + } + ] + } + }, + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzc=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": false, + "allows_force_pushes": false, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzc=", + "pattern": "toto", + "push_restrictions": [], + "repository_id": null, + "require_signed_commits": false, + "required_pull_request_reviews": [], + "required_status_checks": [] + } + }, + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": false, + "allows_force_pushes": false, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0Nzg=", + "pattern": "toto", + "push_restrictions": [], + "repository_id": null, + "require_signed_commits": false, + "required_pull_request_reviews": [], + "required_status_checks": [] + } + }, + { + "Id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0ODA=", + "Type": "github_branch_protection", + "Attrs": { + "allows_deletions": false, + "allows_force_pushes": false, + "enforce_admins": true, + "id": "MDIwOkJyYW5jaFByb3RlY3Rpb25SdWxlMTk1NDg0ODA=", + "pattern": "toto", + "push_restrictions": [], + "repository_id": null, + "require_signed_commits": false, + "required_pull_request_reviews": [], + "required_status_checks": [] + } + } +] \ No newline at end of file diff --git a/pkg/test/github/4.4.0/github_membership/expected.json b/pkg/test/github/4.4.0/github_membership/expected.json new file mode 100755 index 000000000..807763f60 --- /dev/null +++ b/pkg/test/github/4.4.0/github_membership/expected.json @@ -0,0 +1,20 @@ +[ + { + "Id": "driftctl-test:eliecharra", + "Type": "github_membership", + "Attrs": { + "id": "driftctl-test:eliecharra", + "role": "admin", + "username": "eliecharra" + } + }, + { + "Id": "driftctl-test:driftctl-acceptance-tester", + "Type": "github_membership", + "Attrs": { + "id": "driftctl-test:driftctl-acceptance-tester", + "role": "member", + "username": "driftctl-acceptance-tester" + } + } +] \ No newline at end of file diff --git a/pkg/test/github/4.4.0/github_membership/input.json b/pkg/test/github/4.4.0/github_membership/input.json new file mode 100755 index 000000000..fd0eb42c8 --- /dev/null +++ b/pkg/test/github/4.4.0/github_membership/input.json @@ -0,0 +1,22 @@ +[ + { + "Id": "driftctl-test:eliecharra", + "Type": "github_membership", + "Attrs": { + "etag": "W/\"d2a4eb901334f41629f5ead98a4b6e02489ae2f13b2152630f00e4dfa6488586\"", + "id": "driftctl-test:eliecharra", + "role": "admin", + "username": "eliecharra" + } + }, + { + "Id": "driftctl-test:driftctl-acceptance-tester", + "Type": "github_membership", + "Attrs": { + "etag": "W/\"eadf8782b06fdcc3fccc6385639ae067add316ead1742336589555e3627c70d9\"", + "id": "driftctl-test:driftctl-acceptance-tester", + "role": "member", + "username": "driftctl-acceptance-tester" + } + } +] \ No newline at end of file diff --git a/pkg/test/github/4.4.0/github_repository/expected.json b/pkg/test/github/4.4.0/github_repository/expected.json new file mode 100755 index 000000000..ae2a67166 --- /dev/null +++ b/pkg/test/github/4.4.0/github_repository/expected.json @@ -0,0 +1,80 @@ +[ + { + "Id": "driftctl-demos", + "Type": "github_repository", + "Attrs": { + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_squash_merge": true, + "archived": false, + "default_branch": "main", + "delete_branch_on_merge": false, + "description": "material for driftctl demos", + "full_name": "cloudskiff/driftctl-demos", + "git_clone_url": "git://github.com/cloudskiff/driftctl-demos.git", + "has_downloads": false, + "has_issues": false, + "has_projects": false, + "has_wiki": false, + "homepage_url": "https://driftctl.com", + "html_url": "https://github.com/cloudskiff/driftctl-demos", + "http_clone_url": "https://github.com/cloudskiff/driftctl-demos.git", + "id": "driftctl-demos", + "is_template": false, + "name": "driftctl-demos", + "node_id": "MDEwOlJlcG9zaXRvcnkzMzQxMTI2MjQ=", + "private": false, + "repo_id": 334112624, + "ssh_clone_url": "git@github.com:cloudskiff/driftctl-demos.git", + "svn_url": "https://github.com/cloudskiff/driftctl-demos", + "topics": [ + "aws", + "drift", + "iac", + "infrastructure-drift", + "terraform" + ], + "visibility": "public", + "vulnerability_alerts": false + } + }, + { + "Id": "driftctl", + "Type": "github_repository", + "Attrs": { + "allow_merge_commit": true, + "allow_rebase_merge": false, + "allow_squash_merge": false, + "archived": false, + "default_branch": "main", + "delete_branch_on_merge": true, + "description": "Detect, track and alert on infrastructure drift", + "full_name": "cloudskiff/driftctl", + "git_clone_url": "git://github.com/cloudskiff/driftctl.git", + "has_downloads": true, + "has_issues": true, + "has_projects": true, + "has_wiki": false, + "homepage_url": "https://driftctl.com", + "html_url": "https://github.com/cloudskiff/driftctl", + "http_clone_url": "https://github.com/cloudskiff/driftctl.git", + "id": "driftctl", + "is_template": false, + "name": "driftctl", + "node_id": "MDEwOlJlcG9zaXRvcnkyOTc2MjI5NDU=", + "private": false, + "repo_id": 297622945, + "ssh_clone_url": "git@github.com:cloudskiff/driftctl.git", + "svn_url": "https://github.com/cloudskiff/driftctl", + "topics": [ + "aws", + "drift", + "iac", + "infrastructure-drift", + "terraform" + ], + "visibility": "public", + "vulnerability_alerts": false + } + } +] \ No newline at end of file diff --git a/pkg/test/github/4.4.0/github_repository/input.json b/pkg/test/github/4.4.0/github_repository/input.json new file mode 100755 index 000000000..ae36dc130 --- /dev/null +++ b/pkg/test/github/4.4.0/github_repository/input.json @@ -0,0 +1,94 @@ +[ + { + "Id": "driftctl-demos", + "Type": "github_repository", + "Attrs": { + "allow_merge_commit": true, + "allow_rebase_merge": true, + "allow_squash_merge": true, + "archive_on_destroy": null, + "archived": false, + "auto_init": null, + "default_branch": "main", + "delete_branch_on_merge": false, + "description": "material for driftctl demos", + "etag": "W/\"21380a1f582fb9ed2bddaf701a01d5a99f07d3c1849787781d1d7a756c39a94f\"", + "full_name": "cloudskiff/driftctl-demos", + "git_clone_url": "git://github.com/cloudskiff/driftctl-demos.git", + "gitignore_template": null, + "has_downloads": false, + "has_issues": false, + "has_projects": false, + "has_wiki": false, + "homepage_url": "https://driftctl.com", + "html_url": "https://github.com/cloudskiff/driftctl-demos", + "http_clone_url": "https://github.com/cloudskiff/driftctl-demos.git", + "id": "driftctl-demos", + "is_template": false, + "license_template": null, + "name": "driftctl-demos", + "node_id": "MDEwOlJlcG9zaXRvcnkzMzQxMTI2MjQ=", + "pages": null, + "private": false, + "repo_id": 334112624, + "ssh_clone_url": "git@github.com:cloudskiff/driftctl-demos.git", + "svn_url": "https://github.com/cloudskiff/driftctl-demos", + "template": [], + "topics": [ + "aws", + "drift", + "iac", + "infrastructure-drift", + "terraform" + ], + "visibility": "public", + "vulnerability_alerts": false + } + }, + { + "Id": "driftctl", + "Type": "github_repository", + "Attrs": { + "allow_merge_commit": true, + "allow_rebase_merge": false, + "allow_squash_merge": false, + "archive_on_destroy": null, + "archived": false, + "auto_init": null, + "default_branch": "main", + "delete_branch_on_merge": true, + "description": "Detect, track and alert on infrastructure drift", + "etag": "W/\"15a9946c5ed989bc4a0f587a1b470391d5785d164714d0999bf9f0b8ad181e85\"", + "full_name": "cloudskiff/driftctl", + "git_clone_url": "git://github.com/cloudskiff/driftctl.git", + "gitignore_template": null, + "has_downloads": true, + "has_issues": true, + "has_projects": true, + "has_wiki": false, + "homepage_url": "https://driftctl.com", + "html_url": "https://github.com/cloudskiff/driftctl", + "http_clone_url": "https://github.com/cloudskiff/driftctl.git", + "id": "driftctl", + "is_template": false, + "license_template": null, + "name": "driftctl", + "node_id": "MDEwOlJlcG9zaXRvcnkyOTc2MjI5NDU=", + "pages": null, + "private": false, + "repo_id": 297622945, + "ssh_clone_url": "git@github.com:cloudskiff/driftctl.git", + "svn_url": "https://github.com/cloudskiff/driftctl", + "template": [], + "topics": [ + "aws", + "drift", + "iac", + "infrastructure-drift", + "terraform" + ], + "visibility": "public", + "vulnerability_alerts": false + } + } +] \ No newline at end of file diff --git a/pkg/test/github/4.4.0/github_team/expected.json b/pkg/test/github/4.4.0/github_team/expected.json new file mode 100755 index 000000000..d6dc5f226 --- /dev/null +++ b/pkg/test/github/4.4.0/github_team/expected.json @@ -0,0 +1,24 @@ +[ + { + "Id": "4570529:wbeuil", + "Type": "github_team", + "Attrs": { + "id": "4570529:wbeuil", + "role": "maintainer", + "team_id": "4570529", + "create_default_maintainer": false, + "username": "wbeuil" + } + }, + { + "Id": "4570529:driftctl-acceptance-tester", + "Type": "github_team", + "Attrs": { + "id": "4570529:driftctl-acceptance-tester", + "role": "maintainer", + "team_id": "4570529", + "create_default_maintainer": false, + "username": "driftctl-acceptance-tester" + } + } +] \ No newline at end of file diff --git a/pkg/test/github/4.4.0/github_team/input.json b/pkg/test/github/4.4.0/github_team/input.json new file mode 100755 index 000000000..f771bb209 --- /dev/null +++ b/pkg/test/github/4.4.0/github_team/input.json @@ -0,0 +1,24 @@ +[ + { + "Id": "4570529:wbeuil", + "Type": "github_team", + "Attrs": { + "etag": "W/\"36ab7d78ee013792fecf7cc3ebc0fb7e1b8365d3f87791ff589381e58c2c7f34\"", + "id": "4570529:wbeuil", + "role": "maintainer", + "team_id": "4570529", + "username": "wbeuil" + } + }, + { + "Id": "4570529:driftctl-acceptance-tester", + "Type": "github_team", + "Attrs": { + "etag": "W/\"60083b8bf2ced30fbf573dd02317c6e2f659ff7ffe97167d1331b692a39d0d1a\"", + "id": "4570529:driftctl-acceptance-tester", + "role": "maintainer", + "team_id": "4570529", + "username": "driftctl-acceptance-tester" + } + } +] \ No newline at end of file diff --git a/pkg/test/github/4.4.0/github_team_membership/expected.json b/pkg/test/github/4.4.0/github_team_membership/expected.json new file mode 100755 index 000000000..ebed0565e --- /dev/null +++ b/pkg/test/github/4.4.0/github_team_membership/expected.json @@ -0,0 +1,22 @@ +[ + { + "Id": "4570529:wbeuil", + "Type": "github_team_membership", + "Attrs": { + "id": "4570529:wbeuil", + "role": "maintainer", + "team_id": "4570529", + "username": "wbeuil" + } + }, + { + "Id": "4570529:driftctl-acceptance-tester", + "Type": "github_team_membership", + "Attrs": { + "id": "4570529:driftctl-acceptance-tester", + "role": "maintainer", + "team_id": "4570529", + "username": "driftctl-acceptance-tester" + } + } +] \ No newline at end of file diff --git a/pkg/test/github/4.4.0/github_team_membership/input.json b/pkg/test/github/4.4.0/github_team_membership/input.json new file mode 100755 index 000000000..a2106204c --- /dev/null +++ b/pkg/test/github/4.4.0/github_team_membership/input.json @@ -0,0 +1,24 @@ +[ + { + "Id": "4570529:wbeuil", + "Type": "github_team_membership", + "Attrs": { + "etag": "W/\"36ab7d78ee013792fecf7cc3ebc0fb7e1b8365d3f87791ff589381e58c2c7f34\"", + "id": "4570529:wbeuil", + "role": "maintainer", + "team_id": "4570529", + "username": "wbeuil" + } + }, + { + "Id": "4570529:driftctl-acceptance-tester", + "Type": "github_team_membership", + "Attrs": { + "etag": "W/\"60083b8bf2ced30fbf573dd02317c6e2f659ff7ffe97167d1331b692a39d0d1a\"", + "id": "4570529:driftctl-acceptance-tester", + "role": "maintainer", + "team_id": "4570529", + "username": "driftctl-acceptance-tester" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_bigquery_dataset/expected.json b/pkg/test/google/3.78.0/google_bigquery_dataset/expected.json new file mode 100755 index 000000000..6d1286e64 --- /dev/null +++ b/pkg/test/google/3.78.0/google_bigquery_dataset/expected.json @@ -0,0 +1,51 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/datasets/example_dataset", + "Type": "google_bigquery_dataset", + "Attrs": { + "access": [ + { + "domain": "", + "group_by_email": "", + "role": "OWNER", + "special_group": "", + "user_by_email": "elie.charra@cloudskiff.com" + }, + { + "domain": "", + "group_by_email": "", + "role": "OWNER", + "special_group": "projectOwners", + "user_by_email": "" + }, + { + "domain": "", + "group_by_email": "", + "role": "READER", + "special_group": "projectReaders", + "user_by_email": "" + }, + { + "domain": "", + "group_by_email": "", + "role": "WRITER", + "special_group": "projectWriters", + "user_by_email": "" + } + ], + "creation_time": 1634647437581, + "dataset_id": "example_dataset", + "default_partition_expiration_ms": 0, + "default_table_expiration_ms": 0, + "delete_contents_on_destroy": false, + "description": "This is a test description", + "etag": "RrsFjBErVHJw1kDByWfKmQ==", + "friendly_name": "test", + "id": "projects/cloudskiff-dev-elie/datasets/example_dataset", + "last_modified_time": 1634647437581, + "location": "EU", + "project": "cloudskiff-dev-elie", + "self_link": "https://bigquery.googleapis.com/bigquery/v2/projects/cloudskiff-dev-elie/datasets/example_dataset" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_bigquery_dataset/input.json b/pkg/test/google/3.78.0/google_bigquery_dataset/input.json new file mode 100755 index 000000000..6d1286e64 --- /dev/null +++ b/pkg/test/google/3.78.0/google_bigquery_dataset/input.json @@ -0,0 +1,51 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/datasets/example_dataset", + "Type": "google_bigquery_dataset", + "Attrs": { + "access": [ + { + "domain": "", + "group_by_email": "", + "role": "OWNER", + "special_group": "", + "user_by_email": "elie.charra@cloudskiff.com" + }, + { + "domain": "", + "group_by_email": "", + "role": "OWNER", + "special_group": "projectOwners", + "user_by_email": "" + }, + { + "domain": "", + "group_by_email": "", + "role": "READER", + "special_group": "projectReaders", + "user_by_email": "" + }, + { + "domain": "", + "group_by_email": "", + "role": "WRITER", + "special_group": "projectWriters", + "user_by_email": "" + } + ], + "creation_time": 1634647437581, + "dataset_id": "example_dataset", + "default_partition_expiration_ms": 0, + "default_table_expiration_ms": 0, + "delete_contents_on_destroy": false, + "description": "This is a test description", + "etag": "RrsFjBErVHJw1kDByWfKmQ==", + "friendly_name": "test", + "id": "projects/cloudskiff-dev-elie/datasets/example_dataset", + "last_modified_time": 1634647437581, + "location": "EU", + "project": "cloudskiff-dev-elie", + "self_link": "https://bigquery.googleapis.com/bigquery/v2/projects/cloudskiff-dev-elie/datasets/example_dataset" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_bigquery_table/expected.json b/pkg/test/google/3.78.0/google_bigquery_table/expected.json new file mode 100755 index 000000000..20cfbb072 --- /dev/null +++ b/pkg/test/google/3.78.0/google_bigquery_table/expected.json @@ -0,0 +1,26 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/datasets/example_dataset/tables/bar", + "Type": "google_bigquery_table", + "Attrs": { + "creation_time": 1634649708532, + "dataset_id": "example_dataset", + "deletion_protection": true, + "description": "", + "etag": "yP1tU5di6p1hWKNo8DDNYg==", + "expiration_time": 0, + "friendly_name": "", + "id": "projects/cloudskiff-dev-elie/datasets/example_dataset/tables/bar", + "last_modified_time": 1634649708609, + "location": "EU", + "num_bytes": 0, + "num_long_term_bytes": 0, + "num_rows": 0, + "project": "cloudskiff-dev-elie", + "schema": "[{\"description\":\"foobar\",\"mode\":\"NULLABLE\",\"name\":\"bar\",\"type\":\"STRING\"}]", + "self_link": "https://bigquery.googleapis.com/bigquery/v2/projects/cloudskiff-dev-elie/datasets/example_dataset/tables/bar", + "table_id": "bar", + "type": "TABLE" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_bigquery_table/input.json b/pkg/test/google/3.78.0/google_bigquery_table/input.json new file mode 100755 index 000000000..20cfbb072 --- /dev/null +++ b/pkg/test/google/3.78.0/google_bigquery_table/input.json @@ -0,0 +1,26 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/datasets/example_dataset/tables/bar", + "Type": "google_bigquery_table", + "Attrs": { + "creation_time": 1634649708532, + "dataset_id": "example_dataset", + "deletion_protection": true, + "description": "", + "etag": "yP1tU5di6p1hWKNo8DDNYg==", + "expiration_time": 0, + "friendly_name": "", + "id": "projects/cloudskiff-dev-elie/datasets/example_dataset/tables/bar", + "last_modified_time": 1634649708609, + "location": "EU", + "num_bytes": 0, + "num_long_term_bytes": 0, + "num_rows": 0, + "project": "cloudskiff-dev-elie", + "schema": "[{\"description\":\"foobar\",\"mode\":\"NULLABLE\",\"name\":\"bar\",\"type\":\"STRING\"}]", + "self_link": "https://bigquery.googleapis.com/bigquery/v2/projects/cloudskiff-dev-elie/datasets/example_dataset/tables/bar", + "table_id": "bar", + "type": "TABLE" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_bigtable_instance/expected.json b/pkg/test/google/3.78.0/google_bigtable_instance/expected.json new file mode 100755 index 000000000..8987fb560 --- /dev/null +++ b/pkg/test/google/3.78.0/google_bigtable_instance/expected.json @@ -0,0 +1,23 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/instances/tf-instance", + "Type": "google_bigtable_instance", + "Attrs": { + "cluster": [ + { + "cluster_id": "tf-instance-cluster", + "kms_key_name": "", + "num_nodes": 1, + "storage_type": "HDD", + "zone": "us-central1-a" + } + ], + "deletion_protection": false, + "display_name": "tf-instance", + "id": "projects/cloudskiff-dev-elie/instances/tf-instance", + "instance_type": "PRODUCTION", + "name": "tf-instance", + "project": "cloudskiff-dev-elie" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_bigtable_instance/input.json b/pkg/test/google/3.78.0/google_bigtable_instance/input.json new file mode 100755 index 000000000..8987fb560 --- /dev/null +++ b/pkg/test/google/3.78.0/google_bigtable_instance/input.json @@ -0,0 +1,23 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/instances/tf-instance", + "Type": "google_bigtable_instance", + "Attrs": { + "cluster": [ + { + "cluster_id": "tf-instance-cluster", + "kms_key_name": "", + "num_nodes": 1, + "storage_type": "HDD", + "zone": "us-central1-a" + } + ], + "deletion_protection": false, + "display_name": "tf-instance", + "id": "projects/cloudskiff-dev-elie/instances/tf-instance", + "instance_type": "PRODUCTION", + "name": "tf-instance", + "project": "cloudskiff-dev-elie" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_bigtable_table/expected.json b/pkg/test/google/3.78.0/google_bigtable_table/expected.json new file mode 100755 index 000000000..ac79ccbb5 --- /dev/null +++ b/pkg/test/google/3.78.0/google_bigtable_table/expected.json @@ -0,0 +1,12 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/instances/tf-instance/tables/tf-table", + "Type": "google_bigtable_table", + "Attrs": { + "id": "projects/cloudskiff-dev-elie/instances/tf-instance/tables/tf-table", + "instance_name": "tf-instance", + "name": "tf-table", + "project": "cloudskiff-dev-elie" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_bigtable_table/input.json b/pkg/test/google/3.78.0/google_bigtable_table/input.json new file mode 100755 index 000000000..ac79ccbb5 --- /dev/null +++ b/pkg/test/google/3.78.0/google_bigtable_table/input.json @@ -0,0 +1,12 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/instances/tf-instance/tables/tf-table", + "Type": "google_bigtable_table", + "Attrs": { + "id": "projects/cloudskiff-dev-elie/instances/tf-instance/tables/tf-table", + "instance_name": "tf-instance", + "name": "tf-table", + "project": "cloudskiff-dev-elie" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_cloudfunctions_function/expected.json b/pkg/test/google/3.78.0/google_cloudfunctions_function/expected.json new file mode 100755 index 000000000..e23bf818d --- /dev/null +++ b/pkg/test/google/3.78.0/google_cloudfunctions_function/expected.json @@ -0,0 +1,26 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/locations/us-central1/functions/function-test", + "Type": "google_cloudfunctions_function", + "Attrs": { + "available_memory_mb": 128, + "description": "My function", + "entry_point": "helloHttp", + "https_trigger_url": "https://us-central1-cloudskiff-dev-elie.cloudfunctions.net/function-test", + "id": "projects/cloudskiff-dev-elie/locations/us-central1/functions/function-test", + "ingress_settings": "ALLOW_ALL", + "max_instances": 0, + "name": "function-test", + "project": "cloudskiff-dev-elie", + "region": "us-central1", + "runtime": "nodejs14", + "service_account_email": "cloudskiff-dev-elie@appspot.gserviceaccount.com", + "source_archive_bucket": "test-bucket-driftctl", + "source_archive_object": "index.zip", + "timeout": 60, + "trigger_http": true, + "vpc_connector": "", + "vpc_connector_egress_settings": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_cloudfunctions_function/input.json b/pkg/test/google/3.78.0/google_cloudfunctions_function/input.json new file mode 100755 index 000000000..e23bf818d --- /dev/null +++ b/pkg/test/google/3.78.0/google_cloudfunctions_function/input.json @@ -0,0 +1,26 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/locations/us-central1/functions/function-test", + "Type": "google_cloudfunctions_function", + "Attrs": { + "available_memory_mb": 128, + "description": "My function", + "entry_point": "helloHttp", + "https_trigger_url": "https://us-central1-cloudskiff-dev-elie.cloudfunctions.net/function-test", + "id": "projects/cloudskiff-dev-elie/locations/us-central1/functions/function-test", + "ingress_settings": "ALLOW_ALL", + "max_instances": 0, + "name": "function-test", + "project": "cloudskiff-dev-elie", + "region": "us-central1", + "runtime": "nodejs14", + "service_account_email": "cloudskiff-dev-elie@appspot.gserviceaccount.com", + "source_archive_bucket": "test-bucket-driftctl", + "source_archive_object": "index.zip", + "timeout": 60, + "trigger_http": true, + "vpc_connector": "", + "vpc_connector_egress_settings": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_address/expected.json b/pkg/test/google/3.78.0/google_compute_address/expected.json new file mode 100755 index 000000000..959481699 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_address/expected.json @@ -0,0 +1,22 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/regions/us-central1/addresses/my-address", + "Type": "google_compute_address", + "Attrs": { + "address": "34.136.69.225", + "address_type": "EXTERNAL", + "creation_timestamp": "2021-10-19T02:29:32.175-07:00", + "description": "", + "id": "projects/cloudskiff-dev-elie/regions/us-central1/addresses/my-address", + "name": "my-address", + "network": "", + "network_tier": "PREMIUM", + "prefix_length": 0, + "project": "cloudskiff-dev-elie", + "purpose": "", + "region": "us-central1", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/regions/us-central1/addresses/my-address", + "subnetwork": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_address/input.json b/pkg/test/google/3.78.0/google_compute_address/input.json new file mode 100755 index 000000000..959481699 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_address/input.json @@ -0,0 +1,22 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/regions/us-central1/addresses/my-address", + "Type": "google_compute_address", + "Attrs": { + "address": "34.136.69.225", + "address_type": "EXTERNAL", + "creation_timestamp": "2021-10-19T02:29:32.175-07:00", + "description": "", + "id": "projects/cloudskiff-dev-elie/regions/us-central1/addresses/my-address", + "name": "my-address", + "network": "", + "network_tier": "PREMIUM", + "prefix_length": 0, + "project": "cloudskiff-dev-elie", + "purpose": "", + "region": "us-central1", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/regions/us-central1/addresses/my-address", + "subnetwork": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_disk/expected.json b/pkg/test/google/3.78.0/google_compute_disk/expected.json new file mode 100755 index 000000000..422e90162 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_disk/expected.json @@ -0,0 +1,26 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/zones/us-central1-a/disks/test-disk", + "Type": "google_compute_disk", + "Attrs": { + "creation_timestamp": "2021-10-25T07:13:00.035-07:00", + "description": "", + "id": "projects/cloudskiff-dev-elie/zones/us-central1-a/disks/test-disk", + "image": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-9-stretch-v20200805", + "label_fingerprint": "42WmSpB8rSM=", + "last_attach_timestamp": "", + "last_detach_timestamp": "", + "name": "test-disk", + "physical_block_size_bytes": 4096, + "project": "cloudskiff-dev-elie", + "provisioned_iops": 0, + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/zones/us-central1-a/disks/test-disk", + "size": 10, + "snapshot": "", + "source_image_id": "6709658075886210235", + "source_snapshot_id": "", + "type": "pd-standard", + "zone": "us-central1-a" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_disk/input.json b/pkg/test/google/3.78.0/google_compute_disk/input.json new file mode 100755 index 000000000..422e90162 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_disk/input.json @@ -0,0 +1,26 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/zones/us-central1-a/disks/test-disk", + "Type": "google_compute_disk", + "Attrs": { + "creation_timestamp": "2021-10-25T07:13:00.035-07:00", + "description": "", + "id": "projects/cloudskiff-dev-elie/zones/us-central1-a/disks/test-disk", + "image": "https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/debian-9-stretch-v20200805", + "label_fingerprint": "42WmSpB8rSM=", + "last_attach_timestamp": "", + "last_detach_timestamp": "", + "name": "test-disk", + "physical_block_size_bytes": 4096, + "project": "cloudskiff-dev-elie", + "provisioned_iops": 0, + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/zones/us-central1-a/disks/test-disk", + "size": 10, + "snapshot": "", + "source_image_id": "6709658075886210235", + "source_snapshot_id": "", + "type": "pd-standard", + "zone": "us-central1-a" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_firewall/expected.json b/pkg/test/google/3.78.0/google_compute_firewall/expected.json new file mode 100755 index 000000000..34cebb3d2 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_firewall/expected.json @@ -0,0 +1,98 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-1", + "Type": "google_compute_firewall", + "Attrs": { + "allow": [ + { + "ports": [ + "80", + "8080", + "1000-2000" + ], + "protocol": "tcp" + }, + { + "protocol": "icmp" + } + ], + "creation_timestamp": "2021-09-14T05:21:08.730-07:00", + "description": "", + "direction": "INGRESS", + "disabled": false, + "id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-1", + "name": "test-firewall-1", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/networks/test-network", + "priority": 1000, + "project": "cloudskiff-dev-elie", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/firewalls/test-firewall-1", + "source_tags": [ + "web" + ] + } + }, + { + "Id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-0", + "Type": "google_compute_firewall", + "Attrs": { + "allow": [ + { + "ports": [ + "80", + "8080", + "1000-2000" + ], + "protocol": "tcp" + }, + { + "protocol": "icmp" + } + ], + "creation_timestamp": "2021-09-14T05:21:08.744-07:00", + "description": "", + "direction": "INGRESS", + "disabled": false, + "id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-0", + "name": "test-firewall-0", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/networks/test-network", + "priority": 1000, + "project": "cloudskiff-dev-elie", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/firewalls/test-firewall-0", + "source_tags": [ + "web" + ] + } + }, + { + "Id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-2", + "Type": "google_compute_firewall", + "Attrs": { + "allow": [ + { + "ports": [ + "80", + "8080", + "1000-2000" + ], + "protocol": "tcp" + }, + { + "protocol": "icmp" + } + ], + "creation_timestamp": "2021-09-14T05:21:08.624-07:00", + "description": "", + "direction": "INGRESS", + "disabled": false, + "id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-2", + "name": "test-firewall-2", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/networks/test-network", + "priority": 1000, + "project": "cloudskiff-dev-elie", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/firewalls/test-firewall-2", + "source_tags": [ + "web" + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_firewall/input.json b/pkg/test/google/3.78.0/google_compute_firewall/input.json new file mode 100755 index 000000000..896c05d10 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_firewall/input.json @@ -0,0 +1,128 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-1", + "Type": "google_compute_firewall", + "Attrs": { + "allow": [ + { + "ports": [ + "80", + "8080", + "1000-2000" + ], + "protocol": "tcp" + }, + { + "ports": [], + "protocol": "icmp" + } + ], + "creation_timestamp": "2021-09-14T05:21:08.730-07:00", + "deny": [], + "description": "", + "destination_ranges": [], + "direction": "INGRESS", + "disabled": false, + "enable_logging": null, + "id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-1", + "log_config": [], + "name": "test-firewall-1", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/networks/test-network", + "priority": 1000, + "project": "cloudskiff-dev-elie", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/firewalls/test-firewall-1", + "source_ranges": [], + "source_service_accounts": [], + "source_tags": [ + "web" + ], + "target_service_accounts": [], + "target_tags": [], + "timeouts": {} + } + }, + { + "Id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-0", + "Type": "google_compute_firewall", + "Attrs": { + "allow": [ + { + "ports": [ + "80", + "8080", + "1000-2000" + ], + "protocol": "tcp" + }, + { + "ports": [], + "protocol": "icmp" + } + ], + "creation_timestamp": "2021-09-14T05:21:08.744-07:00", + "deny": [], + "description": "", + "destination_ranges": [], + "direction": "INGRESS", + "disabled": false, + "enable_logging": null, + "id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-0", + "log_config": [], + "name": "test-firewall-0", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/networks/test-network", + "priority": 1000, + "project": "cloudskiff-dev-elie", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/firewalls/test-firewall-0", + "source_ranges": [], + "source_service_accounts": [], + "source_tags": [ + "web" + ], + "target_service_accounts": [], + "target_tags": [], + "timeouts": {} + } + }, + { + "Id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-2", + "Type": "google_compute_firewall", + "Attrs": { + "allow": [ + { + "ports": [ + "80", + "8080", + "1000-2000" + ], + "protocol": "tcp" + }, + { + "ports": [], + "protocol": "icmp" + } + ], + "creation_timestamp": "2021-09-14T05:21:08.624-07:00", + "deny": [], + "description": "", + "destination_ranges": [], + "direction": "INGRESS", + "disabled": false, + "enable_logging": null, + "id": "projects/cloudskiff-dev-elie/global/firewalls/test-firewall-2", + "log_config": [], + "name": "test-firewall-2", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/networks/test-network", + "priority": 1000, + "project": "cloudskiff-dev-elie", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/firewalls/test-firewall-2", + "source_ranges": [], + "source_service_accounts": [], + "source_tags": [ + "web" + ], + "target_service_accounts": [], + "target_tags": [], + "timeouts": {} + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_forwarding_rule/expected.json b/pkg/test/google/3.78.0/google_compute_forwarding_rule/expected.json new file mode 100755 index 000000000..7dc4d5d96 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_forwarding_rule/expected.json @@ -0,0 +1,29 @@ +[ + { + "Id": "projects/cloudskiff-dev-william/regions/us-east1/forwardingRules/website-forwarding-rule", + "Type": "google_compute_forwarding_rule", + "Attrs": { + "all_ports": false, + "allow_global_access": false, + "backend_service": "", + "creation_timestamp": "2022-03-16T08:39:19.861-07:00", + "description": "", + "id": "projects/cloudskiff-dev-william/regions/us-east1/forwardingRules/website-forwarding-rule", + "ip_address": "35.231.108.206", + "ip_protocol": "TCP", + "is_mirroring_collector": false, + "load_balancing_scheme": "EXTERNAL", + "name": "website-forwarding-rule", + "network": "", + "network_tier": "PREMIUM", + "port_range": "80", + "project": "cloudskiff-dev-william", + "region": "us-east1", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-william/regions/us-east1/forwardingRules/website-forwarding-rule", + "service_label": "", + "service_name": "", + "subnetwork": "", + "target": "projects/cloudskiff-dev-william/regions/us-east1/targetPools/website-target-pool" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_forwarding_rule/input.json b/pkg/test/google/3.78.0/google_compute_forwarding_rule/input.json new file mode 100755 index 000000000..7dc4d5d96 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_forwarding_rule/input.json @@ -0,0 +1,29 @@ +[ + { + "Id": "projects/cloudskiff-dev-william/regions/us-east1/forwardingRules/website-forwarding-rule", + "Type": "google_compute_forwarding_rule", + "Attrs": { + "all_ports": false, + "allow_global_access": false, + "backend_service": "", + "creation_timestamp": "2022-03-16T08:39:19.861-07:00", + "description": "", + "id": "projects/cloudskiff-dev-william/regions/us-east1/forwardingRules/website-forwarding-rule", + "ip_address": "35.231.108.206", + "ip_protocol": "TCP", + "is_mirroring_collector": false, + "load_balancing_scheme": "EXTERNAL", + "name": "website-forwarding-rule", + "network": "", + "network_tier": "PREMIUM", + "port_range": "80", + "project": "cloudskiff-dev-william", + "region": "us-east1", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-william/regions/us-east1/forwardingRules/website-forwarding-rule", + "service_label": "", + "service_name": "", + "subnetwork": "", + "target": "projects/cloudskiff-dev-william/regions/us-east1/targetPools/website-target-pool" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_global_address/expected.json b/pkg/test/google/3.78.0/google_compute_global_address/expected.json new file mode 100755 index 000000000..87671211d --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_global_address/expected.json @@ -0,0 +1,20 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/global/addresses/global-appserver-ip", + "Type": "google_compute_global_address", + "Attrs": { + "address": "107.178.250.143", + "address_type": "EXTERNAL", + "creation_timestamp": "2021-10-26T07:43:18.117-07:00", + "description": "", + "id": "projects/cloudskiff-dev-elie/global/addresses/global-appserver-ip", + "ip_version": "", + "name": "global-appserver-ip", + "network": "", + "prefix_length": 0, + "project": "cloudskiff-dev-elie", + "purpose": "", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/addresses/global-appserver-ip" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_global_address/input.json b/pkg/test/google/3.78.0/google_compute_global_address/input.json new file mode 100755 index 000000000..87671211d --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_global_address/input.json @@ -0,0 +1,20 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/global/addresses/global-appserver-ip", + "Type": "google_compute_global_address", + "Attrs": { + "address": "107.178.250.143", + "address_type": "EXTERNAL", + "creation_timestamp": "2021-10-26T07:43:18.117-07:00", + "description": "", + "id": "projects/cloudskiff-dev-elie/global/addresses/global-appserver-ip", + "ip_version": "", + "name": "global-appserver-ip", + "network": "", + "prefix_length": 0, + "project": "cloudskiff-dev-elie", + "purpose": "", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/addresses/global-appserver-ip" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_global_forwarding_rule/expected.json b/pkg/test/google/3.78.0/google_compute_global_forwarding_rule/expected.json new file mode 100755 index 000000000..8121137ab --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_global_forwarding_rule/expected.json @@ -0,0 +1,19 @@ +[ + { + "Id": "projects/driftctl-qa-1/global/forwardingRules/global-rule", + "Type": "google_compute_global_forwarding_rule", + "Attrs": { + "description": "", + "id": "projects/driftctl-qa-1/global/forwardingRules/global-rule", + "ip_address": "34.120.169.13", + "ip_protocol": "TCP", + "ip_version": "", + "load_balancing_scheme": "EXTERNAL", + "name": "global-rule", + "port_range": "80", + "project": "driftctl-qa-1", + "self_link": "https://www.googleapis.com/compute/v1/projects/driftctl-qa-1/global/forwardingRules/global-rule", + "target": "projects/driftctl-qa-1/global/targetHttpProxies/target-proxy" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_global_forwarding_rule/input.json b/pkg/test/google/3.78.0/google_compute_global_forwarding_rule/input.json new file mode 100755 index 000000000..8121137ab --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_global_forwarding_rule/input.json @@ -0,0 +1,19 @@ +[ + { + "Id": "projects/driftctl-qa-1/global/forwardingRules/global-rule", + "Type": "google_compute_global_forwarding_rule", + "Attrs": { + "description": "", + "id": "projects/driftctl-qa-1/global/forwardingRules/global-rule", + "ip_address": "34.120.169.13", + "ip_protocol": "TCP", + "ip_version": "", + "load_balancing_scheme": "EXTERNAL", + "name": "global-rule", + "port_range": "80", + "project": "driftctl-qa-1", + "self_link": "https://www.googleapis.com/compute/v1/projects/driftctl-qa-1/global/forwardingRules/global-rule", + "target": "projects/driftctl-qa-1/global/targetHttpProxies/target-proxy" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_health_check/expected.json b/pkg/test/google/3.78.0/google_compute_health_check/expected.json new file mode 100755 index 000000000..b12ef1f1b --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_health_check/expected.json @@ -0,0 +1,35 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/global/healthChecks/https-health-check", + "Type": "google_compute_health_check", + "Attrs": { + "check_interval_sec": 3, + "creation_timestamp": "2021-10-26T06:05:03.005-07:00", + "description": "Health check via https", + "healthy_threshold": 4, + "https_health_check": [ + { + "host": "crvx.fr", + "port": 0, + "port_name": "health-check-port", + "port_specification": "USE_NAMED_PORT", + "proxy_header": "NONE", + "request_path": "/", + "response": "I AM HEALTHY" + } + ], + "id": "projects/cloudskiff-dev-raphael/global/healthChecks/https-health-check", + "log_config": [ + { + "enable": false + } + ], + "name": "https-health-check", + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/healthChecks/https-health-check", + "timeout_sec": 1, + "type": "HTTPS", + "unhealthy_threshold": 5 + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_health_check/input.json b/pkg/test/google/3.78.0/google_compute_health_check/input.json new file mode 100755 index 000000000..b12ef1f1b --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_health_check/input.json @@ -0,0 +1,35 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/global/healthChecks/https-health-check", + "Type": "google_compute_health_check", + "Attrs": { + "check_interval_sec": 3, + "creation_timestamp": "2021-10-26T06:05:03.005-07:00", + "description": "Health check via https", + "healthy_threshold": 4, + "https_health_check": [ + { + "host": "crvx.fr", + "port": 0, + "port_name": "health-check-port", + "port_specification": "USE_NAMED_PORT", + "proxy_header": "NONE", + "request_path": "/", + "response": "I AM HEALTHY" + } + ], + "id": "projects/cloudskiff-dev-raphael/global/healthChecks/https-health-check", + "log_config": [ + { + "enable": false + } + ], + "name": "https-health-check", + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/healthChecks/https-health-check", + "timeout_sec": 1, + "type": "HTTPS", + "unhealthy_threshold": 5 + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_image/expected.json b/pkg/test/google/3.78.0/google_compute_image/expected.json new file mode 100755 index 000000000..8cc75da4e --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_image/expected.json @@ -0,0 +1,28 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/global/images/example-image", + "Type": "google_compute_image", + "Attrs": { + "archive_size_bytes": 539099200, + "creation_timestamp": "2021-10-27T07:18:35.424-07:00", + "description": "", + "disk_size_gb": 3, + "family": "", + "id": "projects/cloudskiff-dev-elie/global/images/example-image", + "label_fingerprint": "42WmSpB8rSM=", + "name": "example-image", + "project": "cloudskiff-dev-elie", + "raw_disk": [ + { + "container_type": "TAR", + "sha1": "", + "source": "https://storage.googleapis.com/bosh-gce-raw-stemcells/bosh-stemcell-97.98-google-kvm-ubuntu-xenial-go_agent-raw-1557960142.tar.gz" + } + ], + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/images/example-image", + "source_disk": "", + "source_image": "", + "source_snapshot": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_image/input.json b/pkg/test/google/3.78.0/google_compute_image/input.json new file mode 100755 index 000000000..8cc75da4e --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_image/input.json @@ -0,0 +1,28 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/global/images/example-image", + "Type": "google_compute_image", + "Attrs": { + "archive_size_bytes": 539099200, + "creation_timestamp": "2021-10-27T07:18:35.424-07:00", + "description": "", + "disk_size_gb": 3, + "family": "", + "id": "projects/cloudskiff-dev-elie/global/images/example-image", + "label_fingerprint": "42WmSpB8rSM=", + "name": "example-image", + "project": "cloudskiff-dev-elie", + "raw_disk": [ + { + "container_type": "TAR", + "sha1": "", + "source": "https://storage.googleapis.com/bosh-gce-raw-stemcells/bosh-stemcell-97.98-google-kvm-ubuntu-xenial-go_agent-raw-1557960142.tar.gz" + } + ], + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-elie/global/images/example-image", + "source_disk": "", + "source_image": "", + "source_snapshot": "" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_instance/expected.json b/pkg/test/google/3.78.0/google_compute_instance/expected.json new file mode 100755 index 000000000..621b2d249 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_instance/expected.json @@ -0,0 +1,30 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "Type": "google_compute_instance", + "Attrs": { + "description": "Terraform test instance group", + "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "name": "driftctl-test-2", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network", + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "size": 0, + "zone": "us-central1-a" + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "Type": "google_compute_instance", + "Attrs": { + "description": "Terraform test instance group", + "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "name": "driftctl-test-1", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network", + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "size": 0, + "zone": "us-central1-a" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_instance/input.json b/pkg/test/google/3.78.0/google_compute_instance/input.json new file mode 100755 index 000000000..d31365e4b --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_instance/input.json @@ -0,0 +1,36 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "Type": "google_compute_instance", + "Attrs": { + "description": "Terraform test instance group", + "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "instances": [], + "name": "driftctl-test-2", + "named_port": [], + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network", + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "size": 0, + "timeouts": {}, + "zone": "us-central1-a" + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "Type": "google_compute_instance", + "Attrs": { + "description": "Terraform test instance group", + "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "instances": [], + "name": "driftctl-test-1", + "named_port": [], + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network", + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "size": 0, + "timeouts": {}, + "zone": "us-central1-a" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_instance_group/expected.json b/pkg/test/google/3.78.0/google_compute_instance_group/expected.json new file mode 100755 index 000000000..faca6aa6c --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_instance_group/expected.json @@ -0,0 +1,30 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "Type": "google_compute_instance_group", + "Attrs": { + "description": "Terraform test instance group", + "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "name": "driftctl-test-2", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network", + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "size": 0, + "zone": "us-central1-a" + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "Type": "google_compute_instance_group", + "Attrs": { + "description": "Terraform test instance group", + "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "name": "driftctl-test-1", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network", + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "size": 0, + "zone": "us-central1-a" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_instance_group/input.json b/pkg/test/google/3.78.0/google_compute_instance_group/input.json new file mode 100755 index 000000000..c5872c132 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_instance_group/input.json @@ -0,0 +1,36 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "Type": "google_compute_instance_group", + "Attrs": { + "description": "Terraform test instance group", + "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "instances": [], + "name": "driftctl-test-2", + "named_port": [], + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network", + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-2", + "size": 0, + "timeouts": {}, + "zone": "us-central1-a" + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "Type": "google_compute_instance_group", + "Attrs": { + "description": "Terraform test instance group", + "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "instances": [], + "name": "driftctl-test-1", + "named_port": [], + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network", + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/driftctl-test-1", + "size": 0, + "timeouts": {}, + "zone": "us-central1-a" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_instance_group_manager/expected.json b/pkg/test/google/3.78.0/google_compute_instance_group_manager/expected.json new file mode 100755 index 000000000..f683560e6 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_instance_group_manager/expected.json @@ -0,0 +1,70 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroupManagers/appserver-igm", + "Type": "google_compute_instance_group_manager", + "Attrs": { + "auto_healing_policies": [ + { + "health_check": "https://www.googleapis.com/compute/beta/projects/cloudskiff-dev-raphael/global/healthChecks/autohealing-health-check", + "initial_delay_sec": 300 + } + ], + "base_instance_name": "app", + "description": "", + "fingerprint": "0ZOcDOzIVtg=", + "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroupManagers/appserver-igm", + "instance_group": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/appserver-igm", + "name": "appserver-igm", + "named_port": [ + { + "name": "customhttp", + "port": 8888 + } + ], + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroupManagers/appserver-igm", + "status": [ + { + "is_stable": false, + "stateful": [ + { + "has_stateful_config": false, + "per_instance_configs": [ + { + "all_effective": true + } + ] + } + ], + "version_target": [ + { + "is_reached": true + } + ] + } + ], + "target_size": 2, + "update_policy": [ + { + "max_surge_fixed": 1, + "max_surge_percent": 0, + "max_unavailable_fixed": 1, + "max_unavailable_percent": 0, + "min_ready_sec": 0, + "minimal_action": "REPLACE", + "replacement_method": "SUBSTITUTE", + "type": "OPPORTUNISTIC" + } + ], + "version": [ + { + "instance_template": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/instanceTemplates/instance-template-21879620220309131441473100000001", + "name": "" + } + ], + "wait_for_instances": false, + "wait_for_instances_status": "STABLE", + "zone": "us-central1-a" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_instance_group_manager/input.json b/pkg/test/google/3.78.0/google_compute_instance_group_manager/input.json new file mode 100755 index 000000000..f683560e6 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_instance_group_manager/input.json @@ -0,0 +1,70 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroupManagers/appserver-igm", + "Type": "google_compute_instance_group_manager", + "Attrs": { + "auto_healing_policies": [ + { + "health_check": "https://www.googleapis.com/compute/beta/projects/cloudskiff-dev-raphael/global/healthChecks/autohealing-health-check", + "initial_delay_sec": 300 + } + ], + "base_instance_name": "app", + "description": "", + "fingerprint": "0ZOcDOzIVtg=", + "id": "projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroupManagers/appserver-igm", + "instance_group": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroups/appserver-igm", + "name": "appserver-igm", + "named_port": [ + { + "name": "customhttp", + "port": 8888 + } + ], + "project": "cloudskiff-dev-raphael", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/zones/us-central1-a/instanceGroupManagers/appserver-igm", + "status": [ + { + "is_stable": false, + "stateful": [ + { + "has_stateful_config": false, + "per_instance_configs": [ + { + "all_effective": true + } + ] + } + ], + "version_target": [ + { + "is_reached": true + } + ] + } + ], + "target_size": 2, + "update_policy": [ + { + "max_surge_fixed": 1, + "max_surge_percent": 0, + "max_unavailable_fixed": 1, + "max_unavailable_percent": 0, + "min_ready_sec": 0, + "minimal_action": "REPLACE", + "replacement_method": "SUBSTITUTE", + "type": "OPPORTUNISTIC" + } + ], + "version": [ + { + "instance_template": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/instanceTemplates/instance-template-21879620220309131441473100000001", + "name": "" + } + ], + "wait_for_instances": false, + "wait_for_instances_status": "STABLE", + "zone": "us-central1-a" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_network/expected.json b/pkg/test/google/3.78.0/google_compute_network/expected.json new file mode 100755 index 000000000..b06dfc1b2 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_network/expected.json @@ -0,0 +1,41 @@ +[ + { + "Id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-3", + "Type": "google_compute_network", + "Attrs": { + "auto_create_subnetworks": false, + "description": "", + "id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-3", + "mtu": 1460, + "name": "driftctl-unittest-3", + "project": "driftctl-qa-1", + "routing_mode": "REGIONAL" + } + }, + { + "Id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-2", + "Type": "google_compute_network", + "Attrs": { + "auto_create_subnetworks": true, + "description": "", + "id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-2", + "mtu": 1460, + "name": "driftctl-unittest-2", + "project": "driftctl-qa-1", + "routing_mode": "REGIONAL" + } + }, + { + "Id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-1", + "Type": "google_compute_network", + "Attrs": { + "auto_create_subnetworks": false, + "description": "", + "id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-1", + "mtu": 1460, + "name": "driftctl-unittest-1", + "project": "driftctl-qa-1", + "routing_mode": "REGIONAL" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_network/input.json b/pkg/test/google/3.78.0/google_compute_network/input.json new file mode 100755 index 000000000..66a9515e7 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_network/input.json @@ -0,0 +1,53 @@ +[ + { + "Id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-3", + "Type": "google_compute_network", + "Attrs": { + "auto_create_subnetworks": false, + "delete_default_routes_on_create": false, + "description": "", + "gateway_ipv4": "", + "id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-3", + "mtu": 1460, + "name": "driftctl-unittest-3", + "project": "driftctl-qa-1", + "routing_mode": "REGIONAL", + "self_link": "https://www.googleapis.com/compute/v1/projects/driftctl-qa-1/global/networks/driftctl-unittest-3", + "timeouts": {} + } + }, + { + "Id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-2", + "Type": "google_compute_network", + "Attrs": { + "auto_create_subnetworks": true, + "delete_default_routes_on_create": false, + "description": "", + "gateway_ipv4": "", + "id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-2", + "mtu": 1460, + "name": "driftctl-unittest-2", + "project": "driftctl-qa-1", + "routing_mode": "REGIONAL", + "self_link": "https://www.googleapis.com/compute/v1/projects/driftctl-qa-1/global/networks/driftctl-unittest-2", + "timeouts": {} + } + }, + { + "Id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-1", + "Type": "google_compute_network", + "Attrs": { + "auto_create_subnetworks": false, + "delete_default_routes_on_create": false, + "description": "", + "gateway_ipv4": "", + "id": "projects/driftctl-qa-1/global/networks/driftctl-unittest-1", + "mtu": 1460, + "name": "driftctl-unittest-1", + "project": "driftctl-qa-1", + "routing_mode": "REGIONAL", + "self_link": "https://www.googleapis.com/compute/v1/projects/driftctl-qa-1/global/networks/driftctl-unittest-1", + "timeouts": {} + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_node_group/expected.json b/pkg/test/google/3.78.0/google_compute_node_group/expected.json new file mode 100755 index 000000000..35b12c9fc --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_node_group/expected.json @@ -0,0 +1,54 @@ +[ + { + "Id": "projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/soletenant-group", + "Type": "google_compute_node_group", + "Attrs": { + "autoscaling_policy": [ + { + "max_nodes": 10, + "min_nodes": 1, + "mode": "ONLY_SCALE_OUT" + } + ], + "creation_timestamp": "2021-12-01T08:49:24.545-08:00", + "description": "example google_compute_node_group for Terraform Google Provider", + "id": "projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/soletenant-group", + "initial_size": 1, + "maintenance_policy": "RESTART_IN_PLACE", + "maintenance_window": [ + { + "start_time": "08:00" + } + ], + "name": "soletenant-group", + "node_template": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-martin/regions/us-central1/nodeTemplates/soletenant-tmpl", + "project": "cloudskiff-dev-martin", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/soletenant-group", + "size": 1, + "zone": "us-central1-f" + } + }, + { + "Id": "projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/simple-group", + "Type": "google_compute_node_group", + "Attrs": { + "autoscaling_policy": [ + { + "max_nodes": 0, + "min_nodes": 0, + "mode": "OFF" + } + ], + "creation_timestamp": "2021-12-01T08:49:24.740-08:00", + "description": "example google_compute_node_group for Terraform Google Provider", + "id": "projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/simple-group", + "maintenance_policy": "DEFAULT", + "name": "simple-group", + "node_template": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-martin/regions/us-central1/nodeTemplates/soletenant-tmpl", + "project": "cloudskiff-dev-martin", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/simple-group", + "size": 1, + "zone": "us-central1-f" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_node_group/input.json b/pkg/test/google/3.78.0/google_compute_node_group/input.json new file mode 100755 index 000000000..35b12c9fc --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_node_group/input.json @@ -0,0 +1,54 @@ +[ + { + "Id": "projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/soletenant-group", + "Type": "google_compute_node_group", + "Attrs": { + "autoscaling_policy": [ + { + "max_nodes": 10, + "min_nodes": 1, + "mode": "ONLY_SCALE_OUT" + } + ], + "creation_timestamp": "2021-12-01T08:49:24.545-08:00", + "description": "example google_compute_node_group for Terraform Google Provider", + "id": "projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/soletenant-group", + "initial_size": 1, + "maintenance_policy": "RESTART_IN_PLACE", + "maintenance_window": [ + { + "start_time": "08:00" + } + ], + "name": "soletenant-group", + "node_template": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-martin/regions/us-central1/nodeTemplates/soletenant-tmpl", + "project": "cloudskiff-dev-martin", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/soletenant-group", + "size": 1, + "zone": "us-central1-f" + } + }, + { + "Id": "projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/simple-group", + "Type": "google_compute_node_group", + "Attrs": { + "autoscaling_policy": [ + { + "max_nodes": 0, + "min_nodes": 0, + "mode": "OFF" + } + ], + "creation_timestamp": "2021-12-01T08:49:24.740-08:00", + "description": "example google_compute_node_group for Terraform Google Provider", + "id": "projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/simple-group", + "maintenance_policy": "DEFAULT", + "name": "simple-group", + "node_template": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-martin/regions/us-central1/nodeTemplates/soletenant-tmpl", + "project": "cloudskiff-dev-martin", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-martin/zones/us-central1-f/nodeGroups/simple-group", + "size": 1, + "zone": "us-central1-f" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_router/expected.json b/pkg/test/google/3.78.0/google_compute_router/expected.json new file mode 100755 index 000000000..987058a6e --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_router/expected.json @@ -0,0 +1,101 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-2", + "Type": "google_compute_router", + "Attrs": { + "bgp": [ + { + "advertise_mode": "CUSTOM", + "advertised_groups": [ + "ALL_SUBNETS" + ], + "advertised_ip_ranges": [ + { + "description": "", + "range": "1.2.3.4" + }, + { + "description": "", + "range": "6.7.0.0/16" + } + ], + "asn": 64514 + } + ], + "creation_timestamp": "2021-09-16T07:40:45.385-07:00", + "description": "", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-2", + "name": "test-router-2", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/my-network", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-2" + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-0", + "Type": "google_compute_router", + "Attrs": { + "bgp": [ + { + "advertise_mode": "CUSTOM", + "advertised_groups": [ + "ALL_SUBNETS" + ], + "advertised_ip_ranges": [ + { + "description": "", + "range": "1.2.3.4" + }, + { + "description": "", + "range": "6.7.0.0/16" + } + ], + "asn": 64514 + } + ], + "creation_timestamp": "2021-09-16T07:40:46.101-07:00", + "description": "", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-0", + "name": "test-router-0", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/my-network", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-0" + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-1", + "Type": "google_compute_router", + "Attrs": { + "bgp": [ + { + "advertise_mode": "CUSTOM", + "advertised_groups": [ + "ALL_SUBNETS" + ], + "advertised_ip_ranges": [ + { + "description": "", + "range": "1.2.3.4" + }, + { + "description": "", + "range": "6.7.0.0/16" + } + ], + "asn": 64514 + } + ], + "creation_timestamp": "2021-09-16T07:40:43.732-07:00", + "description": "", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-1", + "name": "test-router-1", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/my-network", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-1" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_router/input.json b/pkg/test/google/3.78.0/google_compute_router/input.json new file mode 100755 index 000000000..987058a6e --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_router/input.json @@ -0,0 +1,101 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-2", + "Type": "google_compute_router", + "Attrs": { + "bgp": [ + { + "advertise_mode": "CUSTOM", + "advertised_groups": [ + "ALL_SUBNETS" + ], + "advertised_ip_ranges": [ + { + "description": "", + "range": "1.2.3.4" + }, + { + "description": "", + "range": "6.7.0.0/16" + } + ], + "asn": 64514 + } + ], + "creation_timestamp": "2021-09-16T07:40:45.385-07:00", + "description": "", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-2", + "name": "test-router-2", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/my-network", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-2" + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-0", + "Type": "google_compute_router", + "Attrs": { + "bgp": [ + { + "advertise_mode": "CUSTOM", + "advertised_groups": [ + "ALL_SUBNETS" + ], + "advertised_ip_ranges": [ + { + "description": "", + "range": "1.2.3.4" + }, + { + "description": "", + "range": "6.7.0.0/16" + } + ], + "asn": 64514 + } + ], + "creation_timestamp": "2021-09-16T07:40:46.101-07:00", + "description": "", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-0", + "name": "test-router-0", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/my-network", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-0" + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-1", + "Type": "google_compute_router", + "Attrs": { + "bgp": [ + { + "advertise_mode": "CUSTOM", + "advertised_groups": [ + "ALL_SUBNETS" + ], + "advertised_ip_ranges": [ + { + "description": "", + "range": "1.2.3.4" + }, + { + "description": "", + "range": "6.7.0.0/16" + } + ], + "asn": 64514 + } + ], + "creation_timestamp": "2021-09-16T07:40:43.732-07:00", + "description": "", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-1", + "name": "test-router-1", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/my-network", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/routers/test-router-1" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_subnetwork/expected.json b/pkg/test/google/3.78.0/google_compute_subnetwork/expected.json new file mode 100755 index 000000000..d880492f9 --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_subnetwork/expected.json @@ -0,0 +1,71 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-1", + "Type": "google_compute_subnetwork", + "Attrs": { + "creation_timestamp": "2021-10-20T07:39:34.673-07:00", + "description": "", + "gateway_address": "10.2.0.1", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-1", + "ip_cidr_range": "10.2.0.0/16", + "name": "driftctl-unittest-1", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network-1871346572", + "private_ip_google_access": false, + "private_ipv6_google_access": "DISABLE_GOOGLE_ACCESS", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "secondary_ip_range": [ + { + "ip_cidr_range": "192.168.10.0/24", + "range_name": "tf-test-secondary-range-update1" + } + ] + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-2", + "Type": "google_compute_subnetwork", + "Attrs": { + "creation_timestamp": "2021-10-20T07:39:45.114-07:00", + "description": "", + "gateway_address": "10.2.0.1", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-2", + "ip_cidr_range": "10.2.0.0/16", + "name": "driftctl-unittest-2", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network-2871346572", + "private_ip_google_access": false, + "private_ipv6_google_access": "DISABLE_GOOGLE_ACCESS", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "secondary_ip_range": [ + { + "ip_cidr_range": "192.168.10.0/24", + "range_name": "tf-test-secondary-range-update1" + } + ] + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-3", + "Type": "google_compute_subnetwork", + "Attrs": { + "creation_timestamp": "2021-10-20T07:39:34.650-07:00", + "description": "", + "gateway_address": "10.2.0.1", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-3", + "ip_cidr_range": "10.2.0.0/16", + "name": "driftctl-unittest-3", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network-3871346572", + "private_ip_google_access": false, + "private_ipv6_google_access": "DISABLE_GOOGLE_ACCESS", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "secondary_ip_range": [ + { + "ip_cidr_range": "192.168.10.0/24", + "range_name": "tf-test-secondary-range-update1" + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_compute_subnetwork/input.json b/pkg/test/google/3.78.0/google_compute_subnetwork/input.json new file mode 100755 index 000000000..feb6590dd --- /dev/null +++ b/pkg/test/google/3.78.0/google_compute_subnetwork/input.json @@ -0,0 +1,83 @@ +[ + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-1", + "Type": "google_compute_subnetwork", + "Attrs": { + "creation_timestamp": "2021-10-20T07:39:34.673-07:00", + "description": "", + "fingerprint": null, + "gateway_address": "10.2.0.1", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-1", + "ip_cidr_range": "10.2.0.0/16", + "log_config": [], + "name": "driftctl-unittest-1", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network-1871346572", + "private_ip_google_access": false, + "private_ipv6_google_access": "DISABLE_GOOGLE_ACCESS", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "secondary_ip_range": [ + { + "ip_cidr_range": "192.168.10.0/24", + "range_name": "tf-test-secondary-range-update1" + } + ], + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-1", + "timeouts": {} + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-2", + "Type": "google_compute_subnetwork", + "Attrs": { + "creation_timestamp": "2021-10-20T07:39:45.114-07:00", + "description": "", + "fingerprint": null, + "gateway_address": "10.2.0.1", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-2", + "ip_cidr_range": "10.2.0.0/16", + "log_config": [], + "name": "driftctl-unittest-2", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network-2871346572", + "private_ip_google_access": false, + "private_ipv6_google_access": "DISABLE_GOOGLE_ACCESS", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "secondary_ip_range": [ + { + "ip_cidr_range": "192.168.10.0/24", + "range_name": "tf-test-secondary-range-update1" + } + ], + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-2", + "timeouts": {} + } + }, + { + "Id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-3", + "Type": "google_compute_subnetwork", + "Attrs": { + "creation_timestamp": "2021-10-20T07:39:34.650-07:00", + "description": "", + "fingerprint": null, + "gateway_address": "10.2.0.1", + "id": "projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-3", + "ip_cidr_range": "10.2.0.0/16", + "log_config": [], + "name": "driftctl-unittest-3", + "network": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/global/networks/test-network-3871346572", + "private_ip_google_access": false, + "private_ipv6_google_access": "DISABLE_GOOGLE_ACCESS", + "project": "cloudskiff-dev-raphael", + "region": "us-central1", + "secondary_ip_range": [ + { + "ip_cidr_range": "192.168.10.0/24", + "range_name": "tf-test-secondary-range-update1" + } + ], + "self_link": "https://www.googleapis.com/compute/v1/projects/cloudskiff-dev-raphael/regions/us-central1/subnetworks/driftctl-unittest-3", + "timeouts": {} + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_dns_managed_zone/expected.json b/pkg/test/google/3.78.0/google_dns_managed_zone/expected.json new file mode 100755 index 000000000..677dd0200 --- /dev/null +++ b/pkg/test/google/3.78.0/google_dns_managed_zone/expected.json @@ -0,0 +1,24 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/managedZones/example-zone", + "Type": "google_dns_managed_zone", + "Attrs": { + "description": "Example DNS zone", + "dns_name": "example-9d3bea2b.com.", + "force_destroy": false, + "id": "projects/cloudskiff-dev-elie/managedZones/example-zone", + "labels": { + "foo": "bar" + }, + "name": "example-zone", + "name_servers": [ + "ns-cloud-d1.googledomains.com.", + "ns-cloud-d2.googledomains.com.", + "ns-cloud-d3.googledomains.com.", + "ns-cloud-d4.googledomains.com." + ], + "project": "cloudskiff-dev-elie", + "visibility": "public" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_dns_managed_zone/input.json b/pkg/test/google/3.78.0/google_dns_managed_zone/input.json new file mode 100755 index 000000000..677dd0200 --- /dev/null +++ b/pkg/test/google/3.78.0/google_dns_managed_zone/input.json @@ -0,0 +1,24 @@ +[ + { + "Id": "projects/cloudskiff-dev-elie/managedZones/example-zone", + "Type": "google_dns_managed_zone", + "Attrs": { + "description": "Example DNS zone", + "dns_name": "example-9d3bea2b.com.", + "force_destroy": false, + "id": "projects/cloudskiff-dev-elie/managedZones/example-zone", + "labels": { + "foo": "bar" + }, + "name": "example-zone", + "name_servers": [ + "ns-cloud-d1.googledomains.com.", + "ns-cloud-d2.googledomains.com.", + "ns-cloud-d3.googledomains.com.", + "ns-cloud-d4.googledomains.com." + ], + "project": "cloudskiff-dev-elie", + "visibility": "public" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_sql_database_instance/expected.json b/pkg/test/google/3.78.0/google_sql_database_instance/expected.json new file mode 100755 index 000000000..d8b7dfe29 --- /dev/null +++ b/pkg/test/google/3.78.0/google_sql_database_instance/expected.json @@ -0,0 +1,81 @@ +[ + { + "Id": "my-database-instance", + "Type": "google_sql_database_instance", + "Attrs": { + "connection_name": "cloudskiff-dev-elie:us-central1:my-database-instance", + "database_version": "MYSQL_5_6", + "deletion_protection": true, + "first_ip_address": "34.72.72.233", + "id": "my-database-instance", + "ip_address": [ + { + "ip_address": "34.72.72.233", + "time_to_retire": "", + "type": "PRIMARY" + } + ], + "master_instance_name": "", + "name": "my-database-instance", + "private_ip_address": "", + "project": "cloudskiff-dev-elie", + "public_ip_address": "34.72.72.233", + "region": "us-central1", + "self_link": "https://sqladmin.googleapis.com/sql/v1beta4/projects/cloudskiff-dev-elie/instances/my-database-instance", + "server_ca_cert": [ + { + "cert": "-----BEGIN CERTIFICATE-----\nMIIDfzCCAmegAwIBAgIBADANBgkqhkiG9w0BAQsFADB3MS0wKwYDVQQuEyQzOTE2\nYmVhMC00Yjk1LTQ2NzYtODVmZi0zZDU0NDQ3ZTE0ZWMxIzAhBgNVBAMTGkdvb2ds\nZSBDbG91ZCBTUUwgU2VydmVyIENBMRQwEgYDVQQKEwtHb29nbGUsIEluYzELMAkG\nA1UEBhMCVVMwHhcNMjExMDI2MDg0MzAxWhcNMzExMDI0MDg0NDAxWjB3MS0wKwYD\nVQQuEyQzOTE2YmVhMC00Yjk1LTQ2NzYtODVmZi0zZDU0NDQ3ZTE0ZWMxIzAhBgNV\nBAMTGkdvb2dsZSBDbG91ZCBTUUwgU2VydmVyIENBMRQwEgYDVQQKEwtHb29nbGUs\nIEluYzELMAkGA1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\nAQCMPNNM+AI63en/OibDUs6Yt6rCZZDPW2IgTz9AbT8clH/ptC0K2Fao+Sxwu89S\ny2l4jZ1ENLMu7I32uQUJEE7a6a0BKCDUGfO6vC6t1wke3N5t/Uus1wcivmC4aEDR\nDOU2xctZ0EGqfVe5VYTsWMLZVBnk4aLad/nOseNxrldptfFLnLdc3s9RIr8bcpDV\nJW99Q0glWRVOf0heXuanlKkJ6fJ+05DEExE4sBQPx3aEDJLEjFlF//uJR/2oTbKL\nM9NM8Ihq+qWXOTe8TXUn7slJ1c/nJVCwPr3lj5PITeXotd5XkUbijHY4xoqMP+k2\n1YGbmbHL7Iyty+cqECEtQVeZAgMBAAGjFjAUMBIGA1UdEwEB/wQIMAYBAf8CAQAw\nDQYJKoZIhvcNAQELBQADggEBADDe8lUaXBzJoreG3S4avGNVfrL3J+wOItfBe7c/\nTHlVIxRCxLqN6sqEei2nPrhIQJKtH4LagqcWcUZ3a/PbucSmq5IOWf6XCF/U8vum\nqYHwhpyjuURCx8RaIuadPgGMwKb8R+pxdlGWNf99m2bsq+4R4OIegYIVKaKAC7Uy\n2QRHiHRrLGWQXqitwKfp3M+Wzx/XPx61+amVuQgukG2doBbEYzlygzeGN98Pa4FB\nNrVZPlVM2TtmVTyQxYZB3j+D19EobBwRIEpx6Lk9L1Bv8ZR1YQ38+aERIO6X+sac\n9EDLJ19OfGGyrcBi0fwaQEekb44IOFgG9NYiyJrpYR7xWTc=\n-----END CERTIFICATE-----", + "common_name": "C=US,O=Google\\, Inc,CN=Google Cloud SQL Server CA,dnQualifier=3916bea0-4b95-4676-85ff-3d54447e14ec", + "create_time": "2021-10-26T08:43:01.086Z", + "expiration_time": "2031-10-24T08:44:01.086Z", + "sha1_fingerprint": "966c305ef084de5cf152c0d33b0736666882d547" + } + ], + "service_account_email_address": "p260375416303-h0ilel@gcp-sa-cloud-sql.iam.gserviceaccount.com", + "settings": [ + { + "activation_policy": "ALWAYS", + "availability_type": "ZONAL", + "backup_configuration": [ + { + "backup_retention_settings": [ + { + "retained_backups": 7, + "retention_unit": "COUNT" + } + ], + "binary_log_enabled": false, + "enabled": false, + "location": "", + "point_in_time_recovery_enabled": false, + "start_time": "02:00", + "transaction_log_retention_days": 7 + } + ], + "crash_safe_replication": false, + "disk_autoresize": true, + "disk_autoresize_limit": 0, + "disk_size": 10, + "disk_type": "PD_SSD", + "ip_configuration": [ + { + "ipv4_enabled": true, + "private_network": "", + "require_ssl": false + } + ], + "location_preference": [ + { + "follow_gae_application": "", + "zone": "us-central1-f" + } + ], + "pricing_plan": "PER_USE", + "replication_type": "SYNCHRONOUS", + "tier": "db-f1-micro", + "version": 1 + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_sql_database_instance/input.json b/pkg/test/google/3.78.0/google_sql_database_instance/input.json new file mode 100755 index 000000000..d8b7dfe29 --- /dev/null +++ b/pkg/test/google/3.78.0/google_sql_database_instance/input.json @@ -0,0 +1,81 @@ +[ + { + "Id": "my-database-instance", + "Type": "google_sql_database_instance", + "Attrs": { + "connection_name": "cloudskiff-dev-elie:us-central1:my-database-instance", + "database_version": "MYSQL_5_6", + "deletion_protection": true, + "first_ip_address": "34.72.72.233", + "id": "my-database-instance", + "ip_address": [ + { + "ip_address": "34.72.72.233", + "time_to_retire": "", + "type": "PRIMARY" + } + ], + "master_instance_name": "", + "name": "my-database-instance", + "private_ip_address": "", + "project": "cloudskiff-dev-elie", + "public_ip_address": "34.72.72.233", + "region": "us-central1", + "self_link": "https://sqladmin.googleapis.com/sql/v1beta4/projects/cloudskiff-dev-elie/instances/my-database-instance", + "server_ca_cert": [ + { + "cert": "-----BEGIN CERTIFICATE-----\nMIIDfzCCAmegAwIBAgIBADANBgkqhkiG9w0BAQsFADB3MS0wKwYDVQQuEyQzOTE2\nYmVhMC00Yjk1LTQ2NzYtODVmZi0zZDU0NDQ3ZTE0ZWMxIzAhBgNVBAMTGkdvb2ds\nZSBDbG91ZCBTUUwgU2VydmVyIENBMRQwEgYDVQQKEwtHb29nbGUsIEluYzELMAkG\nA1UEBhMCVVMwHhcNMjExMDI2MDg0MzAxWhcNMzExMDI0MDg0NDAxWjB3MS0wKwYD\nVQQuEyQzOTE2YmVhMC00Yjk1LTQ2NzYtODVmZi0zZDU0NDQ3ZTE0ZWMxIzAhBgNV\nBAMTGkdvb2dsZSBDbG91ZCBTUUwgU2VydmVyIENBMRQwEgYDVQQKEwtHb29nbGUs\nIEluYzELMAkGA1UEBhMCVVMwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB\nAQCMPNNM+AI63en/OibDUs6Yt6rCZZDPW2IgTz9AbT8clH/ptC0K2Fao+Sxwu89S\ny2l4jZ1ENLMu7I32uQUJEE7a6a0BKCDUGfO6vC6t1wke3N5t/Uus1wcivmC4aEDR\nDOU2xctZ0EGqfVe5VYTsWMLZVBnk4aLad/nOseNxrldptfFLnLdc3s9RIr8bcpDV\nJW99Q0glWRVOf0heXuanlKkJ6fJ+05DEExE4sBQPx3aEDJLEjFlF//uJR/2oTbKL\nM9NM8Ihq+qWXOTe8TXUn7slJ1c/nJVCwPr3lj5PITeXotd5XkUbijHY4xoqMP+k2\n1YGbmbHL7Iyty+cqECEtQVeZAgMBAAGjFjAUMBIGA1UdEwEB/wQIMAYBAf8CAQAw\nDQYJKoZIhvcNAQELBQADggEBADDe8lUaXBzJoreG3S4avGNVfrL3J+wOItfBe7c/\nTHlVIxRCxLqN6sqEei2nPrhIQJKtH4LagqcWcUZ3a/PbucSmq5IOWf6XCF/U8vum\nqYHwhpyjuURCx8RaIuadPgGMwKb8R+pxdlGWNf99m2bsq+4R4OIegYIVKaKAC7Uy\n2QRHiHRrLGWQXqitwKfp3M+Wzx/XPx61+amVuQgukG2doBbEYzlygzeGN98Pa4FB\nNrVZPlVM2TtmVTyQxYZB3j+D19EobBwRIEpx6Lk9L1Bv8ZR1YQ38+aERIO6X+sac\n9EDLJ19OfGGyrcBi0fwaQEekb44IOFgG9NYiyJrpYR7xWTc=\n-----END CERTIFICATE-----", + "common_name": "C=US,O=Google\\, Inc,CN=Google Cloud SQL Server CA,dnQualifier=3916bea0-4b95-4676-85ff-3d54447e14ec", + "create_time": "2021-10-26T08:43:01.086Z", + "expiration_time": "2031-10-24T08:44:01.086Z", + "sha1_fingerprint": "966c305ef084de5cf152c0d33b0736666882d547" + } + ], + "service_account_email_address": "p260375416303-h0ilel@gcp-sa-cloud-sql.iam.gserviceaccount.com", + "settings": [ + { + "activation_policy": "ALWAYS", + "availability_type": "ZONAL", + "backup_configuration": [ + { + "backup_retention_settings": [ + { + "retained_backups": 7, + "retention_unit": "COUNT" + } + ], + "binary_log_enabled": false, + "enabled": false, + "location": "", + "point_in_time_recovery_enabled": false, + "start_time": "02:00", + "transaction_log_retention_days": 7 + } + ], + "crash_safe_replication": false, + "disk_autoresize": true, + "disk_autoresize_limit": 0, + "disk_size": 10, + "disk_type": "PD_SSD", + "ip_configuration": [ + { + "ipv4_enabled": true, + "private_network": "", + "require_ssl": false + } + ], + "location_preference": [ + { + "follow_gae_application": "", + "zone": "us-central1-f" + } + ], + "pricing_plan": "PER_USE", + "replication_type": "SYNCHRONOUS", + "tier": "db-f1-micro", + "version": 1 + } + ] + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_storage_bucket/expected.json b/pkg/test/google/3.78.0/google_storage_bucket/expected.json new file mode 100755 index 000000000..bab36af8b --- /dev/null +++ b/pkg/test/google/3.78.0/google_storage_bucket/expected.json @@ -0,0 +1,53 @@ +[ + { + "Id": "driftctl-unittest-3", + "Type": "google_storage_bucket", + "Attrs": { + "bucket_policy_only": true, + "default_event_based_hold": false, + "id": "driftctl-unittest-3", + "location": "EU", + "name": "driftctl-unittest-3", + "project": "elie-dev", + "requester_pays": false, + "self_link": "https://www.googleapis.com/storage/v1/b/driftctl-unittest-3", + "storage_class": "STANDARD", + "uniform_bucket_level_access": true, + "url": "gs://driftctl-unittest-3" + } + }, + { + "Id": "driftctl-unittest-2", + "Type": "google_storage_bucket", + "Attrs": { + "bucket_policy_only": true, + "default_event_based_hold": false, + "id": "driftctl-unittest-2", + "location": "EU", + "name": "driftctl-unittest-2", + "project": "elie-dev", + "requester_pays": false, + "self_link": "https://www.googleapis.com/storage/v1/b/driftctl-unittest-2", + "storage_class": "STANDARD", + "uniform_bucket_level_access": true, + "url": "gs://driftctl-unittest-2" + } + }, + { + "Id": "driftctl-unittest-1", + "Type": "google_storage_bucket", + "Attrs": { + "bucket_policy_only": true, + "default_event_based_hold": false, + "id": "driftctl-unittest-1", + "location": "EU", + "name": "driftctl-unittest-1", + "project": "elie-dev", + "requester_pays": false, + "self_link": "https://www.googleapis.com/storage/v1/b/driftctl-unittest-1", + "storage_class": "STANDARD", + "uniform_bucket_level_access": true, + "url": "gs://driftctl-unittest-1" + } + } +] \ No newline at end of file diff --git a/pkg/test/google/3.78.0/google_storage_bucket/input.json b/pkg/test/google/3.78.0/google_storage_bucket/input.json new file mode 100755 index 000000000..515d11ca3 --- /dev/null +++ b/pkg/test/google/3.78.0/google_storage_bucket/input.json @@ -0,0 +1,80 @@ +[ + { + "Id": "driftctl-unittest-3", + "Type": "google_storage_bucket", + "Attrs": { + "bucket_policy_only": true, + "cors": [], + "default_event_based_hold": false, + "encryption": [], + "force_destroy": null, + "id": "driftctl-unittest-3", + "labels": {}, + "lifecycle_rule": [], + "location": "EU", + "logging": [], + "name": "driftctl-unittest-3", + "project": "elie-dev", + "requester_pays": false, + "retention_policy": [], + "self_link": "https://www.googleapis.com/storage/v1/b/driftctl-unittest-3", + "storage_class": "STANDARD", + "uniform_bucket_level_access": true, + "url": "gs://driftctl-unittest-3", + "versioning": [], + "website": [] + } + }, + { + "Id": "driftctl-unittest-2", + "Type": "google_storage_bucket", + "Attrs": { + "bucket_policy_only": true, + "cors": [], + "default_event_based_hold": false, + "encryption": [], + "force_destroy": null, + "id": "driftctl-unittest-2", + "labels": {}, + "lifecycle_rule": [], + "location": "EU", + "logging": [], + "name": "driftctl-unittest-2", + "project": "elie-dev", + "requester_pays": false, + "retention_policy": [], + "self_link": "https://www.googleapis.com/storage/v1/b/driftctl-unittest-2", + "storage_class": "STANDARD", + "uniform_bucket_level_access": true, + "url": "gs://driftctl-unittest-2", + "versioning": [], + "website": [] + } + }, + { + "Id": "driftctl-unittest-1", + "Type": "google_storage_bucket", + "Attrs": { + "bucket_policy_only": true, + "cors": [], + "default_event_based_hold": false, + "encryption": [], + "force_destroy": null, + "id": "driftctl-unittest-1", + "labels": {}, + "lifecycle_rule": [], + "location": "EU", + "logging": [], + "name": "driftctl-unittest-1", + "project": "elie-dev", + "requester_pays": false, + "retention_policy": [], + "self_link": "https://www.googleapis.com/storage/v1/b/driftctl-unittest-1", + "storage_class": "STANDARD", + "uniform_bucket_level_access": true, + "url": "gs://driftctl-unittest-1", + "versioning": [], + "website": [] + } + } +] \ No newline at end of file From 6c5e6787b0d0e5c0e9bd4d15996232e25f061263 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Wed, 27 Jul 2022 15:30:56 +0200 Subject: [PATCH 7/9] fix: fix broken tests Those tests were broken due to removal of SetResolveReadAttributesFunc. Sometimes in those methods we were casting field from different types to string. If we loose that case it causes some issues since in the detail fetcher we only take into account strings attributes. To fix that I added some cast directly in the detail fetcher. That should not cause any issues to retrieve details if we send additional (useless) fields to the ReadResource call. --- .../aws/cloudformation_stack_enumerator.go | 10 +++++-- enumeration/remote/common/details_fetcher.go | 8 ++++++ ..._encryption_default-false.res.golden.json} | 0 ...d657494d17ee2-6-allow-200.res.golden.json} | 0 ...657494d17ee2-17-allow-100.res.golden.json} | 0 ...ef59074b622e-17-allow-100.res.golden.json} | 0 ...6d657494d17ee2-6-deny-100.res.golden.json} | 0 ...4ef59074b622e-17-deny-100.res.golden.json} | 0 enumeration/resource/resource.go | 3 ++ .../aws_default_network_acl_rule.go | 5 ++-- .../aws_default_network_acl_rule_test.go | 28 +++++++++---------- pkg/middlewares/aws_network_acl_expander.go | 4 +-- .../aws_network_acl_expander_test.go | 18 ++++++------ pkg/resource/aws/aws_network_acl_rule.go | 15 +++++++--- 14 files changed, 57 insertions(+), 34 deletions(-) rename enumeration/remote/test/aws_ebs_encryption_by_default_list/{aws_ebs_encryption_by_default-ebs_encryption_default.res.golden.json => aws_ebs_encryption_by_default-ebs_encryption_default-false.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_network_acl_rule/{aws_network_acl_rule-nacl-2289824980-___0-acl-0ad6d657494d17ee2-6-allow.res.golden.json => aws_network_acl_rule-nacl-2289824980-false-___0-acl-0ad6d657494d17ee2-6-allow-200.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_network_acl_rule/{aws_network_acl_rule-nacl-246660311-172.16.1.0_0-acl-0ad6d657494d17ee2-17-allow.res.golden.json => aws_network_acl_rule-nacl-246660311-172.16.1.0_0-true-acl-0ad6d657494d17ee2-17-allow-100.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_network_acl_rule/{aws_network_acl_rule-nacl-4268384215-172.16.1.0_0-acl-0de54ef59074b622e-17-allow.res.golden.json => aws_network_acl_rule-nacl-4268384215-172.16.1.0_0-true-acl-0de54ef59074b622e-17-allow-100.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_network_acl_rule/{aws_network_acl_rule-nacl-4293207588-0.0.0.0_0-acl-0ad6d657494d17ee2-6-deny.res.golden.json => aws_network_acl_rule-nacl-4293207588-0.0.0.0_0-false-acl-0ad6d657494d17ee2-6-deny-100.res.golden.json} (100%) rename enumeration/remote/test/aws_ec2_network_acl_rule/{aws_network_acl_rule-nacl-515082162-0.0.0.0_0-acl-0de54ef59074b622e-17-deny.res.golden.json => aws_network_acl_rule-nacl-515082162-0.0.0.0_0-false-acl-0de54ef59074b622e-17-deny-100.res.golden.json} (100%) diff --git a/enumeration/remote/aws/cloudformation_stack_enumerator.go b/enumeration/remote/aws/cloudformation_stack_enumerator.go index f76f9fe77..c85dc56d6 100644 --- a/enumeration/remote/aws/cloudformation_stack_enumerator.go +++ b/enumeration/remote/aws/cloudformation_stack_enumerator.go @@ -1,9 +1,11 @@ package aws import ( + "fmt" "strconv" "github.com/aws/aws-sdk-go/service/cloudformation" + "github.com/hashicorp/terraform/flatmap" "github.com/snyk/driftctl/enumeration/remote/aws/repository" remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/resource" @@ -38,7 +40,9 @@ func (e *CloudformationStackEnumerator) Enumerate() ([]*resource.Resource, error attrs := map[string]interface{}{} if stack.Parameters != nil && len(stack.Parameters) > 0 { attrs["parameters.%"] = strconv.FormatInt(int64(len(stack.Parameters)), 10) - attrs["parameters"] = flattenParameters(stack.Parameters) + for k, v := range flattenParameters(stack.Parameters) { + attrs[fmt.Sprintf("parameters.%s", k)] = v + } } results = append( @@ -54,10 +58,10 @@ func (e *CloudformationStackEnumerator) Enumerate() ([]*resource.Resource, error return results, err } -func flattenParameters(parameters []*cloudformation.Parameter) interface{} { +func flattenParameters(parameters []*cloudformation.Parameter) flatmap.Map { params := make(map[string]interface{}, len(parameters)) for _, p := range parameters { params[*p.ParameterKey] = *p.ParameterValue } - return params + return flatmap.Flatten(params) } diff --git a/enumeration/remote/common/details_fetcher.go b/enumeration/remote/common/details_fetcher.go index 915c07880..abc78b598 100644 --- a/enumeration/remote/common/details_fetcher.go +++ b/enumeration/remote/common/details_fetcher.go @@ -1,6 +1,8 @@ package common import ( + "strconv" + "github.com/sirupsen/logrus" remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/resource" @@ -29,6 +31,12 @@ func (f *GenericDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.R attributes := map[string]string{} if res.Attributes() != nil { for k, v := range *res.Attributes() { + if b, ok := v.(bool); ok { + attributes[k] = strconv.FormatBool(b) + } + if i64, ok := v.(int64); ok { + attributes[k] = strconv.FormatInt(i64, 10) + } if str, ok := v.(string); ok { attributes[k] = str } diff --git a/enumeration/remote/test/aws_ebs_encryption_by_default_list/aws_ebs_encryption_by_default-ebs_encryption_default.res.golden.json b/enumeration/remote/test/aws_ebs_encryption_by_default_list/aws_ebs_encryption_by_default-ebs_encryption_default-false.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ebs_encryption_by_default_list/aws_ebs_encryption_by_default-ebs_encryption_default.res.golden.json rename to enumeration/remote/test/aws_ebs_encryption_by_default_list/aws_ebs_encryption_by_default-ebs_encryption_default-false.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-___0-acl-0ad6d657494d17ee2-6-allow.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-false-___0-acl-0ad6d657494d17ee2-6-allow-200.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-___0-acl-0ad6d657494d17ee2-6-allow.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-2289824980-false-___0-acl-0ad6d657494d17ee2-6-allow-200.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-172.16.1.0_0-acl-0ad6d657494d17ee2-17-allow.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-172.16.1.0_0-true-acl-0ad6d657494d17ee2-17-allow-100.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-172.16.1.0_0-acl-0ad6d657494d17ee2-17-allow.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-246660311-172.16.1.0_0-true-acl-0ad6d657494d17ee2-17-allow-100.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-172.16.1.0_0-acl-0de54ef59074b622e-17-allow.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-172.16.1.0_0-true-acl-0de54ef59074b622e-17-allow-100.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-172.16.1.0_0-acl-0de54ef59074b622e-17-allow.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4268384215-172.16.1.0_0-true-acl-0de54ef59074b622e-17-allow-100.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-0.0.0.0_0-acl-0ad6d657494d17ee2-6-deny.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-0.0.0.0_0-false-acl-0ad6d657494d17ee2-6-deny-100.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-0.0.0.0_0-acl-0ad6d657494d17ee2-6-deny.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-4293207588-0.0.0.0_0-false-acl-0ad6d657494d17ee2-6-deny-100.res.golden.json diff --git a/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-0.0.0.0_0-acl-0de54ef59074b622e-17-deny.res.golden.json b/enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-0.0.0.0_0-false-acl-0de54ef59074b622e-17-deny-100.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-0.0.0.0_0-acl-0de54ef59074b622e-17-deny.res.golden.json rename to enumeration/remote/test/aws_ec2_network_acl_rule/aws_network_acl_rule-nacl-515082162-0.0.0.0_0-false-acl-0de54ef59074b622e-17-deny-100.res.golden.json diff --git a/enumeration/resource/resource.go b/enumeration/resource/resource.go index f4ec65257..e7279276a 100644 --- a/enumeration/resource/resource.go +++ b/enumeration/resource/resource.go @@ -188,6 +188,9 @@ func (a *Attributes) GetBool(path string) *bool { } func (a *Attributes) GetInt(path string) *int { + // This is a nonsense, if we want to retrieve an int this is gonna fail + // We were doing that because all numbers fields from cty are float64 but sometimes we want to retrieve an int + // TODO Change this to be compatible with both int and float64 underlying type val := a.GetFloat64(path) if val == nil { return nil diff --git a/pkg/middlewares/aws_default_network_acl_rule.go b/pkg/middlewares/aws_default_network_acl_rule.go index 7990af288..6d00b4834 100644 --- a/pkg/middlewares/aws_default_network_acl_rule.go +++ b/pkg/middlewares/aws_default_network_acl_rule.go @@ -62,9 +62,10 @@ func (m AwsDefaultNetworkACLRule) Execute(remoteResources, resourcesFromState *[ func (m *AwsDefaultNetworkACLRule) isDefaultACLRule(res *resource.Resource) bool { isIPv4 := res.Attrs.GetString("cidr_block") != nil + ruleNumber, ruleNumberOk := (*res.Attrs)["rule_number"].(int64) if isIPv4 { - if number := res.Attrs.GetFloat64("rule_number"); number != nil && int(*number) != 32767 { + if ruleNumberOk && ruleNumber != 32767 { return false } if cidr := res.Attrs.GetString("cidr_block"); cidr != nil && *cidr != "0.0.0.0/0" { @@ -73,7 +74,7 @@ func (m *AwsDefaultNetworkACLRule) isDefaultACLRule(res *resource.Resource) bool } if !isIPv4 { - if number := res.Attrs.GetFloat64("rule_number"); number != nil && int(*number) != 32768 { + if ruleNumberOk && ruleNumber != 32768 { return false } if cidr := res.Attrs.GetString("ipv6_cidr_block"); cidr != nil && *cidr != "::/0" { diff --git a/pkg/middlewares/aws_default_network_acl_rule_test.go b/pkg/middlewares/aws_default_network_acl_rule_test.go index 5d0b99f0d..18e46f465 100644 --- a/pkg/middlewares/aws_default_network_acl_rule_test.go +++ b/pkg/middlewares/aws_default_network_acl_rule_test.go @@ -27,7 +27,7 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Id: "default-acl-rule", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(32767), + "rule_number": int64(32767), "rule_action": "deny", "cidr_block": "0.0.0.0/0", "protocol": "-1", @@ -37,14 +37,14 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Id: "non-default-acl", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(100), + "rule_number": int64(100), }, }, { Id: "non-default-acl-2", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(32767), + "rule_number": int64(32767), "rule_action": "allow", }, }, @@ -52,7 +52,7 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Id: "non-default-acl-3", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(32767), + "rule_number": int64(32767), "rule_action": "deny", "cidr_block": "1.2.3.0/0", }, @@ -61,7 +61,7 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Id: "non-default-acl-4", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(32767), + "rule_number": int64(32767), "rule_action": "deny", "cidr_block": "0.0.0.0/0", "protocol": "6", @@ -82,7 +82,7 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Id: "default-acl-rule", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(32767), + "rule_number": int64(32767), "rule_action": "deny", "cidr_block": "0.0.0.0/0", "protocol": "-1", @@ -92,14 +92,14 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Id: "non-default-acl", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(100), + "rule_number": int64(100), }, }, { Id: "non-default-acl-2", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(32767), + "rule_number": int64(32767), "rule_action": "allow", }, }, @@ -107,7 +107,7 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Id: "non-default-acl-3", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(32767), + "rule_number": int64(32767), "rule_action": "deny", "cidr_block": "1.2.3.0/0", }, @@ -116,7 +116,7 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Id: "non-default-acl-4", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(32767), + "rule_number": int64(32767), "rule_action": "deny", "cidr_block": "0.0.0.0/0", "protocol": "6", @@ -135,7 +135,7 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ "network_acl_id": "my-network", - "rule_number": float64(32767), + "rule_number": int64(32767), "rule_action": "deny", "cidr_block": "0.0.0.0/0", "protocol": "-1", @@ -146,7 +146,7 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ "network_acl_id": "my-network", - "rule_number": float64(32768), + "rule_number": int64(32768), "rule_action": "deny", "ipv6_cidr_block": "::/0", "protocol": "-1", @@ -156,7 +156,7 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Id: "non-default-acl", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(32767), + "rule_number": int64(32767), "rule_action": "deny", "cidr_block": "0.0.0.0/0", "protocol": "6", @@ -172,7 +172,7 @@ func TestAwsDefaultNetworkACLRule_Execute(t *testing.T) { Id: "non-default-acl", Type: aws.AwsNetworkACLRuleResourceType, Attrs: &resource.Attributes{ - "rule_number": float64(32767), + "rule_number": int64(32767), "rule_action": "deny", "cidr_block": "0.0.0.0/0", "protocol": "6", diff --git a/pkg/middlewares/aws_network_acl_expander.go b/pkg/middlewares/aws_network_acl_expander.go index 72978b46f..5a683903e 100644 --- a/pkg/middlewares/aws_network_acl_expander.go +++ b/pkg/middlewares/aws_network_acl_expander.go @@ -72,7 +72,7 @@ func (e *AwsNetworkACLExpander) expandBlock(resourcesFromState *[]*resource.Reso for _, rule := range ruleBlock { attrs := rule.(map[string]interface{}) - attrs["rule_number"] = attrs["rule_no"] + attrs["rule_number"] = int64(attrs["rule_no"].(float64)) delete(attrs, "rule_no") attrs["egress"] = egress @@ -86,7 +86,7 @@ func (e *AwsNetworkACLExpander) expandBlock(resourcesFromState *[]*resource.Reso aws.AwsNetworkACLRuleResourceType, aws.CreateNetworkACLRuleID( networkAclId, - int64(attrs["rule_number"].(int)), + attrs["rule_number"].(int64), egress, attrs["protocol"].(string), ), diff --git a/pkg/middlewares/aws_network_acl_expander_test.go b/pkg/middlewares/aws_network_acl_expander_test.go index 6cc6178e9..83ff247dc 100644 --- a/pkg/middlewares/aws_network_acl_expander_test.go +++ b/pkg/middlewares/aws_network_acl_expander_test.go @@ -7,8 +7,8 @@ import ( "github.com/aws/aws-sdk-go/aws/awsutil" "github.com/r3labs/diff/v2" "github.com/snyk/driftctl/enumeration/resource" + "github.com/snyk/driftctl/enumeration/resource/aws" dctlresource "github.com/snyk/driftctl/pkg/resource" - "github.com/snyk/driftctl/pkg/resource/aws" ) func TestAwsNetworkACLExpander_Execute(t *testing.T) { @@ -87,7 +87,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "17", - "rule_number": 100, + "rule_number": int64(100), "to_port": 80, }, ).Once().Return(&resource.Resource{ @@ -114,7 +114,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "6", - "rule_number": 101, + "rule_number": int64(101), "to_port": 80, }, ).Once().Return(&resource.Resource{ @@ -141,7 +141,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "6", - "rule_number": 103, + "rule_number": int64(103), "to_port": 80, }, ).Once().Return(&resource.Resource{ @@ -168,7 +168,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "17", - "rule_number": 100, + "rule_number": int64(100), "to_port": 80, }, ).Once().Return(&resource.Resource{ @@ -190,7 +190,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "17", - "rule_no": 100, + "rule_no": 100.0, "to_port": 80, }, }, @@ -203,7 +203,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "6", - "rule_no": 101, + "rule_no": 101.0, "to_port": 80, }, // This one exist in state, test that we do not duplicate it @@ -216,7 +216,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "6", - "rule_no": 103, + "rule_no": 103.0, "to_port": 80, }, }, @@ -235,7 +235,7 @@ func TestAwsNetworkACLExpander_Execute(t *testing.T) { "icmp_type": 0, "ipv6_cidr_block": "", "protocol": "17", - "rule_no": 100, + "rule_no": 100.0, "to_port": 80, }, }, diff --git a/pkg/resource/aws/aws_network_acl_rule.go b/pkg/resource/aws/aws_network_acl_rule.go index 69e87d78d..b4d163a95 100644 --- a/pkg/resource/aws/aws_network_acl_rule.go +++ b/pkg/resource/aws/aws_network_acl_rule.go @@ -3,12 +3,11 @@ package aws import ( "bytes" "fmt" - dctlresource "github.com/snyk/driftctl/pkg/resource" "strconv" "github.com/hashicorp/terraform/helper/hashcode" - "github.com/snyk/driftctl/enumeration/resource" + dctlresource "github.com/snyk/driftctl/pkg/resource" ) const AwsNetworkACLRuleResourceType = "aws_network_acl_rule" @@ -178,6 +177,14 @@ func initAwsNetworkACLRuleMetaData(resourceSchemaRepository dctlresource.SchemaR _ = res.Attrs.SafeSet([]string{"protocol"}, strconv.Itoa(number)) } + // For some reason, when deserialising the state, this field is deserialized as a float + // We need to make this homogeneous between remote and IaC so we cast this to an int64 + // The real type returned by AWS SDK is int64 + ruleNumber := (*res.Attrs)["rule_number"] + if v, isFloat := ruleNumber.(float64); isFloat { + _ = res.Attrs.SafeSet([]string{"rule_number"}, int64(v)) + } + // ID can be different even if the resource is the same. // protocol is taken into account while creating the ID, if you set protocol="tcp" you'll end with // a resource with a different ID than if you set protocol="6" which is the same @@ -188,7 +195,7 @@ func initAwsNetworkACLRuleMetaData(resourceSchemaRepository dctlresource.SchemaR // This workaround is mandatory to harmonize resources ID res.Id = CreateNetworkACLRuleID( *res.Attrs.GetString("network_acl_id"), - int64(*res.Attrs.GetInt("rule_number")), + (*res.Attrs)["rule_number"].(int64), *res.Attrs.GetBool("egress"), *res.Attrs.GetString("protocol"), ) @@ -200,7 +207,7 @@ func initAwsNetworkACLRuleMetaData(resourceSchemaRepository dctlresource.SchemaR resourceSchemaRepository.SetFlags(AwsNetworkACLRuleResourceType, resource.FlagDeepMode) resourceSchemaRepository.SetHumanReadableAttributesFunc(AwsNetworkACLRuleResourceType, func(res *resource.Resource) map[string]string { - ruleNumber := strconv.FormatInt(int64(*res.Attrs.GetInt("rule_number")), 10) + ruleNumber := strconv.FormatInt((*res.Attrs)["rule_number"].(int64), 10) if ruleNumber == "32767" { ruleNumber = "*" } From ab94124bab70c435d64ffbda72a648e1d75cc6ad Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Thu, 28 Jul 2022 10:30:30 +0200 Subject: [PATCH 8/9] fix: fix aws_security_group_rules tests --- .../remote/aws/vpc_security_group_rule_enumerator.go | 4 ++-- enumeration/remote/common/details_fetcher.go | 10 ++++++++++ ...-0cc8b3c3c2851705a-false--0-egress.res.golden.json} | 0 ...-0254c038e32f25530-false--0-egress.res.golden.json} | 0 ...0254c038e32f25530-false--0-ingress.res.golden.json} | 0 ...0254c038e32f25530-false--0-ingress.res.golden.json} | 0 ...-0254c038e32f25530-false--0-egress.res.golden.json} | 0 ...-0cc8b3c3c2851705a-false--0-egress.res.golden.json} | 0 ...30-false-sg-9e0204ff-65535-ingress.res.golden.json} | 0 ...4c038e32f25530-true--65535-ingress.res.golden.json} | 0 ...c8b3c3c2851705a-false--443-ingress.res.golden.json} | 0 ...0254c038e32f25530-false--0-ingress.res.golden.json} | 0 ...-0cc8b3c3c2851705a-false--0-egress.res.golden.json} | 0 enumeration/resource/aws/aws_security_group_rule.go | 8 ++++---- 14 files changed, 16 insertions(+), 6 deletions(-) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-1175318309--1-sg-0cc8b3c3c2851705a--egress.res.golden.json => aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0-0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-1707973622--1-sg-0254c038e32f25530--egress.res.golden.json => aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0-0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-2165103420--1-sg-0254c038e32f25530--ingress.res.golden.json => aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0-0-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-2582518759--1-sg-0254c038e32f25530--ingress.res.golden.json => aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0-0-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-2821752134--1-sg-0254c038e32f25530--egress.res.golden.json => aws_security_group_rule-sgrule-2821752134-0-0-1-___0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-350400929--1-sg-0cc8b3c3c2851705a--egress.res.golden.json => aws_security_group_rule-sgrule-350400929-0-0-1-___0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-3587309474-tcp-sg-0254c038e32f25530-sg-9e0204ff-ingress.res.golden.json => aws_security_group_rule-sgrule-3587309474-0-0-0-0-tcp-sg-0254c038e32f25530-false-sg-9e0204ff-65535-ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-3970541193-tcp-sg-0254c038e32f25530--ingress.res.golden.json => aws_security_group_rule-sgrule-3970541193-0-0-0-0-tcp-sg-0254c038e32f25530-true--65535-ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-453320892-tcp-sg-0cc8b3c3c2851705a--ingress.res.golden.json => aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-0-0-tcp-sg-0cc8b3c3c2851705a-false--443-ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-674800228--1-sg-0254c038e32f25530--ingress.res.golden.json => aws_security_group_rule-sgrule-674800228-0-0-1-___0-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json} (100%) rename enumeration/remote/test/aws_vpc_security_group_rule_multiple/{aws_security_group_rule-sgrule-850043874-5-sg-0cc8b3c3c2851705a--egress.res.golden.json => aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-0-0-0-5-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json} (100%) diff --git a/enumeration/remote/aws/vpc_security_group_rule_enumerator.go b/enumeration/remote/aws/vpc_security_group_rule_enumerator.go index aacc2f74e..5bcdc3231 100644 --- a/enumeration/remote/aws/vpc_security_group_rule_enumerator.go +++ b/enumeration/remote/aws/vpc_security_group_rule_enumerator.go @@ -43,8 +43,8 @@ func (s *securityGroupRule) getAttrs() resource.Attributes { "type": s.Type, "security_group_id": s.SecurityGroupId, "protocol": s.Protocol, - "from_port": s.FromPort, - "to_port": s.ToPort, + "from_port": int(s.FromPort), + "to_port": int(s.ToPort), "self": s.Self, "source_security_group_id": s.SourceSecurityGroupId, "cidr_blocks": toInterfaceSlice(s.CidrBlocks), diff --git a/enumeration/remote/common/details_fetcher.go b/enumeration/remote/common/details_fetcher.go index abc78b598..312a25855 100644 --- a/enumeration/remote/common/details_fetcher.go +++ b/enumeration/remote/common/details_fetcher.go @@ -3,6 +3,7 @@ package common import ( "strconv" + "github.com/hashicorp/terraform/flatmap" "github.com/sirupsen/logrus" remoteerror "github.com/snyk/driftctl/enumeration/remote/error" "github.com/snyk/driftctl/enumeration/resource" @@ -34,12 +35,21 @@ func (f *GenericDetailsFetcher) ReadDetails(res *resource.Resource) (*resource.R if b, ok := v.(bool); ok { attributes[k] = strconv.FormatBool(b) } + if i, ok := v.(int); ok { + attributes[k] = strconv.Itoa(i) + } if i64, ok := v.(int64); ok { attributes[k] = strconv.FormatInt(i64, 10) } if str, ok := v.(string); ok { attributes[k] = str } + if sliceOfInterface, ok := v.([]interface{}); ok { + m := flatmap.Flatten(map[string]interface{}{k: sliceOfInterface}) + for k2, v2 := range m { + attributes[k2] = v2 + } + } } } ctyVal, err := f.reader.ReadResource(terraform.ReadResourceArgs{ diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309--1-sg-0cc8b3c3c2851705a--egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0-0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309--1-sg-0cc8b3c3c2851705a--egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1175318309-1-0.0.0.0_0-0-0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622--1-sg-0254c038e32f25530--egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0-0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622--1-sg-0254c038e32f25530--egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-1707973622-1-0.0.0.0_0-0-0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420--1-sg-0254c038e32f25530--ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0-0-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420--1-sg-0254c038e32f25530--ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2165103420-1-5.6.7.0_24-0-0-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759--1-sg-0254c038e32f25530--ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0-0-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759--1-sg-0254c038e32f25530--ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2582518759-1-1.2.0.0_16-0-0-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134--1-sg-0254c038e32f25530--egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134-0-0-1-___0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134--1-sg-0254c038e32f25530--egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-2821752134-0-0-1-___0-0--1-sg-0254c038e32f25530-false--0-egress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929--1-sg-0cc8b3c3c2851705a--egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929-0-0-1-___0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929--1-sg-0cc8b3c3c2851705a--egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-350400929-0-0-1-___0-0--1-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-tcp-sg-0254c038e32f25530-sg-9e0204ff-ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-0-0-0-0-tcp-sg-0254c038e32f25530-false-sg-9e0204ff-65535-ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-tcp-sg-0254c038e32f25530-sg-9e0204ff-ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3587309474-0-0-0-0-tcp-sg-0254c038e32f25530-false-sg-9e0204ff-65535-ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-tcp-sg-0254c038e32f25530--ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-0-0-0-0-tcp-sg-0254c038e32f25530-true--65535-ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-tcp-sg-0254c038e32f25530--ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-3970541193-0-0-0-0-tcp-sg-0254c038e32f25530-true--65535-ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-tcp-sg-0cc8b3c3c2851705a--ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-0-0-tcp-sg-0cc8b3c3c2851705a-false--443-ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-tcp-sg-0cc8b3c3c2851705a--ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-453320892-1-0.0.0.0_0-443-0-0-tcp-sg-0cc8b3c3c2851705a-false--443-ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228--1-sg-0254c038e32f25530--ingress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228-0-0-1-___0-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228--1-sg-0254c038e32f25530--ingress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-674800228-0-0-1-___0-0--1-sg-0254c038e32f25530-false--0-ingress.res.golden.json diff --git a/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-5-sg-0cc8b3c3c2851705a--egress.res.golden.json b/enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-0-0-0-5-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json similarity index 100% rename from enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-5-sg-0cc8b3c3c2851705a--egress.res.golden.json rename to enumeration/remote/test/aws_vpc_security_group_rule_multiple/aws_security_group_rule-sgrule-850043874-1-0.0.0.0_0-0-0-0-5-sg-0cc8b3c3c2851705a-false--0-egress.res.golden.json diff --git a/enumeration/resource/aws/aws_security_group_rule.go b/enumeration/resource/aws/aws_security_group_rule.go index 96efcbdce..a65c54d8d 100644 --- a/enumeration/resource/aws/aws_security_group_rule.go +++ b/enumeration/resource/aws/aws_security_group_rule.go @@ -13,11 +13,11 @@ const AwsSecurityGroupRuleResourceType = "aws_security_group_rule" func CreateSecurityGroupRuleIdHash(attrs *resource.Attributes) string { var buf bytes.Buffer buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("security_group_id"))) - if attrs.GetInt("from_port") != nil && *attrs.GetInt("from_port") > 0 { - buf.WriteString(fmt.Sprintf("%d-", *attrs.GetInt("from_port"))) + if (*attrs)["from_port"] != nil && (*attrs)["from_port"].(int) > 0 { + buf.WriteString(fmt.Sprintf("%d-", (*attrs)["from_port"].(int))) } - if attrs.GetInt("to_port") != nil && *attrs.GetInt("to_port") > 0 { - buf.WriteString(fmt.Sprintf("%d-", *attrs.GetInt("to_port"))) + if (*attrs)["to_port"] != nil && (*attrs)["to_port"].(int) > 0 { + buf.WriteString(fmt.Sprintf("%d-", (*attrs)["to_port"].(int))) } buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("protocol"))) buf.WriteString(fmt.Sprintf("%s-", *attrs.GetString("type"))) From a18af39da8c12a00038c7abfa2e0063c0f3eb022 Mon Sep 17 00:00:00 2001 From: Elie CHARRA Date: Thu, 28 Jul 2022 11:56:59 +0200 Subject: [PATCH 9/9] fix: linter --- pkg/driftctl_test.go | 15 --------------- pkg/resource/resource_types.go | 2 +- 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/pkg/driftctl_test.go b/pkg/driftctl_test.go index 300d02fe0..aa66be1f4 100644 --- a/pkg/driftctl_test.go +++ b/pkg/driftctl_test.go @@ -4,7 +4,6 @@ import ( "encoding/json" "io/ioutil" "path" - "reflect" "strings" "testing" @@ -111,15 +110,6 @@ func runTest(t *testing.T, cases TestCases) { } } -func matchByAttributes(input, attrs map[string]interface{}) bool { - for k, v := range attrs { - if value, ok := input[k]; !ok || !reflect.DeepEqual(value, v) { - return false - } - } - return true -} - func TestDriftctlRun_BasicBehavior(t *testing.T) { cases := TestCases{ @@ -1591,8 +1581,3 @@ func TestDriftctlRun_TestResourcesNormalization(t *testing.T) { } } - -func getSchema(repo dctlresource.SchemaRepositoryInterface, resourceType string) *resource.Schema { - sch, _ := repo.GetSchema(resourceType) - return sch -} diff --git a/pkg/resource/resource_types.go b/pkg/resource/resource_types.go index 6461f84f8..e0e658d1e 100644 --- a/pkg/resource/resource_types.go +++ b/pkg/resource/resource_types.go @@ -260,7 +260,7 @@ func IsResourceTypeSupported(ty string) bool { func GetSupportedTypes() []string { types := make([]string, 0, len(supportedTypes)) - for k, _ := range supportedTypes { + for k := range supportedTypes { types = append(types, k) }