<?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: hiroga</title>
    <description>The latest articles on DEV Community by hiroga (@hiroga).</description>
    <link>https://dev.to/hiroga</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%2F356950%2F9a04d5bf-2576-4d03-9b90-451ec588389a.png</url>
      <title>DEV Community: hiroga</title>
      <link>https://dev.to/hiroga</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hiroga"/>
    <language>en</language>
    <item>
      <title>AWS Peacock Management Console enables to change console color as you like.</title>
      <dc:creator>hiroga</dc:creator>
      <pubDate>Sat, 22 Jan 2022 20:23:39 +0000</pubDate>
      <link>https://dev.to/hiroga/aws-peacock-management-console-enables-to-change-console-color-as-you-like-9oa</link>
      <guid>https://dev.to/hiroga/aws-peacock-management-console-enables-to-change-console-color-as-you-like-9oa</guid>
      <description>&lt;p&gt;&lt;a href="https://github.com/xhiroga/aws-peacock-management-console" rel="noopener noreferrer"&gt;AWS Peacock Management Console&lt;/a&gt; enables users to change the color of the AWS management console as like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmeqynob4nr6scn1g14h6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmeqynob4nr6scn1g14h6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The browser extension is now available on both &lt;a href="https://chrome.google.com/webstore/detail/aws-peacock-management-co/bknjjajglapfhbdcfgmhgkgfomkkaidj?utm_source=dev.to"&gt;Chrome Web Store&lt;/a&gt; and &lt;a href="https://addons.mozilla.org/ja/firefox/addon/aws-peacock-management-console/" rel="noopener noreferrer"&gt;Mozzila add-on&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this article, I explain the motivation of development and how it works as the developer of the extension.&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation of development
&lt;/h2&gt;

&lt;p&gt;My company starts switching from AWS Switch Role to AWS SSO for security reasons. However, we are worried that AWS SSO does not provide the feature to change color.&lt;/p&gt;

&lt;p&gt;Changing color is a very simple, but efficient technique to avoid wrong operations. For example, making the production environment red helps operators to remind which environment they use.&lt;/p&gt;

&lt;p&gt;AWS SSO has another problem. The account name is not shown on the menu button. Not setting an account alias is usual if AWS SSO is used. In my opinion, account name instead of account alias should be shown in the menu button.&lt;/p&gt;

&lt;p&gt;After a little inspection, I decided to create a browser extension.&lt;/p&gt;

&lt;h2&gt;
  
  
  How it works
&lt;/h2&gt;

&lt;p&gt;There are 3 steps to change color and show the account name.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Getting account name from AWS SSO screen&lt;/li&gt;
&lt;li&gt;Getting account id and region in the management console.&lt;/li&gt;
&lt;li&gt;Change color and menu button name in the management console.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  1. Getting account name from AWS SSO screen
&lt;/h3&gt;

&lt;p&gt;AWS SSO screen has the pair of account ids and account names.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F92w2y73flzjnav2buasq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F92w2y73flzjnav2buasq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The cookie also has an account name, but using it is not enough. When the user switched role beyond account from AWS SSO logged in user, the parameter does not change.&lt;/p&gt;

&lt;p&gt;The account name information is stored in the browser extensions storage area. If you want to delete it, just uninstall the browser extension.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Getting account id and region in the management console.
&lt;/h2&gt;

&lt;p&gt;Both account id and region are hidden in the management console.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// to get account id&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;HTMLElement&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;button[data-testid="awsc-copy-accountid"]&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)?.&lt;/span&gt;&lt;span class="nx"&gt;previousElementSibling&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;HTMLSpanElement&lt;/span&gt;&lt;span class="p"&gt;)?.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/&lt;/span&gt;&lt;span class="se"&gt;\-&lt;/span&gt;&lt;span class="sr"&gt;/g&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// to get region&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;region&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;awsc-mezz-region&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)?.&lt;/span&gt;&lt;span class="nf"&gt;getAttribute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;content&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  3. Change color and menu button name in the management console.
&lt;/h2&gt;

&lt;p&gt;Changing console color is just embedding CSS, but not simple.&lt;/p&gt;

&lt;p&gt;To ensure visibility, AWS Peacock Management Console can invert the menu icon and string color.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajmlkfnyx2iy1z9l9ts8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fajmlkfnyx2iy1z9l9ts8.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The extension also detects how users logged in. If AWS SSO is used, the menu button name is replaced by the account name.&lt;/p&gt;

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

&lt;p&gt;AWS Peacock Management Console is developed to use AWS SSO convenient as AWS Switch Role.&lt;/p&gt;

&lt;p&gt;The extension is released in &lt;a href="https://chrome.google.com/webstore/detail/aws-peacock-management-co/bknjjajglapfhbdcfgmhgkgfomkkaidj?utm_source=dev.to"&gt;Chrome Web Store&lt;/a&gt; and &lt;a href="https://addons.mozilla.org/ja/firefox/addon/aws-peacock-management-console/" rel="noopener noreferrer"&gt;mozzila add-on&lt;/a&gt;. Source code is also available in &lt;a href="https://github.com/xhiroga/aws-peacock-management-console" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. Any issues or contribution is welcome!&lt;/p&gt;

&lt;p&gt;If this extension helps to improve your productivity, it is glad for me.&lt;/p&gt;

</description>
      <category>aws</category>
      <category>extension</category>
    </item>
    <item>
      <title>makefile styleguide as task runner</title>
      <dc:creator>hiroga</dc:creator>
      <pubDate>Sun, 02 Jan 2022 22:00:25 +0000</pubDate>
      <link>https://dev.to/hiroga/makefile-styleguide-as-task-runner-3i75</link>
      <guid>https://dev.to/hiroga/makefile-styleguide-as-task-runner-3i75</guid>
      <description>&lt;p&gt;Using make as task runner, this is style guide of &lt;code&gt;makefile&lt;/code&gt; for me&lt;/p&gt;

&lt;h2&gt;
  
  
  Style Rules
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Assignment to variables
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;:=&lt;/code&gt; as possible. The variables defined by &lt;code&gt;=&lt;/code&gt; is referred recursively and it is little tricky.&lt;br&gt;&lt;br&gt;
See &lt;a href="https://www.gnu.org/software/make/manual/make.html#Setting"&gt;6.5 Setting Variables&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Order or targets
&lt;/h3&gt;

&lt;p&gt;Here is the preferable target order.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="p"&gt;1.&lt;/span&gt; all (any name you like)
&lt;span class="p"&gt;2.&lt;/span&gt; .PHONY
&lt;span class="p"&gt;3.&lt;/span&gt; (other tasks)
&lt;span class="p"&gt;4.&lt;/span&gt; clean
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;all&lt;/code&gt; is optional and should contains default tasks, like &lt;code&gt;download&lt;/code&gt;, &lt;code&gt;build&lt;/code&gt;, &lt;code&gt;start&lt;/code&gt;. If you do not allow running without specifying goal, just remove this target.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;.PHONY&lt;/code&gt; target should contain all phony targets, which name is not build output. There are two reasons to use phony target. to make sure to run target if a file of the same name exists, and to skip checking a file timestamp of the same name.&lt;/p&gt;

&lt;p&gt;see &lt;a href="https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html"&gt;Phony Targets (GNU make)&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;clean&lt;/code&gt; is used to be placed in the last, as I know.&lt;/p&gt;

&lt;h2&gt;
  
  
  Formatting Rules
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Command substitution
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;$$()&lt;/code&gt; (double dollar) instead of &lt;code&gt;\&lt;/code&gt;`` (backquotes).&lt;br&gt;&lt;br&gt;
Some articles say that backquotes has a little bit more compatibility to ancient make. However, escaping backquotes in nested command substitution is bother jobs.&lt;/p&gt;

&lt;h4&gt;
  
  
  TIPS: &lt;code&gt;$$(command)&lt;/code&gt; vs &lt;code&gt;$(shell command)&lt;/code&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;code&gt;$(shell command)&lt;/code&gt; will be evaluated at the first time. &lt;code&gt;$$(command)&lt;/code&gt; will be evaluated at the execution time.&lt;/p&gt;

&lt;h3&gt;
  
  
  Semicolon vs new line and TAB
&lt;/h3&gt;

&lt;p&gt;Use new line and TAB for command. To keep the format constant regardless of the number of lines in the command.&lt;/p&gt;

&lt;h3&gt;
  
  
  Shell variables
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;$${VAR}&lt;/code&gt; instead of &lt;code&gt;$$VAR&lt;/code&gt;. It help to distinguish shell variables from make variables.&lt;/p&gt;

&lt;h2&gt;
  
  
  Meta Rules
&lt;/h2&gt;

&lt;h3&gt;
  
  
  File name
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;Makefile&lt;/code&gt;, start with capital.&lt;br&gt;&lt;br&gt;
The manual says &lt;a href="https://www.gnu.org/software/make/manual/make.html#Makefile-Names"&gt;We recommend Makefile because it appears prominently near the beginning of a directory listing, right near other important files such as README.&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  References and Inspirations
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.gnu.org/software/make/manual/make.html"&gt;GNU make&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://voyagegroup.github.io/make-advent-calendar-2020/"&gt;Home | Makefile Advent Calendar 2020&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.cloudposse.com/reference/best-practices/make-best-practices/"&gt;Makefile Best Practices — Cloud Posse Developer Hub&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/4708549/what-is-the-difference-between-command-and-command-in-shell-programming"&gt;bash - What is the difference between $(command) and `command` in shell programming? - Stack Overflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/9405478/command-substitution-backticks-or-dollar-sign-paren-enclosed"&gt;bash - Command substitution: backticks or dollar sign / paren enclosed? - Stack Overflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://stackoverflow.com/questions/12669367/should-i-name-makefile-or-makefile"&gt;coding style - Should I name "makefile" or "Makefile"? - Stack Overflow&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://zenn.dev/hiroga/articles/styleguide-of-styleguide"&gt;Style Guide の Style Guide を作る&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>make</category>
    </item>
    <item>
      <title>Run aws-shell by docker</title>
      <dc:creator>hiroga</dc:creator>
      <pubDate>Sat, 28 Mar 2020 22:51:14 +0000</pubDate>
      <link>https://dev.to/hiroga/run-aws-shell-by-docker-1i67</link>
      <guid>https://dev.to/hiroga/run-aws-shell-by-docker-1i67</guid>
      <description>&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;p&gt;Set this alias.&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="nb"&gt;alias &lt;/span&gt;aws-shell&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'docker run --rm -it -v "$HOME/.aws:/root/.aws" hiroga/aws-shell:latest'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Details
&lt;/h2&gt;

&lt;p&gt;As of 2020-03-29, &lt;code&gt;aws-shell&lt;/code&gt; installed by Homebrew does not work.&lt;br&gt;&lt;br&gt;
To avoid the dependency problem, I run my aws-shell by docker.&lt;/p&gt;

&lt;p&gt;Dockerfile is here.&lt;br&gt;&lt;br&gt;
&lt;a href="https://github.com/hiroga-cc/docker-images/blob/master/aws-shell/Dockerfile"&gt;https://github.com/hiroga-cc/docker-images/blob/master/aws-shell/Dockerfile&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Issues
&lt;/h2&gt;

&lt;p&gt;It runs creating index per invoke. I want to avoid it but do not have any good ideas.&lt;/p&gt;

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