C4W4A1 Lab - Unsure about what to put in <PACIFIC-TIME-CURRENT-DATE>

For this section of the lab:
4.2.3. Open the terraform/modules/transform_job/glue.tf file. Complete the code following the instructions and save changes.

And in this section

Set “–ingest_date” to the server’s current date in Pacific Time (UTC-7), in “yyyy-mm-dd” format.

# (replace the placeholder <PACIFIC-TIME-CURRENT-DATE>)
"--ingest_date"             = "<PACIFIC-TIME-CURRENT-DATE>" 

I am getting an error on the timestamp format.

Error: Invalid function argument

│ on modules/transform_job/glue.tf line 25, in resource “aws_glue_job” “json_transformation_job”:
│ 25: “–ingest_date” = formatdate(“yyyy-MM-dd”, timestamp())
│ ├────────────────
│ │ while calling formatdate(format, time)

│ Invalid value for “format” parameter: invalid date format verb “yyyy”.


│ Error: Invalid function argument

│ on modules/transform_job/glue.tf line 65, in resource “aws_glue_job” “songs_transformation_job”:
│ 65: “–ingest_date” = formatdate(“yyyy-MM-dd”, timestamp())
│ ├────────────────
│ │ while calling formatdate(format, time)

│ Invalid value for “format” parameter: invalid date format verb “yyyy”.

Waht should I put in the “–ingest_date” = ?

Hello @weiweiwong
You should put the current date from the pacific time zone in the “yyyy-mm-dd” format. You can use google like this:


Currently, this value should be 2024-12-13.

Thank you very much, Amir. That worked!

Isn’t it really bad practice to hardcode the current date? This can’t be the intention of the lab.

I did something similar to @weiweiwong that worked. But I don’t think it will convert the timezone (shouldn’t be an issue until 9pm PT). The error was using lower case in the format string. Terraform wants upper case. See docs: formatdate - Functions - Configuration Language | Terraform | HashiCorp Developer

This seemed to work:

    "--ingest_date"             = "${formatdate("YYYY-MM-DD",timestamp())}"

@AviShapiro you are right. We’d better not hardcode the current date. However, for educational purposes and to keep the assignments simpler, the team has decided to do so. Thank you for the feedback.