Skip to content

Commit

Permalink
auto retrieve ubuntu ami id in the fifth example
Browse files Browse the repository at this point in the history
  • Loading branch information
diodonfrost committed Dec 25, 2019
1 parent 5afc24e commit 37aed78
Show file tree
Hide file tree
Showing 6 changed files with 885 additions and 10 deletions.
8 changes: 0 additions & 8 deletions 05-autoscaling-group/00-params.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
# parms file for aws ec2 cloud

#### AMI

# Set ec2 image AMI
variable "ami" {
# Canonical, Ubuntu, 16.04 LTS, amd64 xenial image build on 2018-01-09
default = "ami-79873901"
}

#### VPC Network
variable "vpc_cidr" {
default = "192.168.0.0/16"
Expand Down
15 changes: 15 additions & 0 deletions 05-autoscaling-group/015-ami.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
data "aws_ami" "ubuntu" {
most_recent = true

filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"]
}

filter {
name = "virtualization-type"
values = ["hvm"]
}

owners = ["099720109477"] # Canonical
}
2 changes: 1 addition & 1 deletion 05-autoscaling-group/060-instance-http.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ resource "aws_autoscaling_group" "http" {
# Configure instance launching configuration
resource "aws_launch_configuration" "http" {
name_prefix = "http"
image_id = var.ami
image_id = data.aws_ami.ubuntu.id
instance_type = "t2.micro"
key_name = aws_key_pair.user_key.key_name
security_groups = [
Expand Down
2 changes: 1 addition & 1 deletion 05-autoscaling-group/061-instance-db.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ resource "aws_autoscaling_group" "db" {
# Configure instance launching configuration
resource "aws_launch_configuration" "db" {
name_prefix = "db"
image_id = var.ami
image_id = data.aws_ami.ubuntu.id
instance_type = "t2.micro"
key_name = aws_key_pair.user_key.key_name
security_groups = [
Expand Down
8 changes: 8 additions & 0 deletions 05-autoscaling-group/terraform.tfstate
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"version": 4,
"terraform_version": "0.12.8",
"serial": 37,
"lineage": "8777eace-00a6-ea17-9678-67d930b586cd",
"outputs": {},
"resources": []
}
Loading

0 comments on commit 37aed78

Please sign in to comment.