File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
controllers/providers/aws Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -214,7 +214,12 @@ func (w *AwsWorker) CreateScalingGroupRole(name string) (*iam.Role, *iam.Instanc
214214 createdProfile = out .InstanceProfile
215215 time .Sleep (DefaultInstanceProfilePropagationDelay )
216216
217- _ , err = w .IamClient .AddRoleToInstanceProfile (& iam.AddRoleToInstanceProfileInput {
217+ } else {
218+ createdProfile = instanceProfile
219+ }
220+
221+ if len (createdProfile .Roles ) == 0 {
222+ _ , err := w .IamClient .AddRoleToInstanceProfile (& iam.AddRoleToInstanceProfileInput {
218223 InstanceProfileName : aws .String (name ),
219224 RoleName : aws .String (name ),
220225 })
@@ -224,10 +229,9 @@ func (w *AwsWorker) CreateScalingGroupRole(name string) (*iam.Role, *iam.Instanc
224229 return createdRole , createdProfile , errors .Wrap (err , "failed to attach instance-profile" )
225230 }
226231 }
232+ } else {
233+ createdProfile .Roles = append (createdProfile .Roles , createdRole )
227234 }
228-
229- } else {
230- createdProfile = instanceProfile
231235 }
232236
233237 return createdRole , createdProfile , nil
You can’t perform that action at this time.
0 commit comments