<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: brunt@jp</title>
    <description>The latest articles on DEV Community by brunt@jp (@scobin922).</description>
    <link>https://dev.to/scobin922</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F769748%2F6ac823aa-f16f-4b74-81d6-1a9cefb273fc.jpg</url>
      <title>DEV Community: brunt@jp</title>
      <link>https://dev.to/scobin922</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/scobin922"/>
    <language>en</language>
    <item>
      <title>Connecting to RDS from Laravel+Docker via bastion server(EC2)</title>
      <dc:creator>brunt@jp</dc:creator>
      <pubDate>Wed, 08 Dec 2021 04:09:29 +0000</pubDate>
      <link>https://dev.to/scobin922/connecting-to-rds-from-laraveldocker-via-bastion-serverec2-im8</link>
      <guid>https://dev.to/scobin922/connecting-to-rds-from-laraveldocker-via-bastion-serverec2-im8</guid>
      <description>&lt;p&gt;RDS is configured to connect only from EC2, so if you want to connect to RDS from your local environment, you need to do some work.&lt;br&gt;&lt;br&gt;
In this article, I will briefly show you how to connect to RDS from a Laravel application running in a Docker container in the local environment via a bastion server(EC2).  &lt;/p&gt;
&lt;h2&gt;
  
  
  Original Post
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cyublog.com/articles/php-en/en-laravel-bastion-ssh-rds/"&gt;cyublog | Connecting to RDS from Laravel+Docker via bastion server(EC2)&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Local Environment
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;macOS:10.15.7
&lt;/li&gt;
&lt;li&gt;A docker container running a Laravel application.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ docker --version
Docker version 20.10.2, build 2291f61

$ docker-compose --version
docker-compose version 1.27.4, build 40524192
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h2&gt;
  
  
  Pre-conditions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A bastion server(EC2) which can be accessed from your local environment.
&lt;/li&gt;
&lt;li&gt;An AWS RDS which can be accessed from the bastion server.
&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Workflow
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Create a SSH tunnel.
&lt;/li&gt;
&lt;li&gt;Check the connection from the local machine (Mac) and from the Docker container.
&lt;/li&gt;
&lt;li&gt;Modify the .env file so that the Laravel app can connect to the RDS.
&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  SSH tunnel
&lt;/h3&gt;

&lt;p&gt;First, create a SSH tunnel.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh &lt;span class="nt"&gt;-N&lt;/span&gt; &lt;span class="nt"&gt;-L&lt;/span&gt; 3333:[RDS endpoint]:[RDS port] &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;pem file of bastion server] &lt;span class="nt"&gt;-p&lt;/span&gt; 22 &lt;span class="o"&gt;[&lt;/span&gt;EC2 user]@[bastion ip]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time, set the port number of 3333 with RDS.   &lt;/p&gt;

&lt;p&gt;Once it is created, check it with a command.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Check the connection from the local machine
&lt;/h3&gt;

&lt;p&gt;Run the following command in a terminal on your local machine to confirm.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql &lt;span class="nt"&gt;-h&lt;/span&gt; 127.0.0.1 &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;USER NAME] &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;DATABASE NAME] &lt;span class="nt"&gt;-P&lt;/span&gt; 3333
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Check the connection from Docker container
&lt;/h3&gt;

&lt;p&gt;Enter thr Docker container, then run the following command to check the connection.&lt;br&gt;&lt;br&gt;
Note that the host must be &lt;strong&gt;host.docker.internal&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mysql &lt;span class="nt"&gt;-h&lt;/span&gt; host.docker.internal &lt;span class="nt"&gt;-u&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;USER NAME] &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;DATABASE NAME] &lt;span class="nt"&gt;-P&lt;/span&gt; 3333
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Modify DB settings of Laravel application
&lt;/h3&gt;

&lt;p&gt;Next, modify the &lt;code&gt;.env&lt;/code&gt; file of your Laravel application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DB_HOST=host.docker.internal
DB_PORT=3333
DB_DATABASE=[DATABASE NAME]
DB_USERNAME=[USER NAME]
DB_PASSWORD=[PASSWAORD]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, check it in your Laravel application.    &lt;/p&gt;

</description>
      <category>rds</category>
      <category>docker</category>
      <category>bastion</category>
      <category>aws</category>
    </item>
    <item>
      <title>Send A Slack Notification Automatically When A Release Is Published On Github</title>
      <dc:creator>brunt@jp</dc:creator>
      <pubDate>Tue, 07 Dec 2021 03:12:05 +0000</pubDate>
      <link>https://dev.to/scobin922/send-a-slack-notification-automatically-when-a-release-is-published-on-github-55c0</link>
      <guid>https://dev.to/scobin922/send-a-slack-notification-automatically-when-a-release-is-published-on-github-55c0</guid>
      <description>&lt;p&gt;This article will show you a way how to send a notification automatically after you published a release on github.&lt;br&gt;&lt;br&gt;
This way will include &lt;strong&gt;Github Actions&lt;/strong&gt; and &lt;strong&gt;Slack Incoming Webhook&lt;/strong&gt;.  &lt;/p&gt;
&lt;h2&gt;
  
  
  Original Source
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://cyublog.com/articles/dev-en/github-slack/"&gt;cyublog | Send A Slack Notification Automatically When A Release Is Published On Github&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Purpose
&lt;/h2&gt;

&lt;p&gt;Create github release.&lt;br&gt;
　　↓&lt;br&gt;
Publish the github release.&lt;br&gt;
　　↓&lt;br&gt;
Automatically send a message which contains &lt;strong&gt;tag_name&lt;/strong&gt;, &lt;strong&gt;author&lt;/strong&gt;, &lt;strong&gt;release body&lt;/strong&gt;, &lt;strong&gt;github url of the release&lt;/strong&gt; to slack.  &lt;/p&gt;
&lt;h2&gt;
  
  
  Process
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Prepare Slack Incoming Webhook Url
&lt;/h3&gt;

&lt;p&gt;Follow this article &lt;a href="https://slack.com/help/articles/115005265063-Incoming-webhooks-for-Slack"&gt;Incoming webhooks for slack&lt;/a&gt;, and we will get a url that can be use in Github Actions to send messages.  &lt;/p&gt;
&lt;h3&gt;
  
  
  Github
&lt;/h3&gt;

&lt;p&gt;Here are two things has to do.  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;set the slack incoming webhook url to the Actions secrets.
&lt;/li&gt;
&lt;li&gt;Create a Github Actions workflow.
&lt;/li&gt;
&lt;/ol&gt;
&lt;h4&gt;
  
  
  Actions secrets
&lt;/h4&gt;

&lt;p&gt;Go to the github repository, &lt;br&gt;
click &lt;strong&gt;Settings tab&lt;/strong&gt; -&amp;gt; &lt;strong&gt;Secrets&lt;/strong&gt; -&amp;gt; &lt;strong&gt;New repository secret&lt;/strong&gt;. &lt;br&gt;
-&amp;gt; Name: &lt;strong&gt;SLACK_WEBHOOK_URL&lt;/strong&gt;, Value: &lt;strong&gt;The slack incoming webhook url&lt;/strong&gt;.  &lt;/p&gt;
&lt;h4&gt;
  
  
  Workflow
&lt;/h4&gt;
&lt;h5&gt;
  
  
  1. Go to the github repository, click the &lt;strong&gt;actions tab&lt;/strong&gt; to open the github actions page.
&lt;/h5&gt;

&lt;p&gt;(The page link maybe &lt;code&gt;https://github.com/{user_name}/{repository_name}/actions&lt;/code&gt;.&lt;strong&gt;user_name&lt;/strong&gt;, &lt;strong&gt;repository_name&lt;/strong&gt; must be changed to yours.)    &lt;/p&gt;
&lt;h5&gt;
  
  
  2. Create a &lt;strong&gt;New workflow&lt;/strong&gt;.
&lt;/h5&gt;

&lt;p&gt;I will create my workflow, so click &lt;strong&gt;set up a workflow yourself&lt;/strong&gt; link to open a basic workflow.&lt;br&gt;&lt;br&gt;
Enter the workflow file name and edit the contents.&lt;br&gt;&lt;br&gt;
Here is the contents of workflow file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ReleaseNotice&lt;/span&gt;
&lt;span class="na"&gt;on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;release&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;types&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;published&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
  &lt;span class="na"&gt;workflow_dispatch&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;runs-on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;ubuntu-latest&lt;/span&gt;
    &lt;span class="na"&gt;steps&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="c1"&gt;# To check the github context&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Dump Github context&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;GITHUB_CONTEXT&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ toJSON(github) }}&lt;/span&gt;
        &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;echo "$GITHUB_CONTEXT"&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Slack Notification on SUCCESS&lt;/span&gt;
        &lt;span class="na"&gt;if&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;success()&lt;/span&gt;
        &lt;span class="na"&gt;uses&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;tokorom/action-slack-incoming-webhook@main&lt;/span&gt;
        &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;INCOMING_WEBHOOK_URL&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;${{ secrets.SLACK_WEBHOOK_URL }}&lt;/span&gt;
        &lt;span class="na"&gt;with&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="na"&gt;text&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;A release is published.&lt;/span&gt;
          &lt;span class="na"&gt;blocks&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
            &lt;span class="s"&gt;[&lt;/span&gt;
              &lt;span class="s"&gt;{&lt;/span&gt;
                &lt;span class="s"&gt;"type": "header",&lt;/span&gt;
                &lt;span class="s"&gt;"text": {&lt;/span&gt;
                  &lt;span class="s"&gt;"type": "plain_text",&lt;/span&gt;
                  &lt;span class="s"&gt;"text": "${{ github.event.release.tag_name}} is published!"&lt;/span&gt;
                &lt;span class="s"&gt;}&lt;/span&gt;
              &lt;span class="s"&gt;},&lt;/span&gt;
              &lt;span class="s"&gt;{&lt;/span&gt;
                &lt;span class="s"&gt;"type": "section",&lt;/span&gt;
                &lt;span class="s"&gt;"text": {&lt;/span&gt;
                  &lt;span class="s"&gt;"type": "mrkdwn",&lt;/span&gt;
                  &lt;span class="s"&gt;"text": "*Author:*\n${{ github.actor }}"&lt;/span&gt;
                &lt;span class="s"&gt;}&lt;/span&gt;
              &lt;span class="s"&gt;},&lt;/span&gt;
               &lt;span class="s"&gt;{&lt;/span&gt;
                &lt;span class="s"&gt;"type": "section",&lt;/span&gt;
                &lt;span class="s"&gt;"text": {&lt;/span&gt;
                  &lt;span class="s"&gt;"type": "mrkdwn",&lt;/span&gt;
                  &lt;span class="s"&gt;"text": "*Information:*"&lt;/span&gt;
                &lt;span class="s"&gt;}&lt;/span&gt;
              &lt;span class="s"&gt;},&lt;/span&gt;
              &lt;span class="s"&gt;{&lt;/span&gt;
                &lt;span class="s"&gt;"type": "section",&lt;/span&gt;
                &lt;span class="s"&gt;"text": {&lt;/span&gt;
                  &lt;span class="s"&gt;"type": "mrkdwn",&lt;/span&gt;
                  &lt;span class="s"&gt;"text": ${{ toJSON(github.event.release.body) }}&lt;/span&gt;
                &lt;span class="s"&gt;}&lt;/span&gt;
              &lt;span class="s"&gt;},&lt;/span&gt;
              &lt;span class="s"&gt;{&lt;/span&gt;
                &lt;span class="s"&gt;"type": "section",&lt;/span&gt;
                &lt;span class="s"&gt;"text": {&lt;/span&gt;
                  &lt;span class="s"&gt;"type": "mrkdwn",&lt;/span&gt;
                  &lt;span class="s"&gt;"text": "${{ github.event.release.html_url }}"&lt;/span&gt;
                &lt;span class="s"&gt;}&lt;/span&gt;
              &lt;span class="s"&gt;}&lt;/span&gt;
            &lt;span class="s"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h5&gt;
  
  
  3. Start Commit
&lt;/h5&gt;

&lt;p&gt;You can commit it to main branch or other branch to let the workflow be launch.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Test
&lt;/h3&gt;

&lt;p&gt;The workflow will be launched when you publish a release from the branch that the workflow is committed.&lt;br&gt;&lt;br&gt;
Now, create a new release and published it. You will see the message is send to your slack channel. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--r4KvplDI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/scobin/colab-tutorial/blob/main/asserts/image/github-actions-message.png%3Fraw%3Dtrue" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--r4KvplDI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/scobin/colab-tutorial/blob/main/asserts/image/github-actions-message.png%3Fraw%3Dtrue" alt="github-actions-slack-message" width="880" height="368"&gt;&lt;/a&gt;&lt;br&gt;
That’s all. I hope this will help you.  &lt;/p&gt;

</description>
      <category>github</category>
      <category>devops</category>
      <category>slack</category>
      <category>message</category>
    </item>
  </channel>
</rss>
