in .Net, after I create IAM role, I need to wait very long (~20s) before I can create lambda function or Kinesis firehose using that IAM role. Is there any way that I can check if IAM role is active to use? In my current code, I have to wait 20s. That is an unsafe solution because it may take longer than 20s until IAM role is active.
Asked
Active
Viewed 34 times
0
-
Create a loop and check if the role is ready ever 5 second or so. break the loop when its ready. – Marcin Jun 30 '23 at 08:42
-
Create a loop and "check if the role is ready" => how to check if the role is ready? this is my problem @Marcin – Nguyen Hoai Nam Jun 30 '23 at 08:46
-
What problem? You haven't show any code in which you attempt to write the loop. no errors nor any context on what you are doing and what is the problem with your code. – Marcin Jun 30 '23 at 08:49
-
you instruct me to check if the role is ready, what is the code to do that? because my question is: what is the code to check if the role is ready @Marcin – Nguyen Hoai Nam Jun 30 '23 at 08:52
-
Does this answer your question - https://stackoverflow.com/a/20157294/2570277 – Nick Jun 30 '23 at 08:55
-
If you are creating a new IAM Role, just call `GetRole()`, passing the role name. If it doesn't (yet) exist, it will generate an error. To see what that error looks like, call it with an incorrect name. Then you'll know how to recognise a role that does, or doesn't, exist. – John Rotenstein Jun 30 '23 at 09:15
-
thanks @JohnRotenstein, but your solution doesn't work `await client.CreateRoleAsync(roleName); // pass await client.PutRolePolicyAsync(roleName); // pass var roleARN = await client.GetRoleAsync(roleName); // pass await client.CreateDeliveryStreamAsync(roleARN); // fail` mean GetRole() cannot be used to check if the role is active or not – Nguyen Hoai Nam Jun 30 '23 at 09:27