Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/takeruun/aws-free-infra
Web service operation infrastructure configuration within free range using AWS
https://github.com/takeruun/aws-free-infra
cloudfront ecs iac spa terraform
Last synced: 10 days ago
JSON representation
Web service operation infrastructure configuration within free range using AWS
- Host: GitHub
- URL: https://github.com/takeruun/aws-free-infra
- Owner: takeruun
- Created: 2023-06-13T16:05:02.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-27T05:38:50.000Z (over 1 year ago)
- Last Synced: 2024-12-01T20:10:04.443Z (2 months ago)
- Topics: cloudfront, ecs, iac, spa, terraform
- Language: HCL
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# AWS 無料範囲のインフラ構成コード
## 使用方法
### 初めに
#### state 管理用 S3 と 同時更新のブロックする Dynamodb 作成
1. AWS profile 設定
terraform 実行できるように AWS profile を設定する
```sh
export AWS_PROFILE=profile
```
2. S3 と Dynamodb 作成
```sh
cd backendterraform 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 を設定する
```sh
export AWS_PROFILE=profile
```2. 初期化
`-backend-config=../env/backend.config` を指定して、s3 にある stateファイル と Dynamodb を更新する
```sh
terraform init -backend-config=../env/backend.config
```3. プラン
`-var-file` を指定して、変数を読み込む
```sh
terraform plan -var-file=../env/vars/example.tfvars
```4. デプロイ
`-var-file` を指定して、変数を読み込む
```sh
terraform apply -var-file=../env/vars/example.tfvars
```## ssh 接続
Session Manager ec2 に接続する
```sh
ssh -i ecs_api/ssh/aws-free-infra.pem ec2-user@$ec2-id
```### コンテナに接続
```sh
sh ecs_api/ssm_agent/ssm.sh aws-free-infra-cluster aws-free-infra_api
```### マイグレーション実行
マイグレーションコマンド実行するコンテナの作成
```sh
sh ecs_api/db_migrate/migrate.sh aws-free-infra-cluster aws-free-infra-service aws-free-infra_task aws-free-infra
```