github.com/diggerhq/digger/libs@v0.0.0-20240604170430-9d61cdf01cc5/terraform_utils/plan_summary_test.go (about) 1 package terraform_utils 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func TestPlanOutputEmpty(t *testing.T) { 10 emptyTerraformPlanJson := "{\"format_version\":\"1.1\",\"terraform_version\":\"1.4.6\",\"planned_values\":{\"root_module\":{\"resources\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"schema_version\":0,\"values\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"sensitive_values\":{}}]}},\"resource_changes\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"change\":{\"actions\":[\"no-op\"],\"before\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"after\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"after_unknown\":{},\"before_sensitive\":{},\"after_sensitive\":{}}}],\"prior_state\":{\"format_version\":\"1.0\",\"terraform_version\":\"1.4.6\",\"values\":{\"root_module\":{\"resources\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"schema_version\":0,\"values\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"sensitive_values\":{}}]}}},\"configuration\":{\"provider_config\":{\"null\":{\"name\":\"null\",\"full_name\":\"registry.terraform.io/hashicorp/null\"}},\"root_module\":{\"resources\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_config_key\":\"null\",\"schema_version\":0}]}}}\n" 11 isEmpty, _, err := GetPlanSummary(emptyTerraformPlanJson) 12 assert.Nil(t, err) 13 assert.True(t, isEmpty) 14 } 15 16 func TestPlanOutputNonEmpty(t *testing.T) { 17 nonEmptyTerraformPlanJson := "{\"format_version\":\"1.1\",\"terraform_version\":\"1.4.6\",\"planned_values\":{\"root_module\":{\"resources\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"schema_version\":0,\"values\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"sensitive_values\":{}},{\"address\":\"null_resource.testx\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"testx\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"schema_version\":0,\"values\":{\"triggers\":null},\"sensitive_values\":{}}]}},\"resource_changes\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"change\":{\"actions\":[\"no-op\"],\"before\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"after\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"after_unknown\":{},\"before_sensitive\":{},\"after_sensitive\":{}}},{\"address\":\"null_resource.testx\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"testx\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"change\":{\"actions\":[\"create\"],\"before\":null,\"after\":{\"triggers\":null},\"after_unknown\":{\"id\":true},\"before_sensitive\":false,\"after_sensitive\":{}}}],\"prior_state\":{\"format_version\":\"1.0\",\"terraform_version\":\"1.4.6\",\"values\":{\"root_module\":{\"resources\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"schema_version\":0,\"values\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"sensitive_values\":{}}]}}},\"configuration\":{\"provider_config\":{\"null\":{\"name\":\"null\",\"full_name\":\"registry.terraform.io/hashicorp/null\"}},\"root_module\":{\"resources\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_config_key\":\"null\",\"schema_version\":0},{\"address\":\"null_resource.testx\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"testx\",\"provider_config_key\":\"null\",\"schema_version\":0}]}}}\n" 18 isEmpty, _, err := GetPlanSummary(nonEmptyTerraformPlanJson) 19 assert.Nil(t, err) 20 assert.False(t, isEmpty) 21 } 22 23 func TestPlanOutputInvalidJsonFailsGracefully(t *testing.T) { 24 InvalidJson := "{\"format_version\":\" notsovalid" 25 _, _, err := GetPlanSummary(InvalidJson) 26 assert.NotNil(t, err) 27 } 28 29 func TestPlanFootprintSimilarity(t *testing.T) { 30 planJson1 := "{\"format_version\":\"1.2\",\"terraform_version\":\"1.7.3\",\"variables\":{\"environment\":{\"value\":\"devel\"}},\"planned_values\":{\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"schema_version\":0,\"values\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510105906923000000001\",\"bucket\":\"my-tf-test-bucket20240510105906923000000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510105906923000000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"devel\",\"Name\":\"The bucket devel\"},\"tags_all\":{\"Environment\":\"devel\",\"Name\":\"The bucket devel\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"sensitive_values\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}]}},\"resource_changes\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"change\":{\"actions\":[\"update\"],\"before\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510105906923000000001\",\"bucket\":\"my-tf-test-bucket20240510105906923000000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510105906923000000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"devel\",\"Name\":\"My bucket devel\"},\"tags_all\":{\"Environment\":\"devel\",\"Name\":\"My bucket devel\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"after\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510105906923000000001\",\"bucket\":\"my-tf-test-bucket20240510105906923000000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510105906923000000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"devel\",\"Name\":\"The bucket devel\"},\"tags_all\":{\"Environment\":\"devel\",\"Name\":\"The bucket devel\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"after_unknown\":{},\"before_sensitive\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]},\"after_sensitive\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}}],\"prior_state\":{\"format_version\":\"1.0\",\"terraform_version\":\"1.7.3\",\"values\":{\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"schema_version\":0,\"values\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510105906923000000001\",\"bucket\":\"my-tf-test-bucket20240510105906923000000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510105906923000000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"devel\",\"Name\":\"My bucket devel\"},\"tags_all\":{\"Environment\":\"devel\",\"Name\":\"My bucket devel\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"sensitive_values\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}]}}},\"configuration\":{\"provider_config\":{\"aws\":{\"name\":\"aws\",\"full_name\":\"registry.terraform.io/hashicorp/aws\",\"version_constraint\":\"~\\u003e 5.0\"}},\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_config_key\":\"aws\",\"expressions\":{\"bucket_prefix\":{\"constant_value\":\"my-tf-test-bucket\"},\"tags\":{\"references\":[\"var.environment\",\"var.environment\"]}},\"schema_version\":0}],\"variables\":{\"environment\":{}}}},\"timestamp\":\"2024-05-10T15:36:02Z\",\"errored\":false}\n" 31 planJson2 := "{\"format_version\":\"1.2\",\"terraform_version\":\"1.7.3\",\"variables\":{\"environment\":{\"value\":\"staging\"}},\"planned_values\":{\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"schema_version\":0,\"values\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510110101962500000001\",\"bucket\":\"my-tf-test-bucket20240510110101962500000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510110101962500000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"staging\",\"Name\":\"The bucket staging\"},\"tags_all\":{\"Environment\":\"staging\",\"Name\":\"The bucket staging\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"sensitive_values\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}]}},\"resource_changes\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"change\":{\"actions\":[\"update\"],\"before\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510110101962500000001\",\"bucket\":\"my-tf-test-bucket20240510110101962500000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510110101962500000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"staging\",\"Name\":\"My bucket staging\"},\"tags_all\":{\"Environment\":\"staging\",\"Name\":\"My bucket staging\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"after\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510110101962500000001\",\"bucket\":\"my-tf-test-bucket20240510110101962500000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510110101962500000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"staging\",\"Name\":\"The bucket staging\"},\"tags_all\":{\"Environment\":\"staging\",\"Name\":\"The bucket staging\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"after_unknown\":{},\"before_sensitive\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]},\"after_sensitive\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}}],\"prior_state\":{\"format_version\":\"1.0\",\"terraform_version\":\"1.7.3\",\"values\":{\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"schema_version\":0,\"values\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510110101962500000001\",\"bucket\":\"my-tf-test-bucket20240510110101962500000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510110101962500000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"staging\",\"Name\":\"My bucket staging\"},\"tags_all\":{\"Environment\":\"staging\",\"Name\":\"My bucket staging\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"sensitive_values\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}]}}},\"configuration\":{\"provider_config\":{\"aws\":{\"name\":\"aws\",\"full_name\":\"registry.terraform.io/hashicorp/aws\",\"version_constraint\":\"~\\u003e 5.0\"}},\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_config_key\":\"aws\",\"expressions\":{\"bucket_prefix\":{\"constant_value\":\"my-tf-test-bucket\"},\"tags\":{\"references\":[\"var.environment\",\"var.environment\"]}},\"schema_version\":0}],\"variables\":{\"environment\":{}}}},\"timestamp\":\"2024-05-10T15:38:45Z\",\"errored\":false}\n" 32 footprint1, _ := GetPlanFootprint(planJson1) 33 footprint2, _ := GetPlanFootprint(planJson2) 34 isSimilar, _ := PerformPlanSimilarityCheck(*footprint1, *footprint2) 35 assert.True(t, isSimilar) 36 37 footPrints := []TerraformPlanFootprint{*footprint1, *footprint2} 38 isSimilar, _ = SimilarityCheck(footPrints) 39 assert.True(t, isSimilar) 40 41 // In this case addresses don't match so expecting false similarity 42 planJson1 = "{\"format_version\":\"1.2\",\"terraform_version\":\"1.7.3\",\"variables\":{\"environment\":{\"value\":\"devel\"}},\"planned_values\":{\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"schema_version\":0,\"values\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510105906923000000001\",\"bucket\":\"my-tf-test-bucket20240510105906923000000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510105906923000000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"devel\",\"Name\":\"The bucket devel\"},\"tags_all\":{\"Environment\":\"devel\",\"Name\":\"The bucket devel\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"sensitive_values\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}]}},\"resource_changes\":[{\"address\":\"aws_s3_bucket.example_noooooot_same\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"change\":{\"actions\":[\"update\"],\"before\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510105906923000000001\",\"bucket\":\"my-tf-test-bucket20240510105906923000000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510105906923000000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"devel\",\"Name\":\"My bucket devel\"},\"tags_all\":{\"Environment\":\"devel\",\"Name\":\"My bucket devel\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"after\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510105906923000000001\",\"bucket\":\"my-tf-test-bucket20240510105906923000000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510105906923000000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"devel\",\"Name\":\"The bucket devel\"},\"tags_all\":{\"Environment\":\"devel\",\"Name\":\"The bucket devel\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"after_unknown\":{},\"before_sensitive\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]},\"after_sensitive\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}}],\"prior_state\":{\"format_version\":\"1.0\",\"terraform_version\":\"1.7.3\",\"values\":{\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"schema_version\":0,\"values\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510105906923000000001\",\"bucket\":\"my-tf-test-bucket20240510105906923000000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510105906923000000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510105906923000000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"devel\",\"Name\":\"My bucket devel\"},\"tags_all\":{\"Environment\":\"devel\",\"Name\":\"My bucket devel\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"sensitive_values\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}]}}},\"configuration\":{\"provider_config\":{\"aws\":{\"name\":\"aws\",\"full_name\":\"registry.terraform.io/hashicorp/aws\",\"version_constraint\":\"~\\u003e 5.0\"}},\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_config_key\":\"aws\",\"expressions\":{\"bucket_prefix\":{\"constant_value\":\"my-tf-test-bucket\"},\"tags\":{\"references\":[\"var.environment\",\"var.environment\"]}},\"schema_version\":0}],\"variables\":{\"environment\":{}}}},\"timestamp\":\"2024-05-10T15:36:02Z\",\"errored\":false}\n" 43 planJson2 = "{\"format_version\":\"1.2\",\"terraform_version\":\"1.7.3\",\"variables\":{\"environment\":{\"value\":\"staging\"}},\"planned_values\":{\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"schema_version\":0,\"values\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510110101962500000001\",\"bucket\":\"my-tf-test-bucket20240510110101962500000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510110101962500000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"staging\",\"Name\":\"The bucket staging\"},\"tags_all\":{\"Environment\":\"staging\",\"Name\":\"The bucket staging\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"sensitive_values\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}]}},\"resource_changes\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"change\":{\"actions\":[\"update\"],\"before\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510110101962500000001\",\"bucket\":\"my-tf-test-bucket20240510110101962500000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510110101962500000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"staging\",\"Name\":\"My bucket staging\"},\"tags_all\":{\"Environment\":\"staging\",\"Name\":\"My bucket staging\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"after\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510110101962500000001\",\"bucket\":\"my-tf-test-bucket20240510110101962500000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510110101962500000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"staging\",\"Name\":\"The bucket staging\"},\"tags_all\":{\"Environment\":\"staging\",\"Name\":\"The bucket staging\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"after_unknown\":{},\"before_sensitive\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]},\"after_sensitive\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}}],\"prior_state\":{\"format_version\":\"1.0\",\"terraform_version\":\"1.7.3\",\"values\":{\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_name\":\"registry.terraform.io/hashicorp/aws\",\"schema_version\":0,\"values\":{\"acceleration_status\":\"\",\"acl\":null,\"arn\":\"arn:aws:s3:::my-tf-test-bucket20240510110101962500000001\",\"bucket\":\"my-tf-test-bucket20240510110101962500000001\",\"bucket_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.amazonaws.com\",\"bucket_prefix\":\"my-tf-test-bucket\",\"bucket_regional_domain_name\":\"my-tf-test-bucket20240510110101962500000001.s3.eu-west-2.amazonaws.com\",\"cors_rule\":[],\"force_destroy\":false,\"grant\":[{\"id\":\"48ca234ec08b854fd7875d07ed50011a403a0297310717063d53e2085019f22f\",\"permissions\":[\"FULL_CONTROL\"],\"type\":\"CanonicalUser\",\"uri\":\"\"}],\"hosted_zone_id\":\"Z3GKZC51ZF0DB4\",\"id\":\"my-tf-test-bucket20240510110101962500000001\",\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"object_lock_enabled\":false,\"policy\":\"\",\"region\":\"eu-west-2\",\"replication_configuration\":[],\"request_payer\":\"BucketOwner\",\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{\"kms_master_key_id\":\"\",\"sse_algorithm\":\"AES256\"}],\"bucket_key_enabled\":false}]}],\"tags\":{\"Environment\":\"staging\",\"Name\":\"My bucket staging\"},\"tags_all\":{\"Environment\":\"staging\",\"Name\":\"My bucket staging\"},\"timeouts\":null,\"versioning\":[{\"enabled\":false,\"mfa_delete\":false}],\"website\":[],\"website_domain\":null,\"website_endpoint\":null},\"sensitive_values\":{\"cors_rule\":[],\"grant\":[{\"permissions\":[false]}],\"lifecycle_rule\":[],\"logging\":[],\"object_lock_configuration\":[],\"replication_configuration\":[],\"server_side_encryption_configuration\":[{\"rule\":[{\"apply_server_side_encryption_by_default\":[{}]}]}],\"tags\":{},\"tags_all\":{},\"versioning\":[{}],\"website\":[]}}]}}},\"configuration\":{\"provider_config\":{\"aws\":{\"name\":\"aws\",\"full_name\":\"registry.terraform.io/hashicorp/aws\",\"version_constraint\":\"~\\u003e 5.0\"}},\"root_module\":{\"resources\":[{\"address\":\"aws_s3_bucket.example\",\"mode\":\"managed\",\"type\":\"aws_s3_bucket\",\"name\":\"example\",\"provider_config_key\":\"aws\",\"expressions\":{\"bucket_prefix\":{\"constant_value\":\"my-tf-test-bucket\"},\"tags\":{\"references\":[\"var.environment\",\"var.environment\"]}},\"schema_version\":0}],\"variables\":{\"environment\":{}}}},\"timestamp\":\"2024-05-10T15:38:45Z\",\"errored\":false}\n" 44 footprint1, _ = GetPlanFootprint(planJson1) 45 footprint2, _ = GetPlanFootprint(planJson2) 46 isSimilar, _ = PerformPlanSimilarityCheck(*footprint1, *footprint2) 47 assert.False(t, isSimilar) 48 49 footPrints = []TerraformPlanFootprint{*footprint1, *footprint2} 50 isSimilar, _ = SimilarityCheck(footPrints) 51 assert.False(t, isSimilar) 52 53 } 54 55 func TestGetTfSummarizePlan(t *testing.T) { 56 nonEmptyTerraformPlanJson := "{\"format_version\":\"1.1\",\"terraform_version\":\"1.4.6\",\"planned_values\":{\"root_module\":{\"resources\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"schema_version\":0,\"values\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"sensitive_values\":{}},{\"address\":\"null_resource.testx\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"testx\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"schema_version\":0,\"values\":{\"triggers\":null},\"sensitive_values\":{}}]}},\"resource_changes\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"change\":{\"actions\":[\"no-op\"],\"before\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"after\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"after_unknown\":{},\"before_sensitive\":{},\"after_sensitive\":{}}},{\"address\":\"null_resource.testx\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"testx\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"change\":{\"actions\":[\"create\"],\"before\":null,\"after\":{\"triggers\":null},\"after_unknown\":{\"id\":true},\"before_sensitive\":false,\"after_sensitive\":{}}}],\"prior_state\":{\"format_version\":\"1.0\",\"terraform_version\":\"1.4.6\",\"values\":{\"root_module\":{\"resources\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_name\":\"registry.terraform.io/hashicorp/null\",\"schema_version\":0,\"values\":{\"id\":\"7587790946951100994\",\"triggers\":null},\"sensitive_values\":{}}]}}},\"configuration\":{\"provider_config\":{\"null\":{\"name\":\"null\",\"full_name\":\"registry.terraform.io/hashicorp/null\"}},\"root_module\":{\"resources\":[{\"address\":\"null_resource.test\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"test\",\"provider_config_key\":\"null\",\"schema_version\":0},{\"address\":\"null_resource.testx\",\"mode\":\"managed\",\"type\":\"null_resource\",\"name\":\"testx\",\"provider_config_key\":\"null\",\"schema_version\":0}]}}}\n" 57 planSummary, err := GetTfSummarizePlan(nonEmptyTerraformPlanJson) 58 assert.Nil(t, err) 59 assert.NotEmpty(t, planSummary) 60 }