@@ -11,6 +11,7 @@ import (
1111 "log"
1212
1313 "github.com/hashicorp/packer-plugin-sdk/multistep"
14+ "github.com/hashicorp/packer-plugin-sdk/uuid"
1415 cvm "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/cvm/v20170312"
1516)
1617
@@ -130,7 +131,11 @@ func (s *stepRunInstance) Run(ctx context.Context, state multistep.StateBag) mul
130131 req .InternetAccessible .BandwidthPackageId = & s .BandwidthPackageId
131132 }
132133 }
133- req .InstanceName = & s .InstanceName
134+
135+ // Generate a unique ClientToken for each RunInstances request
136+ clientToken := uuid .TimeOrderedUUID ()
137+ req .ClientToken = & clientToken
138+
134139 loginSettings := cvm.LoginSettings {}
135140 if password != "" {
136141 loginSettings .Password = & password
@@ -140,7 +145,7 @@ func (s *stepRunInstance) Run(ctx context.Context, state multistep.StateBag) mul
140145 }
141146 req .LoginSettings = & loginSettings
142147 req .SecurityGroupIds = []* string {& security_group_id }
143- req .ClientToken = & s .InstanceName
148+ req .InstanceName = & s .InstanceName
144149 req .HostName = & s .HostName
145150 req .UserData = & userData
146151 req .CamRoleName = & s .CamRoleName
@@ -178,7 +183,7 @@ func (s *stepRunInstance) Run(ctx context.Context, state multistep.StateBag) mul
178183 }
179184
180185 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 ) , "" )
182187
183188 err = WaitForInstance (ctx , client , s .instanceId , "RUNNING" , 1800 )
184189 if err != nil {
0 commit comments