Terraform: Update logger to use AWS data source for AMI resolution
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
locals {
|
||||
fleet_url = "https://${aws_instance.logger.public_ip}:8412"
|
||||
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" {
|
||||
instance_type = "t2.medium"
|
||||
ami = "ami-0ad16744583f21877"
|
||||
ami = "${coalesce(data.aws_ami.logger_ami.image_id, var.logger_ami)}"
|
||||
|
||||
tags {
|
||||
Name = "logger"
|
||||
@@ -187,8 +187,8 @@ resource "aws_instance" "logger" {
|
||||
resource "aws_instance" "dc" {
|
||||
instance_type = "t2.medium"
|
||||
|
||||
# Change the below variable to "${var.dc_ami}" if using hardcoded AMIs
|
||||
ami = "${data.aws_ami.dc_ami.image_id}"
|
||||
# Uses the local variable if external data source resolution fails
|
||||
ami = "${coalesce(data.aws_ami.dc_ami.image_id, var.dc_ami)}"
|
||||
|
||||
tags {
|
||||
Name = "dc.windomain.local"
|
||||
@@ -206,8 +206,8 @@ resource "aws_instance" "dc" {
|
||||
resource "aws_instance" "wef" {
|
||||
instance_type = "t2.medium"
|
||||
|
||||
# Change the below variable to "${var.wef_ami}" if using hardcoded AMIs
|
||||
ami = "${data.aws_ami.wef_ami.image_id}"
|
||||
# Uses the local variable if external data source resolution fails
|
||||
ami = "${coalesce(data.aws_ami.wef_ami.image_id, var.wef_ami)}"
|
||||
|
||||
tags {
|
||||
Name = "wef.windomain.local"
|
||||
@@ -225,8 +225,8 @@ resource "aws_instance" "wef" {
|
||||
resource "aws_instance" "win10" {
|
||||
instance_type = "t2.medium"
|
||||
|
||||
# Change the below variable to "${var.win10_ami}" if using hardcoded AMIs
|
||||
ami = "${data.aws_ami.win10_ami.image_id}"
|
||||
# Uses the local variable if external data source resolution fails
|
||||
ami = "${coalesce(data.aws_ami.win10_ami.image_id, var.win10_ami)}"
|
||||
|
||||
tags {
|
||||
Name = "win10.windomain.local"
|
||||
|
||||
@@ -18,16 +18,8 @@ output "win10_public_ip" {
|
||||
value = "${aws_instance.win10.public_ip}"
|
||||
}
|
||||
|
||||
output "latest_dc_ami_id" {
|
||||
value = "${data.aws_ami.dc_ami.image_id}"
|
||||
}
|
||||
|
||||
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 "ata_url" {
|
||||
value = "${local.ata_url}"
|
||||
}
|
||||
|
||||
output "fleet_url" {
|
||||
|
||||
@@ -46,6 +46,16 @@ variable "external_dns_servers" {
|
||||
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
|
||||
data "aws_ami" "dc_ami" {
|
||||
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
|
||||
# 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" {
|
||||
type = "string"
|
||||
default = "ami-03e2df055c632a0dd"
|
||||
|
||||
Reference in New Issue
Block a user