Skip to content

Commit e4348dd

Browse files
committed
Modify README
1 parent 0b76bbe commit e4348dd

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

README.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
This is a terraform configuration for deploying a sample Rails application [mpon/rails-blog-example](https://github.com/mpon/rails-blog-example) in Fargate.
44

5-
This repository is just an example, but we are aiming for a level that can be used even for production operations, and to complete the CI/CD only with AWS services.
5+
This repository is just an example, but we are aiming for a level that can be used even for production operations, and to complete the CI/CD only with AWS services, also without using shell like `sed` to replace image tag.
66

7-
You can use this example to try creating your own AWS infrastructure!
7+
You can use this repository to try creating your own AWS infrastructure!
88

99
- [x] VPC
1010
- [x] ECS on Fargate
@@ -46,19 +46,26 @@ You can use this example to try creating your own AWS infrastructure!
4646
### 0. environments
4747

4848
```bash
49-
# This example use ap-northeast-1 region
50-
export REGION=ap-northeast-1
49+
# You can set any region
50+
export AWS_DEFAULT_REGION=ap-northeast-1
51+
5152
# S3 bucket to be used by Terraform remote backend
5253
export TF_VAR_remote_backend=<your s3 bucket>
54+
5355
# GitHub personal token to be used by github provider
5456
export GITHUB_TOKEN=***********************
57+
58+
# Configure aws-cli.
59+
# We have not confirmed the minimum policy, it works AdministratorAccess at least.
60+
# NOTE: In production environments, you have to reduce policy.
61+
aws configure
5562
```
5663

5764
### 1. create remote backend
5865

5966
```bash
60-
aws s3api create-bucket --bucket $TF_VAR_remote_backend --region $REGION \
61-
--create-bucket-configuration LocationConstraint=$REGION
67+
aws s3api create-bucket --bucket $TF_VAR_remote_backend --region $AWS_DEFAULT_REGION \
68+
--create-bucket-configuration LocationConstraint=$AWS_DEFAULT_REGION
6269
aws s3api put-bucket-versioning --bucket $TF_VAR_remote_backend --versioning-configuration Status=Enabled
6370
```
6471

@@ -73,22 +80,25 @@ make plan
7380
make apply
7481
```
7582

76-
### 3. terraform apply(prod)
83+
### 3. terraform apply staging and production
7784

78-
Next, create production environments. If you would fail to apply, please retry once or twice.
85+
Next, create some environments. If you would fail to apply, please retry once or twice.
7986

8087
```bash
81-
cd terraform/prod
88+
cd terraform/stg # also terraform/prod
8289
make init
8390
make plan
8491
make apply
8592
```
8693

8794
Then, it shows ALB DNS name in terminal, you can access it.
95+
At the same time, CodePipeline will be started and deploy rails application after a while.
8896

8997
## Clean up
9098

9199
```bash
100+
cd terraform/stg
101+
terraform destroy
92102
cd terraform/prod
93103
terraform destroy
94104
cd terraform/common
@@ -118,3 +128,11 @@ terraform destroy
118128
6. sync assets
119129
7. get files to deploy ECS from S3 (taskdef, appspec)
120130
8. start CodeDeploy B/G Deployments
131+
132+
## Note for using in production
133+
134+
- Use HTTPS listener
135+
- Set enable_deletion_protection of ALB to true
136+
- Set force_destroy of S3 bucket to false
137+
- Change RDS username/password
138+
- Change resource name using random_pet that makes it unique in this example

0 commit comments

Comments
 (0)