Terraform: Update logger to use AWS data source for AMI resolution
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
locals {
|
locals {
|
||||||
fleet_url = "https://${aws_instance.logger.public_ip}:8412"
|
fleet_url = "https://${aws_instance.logger.public_ip}:8412"
|
||||||
splunk_url = "https://${aws_instance.logger.public_ip}:8000"
|
splunk_url = "https://${aws_instance.logger.public_ip}:8000"
|
||||||
|
ata_url = "https://${aws_instance.wef.public_ip}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ resource "aws_key_pair" "auth" {
|
|||||||
|
|
||||||
resource "aws_instance" "logger" {
|
resource "aws_instance" "logger" {
|
||||||
instance_type = "t2.medium"
|
instance_type = "t2.medium"
|
||||||
ami = "ami-0ad16744583f21877"
|
ami = "${coalesce(data.aws_ami.logger_ami.image_id, var.logger_ami)}"
|
||||||
|
|
||||||
tags {
|
tags {
|
||||||
Name = "logger"
|
Name = "logger"
|
||||||
@@ -187,8 +187,8 @@ resource "aws_instance" "logger" {
|
|||||||
resource "aws_instance" "dc" {
|
resource "aws_instance" "dc" {
|
||||||
instance_type = "t2.medium"
|
instance_type = "t2.medium"
|
||||||
|
|
||||||
# Change the below variable to "${var.dc_ami}" if using hardcoded AMIs
|
# Uses the local variable if external data source resolution fails
|
||||||
ami = "${data.aws_ami.dc_ami.image_id}"
|
ami = "${coalesce(data.aws_ami.dc_ami.image_id, var.dc_ami)}"
|
||||||
|
|
||||||
tags {
|
tags {
|
||||||
Name = "dc.windomain.local"
|
Name = "dc.windomain.local"
|
||||||
@@ -206,8 +206,8 @@ resource "aws_instance" "dc" {
|
|||||||
resource "aws_instance" "wef" {
|
resource "aws_instance" "wef" {
|
||||||
instance_type = "t2.medium"
|
instance_type = "t2.medium"
|
||||||
|
|
||||||
# Change the below variable to "${var.wef_ami}" if using hardcoded AMIs
|
# Uses the local variable if external data source resolution fails
|
||||||
ami = "${data.aws_ami.wef_ami.image_id}"
|
ami = "${coalesce(data.aws_ami.wef_ami.image_id, var.wef_ami)}"
|
||||||
|
|
||||||
tags {
|
tags {
|
||||||
Name = "wef.windomain.local"
|
Name = "wef.windomain.local"
|
||||||
@@ -225,8 +225,8 @@ resource "aws_instance" "wef" {
|
|||||||
resource "aws_instance" "win10" {
|
resource "aws_instance" "win10" {
|
||||||
instance_type = "t2.medium"
|
instance_type = "t2.medium"
|
||||||
|
|
||||||
# Change the below variable to "${var.win10_ami}" if using hardcoded AMIs
|
# Uses the local variable if external data source resolution fails
|
||||||
ami = "${data.aws_ami.win10_ami.image_id}"
|
ami = "${coalesce(data.aws_ami.win10_ami.image_id, var.win10_ami)}"
|
||||||
|
|
||||||
tags {
|
tags {
|
||||||
Name = "win10.windomain.local"
|
Name = "win10.windomain.local"
|
||||||
|
|||||||
@@ -18,16 +18,8 @@ output "win10_public_ip" {
|
|||||||
value = "${aws_instance.win10.public_ip}"
|
value = "${aws_instance.win10.public_ip}"
|
||||||
}
|
}
|
||||||
|
|
||||||
output "latest_dc_ami_id" {
|
output "ata_url" {
|
||||||
value = "${data.aws_ami.dc_ami.image_id}"
|
value = "${local.ata_url}"
|
||||||
}
|
|
||||||
|
|
||||||
output "latest_wef_ami_id" {
|
|
||||||
value = "${data.aws_ami.wef_ami.image_id}"
|
|
||||||
}
|
|
||||||
|
|
||||||
output "latest_win10_ami_id" {
|
|
||||||
value = "${data.aws_ami.wef_ami.image_id}"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
output "fleet_url" {
|
output "fleet_url" {
|
||||||
|
|||||||
@@ -46,6 +46,16 @@ variable "external_dns_servers" {
|
|||||||
default = ["8.8.8.8"]
|
default = ["8.8.8.8"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Use Data Sources to resolve the AMI-ID for the Ubuntu 16.04 AMI
|
||||||
|
data "aws_ami" "logger_ami" {
|
||||||
|
owners = ["099720109477"]
|
||||||
|
|
||||||
|
filter {
|
||||||
|
name = "name"
|
||||||
|
values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-20180912"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# Use Data Sources to resolve the AMI-ID for the pre-built DC host
|
# Use Data Sources to resolve the AMI-ID for the pre-built DC host
|
||||||
data "aws_ami" "dc_ami" {
|
data "aws_ami" "dc_ami" {
|
||||||
owners = ["505638924199"]
|
owners = ["505638924199"]
|
||||||
@@ -78,9 +88,15 @@ data "aws_ami" "win10_ami" {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# The logger host uses the Amazon Ubuntu 16.04 image
|
|
||||||
# If you are building your own AMIs, replace the default values below with
|
# If you are building your own AMIs, replace the default values below with
|
||||||
# the AMI IDs
|
# the AMI IDs
|
||||||
|
# The default values for us-west-1 have been provied for you
|
||||||
|
# You will have to change the default values if you use a different region
|
||||||
|
variable "logger_ami" {
|
||||||
|
type = "string"
|
||||||
|
default = "ami-0ad16744583f21877"
|
||||||
|
}
|
||||||
|
|
||||||
variable "dc_ami" {
|
variable "dc_ami" {
|
||||||
type = "string"
|
type = "string"
|
||||||
default = "ami-03e2df055c632a0dd"
|
default = "ami-03e2df055c632a0dd"
|
||||||
|
|||||||
Reference in New Issue
Block a user