when i run terraform apply the terminal crashes. It seems there is something wrong with environmental variables. Then eventually if i keep trying to run terraform the window disconnects and tells me to reload.
Hello @SRA95
You can use the command terraform apply -no-color 2> errors.txt
. This way, the output to the terraform apply command gets written to a text file, and you can read the text file to see what’s causing the issue.
Hello @Amir_Zare, I have a somehow different issue. It is with C4W4 Capstone part 1 Terraform, so I’m posting it here as a response. My almost week-old issue is at the “4.3 - Serving Zone” terraform apply: it invariably crashes with “exit code: 1” and forces me to reboot my lab.
I already tried almost anything, even filling that lab refresh form…
Now I’m deleting the .terraform.lock.hcl file, to force terraform to start clean, checking the Cloud Formation outputs for eventually changed items, finding most of the times everything is the same, or that all that changed was the APIEndpoint, running all code cells successfully, copying the script files over the ones already there, reusing all my changed and several times reviewed source files, leaving the 4.3.6 section’s terraform to do it all.
Before the Lab support refresh, which I found strange to keep some items, the errors.txt resulted empty, but today, at my second and first to use it run, it holds this information:
Error: creating Glue Connection (de-c4w4a1-connection-rds): operation error Glue: CreateConnection, https response error StatusCode: 400, RequestID: ca6329c6-d6a2-443d-8bb3-18707974e749, AlreadyExistsException: Connection already exists.
with module.extract_job.aws_glue_connection.rds_connection,
on modules/extract_job/glue.tf line 2, in resource "aws_glue_connection" "rds_connection":
2: resource "aws_glue_connection" "rds_connection" {
Error: creating IAM Role (de-c4w4a1-glue-role): operation error IAM: CreateRole, https response error StatusCode: 409, RequestID: 6adc5baa-2d0c-448f-ac64-cbd305884119, EntityAlreadyExists: Role with name de-c4w4a1-glue-role already exists.
with module.extract_job.aws_iam_role.glue_role,
on modules/extract_job/iam.tf line 1, in resource "aws_iam_role" "glue_role":
1: resource "aws_iam_role" "glue_role" {
Error: pq: Schema "deftunes_serving" already exists
with module.serving.redshift_schema.serving_schema,
on modules/serving/redshift.tf line 2, in resource "redshift_schema" "serving_schema":
2: resource "redshift_schema" "serving_schema" {
Error: pq: Schema "deftunes_transform" already exists
with module.serving.redshift_schema.transform_external_from_glue_data_catalog,
on modules/serving/redshift.tf line 12, in resource "redshift_schema" "transform_external_from_glue_data_catalog":
12: resource "redshift_schema" "transform_external_from_glue_data_catalog" {
I tried to delete some objects, but have no permissions… Can you please help? This crash is driving me mad!..
Thanks!
Will a terraform destroy do it?
@nmsleal When you tried the lab again, did you skip all the sections 4.1 and 4.2 and directly started at 4.3?
Hi @hawraa.salami, I fast forwarded all the sections, but did update all the changed cloud formation references and executed all code cells to confirm it. As I had completed all the changes to the files and had everything working till the end of transformation, the terraform execution was done only once, at 4.3. It made no sense to me put comments back and do partial terraforms again. After this sole execution all services and scripts should be in place, and then I’d execute the latter in order, first extraction, then transformation (I did it before with no issues at all).
The only changes I’ve made after completing transformation were the changes in the Serving files (4.3 section), which are extremely simple, by the way, and then the terraform apply started to crash…
To better reply to your question, I have not re-run all the jobs before the 4.3 terraform, though their scripts, and the Glue jobs, were all updated.
@nmsleal I will look into the details of the lab files later today and get back to you with a detailed answer.
But in the mean time, if you’d like to redo the lab, I highly suggest that you do the lab steps in the exact order they appear in the lab (as if you’re doing the lab for the first time).
- first module (other modules and outputs are commented) → run its glue jobs
- second module (the third module is commented) → run its glue jobs
and so on..
And that’s because of the dependencies between the modules and their outputs.
I’ll be looking into your issue in more details later today.
@nmsleal As another tip, one learner suggested appending || echo “$?”
to all the terraform commands so the error gets displayed in the terminal without crashing it ( as an alternative to printing the errors in the text file). I thought of sharing it also here.
@nmsleal Can you also share in a message your lab id to make sure all is good from the respect of the lab time budget?
now i just get the script jobs failing here is the code screenshot:
@SRA95 could you please delete the screenshots from here. You can share them with me in a separate message.
okay i think i know where its failing: I dont have the original terraform shell code. but i think the EC2 API endpoint shell fill in is missing something like users and session. Could i get that skeleton code for the glue.tf again?
so how do i message you separately? and how can i get the skeleton terraform files? Is there a chance i can just send you my code for review?
zpefheynoyth
Thanks
I can’t redo the lab anymore:
~/project$ source scripts/setup.sh
An error occurred (InvalidClientTokenId) when calling the DescribeDBInstances operation: The security token included in the request is invalid.
I’ll wait for it to become available again (tell me if I have to request something, please) and then will try doing the awkward re-commenting/running phases. Doing Extract and Transformation terraform in one go, and running the jobs in the corresponding order did work before…
Thanks!
@nmsleal I just adjusted your lab time budget as it was exceeded. You can try again. If you don’t want to comment things again, that’s fine. Maybe the issue was just because you exceed the total time budget.
@hawraa.salami, thanks a lot for all the help! I ended up re-commenting the troublesome serving part, re-ran all code cells, copied all the scripts, updated the changed placeholders, bypassed the extract terraform and executed the transformation one, that built all. Then, I ran the jobs in order and finally executed the serving terraform. It worked!!!
After all this, I was able to finish the lab! It took me too much time, unfortunately. I was on schedule and failed my deadlines because of all these troubles. Must say this lab was the most problematic of all the previous, though I’ve been experiencing several delays at every lab…
Now it’s time to move to part II. I checked the deadline and it says:
Deadline
The assignment was due on Jun 8, 11:59 PM WEST
You can still pass this assignment before the course ends.
How many days do I have to do it, do you know?
Thanks!
@nmsleal Great to hear that! As long your subscription is valid, you can try the lab anytime, deadlines will automatically reset. Please let me know how things will go with you in part 2.