Skip to content

Commit

Permalink
Merge pull request #3 from hazelops/feature/set-permanent-ami
Browse files Browse the repository at this point in the history
Set up permanent ami id to "ami-022d4249382309a48" (CORE-228)
  • Loading branch information
kobrikx authored Nov 30, 2021
2 parents 7bd2674 + a2c2c75 commit 9c0f7e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 3 additions & 1 deletion data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ data "aws_ami" "ubuntu_20_04" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"]
# Ubuntu 20.04 LTS amd64 image in us-east-1. If upgrade is needed, you would need to re-connect to openvpn.
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-20211118"]

}
filter {
name = "virtualization-type"
Expand Down
17 changes: 8 additions & 9 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,30 @@ resource "aws_security_group" "this" {
Env = var.env
Name = local.name
}

lifecycle {
create_before_destroy = true
}
}

# EC2
resource "aws_instance" "this" {
ami = join("", data.aws_ami.ubuntu_20_04.*.id)
instance_type = var.instance_type
iam_instance_profile = aws_iam_instance_profile.this.name
subnet_id = var.private_subnets[0]
key_name = var.ec2_key_pair_name
ami = join("", data.aws_ami.ubuntu_20_04.*.id)
instance_type = var.instance_type
iam_instance_profile = aws_iam_instance_profile.this.name
subnet_id = var.private_subnets[0]
key_name = var.ec2_key_pair_name
vpc_security_group_ids = concat(var.ext_security_groups, [
aws_security_group.this.id
])

disable_api_termination = var.vpn_enabled ? true : false

associate_public_ip_address = false

lifecycle {
ignore_changes = all
}

user_data = var.vpn_enabled ? data.template_file.ec2_user_data.rendered : null
user_data = var.vpn_enabled ? data.template_file.ec2_user_data.rendered : null

tags = {
Terraform = "true"
Expand Down

0 comments on commit 9c0f7e6

Please sign in to comment.