@@ -904,6 +904,8 @@ func TestAccFunction_logConfig(t *testing.T) {
904
904
// The empty strings of the LTS group and stream will be returned, but the nil values returned for
905
905
// their names.
906
906
resource .TestCheckResourceAttr (withoutLtsParams , "log_group_id" , "" ),
907
+ // When a parameter is not configured in the ReadContext phase and has never been configured in the
908
+ // script, its value in tfstate is null after creation.
907
909
resource .TestCheckNoResourceAttr (withoutLtsParams , "log_group_name" ),
908
910
resource .TestCheckResourceAttr (withoutLtsParams , "log_stream_id" , "" ),
909
911
resource .TestCheckNoResourceAttr (withoutLtsParams , "log_stream_name" ),
@@ -946,15 +948,27 @@ func TestAccFunction_logConfig(t *testing.T) {
946
948
Check : resource .ComposeTestCheckFunc (
947
949
rcWithLtsParams .CheckResourceExists (),
948
950
resource .TestCheckResourceAttr (withLtsParams , "functiongraph_version" , "v1" ),
949
- resource .TestCheckResourceAttrPair (withLtsParams , "log_group_id" ,
950
- "huaweicloud_lts_group.test.1" , "id" ),
951
- resource .TestCheckResourceAttrPair (withLtsParams , "log_group_name" ,
952
- "huaweicloud_lts_group.test.1" , "group_name" ),
953
- resource .TestCheckResourceAttrPair (withLtsParams , "log_stream_id" ,
954
- "huaweicloud_lts_stream.test.1" , "id" ),
955
- resource .TestCheckResourceAttrPair (withLtsParams , "log_stream_name" ,
956
- "huaweicloud_lts_stream.test.1" , "stream_name" ),
951
+ // The empty strings of the LTS group and stream will be returned, but the nil values returned for
952
+ // their names.
953
+ resource .TestCheckResourceAttr (withLtsParams , "log_group_id" , "" ),
954
+ // When a parameter is not configured in the ReadContext phase and has been configured in the
955
+ // script, its value in tfstate is the corresponding null value instead of null after it is changed
956
+ // to null or empty value.
957
+ resource .TestCheckResourceAttr (withLtsParams , "log_group_name" , "" ),
958
+ resource .TestCheckResourceAttr (withLtsParams , "log_stream_id" , "" ),
959
+ resource .TestCheckResourceAttr (withLtsParams , "log_stream_name" , "" ),
957
960
resource .TestCheckResourceAttr (withLtsParams , "lts_custom_tag.%" , "0" ),
961
+ rcWithoutLtsParams .CheckResourceExists (),
962
+ resource .TestCheckResourceAttr (withoutLtsParams , "functiongraph_version" , "v1" ),
963
+ // The empty strings of the LTS group and stream will be returned, but the nil values returned for
964
+ // their names.
965
+ resource .TestCheckResourceAttr (withoutLtsParams , "log_group_id" , "" ),
966
+ resource .TestCheckResourceAttr (withoutLtsParams , "log_group_name" , "" ),
967
+ resource .TestCheckResourceAttr (withoutLtsParams , "log_stream_id" , "" ),
968
+ resource .TestCheckResourceAttr (withoutLtsParams , "log_stream_name" , "" ),
969
+ resource .TestCheckResourceAttr (withoutLtsParams , "lts_custom_tag.%" , "2" ),
970
+ resource .TestCheckResourceAttr (withoutLtsParams , "lts_custom_tag.foo" , "bar" ),
971
+ resource .TestCheckResourceAttr (withoutLtsParams , "lts_custom_tag.key" , "value" ),
958
972
),
959
973
},
960
974
},
@@ -1088,11 +1102,24 @@ resource "huaweicloud_fgs_function" "create_with_lts_params" {
1088
1102
func_code = base64encode(var.script_content)
1089
1103
description = "Created by terraform script"
1090
1104
functiongraph_version = "v1"
1105
+ }
1106
+
1107
+ resource "huaweicloud_fgs_function" "create_without_lts_params" {
1108
+ name = "%[2]s_without_lts_params"
1109
+ memory_size = 128
1110
+ runtime = "Python2.7"
1111
+ timeout = 3
1112
+ app = "default"
1113
+ handler = "index.handler"
1114
+ code_type = "inline"
1115
+ func_code = base64encode(var.script_content)
1116
+ description = "Created by terraform script"
1117
+ functiongraph_version = "v1"
1091
1118
1092
- log_group_id = huaweicloud_lts_group.test[1].id
1093
- log_stream_id = huaweicloud_lts_stream.test[1].id
1094
- log_group_name = huaweicloud_lts_group.test[1].group_name
1095
- log_stream_name = huaweicloud_lts_stream.test[1].stream_name
1119
+ lts_custom_tag = {
1120
+ foo = "bar"
1121
+ key = "value"
1122
+ }
1096
1123
}
1097
1124
` , testAccFunction_logConfig_base (name ), name )
1098
1125
}
0 commit comments