Skip to content

Commit af4b546

Browse files
committed
set default aws region (us-east-1)
1 parent bcac6ca commit af4b546

File tree

3 files changed

+29
-27
lines changed

3 files changed

+29
-27
lines changed

README-ja.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ API 経由でアクセスするため、バケットに静的 Web サイトホ
1212

1313
### 1. 環境変数をセットします
1414

15-
環境変数 | 説明 | 必須
16-
------------------------- | ----------------------------------------------- | ---------
17-
AWS_S3_BUCKET | プロキシ先の S3 バケット | *
18-
AWS_REGION | バケットの存在する AWS リージョン | *
19-
AWS_ACCESS_KEY_ID | API を使うための AWS アクセスキー | インスタンスロールでも OK
20-
AWS_SECRET_ACCESS_KEY | API を使うための AWS シークレットキー |
21-
BASIC_AUTH_PASS | Basic 認証をかけるなら、その `パスワード` |
22-
APP_PORT | このサービスが待機する `ポート番号` (デフォルト 80番) |
23-
SSL_CERT_PATH | TLS を有効にしたいなら、その `cert.pem` へのパス |
24-
SSL_KEY_PATH | TLS を有効にしたいなら、その `key.pem` へのパス |
25-
ACCESS_LOG | 標準出力へアクセスログを送る (初期値: false) |
15+
環境変数 | 説明 | 必須 | 初期値
16+
------------------------- | ----------------------------------------------- | ------ | ---
17+
AWS_S3_BUCKET | プロキシ先の S3 バケット | * |
18+
AWS_REGION | バケットの存在する AWS リージョン | | us-east-1
19+
AWS_ACCESS_KEY_ID | API を使うための AWS アクセスキー | | EC2 インスタンスロール
20+
AWS_SECRET_ACCESS_KEY | API を使うための AWS シークレットキー | | EC2 インスタンスロール
21+
BASIC_AUTH_PASS | Basic 認証をかけるなら、その `パスワード` | | -
22+
SSL_CERT_PATH | TLS を有効にしたいなら、その `cert.pem` へのパス | | -
23+
SSL_KEY_PATH | TLS を有効にしたいなら、その `key.pem` へのパス | | -
24+
APP_PORT | このサービスが待機する `ポート番号` | | 80
25+
ACCESS_LOG | 標準出力へアクセスログを送る | | false
2626

2727
### 2. アプリを起動します
2828

README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ You don't need to configure a Bucket for `Website Hosting`.
1313

1414
### 1. Set environment variables
1515

16-
Environment Variables | Description | Required
17-
------------------------- | ------------------------------------------------- | ---------
18-
AWS_S3_BUCKET | The `S3 bucket` to be proxied with this app. | *
19-
AWS_REGION | The AWS `region` where the S3 bucket exists. | *
20-
AWS_ACCESS_KEY_ID | AWS `access key` for API access. | or EC2 Instance Role
21-
AWS_SECRET_ACCESS_KEY | AWS `secret key` for API access. |
22-
BASIC_AUTH_USER | User for basic authentication. |
23-
BASIC_AUTH_PASS | Password for basic authentication. |
24-
APP_PORT | The port number to be assigned for listening. |
25-
SSL_CERT_PATH | TLS: cert.pem file path. |
26-
SSL_KEY_PATH | TLS: key.pem file path. |
27-
ACCESS_LOG | Send access logs to /dev/stdout. (default: false) |
16+
Environment Variables | Description | Required | Default
17+
------------------------- | ------------------------------------------------- | -------- | -----------------
18+
AWS_S3_BUCKET | The `S3 bucket` to be proxied with this app. | * |
19+
AWS_REGION | The AWS `region` where the S3 bucket exists. | | us-east-1
20+
AWS_ACCESS_KEY_ID | AWS `access key` for API access. | | EC2 Instance Role
21+
AWS_SECRET_ACCESS_KEY | AWS `secret key` for API access. | | EC2 Instance Role
22+
BASIC_AUTH_USER | User for basic authentication. | | -
23+
BASIC_AUTH_PASS | Password for basic authentication. | | -
24+
SSL_CERT_PATH | TLS: cert.pem file path. | | -
25+
SSL_KEY_PATH | TLS: key.pem file path. | | -
26+
APP_PORT | The port number to be assigned for listening. | | 80
27+
ACCESS_LOG | Send access logs to /dev/stdout. | | false
2828

2929
### 2. Run the application
3030

main.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,13 @@ func configFromEnvironmentVariables() *config {
6161
if len(os.Getenv("AWS_SECRET_ACCESS_KEY")) == 0 {
6262
log.Print("Not defined environment variable: AWS_SECRET_ACCESS_KEY")
6363
}
64-
if len(os.Getenv("AWS_REGION")) == 0 {
65-
log.Fatal("Missing required environment variable: AWS_REGION")
66-
}
6764
if len(os.Getenv("AWS_S3_BUCKET")) == 0 {
6865
log.Fatal("Missing required environment variable: AWS_S3_BUCKET")
6966
}
67+
region := os.Getenv("AWS_REGION")
68+
if len(region) == 0 {
69+
region = "us-east-1"
70+
}
7071
port := os.Getenv("APP_PORT")
7172
if len(port) == 0 {
7273
port = "80"
@@ -76,7 +77,7 @@ func configFromEnvironmentVariables() *config {
7677
accessLog = b
7778
}
7879
conf := &config{
79-
awsRegion: os.Getenv("AWS_REGION"),
80+
awsRegion: region,
8081
s3Bucket: os.Getenv("AWS_S3_BUCKET"),
8182
basicAuthUser: os.Getenv("BASIC_AUTH_USER"),
8283
basicAuthPass: os.Getenv("BASIC_AUTH_PASS"),
@@ -87,6 +88,7 @@ func configFromEnvironmentVariables() *config {
8788
}
8889
// Proxy
8990
log.Printf("[config] Proxy to %v", conf.s3Bucket)
91+
log.Printf("[config] AWS Region: %v", conf.awsRegion)
9092

9193
// TLS pem files
9294
if (len(conf.sslCert) > 0) && (len(conf.sslKey) > 0) {

0 commit comments

Comments
 (0)