cleanup directory strucutre and fine tune

This commit is contained in:
Joe Tretter
2022-09-30 10:55:07 -05:00
parent dae7fbc9e7
commit 9b25fa2eda
19 changed files with 69 additions and 27 deletions

64
terraform/appServer.tf Normal file
View File

@@ -0,0 +1,64 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}
required_version = ">= 1.2.0"
}
provider "aws" {
region = "us-west-2"
}
resource "aws_instance" "app_server" {
ami = var.ami_id
instance_type = "t2.micro"
key_name = var.ami_key_pair_name
security_groups = ["${aws_security_group.ingress-all-test.id}"]
# this is probably the only way to get the remote-execution (below) working. The elastic IP is not avaialable at this time
associate_public_ip_address = true
tags = {
"Name" = var.ami_name
}
subnet_id = "${aws_subnet.subnet-uno.id}"
connection {
type="ssh"
user="ubuntu"
host = self.public_ip
# we are assuming the ppk key is loaded into pageant...
agent = true
}
# Upload the set up script
provisioner "file" {
source = "setupAppServer.sh"
destination = "/tmp/setupAppServer.sh"
}
# Uplaod docker image
provisioner "file" {
source = "../docker/dumbserver.image.tar"
destination = "/tmp/dumbserver.image.tar"
}
# Upload example data file
provisioner "file" {
source = "../app/dataDir/data"
destination = "/tmp/data"
}
provisioner "remote-exec" {
inline = [
"chmod +x /tmp/setupAppServer.sh",
"sudo /tmp/setupAppServer.sh"
]
}
}