<?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: t.okazaki</title>
    <description>The latest articles on DEV Community by t.okazaki (@tokazaki42).</description>
    <link>https://dev.to/tokazaki42</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%2F412742%2F512c0964-267e-4d97-a132-bcc29f347c67.jpg</url>
      <title>DEV Community: t.okazaki</title>
      <link>https://dev.to/tokazaki42</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tokazaki42"/>
    <language>en</language>
    <item>
      <title>Save the HTTP request body received by Go Gin to AWS Kinesis Firehose</title>
      <dc:creator>t.okazaki</dc:creator>
      <pubDate>Sat, 15 May 2021 11:10:35 +0000</pubDate>
      <link>https://dev.to/tokazaki42/save-the-http-request-body-received-by-go-gin-to-aws-kinesis-firehose-2eb2</link>
      <guid>https://dev.to/tokazaki42/save-the-http-request-body-received-by-go-gin-to-aws-kinesis-firehose-2eb2</guid>
      <description>&lt;p&gt;I wanted to run Kinesis Firehose in Go, but I couldn't find any sample code.&lt;br&gt;
Here is a simple example.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="k"&gt;package&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"fmt"&lt;/span&gt;
    &lt;span class="s"&gt;"encoding/json"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/aws/aws-sdk-go/aws"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/aws/aws-sdk-go/aws/awserr"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/aws/aws-sdk-go/aws/session"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/aws/aws-sdk-go/service/firehose"&lt;/span&gt;
    &lt;span class="s"&gt;"github.com/gin-gonic/gin"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;type&lt;/span&gt; &lt;span class="n"&gt;EntryRecord&lt;/span&gt; &lt;span class="k"&gt;struct&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;PostBodyField&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="s"&gt;`json:"entry"`&lt;/span&gt;
    &lt;span class="n"&gt;Host&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="s"&gt;`json:"host"`&lt;/span&gt;
    &lt;span class="n"&gt;RemoteAddr&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="s"&gt;`json:"remoteaddr"`&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="n"&gt;deliveryStreamName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"firehose-dest-bucket"&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;handleEntry&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="n"&gt;buf&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;make&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2048&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Body&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Read&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;body_filed&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;buf&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
    &lt;span class="n"&gt;fmt&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Println&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;body_filed&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;entry_record&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;EntryRecord&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;PostBodyField&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;body_filed&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;Host&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="n"&gt;RemoteAddr&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Request&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;RemoteAddr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;firehose_svc&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;firehose&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;New&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;aws&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;NewConfig&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;WithRegion&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"ap-northeast-1"&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
    &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;firehose&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Record&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Marshal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry_record&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;record_byte&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SetData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;record_byte&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;firehose_svc&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PutRecord&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;firehose&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PutRecordInput&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;DeliveryStreamName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;aws&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deliveryStreamName&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="n"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;             &lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="no"&gt;nil&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;awsErr&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;err&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;awserr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;ok&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nb"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;awsErr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Message&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;func&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;gin&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Default&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;POST&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/submit"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;handleEntry&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;r&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You have already set up Kinesis Firehose&lt;/li&gt;
&lt;li&gt;You have already set up S3 bucket to store the request body data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following is the part that is sending data to Firehose.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;firehose&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;PutRecordInput&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;DeliveryStreamName&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="n"&gt;aws&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;String&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;deliveryStreamName&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="n"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt;             &lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The argument Record is a structure defined in the SDK.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight go"&gt;&lt;code&gt;    &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;firehose&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Record&lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;
    &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;_&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Marshal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;entry_record&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;record_byte&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nb"&gt;append&lt;/span&gt;&lt;span class="p"&gt;([]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;&lt;span class="kt"&gt;byte&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\n&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;...&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;record&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="n"&gt;SetData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;record_byte&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reference
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/sdk-for-go/api/service/firehose/"&gt;AWS Go SDK&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>go</category>
    </item>
    <item>
      <title>Creating AWS EKS cluster with Fargate</title>
      <dc:creator>t.okazaki</dc:creator>
      <pubDate>Wed, 19 Aug 2020 11:21:10 +0000</pubDate>
      <link>https://dev.to/tokazaki42/creating-aws-eks-cluster-with-fargate-4m6e</link>
      <guid>https://dev.to/tokazaki42/creating-aws-eks-cluster-with-fargate-4m6e</guid>
      <description>&lt;p&gt;Recently I've been experimenting with a configuration using Fargate with AWS EKS (Kubernetes version 1.17). I think I can reduce the burden of infrastructure management, by adoption Fargate which can worker nodes be managed. I wondered which terraform and eksctl are nicer to create Fargate on AWS EKS.&lt;/p&gt;

&lt;p&gt;By the way, Fargate only supports ALB as a load balancer, and EKS only supports the Classic Load Balancer as the default.&lt;br&gt;
In order to use Fargate and ALB, you need to follow the following documentation to deploy the ALB Ingress Controller on an EKS cluster.&lt;br&gt;
&lt;a href="https://docs.aws.amazon.com/eks/latest/userguide/alb-ingress.html"&gt;https://docs.aws.amazon.com/eks/latest/userguide/alb-ingress.html&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above AWS documentation uses eksctl. When I created an EKS cluster with eksctl, I could do the procedure smoothly.&lt;br&gt;
However, when I created an EKS cluster with Terraform, I was not able to build the ALB Ingress Controller with above documantation because the EKS cluster was not created by eksctl which uses CloudFormation stack.&lt;/p&gt;

&lt;p&gt;So my conclusion, the following step would be easier to create and manage the structure of Fargate with EKS.&lt;br&gt;
First, build VPC, subnetworks, databases and any AWS resources using Terraform.&lt;br&gt;
Second,  build an EKS cluster or ALB Ingress Controller using eksctl.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>kubernetes</category>
    </item>
    <item>
      <title>My Website about Terraform examples</title>
      <dc:creator>t.okazaki</dc:creator>
      <pubDate>Sun, 16 Aug 2020 06:39:41 +0000</pubDate>
      <link>https://dev.to/tokazaki42/my-website-about-terraform-examples-1l7f</link>
      <guid>https://dev.to/tokazaki42/my-website-about-terraform-examples-1l7f</guid>
      <description>&lt;p&gt;I recently created the following web page, instead of posting on DEV.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.learningcloudinfra.tokyo/en/aws/" rel="noopener noreferrer"&gt;https://www.learningcloudinfra.tokyo/en/aws/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I built various AWS resources using Terraform for my own learning and summarized what I built in each posts. &lt;br&gt;
Each code is available under the MIT license on my Github repository.&lt;br&gt;
Some of the code examples are simply to launch EC2 and RDS or to launch the Go application with Fargate.&lt;br&gt;
I will continue to update this website with articles like EKS  and other AWS resources.&lt;/p&gt;

&lt;p&gt;By the way, this site was created using Hugo and Netlify.&lt;br&gt;
It's easy for me to build a website because I can write articles in Markdown and deploy them just pushing Github ;)&lt;/p&gt;

</description>
      <category>aws</category>
      <category>terraform</category>
    </item>
    <item>
      <title>Vuls:  Open-source vulnerability scanner</title>
      <dc:creator>t.okazaki</dc:creator>
      <pubDate>Tue, 14 Jul 2020 22:54:18 +0000</pubDate>
      <link>https://dev.to/tokazaki42/vuls-open-source-vulnerability-scanner-in8</link>
      <guid>https://dev.to/tokazaki42/vuls-open-source-vulnerability-scanner-in8</guid>
      <description>&lt;p&gt;Vuls is an open-source vulnerability scanner. It automates security vulnerability checks on the software installed on a system.&lt;br&gt;
 Vuls comes with an agent-less architecture, meaning that it uses SSH to scan remote hosts.&lt;/p&gt;

&lt;p&gt;Vuls checks the following vulnerability information sources&lt;br&gt;
see: &lt;a href="https://github.com/future-architect/vuls#high-quality-scan"&gt;https://github.com/future-architect/vuls#high-quality-scan&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How to install
&lt;/h2&gt;

&lt;p&gt;We will install Vuls in the AWS EC2 AmazonLinux2.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Logging on an EC2 instance by ec2-user

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;yum &lt;span class="nt"&gt;-y&lt;/span&gt; &lt;span class="nb"&gt;install &lt;/span&gt;docker git
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;usermod &lt;span class="nt"&gt;-aG&lt;/span&gt; docker ec2-user
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /home/ec2-user/
&lt;span class="nv"&gt;$ &lt;/span&gt;git clone https://github.com/vulsio/vulsctl.git

&lt;span class="c"&gt;# logging out and logging in the instance again.&lt;/span&gt;

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;systemctl start docker

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;vulsctl &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ./update-all.sh

&lt;span class="c"&gt;# it takes about 20-30 minitues.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Preparation
&lt;/h2&gt;

&lt;p&gt;After Vuls is installed, we prepare the configuration file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; config.toml.template config.toml
&lt;span class="nv"&gt;$ &lt;/span&gt;vim config.toml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;specify default section.&lt;br&gt;
Note that if you place the SSH key in your /home/ec2-user/.ssh/id_rsa, you have to write this way.&lt;br&gt;
Because Vuls runs on Docker container and it mounts SSH key on "/root/.ssh/id_rsa" inside the container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="o"&gt;[&lt;/span&gt;default]
port               &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"22"&lt;/span&gt;
user               &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"ec2-user"&lt;/span&gt;
keyPath            &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/root/.ssh/id_rsa"&lt;/span&gt;
scanMode           &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"fast"&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you write the hostname or IP address of servers which you want to scan.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[servers.name]
host                = "10.10.1.251"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you want to scan local host, you need to specify the IP address which allocated to the interface instead of "127.0.0.1" .&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting SSH keys
&lt;/h2&gt;

&lt;p&gt;You have to register your public key to known_hosts of the scanned servers. To do this, you logging on the server onece or use following command.&lt;/p&gt;

&lt;p&gt;Generate a key pair locally.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-keygen &lt;span class="nt"&gt;-t&lt;/span&gt; rsa &lt;span class="nt"&gt;-b&lt;/span&gt; 4096
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Register a locally generated public key to the target host to be scanned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh-copy-id &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;USER&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;@&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;target_host&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add the target host in local known_hosts file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;ssh-keyscan &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;target_host&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; ~/.ssh/known_hosts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Scanning
&lt;/h2&gt;

&lt;p&gt;Just execute the following shell script.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ./scan.sh -vvv

Using default tag: latest
latest: Pulling from vuls/vuls
Digest: sha256:e39edb92833e7d6f6490620e11221f1a456ca2dec4f5f3ab1c15e12c75ecdcbb
Status: Image is up to date for vuls/vuls:latest
docker.io/vuls/vuls:latest
[Jul 11 10:39:44]  INFO [localhost] Validating config...
[Jul 11 10:39:44]  INFO [localhost] Detecting Server/Container OS...
[Jul 11 10:39:44]  INFO [localhost] Detecting OS of servers...
[Jul 11 10:39:47]  INFO [localhost] (1/1) Detected: name: amazon 2 (Karoo)
[Jul 11 10:39:47]  INFO [localhost] Detecting OS of containers...
[Jul 11 10:39:47]  INFO [localhost] Checking Scan Modes...
[Jul 11 10:39:47]  INFO [localhost] Checking dependencies...
...(snip)...
[Jul 11 10:39:52]  INFO [localhost] Scanning vulnerabilities...
[Jul 11 10:39:52]  INFO [localhost] Scanning vulnerable OS packages...
[Jul 11 10:39:52]  INFO [name] Scanning in fast mode

One Line Summary
================
name    amazon2 (Karoo) 451 installed, 16 updatable

To view the detail, vuls tui is useful.
To send a report, run vuls report -h.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see the scan result on the command line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ ./report.sh

Using default tag: latest
latest: Pulling from vuls/vuls
...(snip)...
name (amazon2 (Karoo))
======================
Total: 10 (High:3 Medium:4 Low:3 ?:0), 10/10 Fixed, 451 installed, 16 updatable, 0 exploits, 0 modules, en: 0, ja: 2 alerts

+----------------+------+--------+-----+--------+---------+-------------------------------------------------+
|     CVE-ID     | CVSS | ATTACK | POC |  CERT  |  FIXED  |                       NVD                       |
+----------------+------+--------+-----+--------+---------+-------------------------------------------------+
| CVE-2018-20060 |  9.8 |  AV:N  |     |        |   fixed | https://nvd.nist.gov/vuln/detail/CVE-2018-20060 |
| CVE-2019-17041 |  9.8 |  AV:N  |     |        |   fixed | https://nvd.nist.gov/vuln/detail/CVE-2019-17041 |
| CVE-2019-17042 |  9.8 |  AV:N  |     |        |   fixed | https://nvd.nist.gov/vuln/detail/CVE-2019-17042 |
| CVE-2019-6477  |  7.8 |  AV:N  |     | JPCERT |   fixed | https://nvd.nist.gov/vuln/detail/CVE-2019-6477  |
| CVE-2020-12762 |  7.8 |  AV:L  |     |        |   fixed | https://nvd.nist.gov/vuln/detail/CVE-2020-12762 |
| CVE-2018-5745  |  7.5 |  AV:N  |     |        |   fixed | https://nvd.nist.gov/vuln/detail/CVE-2018-5745  |
| CVE-2019-6465  |  7.5 |  AV:N  |     | JPCERT |   fixed | https://nvd.nist.gov/vuln/detail/CVE-2019-6465  |
| CVE-2020-0543  |  6.5 |  AV:L  |     |        |   fixed | https://nvd.nist.gov/vuln/detail/CVE-2020-0543  |
| CVE-2020-0549  |  6.5 |  AV:L  |     |        |   fixed | https://nvd.nist.gov/vuln/detail/CVE-2020-0549  |
| CVE-2020-0548  |  5.5 |  AV:L  |     |        |   fixed | https://nvd.nist.gov/vuln/detail/CVE-2020-0548  |
+----------------+------+--------+-----+--------+---------+-------------------------------------------------+
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The report files are generated in the directory named "results". Note that the report files and directory will be made as a root owner. If you want to access the files, you may change the permission the directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; ec2-user:ec2-user results/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  VulsRepo: watch the result on your browser
&lt;/h2&gt;

&lt;p&gt;You can also view the scan result on your browser using VulsRepo.&lt;br&gt;
Github: &lt;a href="https://vuls.io/docs/en/vulsrepo.html"&gt;https://vuls.io/docs/en/vulsrepo.html&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; /home/ec2-user/
&lt;span class="nv"&gt;$ &lt;/span&gt;git clone https://github.com/ishiDACo/vulsrepo

&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;vulsrepo/server
&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cp &lt;/span&gt;vulsrepo-config.toml.sample vulsrepo-config.toml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;vi vulsrepo-config.toml

&lt;span class="o"&gt;[&lt;/span&gt;Server]
rootPath &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/home/ec2-user/vulsrepo"&lt;/span&gt;
resultsPath  &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"/home/ec2-user/vulsctl/results
serverPort  = "&lt;/span&gt;5111&lt;span class="s2"&gt;"
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./vulsrepo-server
 &lt;span class="o"&gt;[&lt;/span&gt;ec2-user@ip-10-10-1-82 server]&lt;span class="nv"&gt;$ &lt;/span&gt;./vulsrepo-server
2020/07/11 10:53:11 main.go:153: INFO: RootPath Load:  /home/ec2-user/vulsrepo
2020/07/11 10:53:11 main.go:160: INFO: ResultsPath Load:  /home/ec2-user/vulsctl/results
2020/07/11 10:53:11 main.go:128: Start: Listening port: :5111
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Access the server with port 5111 on your browser.&lt;br&gt;
Actual screen images are shown in the official documentation.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>security</category>
      <category>aws</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Performance Test: Basics</title>
      <dc:creator>t.okazaki</dc:creator>
      <pubDate>Fri, 10 Jul 2020 21:56:35 +0000</pubDate>
      <link>https://dev.to/tokazaki42/performance-test-basics-3mpf</link>
      <guid>https://dev.to/tokazaki42/performance-test-basics-3mpf</guid>
      <description>&lt;p&gt;I have been working as an engineer for a cloud-based SaaS system. As the amount of data increases, I have encountered problems in the system. For example, the web servers are not down, but it's response time becomes extremely long. I come up with learning about performance testing because I wanted to anticipate these future problems in advance and prepare trump cards. In this article, I would like to summarize performance testing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Purpose of Performance Testing
&lt;/h2&gt;

&lt;p&gt;The goal of performance testing is to measure the performance of the system and plan to increase system's availability. We look at this following point of views.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;To estimate the response performance of the system in each of the various use cases.&lt;/li&gt;
&lt;li&gt;Improve system performance under high load&lt;/li&gt;
&lt;li&gt;Ensure that the system is scalable.&lt;/li&gt;
&lt;li&gt;Check the scale characteristics of the system.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In a cloud environment, web severs can be provisioned quickly and can be scaled out after actual user access occurs. However, depending on the application and the configuration of the middleware, scaling out in a hurry after the load has increased will not well handle traffics because of lacking of scalability.&lt;/p&gt;

&lt;h2&gt;
  
  
  System Performance Metrics
&lt;/h2&gt;

&lt;p&gt;As performance metrics, throughput and latency should be considered.&lt;/p&gt;

&lt;h3&gt;
  
  
  Throughput
&lt;/h3&gt;

&lt;p&gt;For a web application, this often indicates the number of HTTP requests to be processed per second. The throughput of the overall system is constrained by the throughput of the bottleneck portion of the system. We investigate where the bottleneck is located and improve it's throughput. It is important to correctly identify where the bottleneck is. If you get it wrong, the solution will not only be ineffective, but it can cause severe congestion at worse.&lt;/p&gt;

&lt;h3&gt;
  
  
  Latency
&lt;/h3&gt;

&lt;p&gt;It is a processing time. There are two aspects:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Processing time from the user's point of view. The time between when the user sends a request and when the response is received.&lt;/li&gt;
&lt;li&gt;Processing time in the system. This is the time between when the system sends the request and when it returns the response.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In a performance test, we will focus on the processing time in the system (2.) because it is difficult to simulate actual network conditions from the user to the system. &lt;/p&gt;

&lt;p&gt;Latency is different from throughput improvement; reducing the latency at one location reduces the latency of the entire system. &lt;/p&gt;

&lt;h2&gt;
  
  
  Characteristics of scalability
&lt;/h2&gt;

&lt;p&gt;As Characteristics of scalability, we consider What parts of the system need to be augmented to increase performance. For example, we think, can we increase the throughput by increasing the number of web servers? Do we need to increase the memory size of the database at the same time?&lt;/p&gt;

&lt;p&gt;We want to mainly know following perspectives:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Optimal infrastructure configuration to handle several throughput levels (100rps, 500rps,,,)&lt;/li&gt;
&lt;li&gt;The actual performance limit of the web system&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It is difficult to know exactly what the marginal performance is. Because we don't know what our future application code or system configuration or users will look like.　However, it is meaningful to investigate the system performance. Because in the process of investigating the critical performance, it is possible to discover some improvements or unexpected bottlenecks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;At this post, I wrote about the purpose of performance testing, system metrics, and the system scalability these for the basis of performance testing. I will write about how to plan a performance test in the future post.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>AWS Codebuild: Prepare your own custom build environment </title>
      <dc:creator>t.okazaki</dc:creator>
      <pubDate>Sat, 04 Jul 2020 14:46:49 +0000</pubDate>
      <link>https://dev.to/tokazaki42/aws-codebuild-kp0</link>
      <guid>https://dev.to/tokazaki42/aws-codebuild-kp0</guid>
      <description>&lt;p&gt;AWS Codebuild is a fully managed continuous integration service that compiles source code, runs tests, and produces software packages that are ready to deploy.You can create custom build environments that use your own build tools.&lt;/p&gt;

&lt;p&gt;This feature caught my attention because I am a little bothered that existing fully managed CI service has  changed their build environment and  our development team took a time to repair the build script.&lt;br&gt;
( Of ourse, you can also get started quickly by using prepackaged build environments on Codebuild )&lt;/p&gt;
&lt;h2&gt;
  
  
  How to prepare your own custom build environment
&lt;/h2&gt;

&lt;p&gt;We have to prepare a Docker image for custom build environment. Hopefully, AWS give us sample docker images. You can get them by following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ git clone https://github.com/aws/aws-codebuild-docker-images.git
$ cd aws-codebuild-docker-images
$ cd ubuntu/standard/4.0
$ docker build -t aws/codebuild/standard:4.0 .
$ ls -1
Dockerfile
amazon-ssm-agent.json
dockerd-entrypoint.sh
legal
runtimes.yml
ssh_config
tools

$ docker run -it --entrypoint sh aws/codebuild/standard:4.0 -c bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the Dockerfile, various programming language packages, browsers and another build tools are installed&lt;br&gt;
For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ChromeDriver, Chrome, Firefox&lt;/li&gt;
&lt;li&gt;Java, Ruby, Python, PHP,  Golang, Nodejs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can add or choose packages which you need by customising above Dockerfile.&lt;/p&gt;
&lt;h2&gt;
  
  
  Local debugging your custom build environment
&lt;/h2&gt;

&lt;p&gt;You can run Codebuild on your laptop using Docker. You can test and build your custom Codebuild docker image and your application locally before committing.&lt;/p&gt;

&lt;p&gt;Pull  the docker image of the local CodeBuild agent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker pull amazon/aws-codebuild-local:latest &lt;span class="nt"&gt;--disable-content-trust&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Download the shell script named codebuild_build.sh from AWS GIthub&lt;br&gt;
&lt;a href="https://github.com/aws/aws-codebuild-docker-images/tree/master/local_builds"&gt;https://github.com/aws/aws-codebuild-docker-images/tree/master/local_builds&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;./codebuild_build.sh &lt;span class="nt"&gt;-i&lt;/span&gt; codebuild4-test:1.0 &lt;span class="nt"&gt;-a&lt;/span&gt; /tmp &lt;span class="nt"&gt;-s&lt;/span&gt; /work/repo &lt;span class="nt"&gt;-m&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;options &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;-i Specify docker image tag of your custom build environment image.&lt;/li&gt;
&lt;li&gt;-a Used to specify an artifact output directory.&lt;/li&gt;
&lt;li&gt;-s Used to specify a source directory. Defaults to the current working directory.&lt;/li&gt;
&lt;li&gt;-m  Used to mount the source directory to the customer build container directly.&lt;/li&gt;
&lt;li&gt;-c Use the AWS configuration and credentials from your local host. This includes ~/.aws and any AWS_* environment variables.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.aws.amazon.com/codebuild/latest/userguide/welcome.html"&gt;AWS Codebuild documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>aws</category>
      <category>devops</category>
    </item>
    <item>
      <title> Launch an AWS Spot Fleet instance using Terraform</title>
      <dc:creator>t.okazaki</dc:creator>
      <pubDate>Sat, 27 Jun 2020 15:25:00 +0000</pubDate>
      <link>https://dev.to/tokazaki42/launch-an-aws-spotfleet-instance-using-terraform-4okh</link>
      <guid>https://dev.to/tokazaki42/launch-an-aws-spotfleet-instance-using-terraform-4okh</guid>
      <description>&lt;p&gt;Today, I share a way to launch an AWS instance using Terraform, which has following features: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use EC2 Spot fleet instance which is cheaper than the on-demand instance.&lt;/li&gt;
&lt;li&gt;Use AWS Session Manager to connect to the instance, so that you don't need to prepare the SSH setting. Also you don't need any bastion host to connect the instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bWoKfJjS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/z3hlq18exu7vgncgs7t4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bWoKfJjS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/z3hlq18exu7vgncgs7t4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;You can download the Terraform code on my Github repository.&lt;br&gt;
&lt;a href="https://github.com/syuren42/terraform-examples/tree/master/spot-ssm-example"&gt;Terraform example&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I made these code with Terraform version &lt;strong&gt;v0.12.25&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Download the repository and type following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;terraform-examples/spot-ssm-example
&lt;span class="nv"&gt;$ &lt;/span&gt;terraform init
&lt;span class="nv"&gt;$ &lt;/span&gt;terraform plan &lt;span class="nt"&gt;-var-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;aws.tfvars
&lt;span class="nv"&gt;$ &lt;/span&gt;terraform apply &lt;span class="nt"&gt;-var-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;aws.tfvars
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After that you can connect the instance via Session Manager console in AWS console.You find the way on following short video and AWS document.&lt;br&gt;
 &lt;iframe width="710" height="399" src="https://www.youtube.com/embed/GytEehnuzzs"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://aws.amazon.com/ec2/spot/"&gt;AWS EC2 Spot instance document&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager.html"&gt;AWS System Manager Session Manager document&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>terraform</category>
      <category>devops</category>
    </item>
    <item>
      <title>Traffic Mirroring with GoReplay</title>
      <dc:creator>t.okazaki</dc:creator>
      <pubDate>Sun, 21 Jun 2020 09:35:10 +0000</pubDate>
      <link>https://dev.to/tokazaki42/traffic-mirroring-with-goreplay-48ii</link>
      <guid>https://dev.to/tokazaki42/traffic-mirroring-with-goreplay-48ii</guid>
      <description>&lt;h2&gt;
  
  
  What is GoReplay?
&lt;/h2&gt;

&lt;p&gt;Github: &lt;a href="https://github.com/buger/goreplay"&gt;https://github.com/buger/goreplay&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It captures HTTP requests received by the server and then  duplicate the traffic to another server.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;For example, when you test the new version of your application on the stating environment, you can check the behavior of the application by replicating the trrafic using GoReplay.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This can be done without affecting existing application and traffics. (Because GoReplay uses libpcap, which retrieves packets at the L2 level, as well as tcpdump)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Solves the problem of shadow proxies which is used for similar purposes. ( it can be a critical path of the traffic.)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  You can do for example,
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Capture HTTP request packets and duplicate them&lt;/li&gt;
&lt;li&gt;Save the packet on the file, restoring it from the file&lt;/li&gt;
&lt;li&gt;Filtering request packets&lt;/li&gt;
&lt;li&gt;Rewriting request headers &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to install
&lt;/h2&gt;

&lt;p&gt;You can download rpm, deb and tar.gz from&lt;br&gt;
&lt;a href="https://github.com/buger/gor/releases"&gt;https://github.com/buger/gor/releases&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For AmazonLinux, you can get a tar.gz of the executable binary. If you get the tar.gz and decompress it, you get "gor".&lt;/p&gt;
&lt;h2&gt;
  
  
  Simple Usage.
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; ./gor &lt;span class="nt"&gt;--input-raw&lt;/span&gt; :8000 &lt;span class="nt"&gt;--output-stdout&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;By default, no response contents are received.&lt;br&gt;
you can receive them by adding --output-http-track-response option.&lt;/p&gt;

&lt;p&gt;Replaying Packets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; ./gor &lt;span class="nt"&gt;--input-raw&lt;/span&gt; :8000 &lt;span class="nt"&gt;--output-http&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"http://localhost:8001"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Save the requests &lt;br&gt;
 to a file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; ./gor &lt;span class="nt"&gt;--input-raw&lt;/span&gt; :8000 &lt;span class="nt"&gt;--output-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;requests.gor
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restore and send the requests stored in the file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; ./gor &lt;span class="nt"&gt;--input-file&lt;/span&gt; requests.gor &lt;span class="nt"&gt;--output-http&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"http://localhost:8001"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also specify multiple IP addresses to send requests &lt;br&gt;
 by round-robin feature.&lt;/p&gt;

&lt;p&gt;The response body is designed to receive up to 200KB by default.&lt;/p&gt;

&lt;p&gt;Supports BASIC authentication. You can specify user:pass@ before the URL.&lt;br&gt;
You can specify user:pass@ before the URL.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; ./gor &lt;span class="nt"&gt;--input-raw&lt;/span&gt; :80 &lt;span class="nt"&gt;--output-http&lt;/span&gt; &lt;span class="s2"&gt;"http://user:pass@staging.com"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Filtering Requests.&lt;br&gt;
Replay only requests to /api&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; ./gor &lt;span class="nt"&gt;--input-raw&lt;/span&gt; :8080 &lt;span class="nt"&gt;--output-http&lt;/span&gt; staging.com &lt;span class="nt"&gt;--http-allow-url&lt;/span&gt; /api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Excluding only requests to /api&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; ./gor &lt;span class="nt"&gt;--input-raw&lt;/span&gt; :8080 &lt;span class="nt"&gt;--output-http&lt;/span&gt; staging.com &lt;span class="nt"&gt;--http-disallow-url&lt;/span&gt; /api
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example Use Case 1
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Capture HTTP packets to /production/submission on port 80&lt;/li&gt;
&lt;li&gt;The path changes from  /production/submission to /staging/submission/ &lt;/li&gt;
&lt;li&gt;Saving the source IP addresses of the packets&lt;/li&gt;
&lt;li&gt;Replay the packet to &lt;a href="https://staging.abc.com"&gt;https://staging.abc.com&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; ./gor &lt;span class="nt"&gt;--input-raw&lt;/span&gt; :80 &lt;span class="nt"&gt;--output-http&lt;/span&gt; &lt;span class="s1"&gt;'https://staging.abc.com '&lt;/span&gt;
&lt;span class="nt"&gt;--http-allow-url&lt;/span&gt; /production/submission
&lt;span class="nt"&gt;--http-rewrite-url&lt;/span&gt; /production/submission:/staging/submission &lt;span class="nt"&gt;--input-raw-realip-header&lt;/span&gt; &lt;span class="s2"&gt;"X-Real-IP"&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example Use Case 2
&lt;/h2&gt;

&lt;p&gt;Capture the requests and save it to a file.&lt;br&gt;
AUTH-TOKEN is rewritten to an arbitrary value for the test user on the staging environment.&lt;br&gt;
Do not save requests for sign_in, sign_out operation.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;sudo&lt;/span&gt; ./gor &lt;span class="nt"&gt;--input-raw&lt;/span&gt; :80 &lt;span class="nt"&gt;--output-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;requests.gor 
&lt;span class="nt"&gt;--input-raw&lt;/span&gt; :80 &lt;span class="nt"&gt;--output-file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;requests.gor
&lt;span class="nt"&gt;--http-set-header&lt;/span&gt; &lt;span class="s2"&gt;"X-HTTP-AUTH-TOKEN: abcdefghijk"&lt;/span&gt;
&lt;span class="nt"&gt;--http-disallow-url&lt;/span&gt; /sign_in
&lt;span class="nt"&gt;--http-disallow-url&lt;/span&gt; /sign_out
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>linux</category>
    </item>
  </channel>
</rss>
