{"id":2073,"date":"2025-04-15T08:52:30","date_gmt":"2025-04-15T08:52:30","guid":{"rendered":"https:\/\/200oksolutions.com\/blog\/?p=2073"},"modified":"2025-12-04T07:44:04","modified_gmt":"2025-12-04T07:44:04","slug":"blog-aws-secrets-manager-laravel-integration","status":"publish","type":"post","link":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/","title":{"rendered":"INTEGRATING AWS SECRETS MANAGER IN LARAVEL"},"content":{"rendered":"\n<p><strong><u>Pre-requisites:<\/u><\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>&nbsp;Laravel app installed through <strong><em>composer create-project laravel\/laravel your-project-name.<\/em><\/strong> Also, a package installed through <strong><em>composer require aws\/aws-sdk-php.<\/em><\/strong><\/li>\n\n\n\n<li>Account on aws with following credentials saved in the .env file of the project<br>AWS_ACCESS_KEY_ID, AWS_ACCESS_SECRET_KEY, AWS_DEFAULT_REGION.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Configure AWS Secrets Manager?<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Open AWS Secrets Manager<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Sign into the AWS Management Console.<\/li>\n\n\n\n<li>Search for Secrets Manager and open it.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"624\" height=\"300\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture1-19.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2074\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture1-19.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture1-19-300x144.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Store a New Secret<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click &#8220;Store a new secret&#8221;.<\/li>\n\n\n\n<li>Choose secret type (e.g., credentials for RDS, other types, or plain text).<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"624\" height=\"60\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture3x.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2078\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture3x.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture3x-300x29.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture4x-1024x640.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2079\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture4x-1024x640.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture4x-300x188.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture4x-768x480.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture4x-1536x960.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture4x-2048x1280.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Configure the Secret<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Provide the name of the secret to be made, optionally provide the description for the secret.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"517\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture2x-1024x517.png\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2075\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture2x-1024x517.png 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture2x-300x151.png 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture2x-768x388.png 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture2x-1536x775.png 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture2x.png 1892w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Create a rotation schedule for your secret(optional).<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"471\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture5x-1024x471.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2080\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture5x-1024x471.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture5x-300x138.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture5x-768x353.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture5x-1536x707.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture5x-2048x942.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Review the configuration of the secret you created.<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"423\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture6x-1024x423.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2082\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture6x-1024x423.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture6x-300x124.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture6x-768x318.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture6x-1536x635.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture6x-2048x847.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"94\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture7x-1024x94.webp\" alt=\"\" class=\"wp-image-2081\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture7x-1024x94.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture7x-300x27.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture7x-768x70.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture7x-1536x140.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture7x-2048x187.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to configure IAM for Secrets Manager?<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Search for<strong> IAM <\/strong>in the <em>aws console search bar.<\/em><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go for <strong>users <\/strong>menu in the sidebar<\/li>\n\n\n\n<li>Click on <strong>create user<\/strong> button to create the user<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"338\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture8x-1024x338.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2083\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture8x-1024x338.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture8x-300x99.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture8x-768x253.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture8x-1536x507.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture8x.webp 1925w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><br>Step 2: Provide the user details<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"340\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture9-2-1024x340.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2084\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture9-2-1024x340.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture9-2-300x100.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture9-2-768x255.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture9-2-1536x510.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture9-2-2048x680.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Set the user permission for the secrets manager being created.<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"240\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture11.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2085\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture11.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture11-300x115.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Review the details entered for creating the user and click on the <strong>Create user<\/strong> button to create the user.<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"541\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture12-1024x541.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2086\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture12-1024x541.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture12-300x158.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture12-768x406.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture12-1536x812.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture12.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Once user<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"541\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture13-1024x541.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2087\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture13-1024x541.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture13-300x158.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture13-768x406.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture13-1536x812.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture13.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"317\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture14-1024x317.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2088\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture14-1024x317.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture14-300x93.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture14-768x237.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture14-1536x475.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture14.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Clicking on the user\u2019s name in the table will take you to this page to add the permissions for the user.<\/h3>\n\n\n\n<p>\u2022 Click on add permissions.<br>\u2022 Select Create inline policy.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"404\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture15-1024x404.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2089\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture15-1024x404.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture15-300x118.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture15-768x303.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture15-1536x605.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture15.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 7: Specify the permissions for the policy<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"384\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture18-1024x384.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2090\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture18-1024x384.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture18-300x112.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture18-768x288.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture18-1536x575.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture18.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"399\" height=\"118\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture19.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2091\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture19.webp 399w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture19-300x89.webp 300w\" sizes=\"(max-width: 399px) 100vw, 399px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 8: To specify what resource to be included in the permission, go back to the Secrets Manager console.<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click on the name of the secret.It will take to the details of the secret. And it contains Secret ARN. Copy it and put it in the policy\u2019s resource parameter.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"97\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture23-1024x97.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2103\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture23-1024x97.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture23-300x28.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture23-768x72.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture23-1536x145.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture23.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"195\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture24-1024x195.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2104\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture24-1024x195.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture24-300x57.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture24-768x146.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture24-1536x293.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture24.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Step 9: Review the policy and click on create policy button. It will be attached to the users<\/h3>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"195\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture20-1024x195.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2092\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture20-1024x195.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture20-300x57.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture20-768x146.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture20-1536x293.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture20.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"454\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture21-1-1024x454.webp\" alt=\"AWS Secrets Manager integration with Laravel code example\" class=\"wp-image-2093\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture21-1-1024x454.webp 1024w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture21-1-300x133.webp 300w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture21-1-768x341.webp 768w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture21-1-1536x681.webp 1536w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture21-1.webp 2048w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><br><br><strong>Laravel App<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Create a service provider class like this:<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nnamespace App\\Services;\n\nuse Aws\\SecretsManager\\SecretsManagerClient;\nuse Aws\\Exception\\AwsException;\n\nclass SecretsManagerService\n{\n    protected $client;\n\n    public function __construct()\n    {\n        $this-&gt;client = new SecretsManagerClient(&#91;\n            'version' =&gt; 'latest',\n            'region' =&gt; 'your-aws-default-region',\n        ]);\n    }\n\n    public function getSecret(string $secretName)\n    {\n        try {\n            $result = $this-&gt;client-&gt;getSecretValue(&#91;\n                'SecretId' =&gt; $secretName,\n            ]);\n  \n            if (isset($result&#91;'SecretString'])) {\n                return json_decode($result&#91;'SecretString'], true);\n            }\n        } catch (AwsException $e) {\n            report($e);\n            return null;\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Create a controller by running a command: <strong><em>php artisan make:controller nameOfYourController<\/em><\/strong> The ideal controller would look like this<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nnamespace App\\Http\\Controllers;\n\nuse App\\Services\\SecretsManagerService;\nuse Illuminate\\Http\\Request;\n\nclass AwsSecretsManagerController extends Controller\n{\n    \/\/\n    public function index(SecretsManagerService $secretManager)\n    {\n        $data = $secretManager-&gt;getSecret('local\/aws-secrets\/databaseCredentials');\n               if($data){\n            return view('index');\n        }else{\n            echo \"There is some issue\";\n        }\n      \n    }\n}\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Create a blade file for confirming whether the output is seen in the view if credentials are matched.<br>The ideal blade file would look like this:<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n    &lt;meta charset=\"UTF-8\"&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n    &lt;title&gt;AWS SECRETS&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h3&gt;Hurray you made it here through secrets manager of aws.&lt;\/h3&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Look for <strong><em>database.php <\/em><\/strong>file and make changes in it like configuration of the connection driver you are using for the project.<br>For me its mysql so here\u2019s an example of it.<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nuse Illuminate\\Support\\Str;\nuse App\\Services\\SecretsManagerService;\n\n$secrets = app(SecretsManagerService::class)-&gt;getSecret('local\/aws-secrets\/databaseCredentials');\nreturn &#91;\n'default' =&gt; $secrets&#91;'DB_CONNECTION'],\n'connections' =&gt; &#91;\n'mysql' =&gt; &#91;\n            'driver' =&gt; 'mysql',\n            'url' =&gt; env('DB_URL'),\n            'host' =&gt; $secrets&#91;'DB_HOST'],\n            'port' =&gt; $secrets&#91;'DB_PORT'],\n            'database' =&gt; $secrets&#91;'DB_DATABASE'],\n            'username' =&gt; $secrets&#91;'DB_USERNAME'],\n            'password' =&gt; $secrets&#91;'DB_PASSWORD'],\n            'unix_socket' =&gt; env('DB_SOCKET', ''),\n            'charset' =&gt; env('DB_CHARSET', 'utf8mb4'),\n            'collation' =&gt; env('DB_COLLATION', 'utf8mb4_unicode_ci'),\n            'prefix' =&gt; '',\n            'prefix_indexes' =&gt; true,\n            'strict' =&gt; true,\n            'engine' =&gt; null,\n            'options' =&gt; extension_loaded('pdo_mysql') ? array_filter(&#91;\n                PDO::MYSQL_ATTR_SSL_CA =&gt; env('MYSQL_ATTR_SSL_CA'),\n            ]) : &#91;],\n        ],\n      ],\n    ];\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Create a route in the<strong> web.php <\/strong>file like this<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nuse App\\Http\\Controllers\\AwsSecretsManagerController;\nuse Illuminate\\Support\\Facades\\Route;\n\nRoute::get('\/test-secret', &#91;AwsSecretsManagerController::class, 'index']);<\/code><\/pre>\n\n\n\n<p>Step 6: Hit the route in the browser and see the output. If the credentials are matched and connection is created then you will see the following output.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"106\" src=\"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture22.webp\" alt=\"\" class=\"wp-image-2094\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture22.webp 624w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/Picture22-300x51.webp 300w\" sizes=\"(max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>Else you might see the error message if credentials are null or not matched.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Integrating AWS Secrets Manager with Laravel provides a secure and scalable way to manage sensitive configuration data such as database credentials, API keys, and other secrets. By offloading secret management to AWS, you reduce the risk of exposing sensitive data in your codebase or configuration files. With a simple service class and controller setup, Laravel can efficiently fetch secrets on demand while keeping your application clean, secure, and compliant with best practices. As your application grows, this approach ensures that secret rotation, auditing, and access control can all be handled centrally and securely through AWS.<\/p>\n\n\n\n<p>Ready to take your Laravel security to the next level? Start using AWS Secrets Manager today and keep your secrets safe!<\/p>\n\n\n\n<details class=\"wp-block-details is-layout-flow wp-block-details-is-layout-flow\"><summary>At <strong>200OK Solutions<\/strong>, we help businesses elevate their digital infrastructure with secure, scalable, and performance-driven solutions. Whether you&#8217;re optimizing Laravel applications or integrating AWS services, our cloud and development experts ensure a seamless experience tailored to your growth. Partner with us to future-proof your tech stack.<\/summary><div class=\"is-default-size wp-block-site-logo\"><a href=\"https:\/\/www.200oksolutions.com\/blog\/\" class=\"custom-logo-link light-mode-logo\" rel=\"home\"><img loading=\"lazy\" decoding=\"async\" width=\"484\" height=\"191\" src=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2026\/01\/cropped-200ok_logo.png\" class=\"custom-logo\" alt=\"Web Development, Software, and App Blog | 200OK Solutions\" srcset=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2026\/01\/cropped-200ok_logo.png 484w, https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2026\/01\/cropped-200ok_logo-300x118.png 300w\" sizes=\"(max-width: 484px) 100vw, 484px\" \/><\/a><\/div><\/details>\n","protected":false},"excerpt":{"rendered":"<p>Pre-requisites: How to Configure AWS Secrets Manager? Step 1: Open AWS Secrets Manager Step 2: Store a&hellip;<\/p>\n","protected":false},"author":5,"featured_media":2108,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[785,28],"tags":[392,786,629,787,161,789,127,790,788,791],"class_list":["post-2073","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aws","category-laravel","tag-200ok-solutions","tag-aws-secrets-manager","tag-cloud-integration","tag-cloud-security","tag-devops","tag-environment-variables","tag-laravel","tag-laravel-deployment","tag-php-frameworks","tag-secure-application-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>INTEGRATING AWS SECRETS MANAGER IN LARAVEL Web Development, Software, and App Blog | 200OK Solutions<\/title>\n<meta name=\"description\" content=\"Secure your Laravel applications by integrating AWS Secrets Manager. Learn step-by-step how to manage sensitive credentials efficiently with 200OK Solutions&#039; expert guide.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"INTEGRATING AWS SECRETS MANAGER IN LARAVEL Web Development, Software, and App Blog | 200OK Solutions\" \/>\n<meta property=\"og:description\" content=\"Secure your Laravel applications by integrating AWS Secrets Manager. Learn step-by-step how to manage sensitive credentials efficiently with 200OK Solutions&#039; expert guide.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Development, Software, and App Blog | 200OK Solutions\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-15T08:52:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-04T07:44:04+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/aws_laravel_banner.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"2048\" \/>\n\t<meta property=\"og:image:height\" content=\"1152\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Piyush Solanki\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Piyush Solanki\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"INTEGRATING AWS SECRETS MANAGER IN LARAVEL Web Development, Software, and App Blog | 200OK Solutions","description":"Secure your Laravel applications by integrating AWS Secrets Manager. Learn step-by-step how to manage sensitive credentials efficiently with 200OK Solutions' expert guide.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/","og_locale":"en_US","og_type":"article","og_title":"INTEGRATING AWS SECRETS MANAGER IN LARAVEL Web Development, Software, and App Blog | 200OK Solutions","og_description":"Secure your Laravel applications by integrating AWS Secrets Manager. Learn step-by-step how to manage sensitive credentials efficiently with 200OK Solutions' expert guide.","og_url":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/","og_site_name":"Web Development, Software, and App Blog | 200OK Solutions","article_published_time":"2025-04-15T08:52:30+00:00","article_modified_time":"2025-12-04T07:44:04+00:00","og_image":[{"width":2048,"height":1152,"url":"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/aws_laravel_banner.webp","type":"image\/webp"}],"author":"Piyush Solanki","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Piyush Solanki","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/#article","isPartOf":{"@id":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/"},"author":{"name":"Piyush Solanki","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/person\/e07f6b8e3c9a90ce7b3b09427d26155e"},"headline":"INTEGRATING AWS SECRETS MANAGER IN LARAVEL","datePublished":"2025-04-15T08:52:30+00:00","dateModified":"2025-12-04T07:44:04+00:00","mainEntityOfPage":{"@id":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/"},"wordCount":619,"commentCount":0,"publisher":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/#primaryimage"},"thumbnailUrl":"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/aws_laravel_banner.webp","keywords":["200OK Solutions","AWS Secrets Manager","Cloud Integration","Cloud Security","DevOps","Environment Variables","Laravel","Laravel Deployment","PHP Frameworks","Secure Application Development"],"articleSection":["AWS","Laravel"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/","url":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/","name":"INTEGRATING AWS SECRETS MANAGER IN LARAVEL Web Development, Software, and App Blog | 200OK Solutions","isPartOf":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/#primaryimage"},"image":{"@id":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/#primaryimage"},"thumbnailUrl":"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/aws_laravel_banner.webp","datePublished":"2025-04-15T08:52:30+00:00","dateModified":"2025-12-04T07:44:04+00:00","description":"Secure your Laravel applications by integrating AWS Secrets Manager. Learn step-by-step how to manage sensitive credentials efficiently with 200OK Solutions' expert guide.","breadcrumb":{"@id":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/#primaryimage","url":"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/aws_laravel_banner.webp","contentUrl":"https:\/\/www.200oksolutions.com\/blog\/wp-content\/uploads\/2025\/04\/aws_laravel_banner.webp","width":2048,"height":1152,"caption":"aws laravel banner"},{"@type":"BreadcrumbList","@id":"https:\/\/www.200oksolutions.com\/blog\/blog-aws-secrets-manager-laravel-integration\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.200oksolutions.com\/blog\/"},{"@type":"ListItem","position":2,"name":"INTEGRATING AWS SECRETS MANAGER IN LARAVEL"}]},{"@type":"WebSite","@id":"https:\/\/www.200oksolutions.com\/blog\/#website","url":"https:\/\/www.200oksolutions.com\/blog\/","name":"Web Development, Software, and App Blog | 200OK Solutions","description":"","publisher":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.200oksolutions.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.200oksolutions.com\/blog\/#organization","name":"Web Development Blog | Software Blog | App Blog","url":"https:\/\/www.200oksolutions.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/09\/200ok_logo-CGzMrWDu.png","contentUrl":"https:\/\/200oksolutions.com\/blog\/wp-content\/uploads\/2025\/09\/200ok_logo-CGzMrWDu.png","width":500,"height":191,"caption":"Web Development Blog | Software Blog | App Blog"},"image":{"@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.instagram.com\/200ok_solutions\/"]},{"@type":"Person","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/person\/e07f6b8e3c9a90ce7b3b09427d26155e","name":"Piyush Solanki","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.200oksolutions.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/962a2b0b4db856e6851ec7d838597a0395adcaae9c0091d223de9942a4254461?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/962a2b0b4db856e6851ec7d838597a0395adcaae9c0091d223de9942a4254461?s=96&d=mm&r=g","caption":"Piyush Solanki"},"description":"Piyush is a seasoned PHP Tech Lead with 10+ years of experience architecting and delivering scalable web and mobile backend solutions for global brands and fast-growing SMEs. He specializes in PHP, MySQL, CodeIgniter, WordPress, and custom API development, helping businesses modernize legacy systems and launch secure, high-performance digital products. He collaborates closely with mobile teams building Android &amp; iOS apps , developing RESTful APIs, cloud integrations, and secure payment systems using platforms like Stripe, AWS S3, and OTP\/SMS gateways. His work extends across CMS customization, microservices-ready backend architectures, and smooth product deployments across Linux and cloud-based environments. Piyush also has a strong understanding of modern front-end technologies such as React and TypeScript, enabling him to contribute to full-stack development workflows and advanced admin panels. With a successful delivery track record in the UK market and experience building digital products for sectors like finance, hospitality, retail, consulting, and food services, Piyush is passionate about helping SMEs scale technology teams, improve operational efficiency, and accelerate innovation through backend excellence and digital tools.","url":"https:\/\/www.200oksolutions.com\/blog\/author\/piyush\/"}]}},"_links":{"self":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2073","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2073"}],"version-history":[{"count":8,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2073\/revisions"}],"predecessor-version":[{"id":2113,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2073\/revisions\/2113"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/media\/2108"}],"wp:attachment":[{"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2073"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2073"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.200oksolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2073"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}