· 8 years ago · Aug 24, 2017, 01:22 PM
1provider "aws" {
2 access_key = "${var.aws_access_key}"
3 secret_key = "${var.aws_secret}"
4 region = "${var.region}"
5}
6
7resource "aws_key_pair" "auth" {
8 key_name = "${var.key_name}"
9 public_key = "${file(var.public_key_path)}"
10}
11
12resource "aws_instance" "pivot_gocd_agent" {
13 ami = "ami-cb4b94dd"
14 instance_type = "t2.medium"
15
16 # The name of our SSH keypair we created above.
17 key_name = "${aws_key_pair.auth.id}"
18
19 connection {
20 # The default username for our AMI
21 user = "root"
22
23 # The connection will use the local SSH agent for authentication.
24 }
25
26 provisioner "remote-exec" {
27 scripts = [
28 "./bin/provision.sh",
29 "./bin/start.sh"
30 ]
31 }
32
33}
34
35###
36# the above yelds a ssh timeout
37# aws_instance.pivot_gocd_agent (remote-exec): Connecting to remote host via SSH...
38# aws_instance.pivot_gocd_agent (remote-exec): Host: 54.159.165.163
39# aws_instance.pivot_gocd_agent (remote-exec): User: root
40# aws_instance.pivot_gocd_agent (remote-exec): Password: false
41# aws_instance.pivot_gocd_agent (remote-exec): Private key: false
42# aws_instance.pivot_gocd_agent (remote-exec): SSH Agent: true
43# aws_instance.pivot_gocd_agent: Still creating... (5m10s elapsed)