@@ -128,6 +128,10 @@ func resourceTencentCloudMonitorTmpInstanceCreate(d *schema.ResourceData, meta i
128
128
logId , request .GetAction (), request .ToJsonString (), result .ToJsonString ())
129
129
}
130
130
131
+ if result == nil || result .Response == nil {
132
+ return resource .NonRetryableError (fmt .Errorf ("Create monitor tmpInstance failed, Response is nil." ))
133
+ }
134
+
131
135
response = result
132
136
return nil
133
137
})
@@ -137,6 +141,10 @@ func resourceTencentCloudMonitorTmpInstanceCreate(d *schema.ResourceData, meta i
137
141
return err
138
142
}
139
143
144
+ if response .Response .InstanceId == nil {
145
+ return fmt .Errorf ("InstanceId is nil." )
146
+ }
147
+
140
148
tmpInstanceId := * response .Response .InstanceId
141
149
service := svcmonitor .NewMonitorService (meta .(tccommon.ProviderMeta ).GetAPIV3Conn ())
142
150
ctx := context .WithValue (context .TODO (), tccommon .LogIdKey , logId )
@@ -162,6 +170,31 @@ func resourceTencentCloudMonitorTmpInstanceCreate(d *schema.ResourceData, meta i
162
170
return err
163
171
}
164
172
173
+ // wait
174
+ initStatus := monitor .NewDescribePrometheusInstanceInitStatusRequest ()
175
+ initStatus .InstanceId = & tmpInstanceId
176
+ err = resource .Retry (8 * tccommon .ReadRetryTimeout , func () * resource.RetryError {
177
+ result , errRet := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().UseMonitorClient ().DescribePrometheusInstanceInitStatus (initStatus )
178
+ if errRet != nil {
179
+ return tccommon .RetryError (errRet , tccommon .InternalError )
180
+ }
181
+
182
+ if result == nil || result .Response == nil || result .Response .Status == nil {
183
+ return resource .NonRetryableError (fmt .Errorf ("prometheusInstanceInit status is nil, operate failed" ))
184
+ }
185
+
186
+ status := result .Response .Status
187
+ if * status == "running" {
188
+ return nil
189
+ }
190
+
191
+ return resource .RetryableError (fmt .Errorf ("prometheusInstanceInit status is %s" , * status ))
192
+ })
193
+
194
+ if err != nil {
195
+ return err
196
+ }
197
+
165
198
if tags := helper .GetTags (d , "tags" ); len (tags ) > 0 {
166
199
tagService := svctag .NewTagService (meta .(tccommon.ProviderMeta ).GetAPIV3Conn ())
167
200
region := meta .(tccommon.ProviderMeta ).GetAPIV3Conn ().Region
0 commit comments