File tree Expand file tree Collapse file tree 7 files changed +19
-42
lines changed Expand file tree Collapse file tree 7 files changed +19
-42
lines changed Original file line number Diff line number Diff line change @@ -3,19 +3,16 @@ terraform {
3
3
}
4
4
5
5
provider "aws" {
6
- version = " ~> 1.5"
7
- access_key = " ${ var . access_key } "
8
- secret_key = " ${ var . secret_key } "
9
- region = " ${ var . region } "
6
+ version = " ~> 1.5"
10
7
}
11
8
12
9
module "server" {
13
10
source = " ./server"
14
11
15
- num_webs = " ${ var . num_webs } "
16
- identity = " ${ var . identity } "
17
- ami = " ${ var . ami } "
18
- ingress_cidr = " ${ var . ingress_cidr } "
19
- public_key_path = " ${ var . public_key_path } "
20
- private_key_path = " ${ var . private_key_path } "
12
+ num_webs = " ${ var . num_webs } "
13
+ identity = " ${ var . identity } "
14
+ ami = " ${ var . ami } "
15
+ ingress_cidr = " ${ var . ingress_cidr } "
16
+ public_key = " ${ var . public_key } "
17
+ private_key = " ${ var . private_key } "
21
18
}
Original file line number Diff line number Diff line change 1
-
2
1
output "public_ip" {
3
2
value = " ${ module . server . public_ip } "
4
3
}
Original file line number Diff line number Diff line change 1
1
resource "aws_key_pair" "default" {
2
2
key_name = " ${ var . identity } -key"
3
- public_key = " ${ file ( " ${ var . public_key_path } " ) } "
3
+ public_key = " ${ var . public_key } "
4
4
}
5
5
6
6
resource "aws_security_group" "default" {
@@ -50,7 +50,7 @@ resource "aws_instance" "web" {
50
50
51
51
connection {
52
52
user = " ubuntu"
53
- private_key = " ${ file ( " ${ var . private_key_path } " ) } "
53
+ private_key = " ${ var . private_key } "
54
54
}
55
55
56
56
provisioner "file" {
Original file line number Diff line number Diff line change 1
-
2
1
output "public_ip" {
3
2
value = [" ${ aws_instance . web . * . public_ip } " ]
4
3
}
Original file line number Diff line number Diff line change 1
-
2
1
variable "ami" {
3
2
description = " Base machine image for running this server"
4
3
}
@@ -16,11 +15,10 @@ variable "ingress_cidr" {
16
15
description = " IP address block from which connections to this instance will be made"
17
16
}
18
17
19
- variable "public_key_path " {
20
- description = " Path on disk to the public key used to connect to this instance"
18
+ variable "public_key " {
19
+ description = " Contents of the public key used to connect to this instance"
21
20
}
22
21
23
- variable "private_key_path " {
24
- description = " Path on disk to the private key used to connect to this instance"
22
+ variable "private_key " {
23
+ description = " Contents of the private key used to connect to this instance"
25
24
}
26
-
Original file line number Diff line number Diff line change 1
- access_key=""
2
- secret_key=""
3
1
identity="demo-wallaby"
4
- region="us-west-2"
5
2
ingress_cidr="0.0.0.0/0"
3
+ public_key="AAAA"
4
+ private_key="AAAA"
Original file line number Diff line number Diff line change 1
1
2
- variable "access_key" {
3
- description = " The AWS access key used to provision resources"
4
- }
5
-
6
- variable "secret_key" {
7
- description = " The AWS secret key used to provision resources"
8
- }
9
-
10
- variable "region" {
11
- description = " The AWS region in which to provision resources"
12
- default = " us-west-2"
13
- }
14
-
15
2
variable "identity" {
16
3
description = " A unique name for your resources"
17
4
}
@@ -26,14 +13,12 @@ variable "ingress_cidr" {
26
13
description = " IP block from which connections to this instance will be made"
27
14
}
28
15
29
- variable "public_key_path" {
30
- description = " Path on disk to the public key used to connect to this instance"
31
- default = " ~/.ssh/id_rsa.pub"
16
+ variable "public_key" {
17
+ description = " Contents of the public key used to connect to this instance"
32
18
}
33
19
34
- variable "private_key_path" {
35
- description = " Path on disk to the private key used to connect to this instance"
36
- default = " ~/.ssh/id_rsa"
20
+ variable "private_key" {
21
+ description = " Contents of the private key used to connect to this instance"
37
22
}
38
23
39
24
variable "num_webs" {
You can’t perform that action at this time.
0 commit comments