@@ -11,6 +11,7 @@ import (
11
11
"log"
12
12
13
13
"github.com/hashicorp/packer-plugin-sdk/multistep"
14
+ "github.com/hashicorp/packer-plugin-sdk/uuid"
14
15
cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
15
16
)
16
17
@@ -130,7 +131,11 @@ func (s *stepRunInstance) Run(ctx context.Context, state multistep.StateBag) mul
130
131
req .InternetAccessible .BandwidthPackageId = & s .BandwidthPackageId
131
132
}
132
133
}
133
- req .InstanceName = & s .InstanceName
134
+
135
+ // Generate a unique ClientToken for each RunInstances request
136
+ clientToken := uuid .TimeOrderedUUID ()
137
+ req .ClientToken = & clientToken
138
+
134
139
loginSettings := cvm.LoginSettings {}
135
140
if password != "" {
136
141
loginSettings .Password = & password
@@ -140,7 +145,7 @@ func (s *stepRunInstance) Run(ctx context.Context, state multistep.StateBag) mul
140
145
}
141
146
req .LoginSettings = & loginSettings
142
147
req .SecurityGroupIds = []* string {& security_group_id }
143
- req .ClientToken = & s .InstanceName
148
+ req .InstanceName = & s .InstanceName
144
149
req .HostName = & s .HostName
145
150
req .UserData = & userData
146
151
req .CamRoleName = & s .CamRoleName
@@ -178,7 +183,7 @@ func (s *stepRunInstance) Run(ctx context.Context, state multistep.StateBag) mul
178
183
}
179
184
180
185
s .instanceId = * resp .Response .InstanceIdSet [0 ]
181
- Message (state , "Waiting for instance ready" , "" )
186
+ Message (state , fmt . Sprintf ( "Instance %s created, waiting for instance ready", s . instanceId ) , "" )
182
187
183
188
err = WaitForInstance (ctx , client , s .instanceId , "RUNNING" , 1800 )
184
189
if err != nil {
0 commit comments