diff --git a/ec2-bastion.tf b/ec2-bastion.tf index 76ffbd5..18a3db6 100644 --- a/ec2-bastion.tf +++ b/ec2-bastion.tf @@ -4,8 +4,8 @@ resource "aws_instance" "bastion" { count = var.operator_mode ? 1 : 0 - ami = var.use_lastest_ami ? data.aws_ssm_parameter.latest_ami.value : "ami-0323c3dd2da7fb37d" - instance_type = "t2.micro" + ami = var.use_latest_ami ? data.aws_ssm_parameter.latest_ami.value : var.ami_id + instance_type = var.bastion_instance_type key_name = var.ec2_key_pair_name vpc_security_group_ids = [aws_security_group.bastion.id] subnet_id = aws_subnet.public[0].id diff --git a/ec2-data.tf b/ec2-data.tf index 55e4d97..df6b650 100644 --- a/ec2-data.tf +++ b/ec2-data.tf @@ -1,5 +1,5 @@ # EC2 Data data "aws_ssm_parameter" "latest_ami" { - name = "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2" + name = "/aws/service/debian/release/12/latest/amd64" } \ No newline at end of file diff --git a/ec2-launch-template.tf b/ec2-launch-template.tf index 53329fc..9b5bf48 100644 --- a/ec2-launch-template.tf +++ b/ec2-launch-template.tf @@ -1,7 +1,7 @@ # EC2 Launch Template resource "aws_launch_template" "vault_instance" { name_prefix = "${var.main_project_tag}-lt-" - image_id = var.use_lastest_ami ? data.aws_ssm_parameter.latest_ami.value : "ami-0323c3dd2da7fb37d" + image_id = var.use_latest_ami ? data.aws_ssm_parameter.latest_ami.value : var.ami_id instance_type = var.vault_instance_type key_name = var.ec2_key_pair_name vpc_security_group_ids = [aws_security_group.vault_instance.id] diff --git a/providers.tf b/providers.tf index 52fa9e7..8877fe4 100644 --- a/providers.tf +++ b/providers.tf @@ -1,4 +1,20 @@ -provider "aws" { - region = var.aws_default_region - profile = var.aws_profile +terraform { + required_version = ">= 1.0" + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.38.0" + } + random = { + source = "hashicorp/random" + version = "~> 3.5" + } + } } +provider "aws" { + region = var.aws_default_region + profile = var.aws_profile +} + +provider "random" { +} \ No newline at end of file diff --git a/terraform.tfvars.example b/terraform.tfvars.example index 0b4eff4..5aa4249 100644 --- a/terraform.tfvars.example +++ b/terraform.tfvars.example @@ -8,6 +8,9 @@ ec2_key_pair_name = "vault_key_pair" ### OPTIONAL VARIABLES +# Use latest ami id +# use_latest_ami = false + # Version # vault_version = "1.15.5" diff --git a/variables.tf b/variables.tf index da9ad34..0683f66 100644 --- a/variables.tf +++ b/variables.tf @@ -46,6 +46,12 @@ variable "vault_version" { default = "1.15.5" } +variable "bastion_instance_type" { + description = "The EC2 instance size of the bastion server." + type = string + default = "t3.micro" +} + # Operator Mode ## Turning this on will enable NAT and Bastion to access the Vault Instances @@ -152,12 +158,18 @@ variable "vault_instance_count" { # EC2 - AMI -variable "use_lastest_ami" { - description = "Whether or not to use the latest version of Amazon Linux 2. Defaults to false and uses a version that is known to work with this deployment." +variable "use_latest_ami" { + description = "Whether or not to use the latest version. Defaults to false and uses a version that is known to work with this deployment." type = bool default = false } +variable "ami_id" { + description = "The AMI ID to use for the Vault instances. Defaults to Debian 12 x86_64." + type = string + default = "ami-0506d6d51f1916a96" +} + # DynamoDB variable "dynamodb_table_name" {