This is full source code to the article Terraform recipe โ Managing Auto Scaling Groups and Load Balancers
Execute the following commands:
terraform init
terraform plan
terraform apply
This is full source code to the article Terraform recipe โ Managing Auto Scaling Groups and Load Balancers
Execute the following commands:
terraform init
terraform plan
terraform apply
Could you show how to thanks
Hi why there is no aws_instance? is it because this is managed by the aws_autoscaling_group?
variable "ami" {
description = "The AMI ID"
default = "ami-87848ee3"
}
variable "public_ip" {
description = "Public IP"
// default = "52.62.107.101"
default = ""
}
data "external" "whatismyip" {
program = [
"${path.module}/whatismyip.sh"]
}
resource "aws_security_group" "aws1" {
name = "Default Security Group"
description = "Allows all traffic"
ingress {
from_port = 15672
protocol = "tcp"
to_port = 15672
cidr_blocks = [
"${data.external.whatismyip.result["internet_ip"]}/32"]
}
ingress {
from_port = 8883
protocol = "tcp"
to_port = 8883
cidr_blocks = [
"${data.external.whatismyip.result["internet_ip"]}/32"]
}
ingress {
from_port = 5672
protocol = "tcp"
to_port = 5672
cidr_blocks = [
"${data.external.whatismyip.result["internet_ip"]}/32"]
}
ingress {
from_port = "${var.ssh_port}"
to_port = "${var.ssh_port}"
protocol = "tcp"
cidr_blocks = [
"${data.external.whatismyip.result["internet_ip"]}/32"]
}
ingress {
from_port = "${var.icmp_port}"
protocol = "icmp"
to_port = 0
cidr_blocks = [
"${data.external.whatismyip.result["internet_ip"]}/32"]
}
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [
"0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [
"0.0.0.0/0"]
}
}
resource "aws_key_pair" "auth" {
key_name = "tls_public_key"
public_key = "${file("~/.ssh/debian9KeyPair.pub")}"
}
resource "aws_instance" "launch_instance" {
ami = "${lookup(var.aws_amis, var.aws_region)}"
instance_type = "t2.micro"
key_name = "${aws_key_pair.auth.id}"
vpc_security_group_ids = ["${aws_security_group.aws1.id}"]
// public_ip = "${var.public_ip}"
# This EC2 Instance has a public IP and will be accessible directly from the public Internet
associate_public_ip_address = true
tags {
Name = "${var.instance_name}-public"
}
}
ssh admin@variable "ami" {
description = "The AMI ID"
default = "ami-87848ee3"
}
variable "public_ip" {
description = "Public IP"
// default = "52.62.107.101"
default = ""
}
data "external" "whatismyip" {
program = [
"${path.module}/whatismyip.sh"]
}
resource "aws_security_group" "aws1" {
name = "Default Security Group"
description = "Allows all traffic"
ingress {
from_port = 15672
protocol = "tcp"
to_port = 15672
cidr_blocks = [
"${data.external.whatismyip.result["internet_ip"]}/32"]
}
ingress {
from_port = 8883
protocol = "tcp"
to_port = 8883
cidr_blocks = [
"${data.external.whatismyip.result["internet_ip"]}/32"]
}
ingress {
from_port = 5672
protocol = "tcp"
to_port = 5672
cidr_blocks = [
"${data.external.whatismyip.result["internet_ip"]}/32"]
}
ingress {
from_port = "${var.ssh_port}"
to_port = "${var.ssh_port}"
protocol = "tcp"
cidr_blocks = [
"${data.external.whatismyip.result["internet_ip"]}/32"]
}
ingress {
from_port = "${var.icmp_port}"
protocol = "icmp"
to_port = 0
cidr_blocks = [
"${data.external.whatismyip.result["internet_ip"]}/32"]
}
ingress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [
"0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = [
"0.0.0.0/0"]
}
}
resource "aws_key_pair" "auth" {
key_name = "tls_public_key"
public_key = "${file("~/.ssh/debian9KeyPair.pub")}"
}
resource "aws_instance" "launch_instance" {
ami = "${lookup(var.aws_amis, var.aws_region)}"
instance_type = "t2.micro"
key_name = "${aws_key_pair.auth.id}"
vpc_security_group_ids = ["${aws_security_group.aws1.id}"]
// public_ip = "${var.public_ip}"
# This EC2 Instance has a public IP and will be accessible directly from the public Internet
associate_public_ip_address = true
tags {
Name = "${var.instance_name}-public"
}
}
Then ssh into EC2 debian:
$ netstat -tunlp
(No info could be read for "-p": geteuid()=1000 but you should be root.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
Don't see the ports 5672, 8883, 15672?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.