Alpine-based Terraform image used as the base for leverage-toolbox, contains a binary for date that doesn't include the -d flag.
Since AWS seems to be sending now MFA credentials in this format:
2022-11-01T10:00:00-00:00
# previous version seemed to be
2022-11-01T10:00:00Z
Inside the scripts, Toolbox is getting rid of the T and the Z generating this command:
date -d '2022-11-01 10:00:00'
With the new format, the command is:
date -d '2022-11-01 10:00:00-00:00'
...raising an error.
Expected Behavior
Toolbox managing both cases.
Steps to Reproduce
Steps to reproduce the behavior:
Run this:
╰─ docker run -it --rm --entrypoint /bin/sh binbash/leverage-toolbox:1.2.7-latest -c 'DATE="2022-11-01T10:00:00+00:00" && DATE=$(echo $DATE | sed "s/T/ /" | sed "s/Z//") && echo $DATE && date -d "$DATE" +"%s"'
2022-11-01 10:00:00+00:00
date: invalid date '2022-11-01 10:00:00+00:00'
See the error
Screenshots
n/a
Environment (please complete the following information):
Containers.
The previous Leverage CLI version used terraform:1.1.9 as a base. The new toolbox uses terraform:1.2.7 and it seems to be some differences:
╰─ docker run -it --rm --entrypoint /bin/sh hashicorp/terraform:1.1.9 -c 'DATE="2022-11-01T10:00:00+00:00" && DATE=$(echo $DATE | sed "s/T/ /" | sed "s/Z//") && echo $DATE && date -d "$DATE" +"%s"'
2022-11-01 10:00:00+00:00
1667296800
╰─ docker run -it --rm --entrypoint /bin/sh hashicorp/terraform:1.2.7 -c 'DATE="2022-11-01T10:00:00+00:00" && DATE=$(echo $DATE | sed "s/T/ /" | sed "s/Z//") && echo $DATE && date -d "$DATE" +"%s"'
2022-11-01 10:00:00+00:00
date: invalid date '2022-11-01 10:00:00+00:00'
Additional Context
Solution
Removing the extra digits will solve the issue partially. (supposing always it will be UTC+0 timezone)
E.g.:
╰─ docker run -it --rm --entrypoint /bin/sh hashicorp/terraform:1.2.7 -c 'DATE="2022-11-01T10:00:00+00:00" && DATE=$(echo $DATE | sed "s/T/ /" | sed -E "s/(Z|\+[0-9]{2}:[0-9]{2})$//") && echo $DATE && date -d "$DATE" +"%s"'
2022-11-01 10:00:00
1667296800
Regarding time zones
Due to the Time Zone issue (do we need to pay attention to the TZ or AWS will always send Zulu Time?) I'll keep this issue opened for further discussion.
Wider solution
As per this post, this scenario can be handled by date by installing coreutils:
Describe the Bug
Alpine-based Terraform image used as the base for
leverage-toolbox
, contains a binary fordate
that doesn't include the-d
flag.Since AWS seems to be sending now MFA credentials in this format:
Inside the scripts, Toolbox is getting rid of the T and the Z generating this command:
With the new format, the command is:
...raising an error.
Expected Behavior
Toolbox managing both cases.
Steps to Reproduce
Steps to reproduce the behavior:
Screenshots
n/a
Environment (please complete the following information):
Containers. The previous Leverage CLI version used
terraform:1.1.9
as a base. The new toolbox usesterraform:1.2.7
and it seems to be some differences:Additional Context
Solution
Removing the extra digits will solve the issue partially. (supposing always it will be UTC+0 timezone)
E.g.:
Regarding time zones
Due to the Time Zone issue (do we need to pay attention to the TZ or AWS will always send Zulu Time?) I'll keep this issue opened for further discussion.
Wider solution
As per this post, this scenario can be handled by
date
by installingcoreutils
:Evidence: