how can i allow aws IAM permission only specific time

Viewed 147

I am trying to make IAM polish to only work from 9AM to 10AM.

Since I am not corder, so I am struggle with this...

help me plz....

I tried to add conditions:

"Condition": {
    "DateGreaterThan": {"aws:CurrentTime": "2021-04-20T09:00:00Z"},
    "DateLessThan": {"aws:CurrentTime": "2021-04-20T10:00:00Z"}

but.. in this way, i have to update manually every day.. So i tried ...

"Condition": {
    "DateGreaterThan": {"aws:CurrentTime": "****-**-**T09:00:00Z"},
    "DateLessThan": {"aws:CurrentTime": "****-**-**T10:00:00Z"}

but this is not working.

How can i accomplish working depends on time not depends on date..?

Thank you

1 Answers

You can't use wildcards in datetime operations in IAM. From docs

Wildcards are not permitted for date condition operators.

So you either have to use full date/time or timestamp. To automate this, you can create a lambda function that is triggered on a schedule. The lambda would use AWS sdk to update your policy everyday.

Related