Always use the latest AMI image
This commit is contained in:
parent
ac9371a2ed
commit
a5d0e6eba2
|
@ -1,12 +1,12 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"region": "eu-west-1",
|
"region": "eu-west-1",
|
||||||
"ami": "ami-861125ff",
|
"android_version": "6.0",
|
||||||
"instance": "t2.small"
|
"instance": "t2.small"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"region": "eu-west-1",
|
"region": "eu-west-1",
|
||||||
"ami": "ami-861125ff",
|
"android_version": "8.0",
|
||||||
"instance": "t2.small"
|
"instance": "t2.small"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
|
@ -45,12 +45,12 @@ function prepare_geny_aws() {
|
||||||
}
|
}
|
||||||
|
|
||||||
region=$(get_value '.region')
|
region=$(get_value '.region')
|
||||||
ami=$(get_value '.ami')
|
android_version=$(get_value '.android_version')
|
||||||
instance=$(get_value '.instance')
|
instance=$(get_value '.instance')
|
||||||
|
|
||||||
|
|
||||||
echo $region
|
echo $region
|
||||||
echo $ami
|
echo $android_version
|
||||||
echo $instance
|
echo $instance
|
||||||
|
|
||||||
aws_tf_content=$(cat <<_EOF
|
aws_tf_content=$(cat <<_EOF
|
||||||
|
@ -59,9 +59,9 @@ variable "aws_region_$index" {
|
||||||
default = "$region"
|
default = "$region"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "ami_id_$index" {
|
variable "android_version_$index" {
|
||||||
type = "string"
|
type = "string"
|
||||||
default = "$ami"
|
default = "$android_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "instance_type_$index" {
|
variable "instance_type_$index" {
|
||||||
|
@ -79,26 +79,44 @@ resource "aws_security_group" "geny_sg_$index" {
|
||||||
name = "geny_sg_$index"
|
name = "geny_sg_$index"
|
||||||
description = "Security group for EC2 instance of Genymotion"
|
description = "Security group for EC2 instance of Genymotion"
|
||||||
ingress {
|
ingress {
|
||||||
from_port = 0
|
from_port = 0
|
||||||
to_port = 65535
|
to_port = 65535
|
||||||
protocol = "tcp"
|
protocol = "tcp"
|
||||||
cidr_blocks = ["0.0.0.0/0"]
|
cidr_blocks = ["0.0.0.0/0"]
|
||||||
}
|
}
|
||||||
|
egress {
|
||||||
|
from_port = 0
|
||||||
|
to_port = 65535
|
||||||
|
protocol = "udp"
|
||||||
|
cidr_blocks = ["0.0.0.0/0"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
data "aws_ami" "geny_aws_$index" {
|
||||||
|
provider = "aws.provider_$index"
|
||||||
|
most_recent = true
|
||||||
|
|
||||||
|
filter {
|
||||||
|
name = "name"
|
||||||
|
values = ["genymotion-ami-\${var.android_version_$index}-*"]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "aws_instance" "geny_aws_$index" {
|
resource "aws_instance" "geny_aws_$index" {
|
||||||
provider = "aws.provider_$index"
|
provider = "aws.provider_$index"
|
||||||
ami = "\${var.ami_id_$index}"
|
ami = "\${data.aws_ami.geny_aws_$index.id}"
|
||||||
instance_type = "\${var.instance_type_$index}"
|
instance_type = "\${var.instance_type_$index}"
|
||||||
|
|
||||||
vpc_security_group_ids = ["\${aws_security_group.geny_sg_$index.name}"]
|
vpc_security_group_ids = ["\${aws_security_group.geny_sg_$index.name}"]
|
||||||
|
|
||||||
tags {
|
tags {
|
||||||
Name = "EK-\${var.ami_id_$index}"
|
Name = "EK-\${data.aws_ami.geny_aws_$index.id}"
|
||||||
}
|
}
|
||||||
count = 1
|
count = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
output "image_id_$index" {
|
||||||
|
value = "\${data.aws_ami.geny_aws_$index.id}"
|
||||||
|
}
|
||||||
|
|
||||||
output "instance_id_$index" {
|
output "instance_id_$index" {
|
||||||
value = "\${aws_instance.geny_aws_$index.*.id}"
|
value = "\${aws_instance.geny_aws_$index.*.id}"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue