質問編集履歴

1

aws_instanceにkey_nameを追加、aws_key_pairを追加

2020/08/31 14:43

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -274,6 +274,8 @@
274
274
 
275
275
  instance_type = "t2.micro"
276
276
 
277
+ key_name = "${aws_key_pair.auth.id}"
278
+
277
279
  vpc_security_group_ids = [
278
280
 
279
281
  "${aws_security_group.securitygroup.id}"
@@ -288,6 +290,16 @@
288
290
 
289
291
 
290
292
 
293
+ resource "aws_key_pair" "auth" {
294
+
295
+ key_name = "${var.key_name}"
296
+
297
+ public_key = "${file(var.public_key_path)}"
298
+
299
+ }
300
+
301
+
302
+
291
303
  resource "aws_eip" "elastic_ip" {
292
304
 
293
305
  instance = "${aws_instance.ec2-test.id}"