Skip to content

Commit

Permalink
removed searching for the AMI in favor of data source
Browse files Browse the repository at this point in the history
  • Loading branch information
zachreborn committed Jul 22, 2024
1 parent d1a475f commit 08015b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
12 changes: 11 additions & 1 deletion modules/aws/vendor/velocloud/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ terraform {
# data "aws_caller_identity" "current" {}
data "aws_region" "current" {}

data "aws_ami" "velocloud" {
executable_users = ["self"]
most_recent = true
owners = ["679593333241"]
filter {
name = "name"
values = ["VeloCloud VCE ${var.velocloud_version}*"]
}
}

############################################
# Security Groups
############################################
Expand Down Expand Up @@ -151,7 +161,7 @@ resource "aws_network_interface" "private_nic" {
############################################

resource "aws_instance" "ec2_instance" {
ami = var.ami
ami = data.aws_ami.velocloud.id
count = var.number
ebs_optimized = var.ebs_optimized
iam_instance_profile = var.iam_instance_profile
Expand Down
15 changes: 10 additions & 5 deletions modules/aws/vendor/velocloud/variables.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
############################################
# Data Sources
############################################

variable "velocloud_version" {
description = "(Optional) The version ID of the VeloCloud VCE AMI to use. Defaults to the latest version. Use semantic versioning to specify a version. Example: 4.5"
default = "4.5"
type = string
}

############################################
# Security Groups
############################################
Expand Down Expand Up @@ -114,11 +124,6 @@ variable "monitoring" {
type = bool
}

variable "ami" {
description = "(Required) AMI to use for the instance. Required unless launch_template is specified and the Launch Template specifes an AMI. If an AMI is specified in the Launch Template, setting ami will override the AMI specified in the Launch Template."
type = string
}

variable "instance_type" {
description = "(Optional) Instance type to use for the instance. Updates to this field will trigger a stop/start of the EC2 instance."
default = "c5.xlarge"
Expand Down

0 comments on commit 08015b9

Please sign in to comment.