I tried manually typing said code, and even considered using a separate file for my user-data. I fixed it by baking an image with the wp-config I wanted. I still use a launch template to ‘sed’ over things in the configuration I want to use environment variables with from the Parameter Store. I think I could have come across a way more elegant solution, but it will do for now.
http://3.239.162.123/index.php/2023/11/21/i-did-it-what-did-i-do/
This got me in the end. Well, sort of. I noticed lcrosendo.info acting funky this week. It’s acted funky before, but not like this. The website would go down at random times; like I would move around the WordPress dashboard and BAM. This time though no fixes worked and the site stayed down. Not even an error page. Going back to the previous solution I mentioned in the quote, the configuration wasn’t future proof. It relied on a baked image. Unless you’re on the ball with baking new configs, when a new instance gets launched up by the auto-scaler, any new OS updates by AWS for their Amazon Linux images will not carry over. The solution was in general not very scalable.
Now I really had to do something. It was hell. I tried going small at first, but whenever I thought I would get close to a fix, it just escaped me. I got the site back up, but the web elements were all over the place and I couldn’t get into the WP admin page. I redid almost everything after that. I couldn’t pinpoint the main issue at first so I went and started clean with the database thinking it was corrupted. The WP fix tool that’s supposed to fix a corrupted database didn’t work. Along with the new database, I changed from Amazon Linux HVM to Amazon Linux 2023, as well as using different packages than before. I went away from the baked images to finding a solution that put everything into the launch templates. It’s been a long time since I touched all the nuts and bolts for the website, and since then I’ve learned a lot of new things. Sed was what was causing me lots of problems originally. I felt like I didn’t shy away from this now I was more comfortable using Linux and formatting and everything. I found things in wp-config.php wouldn’t work if it’s below the add script comments. Echo wouldn’t also work in that case so I troubled myself over trying to insert things just after “<?php”. The workaround for HTTPS that was working for me also had to go before the rest of the stuff I needed to add into the config.
In the end, I got everything to work. It used to take me weeks just to get things up and running dealing with HTTPS, with a hundred different tabs and tutorials, and I only came up with a very subpar solution. It only took me a day and a half now for me to fix. I even made it more future-proof. I think it was the new WordPress update that caused issues with my website, but I’m glad I got to fix things and add stuff on top anyway despite the very turbid 24 hours.