Skip to content

Web service operation infrastructure configuration within free range using AWS

Notifications You must be signed in to change notification settings

takeruun/aws-free-infra

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AWS 無料範囲のインフラ構成コード

使用方法

初めに

state 管理用 S3 と 同時更新のブロックする Dynamodb 作成

  1. AWS profile 設定 terraform 実行できるように AWS profile を設定する
export AWS_PROFILE=profile
  1. S3 と Dynamodb 作成
cd backend

terraform init

terraform plan

terraform apply

設定

./env/vars/example.tfvars

domain              = "samplet"
app_name            = "aws-free-infra"
aws_profile         = "sample"
aws_region          = "sample"
remote_state_bucket = "sample"
変数 説明
domain ドメイン
app_name アプリ名(バックエンドのECRに使用される)
aws_profile AWS実行アカウント
aws_region AWS実行リージョン
remote_state_bucket tfstate保存バケット名

リソース作成

作成順番

network → alb → s3_images → rds → spa → ecs_api 各々のディレクトリに移動して、以下の手順を実行する

  1. AWS profile 設定 terraform 実行できるように AWS profile を設定する
export AWS_PROFILE=profile
  1. 初期化 -backend-config=../env/backend.config を指定して、s3 にある stateファイル と Dynamodb を更新する
terraform init -backend-config=../env/backend.config
  1. プラン -var-file を指定して、変数を読み込む
terraform plan -var-file=../env/vars/example.tfvars
  1. デプロイ -var-file を指定して、変数を読み込む
terraform apply -var-file=../env/vars/example.tfvars

ssh 接続

Session Manager ec2 に接続する

ssh -i ecs_api/ssh/aws-free-infra.pem ec2-user@$ec2-id

コンテナに接続

sh ecs_api/ssm_agent/ssm.sh aws-free-infra-cluster aws-free-infra_api

マイグレーション実行

マイグレーションコマンド実行するコンテナの作成

sh ecs_api/db_migrate/migrate.sh aws-free-infra-cluster aws-free-infra-service aws-free-infra_task aws-free-infra

About

Web service operation infrastructure configuration within free range using AWS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published