Commit 9da17b1b authored by Anton Babenko's avatar Anton Babenko

Updated example and made security group required

parent 0bfc6f0e
...@@ -2,6 +2,22 @@ provider "aws" { ...@@ -2,6 +2,22 @@ provider "aws" {
region = "eu-west-1" region = "eu-west-1"
} }
##################################################################
# Data sources to get VPC, subnet, security group and AMI details
##################################################################
data "aws_vpc" "default" {
default = true
}
data "aws_subnet_ids" "all" {
vpc_id = "${data.aws_vpc.default.id}"
}
data "aws_security_group" "default" {
vpc_id = "${data.aws_vpc.default.id}"
name = "default"
}
data "aws_ami" "amazon_linux" { data "aws_ami" "amazon_linux" {
most_recent = true most_recent = true
...@@ -28,4 +44,6 @@ module "ec2" { ...@@ -28,4 +44,6 @@ module "ec2" {
name = "example" name = "example"
ami = "${data.aws_ami.amazon_linux.id}" ami = "${data.aws_ami.amazon_linux.id}"
instance_type = "t2.micro" instance_type = "t2.micro"
vpc_security_group_ids = ["${data.aws_security_group.default.id}"]
associate_public_ip_address = true
} }
...@@ -57,7 +57,7 @@ variable "monitoring" { ...@@ -57,7 +57,7 @@ variable "monitoring" {
variable "vpc_security_group_ids" { variable "vpc_security_group_ids" {
description = "A list of security group IDs to associate with" description = "A list of security group IDs to associate with"
default = [] type = "list"
} }
variable "subnet_id" { variable "subnet_id" {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment