質問するログイン新規登録

質問編集履歴

4

追記

2021/03/04 06:35

投稿

pay_561
pay_561

スコア26

title CHANGED
File without changes
body CHANGED
@@ -63,6 +63,13 @@
63
63
  on <input-prompt> line 1:
64
64
  (source code not available)
65
65
  ```
66
+ ## ~/.aws/credentials
67
+ ```ここに言語を入力
68
+ [default]
69
+ aws_access_key_id = ☓☓☓☓☓☓☓☓☓☓☓
70
+ aws_secret_access_key = ☓☓☓☓☓☓☓☓☓☓☓
71
+ ```
72
+
66
73
  ## ~/.aws/config
67
74
  ```ここに言語を入力
68
75
  [default]

3

修正

2021/03/04 06:35

投稿

pay_561
pay_561

スコア26

title CHANGED
File without changes
body CHANGED
@@ -68,4 +68,18 @@
68
68
  [default]
69
69
  region = ap-northeast-1
70
70
  output = json
71
+ ```
72
+ ##main.tf
73
+ ```ここに言語を入力
74
+ provider "aws" {
75
+ profile = var.aws["profile"]
76
+ }
77
+ ```
78
+ ##variable.tf
79
+ ```ここに言語を入力
80
+ variable "aws" {
81
+ default = {
82
+ profile = "default"
83
+ }
84
+ }
71
85
  ```

2

追記

2021/03/04 04:09

投稿

pay_561
pay_561

スコア26

title CHANGED
File without changes
body CHANGED
@@ -38,4 +38,34 @@
38
38
  # secret_key = "☓☓☓☓☓☓☓☓☓☓☓☓☓☓☓☓☓"
39
39
  }
40
40
  }
41
+ ```
42
+
43
+ ##追記
44
+ ~/.aws/config ~/.aws/credentialsに正しく設定されていないのが原因でした。
45
+ ですが、terraform planを実行すると下記のエラーが発生しました。
46
+ ```ここに言語を入力
47
+ provider.aws.region
48
+ The region where AWS operations will take place. Examples
49
+ are us-east-1, us-west-2, etc.
50
+
51
+ Enter a value: ap-northeast-1
52
+
53
+ Refreshing Terraform state in-memory prior to plan...
54
+ The refreshed state will be used to calculate this plan, but will not be
55
+ persisted to local or remote state storage.
56
+
57
+
58
+ ------------------------------------------------------------------------
59
+
60
+ Error: error configuring Terraform AWS Provider: error validating provider credentials: error calling sts:GetCallerIdentity: InvalidClientTokenId: The security token included in the request is invalid.
61
+ status code: 403, request id: 4e474dc1-bf31-4383-93ea-4c26c368c092
62
+
63
+ on <input-prompt> line 1:
64
+ (source code not available)
65
+ ```
66
+ ## ~/.aws/config
67
+ ```ここに言語を入力
68
+ [default]
69
+ region = ap-northeast-1
70
+ output = json
41
71
  ```

1

修正

2021/03/04 04:02

投稿

pay_561
pay_561

スコア26

title CHANGED
@@ -1,1 +1,1 @@
1
- アクセスキーとシークレットキーをmain.tfに記述しない方法をしりたい。
1
+ アクセスキーとシークレットキーをmain.tfに直接記述しない方法をしりたい。
body CHANGED
@@ -2,7 +2,7 @@
2
2
  Terraformでインフラを構築しGitHubに公開したいのですが、このままだとaccess_keyとsecret_keyが
3
3
  全世界に公開することになってしまいます。
4
4
 
5
- ローカルでクレデンシャル情報を登録したのですが、terraform planするとエラーになってしまいます。
5
+ ローカルでクレデンシャル情報を登録したのですが、terraform planするとエラーになってしまいます。
6
6
  main.tfに直接記述することでterraform planで確認できました。
7
7
 
8
8
  ```ここに言語を入力