• Connect Laravel to AWS RDS MySQL Database Through AWS Secrets Manager

    I assume you already have an Amazon RDS DB instance. If not, just create a free-tier one.

    Then, click on your DB instance → ConfigurationManage in Secrets Manager. Here, you will find your Secret Name.

    You will need this in your Laravel service later.

    But first, you need to create an IAM Role, so your EC2 instance can connect to the database easily.

    At the top right corner, you should see your AWS username. Click on it, and in the dropdown menu, click Security CredentialsRolesCreate RoleAWS Service → Use case: EC2. Then, select the SecretsManagerReadWrite policy (you can customize permissions later to control what your EC2 instance can and cannot access).

    Give the role a name, for example: EC2-SecretManager-Role.

    That’s it!

    Now your EC2 instance can communicate with Secrets Manager.
    (Of course, you could make it even more secure by allowing access to only specific databases for specific instances — you can fine-tune this with IAM policies.)

    First, you’ll need to install the AWS SDK

    composer require aws/aws-sdk-phpCode language: JavaScript (javascript)


    Now, create a service class in your Laravel application at app/Services/AWSSecretsManager.php

    <?php
    
    namespace App\Services;
    
    use Aws\Exception\AwsException;
    use Aws\SecretsManager\SecretsManagerClient;
    
    class AWSSecretsManagerService
    {
        public function getSecret($secretName)
        {
            $client = new SecretsManagerClient([
                'version' => 'latest',
                'region' => 'eu-central-1'
            ]);
    
            try {
                $result = $client->getSecretValue([
                    'SecretId' => $secretName,
                ]);
            } catch (AwsException $e) {
                throw $e;
            }
    
            return json_decode($result['SecretString'], true);
        }
    }Code language: PHP (php)

    This function connects to AWS Secrets Manager every time your application connects to the database, so you no longer need to store DB credentials in your .env file.

    The final step: you should add your database configuration in .env, but fetch the username and password dynamically from Secrets Manager.

    When you click on your database instance in AWS, you’ll find:

    • Endpoint → use it as your DB_HOST
    • Database Name → use it as your DB_DATABASE

    The magic happens in config/database.php

    $secretsManager = app(\App\Services\AWSSecretsManagerService::class);
    $secrets = $secretsManager->getSecret('your-secret-name-from-the-beginning-of-the-post');
    Code language: PHP (php)
    'mysql' => [
                'username' => env('APP_ENV') === 'production' ? $secrets['username'] : env('DB_USERNAME', 'root'),
                'password' => env('APP_ENV') === 'production' ? $secrets['password'] : env('DB_PASSWORD', ''),
                ],Code language: PHP (php)


    Tadaaa! 🎉

    Now you have a secure AWS EC2 → AWS RDS connection in Laravel without hardcoding your database credentials!

  • Why Job Searching Feels Like a Broken System

    As a Laravel developer, my career has been a series of projects—some long-term, some short-lived. Sometimes, I outgrow a company due to its atmosphere or management style. Other times, the projects dry up, and I find myself back in the frustrating cycle of job searching.

    But let me tell you, it sucks.

    I recently sent out my CV (with over five years of PHP experience) to about 60 companies. Out of those, I got interviews with only six. After rounds of technical assessments and interviews, only two companies got back to me with offers. And guess what? The salaries were way below my expectations.

    Let’s talk about the time investment here. I spent countless hours preparing for these interviews, doing take-home test tasks, and hopping on calls that felt more like interrogations than discussions. Seriously, who has time to do free work? The market dictates that you have to prove yourself again and again, even when your portfolio speaks for itself.

    Then, in the middle of this exhausting process, an old friend’s friend reached out. He had a project and needed someone with my skill set. We started working together, and things just clicked. From the first line of code to the final deployment, we nailed it. The project was delivered 30% faster than expected, thanks to my streamlined solutions. The client, who runs his own IT company, even called it the cleanest code he had ever seen.

    And the best part? I made 200% more money on this freelance project than I would have in a full-time role with one of those companies that ghosted me after an interview.

    So what’s the takeaway? If you know your strengths, lean into them. Ignore the noise about needing to learn every single new framework or tool just because the market says so. If you’re a master at one tech stack—be it Laravel, MySQL, or DevOps—you’re valuable, whether or not the big corporations recognize it.

    Personally, I prefer working with medium-sized companies over massive corporations. The speed of development is better, the human element is stronger, and you don’t have to constantly fear being laid off just because you were 3% slower than your colleague one month.

    So, if you’re feeling stuck in the job hunt, don’t lose hope. Your skills are worth more than endless test tasks and lowball offers. And who knows? Maybe we can help each other out. Drop your CV, your ideas, or your side projects. Let’s build something better together.

    [email protected]