-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryosuke Tomita
committed
Dec 16, 2023
1 parent
f81259f
commit 3329358
Showing
11 changed files
with
123 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,113 @@ | ||
# INDEX | ||
|
||
- [ABOUT](#ABOUT) | ||
- [ENVIRONMENT](#ENVIRONMENT) | ||
- [PREPARING](#PREPARING) | ||
- [HOW TO USE](#HOW-TO-USE) | ||
- [REFERENCE](#REFERENCE) | ||
****** | ||
|
||
|
||
# ABOUT | ||
Sample for DevSecOps environment. | ||
See [./doc/tools_doc](./doc/tools_doc) | ||
****** | ||
|
||
|
||
# ENVIRONMENT | ||
- AWS | ||
- Github Actions | ||
- node:20 | ||
****** | ||
|
||
|
||
# PREPARING | ||
## AWSの設定 | ||
copilot cliを使って環境構築を行う。 | ||
### appの作成 | ||
- 名前は任意だが,自分はreact-appとした | ||
- ここで必用なIAMロールの一部やKMSのキーやCodePipelineに使うS3やそのポリシーが作成されている。 | ||
|
||
```shell | ||
copilot app init | ||
cat ./copilot/.workspace | ||
application: react-app | ||
``` | ||
### development用のenvironmentとserviceをまとめて作成する。 | ||
- amd64を指定しないとなぜかビルドエラーになる。 | ||
|
||
```shell | ||
DOCKER_DEFAULT_PLATFORM=linux/amd64 copilot init | ||
``` | ||
- 名前は任意だが,dev-envとdev-svcとした。 | ||
- copilot/以下のファイルを編集することで設定を変更できる。 | ||
- 新しいVPCや,ECSのCluster,Load Balancerや権限周りが作成される。 | ||
|
||
### production用のenvironmentとserviceをまとめて作成する。 | ||
- vpcをいくつも作りたくない場合はenvironment単体で作成すると既存リソースの使用が選択できる。 | ||
|
||
```shell | ||
copilot env init # prod-envと命名してcopilot-react-app-dev-vpcを選択する。 | ||
``` | ||
<details> | ||
<summary>see detail</summary> | ||
|
||
```shell | ||
copilot env init | ||
Environment name: prod-env | ||
|
||
Which credentials would you like to use to create hoge? [Use arrows to move, type to filter, ? for more help] | ||
Enter temporary credentials | ||
> [profile default] | ||
|
||
|
||
Environment name: prod-env | ||
Credential source: [profile default] | ||
Would you like to use the default configuration for a new environment? | ||
- A new VPC with 2 AZs, 2 public subnets and 2 private subnets | ||
- A new ECS Cluster | ||
- New IAM Roles to manage services and jobs in your environment | ||
[Use arrows to move, type to filter] | ||
Yes, use default. | ||
Yes, but I'd like configure the default resources (CIDR ranges, AZs). | ||
> No, I'd like to import existing resources (VPC, subnets). | ||
|
||
|
||
Environment name: prod-env | ||
Credential source: [profile default] | ||
Default environment configuration? No, I'd like to import existing resources | ||
Which VPC would you like to use? [Use arrows to move, type to filter] | ||
> vpc-xxxxxxxxxxxxxxxxx (copilot-react-app-dev-env) | ||
``` | ||
</details> | ||
- environmentをデプロイ | ||
```shell | ||
copilot env deploy | ||
``` | ||
- prod用のserviceを作成してデプロイする。 | ||
この際に間違えてdev-svcやdev-envを選ばないように注意する。 | ||
```shell | ||
DOCKER_DEFAULT_PLATFORM=linux/amd64 copilot svc init | ||
copilot svc deploy | ||
``` | ||
### CodePipelineの作成 | ||
## その他の設定 | ||
- ローカルでのインストールが必須なのはpre-commitくらい | ||
```shell | ||
cd devsecops-demo-aws-ecs | ||
pre-commit install | ||
``` | ||
- VSCodeのExtensionsもお好みで。Dockerのhadolintはおすすめ。 | ||
****** | ||
# HOW TO USE | ||
# REFERENCE | ||
- [ECSの仕様で非特権ユーザを使用したコンテナでは80番ポートが使えないっぽい](https://repost.aws/questions/QU1bCV9wT4T5iBrrP1c2ISfg/container-cannot-bind-to-port-80-running-as-non-root-user-on-ecs-fargate) --> つまり,localのdockerで80でサービスが起動できてもECSだと権限エラーになる。 | ||
> nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
application: roulette-app | ||
application: react-app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters