<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>RDS on Indexing my brain</title><link>https://tech.yyh-gl.dev/categories/rds/</link><description>Recent content in RDS on Indexing my brain</description><generator>Hugo -- gohugo.io</generator><language>ja</language><lastBuildDate>Tue, 04 Jun 2019 09:00:00 +0900</lastBuildDate><atom:link href="https://tech.yyh-gl.dev/categories/rds/index.xml" rel="self" type="application/rss+xml"/><item><title>【Terraform + ECS + RDS】Terraform で ECS環境構築してみた</title><link>https://tech.yyh-gl.dev/blog/terraform_ecs/</link><pubDate>Tue, 04 Jun 2019 09:00:00 +0900</pubDate><guid>https://tech.yyh-gl.dev/blog/terraform_ecs/</guid><description>&lt;h1 id="terraform-とは">Terraform とは&lt;/h1>
&lt;p>最近流行りの IaC です。&lt;/p>
&lt;p>つまり、コードベースでインフラリソースを管理するためのツールです。&lt;/p>
&lt;p>中でもTerraform はクラウドに特化した IaC ツールという立ち位置です。&lt;/p>
&lt;p>AWSやGCP, Azure などの他に&lt;a href="https://www.terraform.io/docs/providers/index.html" target="_blank" rel="noopener noreferrer">様々なクラウドプラットフォーム&lt;/a>
に対応しています。&lt;/p>
&lt;p>（ちなみに、Vagrant 開発元の &lt;a href="https://www.hashicorp.com/" target="_blank" rel="noopener noreferrer">HashiCorp&lt;/a>
社が開発しています）&lt;/p>
&lt;h1 id="今回やること">今回やること&lt;/h1>
&lt;p>Terraform で AWS 上に下記のような環境を自動構築します。&lt;/p>
&lt;img src="https://tech.yyh-gl.dev/img/2019/06/terraform_ecs/architecture.png" width="600">
&lt;br>
&lt;p>ECS でデプロイされるサービスは ECR から引っ張ってくるようにします。&lt;/p>
&lt;p>そして、そのサービスは Aurora を使うシステムを想定しています。&lt;/p>
&lt;p>&lt;u>【⚠注意⚠】上記構成はお金が発生します！ まったくもって無料枠ではありません！&lt;/u>&lt;/p>
&lt;p>【⚠注意⚠】今回独自ドメインを使用していますが、ドメイン取得に関しては省略しています。&lt;/p>
&lt;h2 id="今回やる内容は">今回やる内容は…&lt;/h2>
&lt;p>僕が所属する会社の研修資料を参考に進めています。&lt;/p>
&lt;p>資料を作成してくださった&lt;a href="https://twitter.com/_y_ohgi" target="_blank" rel="noopener noreferrer">@_y_ohgi&lt;/a>
さんに感謝。&lt;/p>
&lt;h1 id="自動構築プロセス全体で使用する共通設定を定義">自動構築プロセス全体で使用する共通設定を定義&lt;/h1>
&lt;p>まず、 &lt;code>main.tf&lt;/code> を作成し、以下のとおり共通設定を定義していきます。&lt;/p>
&lt;pre class="line-numbers">&lt;code class="language-text"># AWS を利用することを明示
provider &amp;#34;aws&amp;#34; {
# リージョンを設定
region = &amp;#34;ap-northeast-1&amp;#34;
}
# これから作成するリソースに付与する名前のプリフィックスを設定
# グローバル変数的な立ち位置で定義
variable &amp;#34;prefix&amp;#34; {
default = &amp;#34;sample-project&amp;#34;
}&lt;/code>&lt;/pre>
&lt;p>&lt;code>provider&lt;/code> で使用するクラウドを指定することができます。&lt;/p>
&lt;p>&lt;code>variable&lt;/code> は変数定義です。&lt;/p>
&lt;p>&lt;code>${var.prefix}&lt;/code> と書くことで &lt;code>default&lt;/code> で指定した内容が展開されます。&lt;/p></description></item></channel></rss>