Skip to content

Commit

Permalink
Refactor AMI configuration in morpheus.tf and add base_images.tf and …
Browse files Browse the repository at this point in the history
…variables.tf

This commit refactors the AMI configuration in morpheus.tf by introducing a local variable for the AMI ID and updating the module configuration accordingly. Additionally, it adds the base_images.tf file, which contains a data source for the AWS SSM parameter "rhel9_ami". Finally, it includes the variables.tf file, which defines the "use_rhel9_ami" variable to control whether to use the RHEL 9 AMI.
  • Loading branch information
arnol377 committed Dec 17, 2024
1 parent 49b9ce7 commit 4dfe89e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions base_images.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data aws_ssm_parameter "rhel9_ami" {
count = var.use_rhel9_ami ? 1 : 0
name = "/enterprise/ami/rhel9"
}
7 changes: 4 additions & 3 deletions morpheus.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
data aws_ssm_parameter "rhel9_ami" {
name = "/enterprise/ami/rhel9"
locals {
morpheus_ami = "ami-04a32122e0bdbb20f"
}

module "morpheus" {
Expand All @@ -23,6 +23,7 @@ module "morpheus" {
name = aws_s3_bucket.assets_bucket.bucket
key = "linux-image-pipeline.zip"
}
packer_config = "morpheus-build.pkr.hcl"
ansible_source_type = "S3"
ansible_bucket = {
name = aws_s3_bucket.assets_bucket.bucket
Expand All @@ -38,7 +39,7 @@ module "morpheus" {
state = local.state_config
vpc_config = local.vpc_config
ami = {
source_ami = data.aws_ssm_parameter.rhel9_ami.value
source_ami = var.use_rhel9_ami ? one(data.aws_ssm_parameter.rhel9_ami).value : local.morpheus_ami
instance_type = "t3.micro" # x86_64 compatible instance type
}
}
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable use_rhel9_ami {
description = "Use RHEL 9 AMI"
type = bool
default = false
}

0 comments on commit 4dfe89e

Please sign in to comment.