- AWS profile 設定 terraform 実行できるように AWS profile を設定する
export AWS_PROFILE=profile- 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 各々のディレクトリに移動して、以下の手順を実行する
- AWS profile 設定 terraform 実行できるように AWS profile を設定する
export AWS_PROFILE=profile- 初期化
-backend-config=../env/backend.configを指定して、s3 にある stateファイル と Dynamodb を更新する
terraform init -backend-config=../env/backend.config- プラン
-var-fileを指定して、変数を読み込む
terraform plan -var-file=../env/vars/example.tfvars- デプロイ
-var-fileを指定して、変数を読み込む
terraform apply -var-file=../env/vars/example.tfvarsSession Manager ec2 に接続する
ssh -i ecs_api/ssh/aws-free-infra.pem ec2-user@$ec2-idsh 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