Skip to content

Instantly share code, notes, and snippets.

@wsargent
Created December 12, 2019 18:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wsargent/80055a3ae534203cd8f009ce9dfc55f2 to your computer and use it in GitHub Desktop.
Save wsargent/80055a3ae534203cd8f009ce9dfc55f2 to your computer and use it in GitHub Desktop.
module "aws_security_group" {
source = "terraform-aws-modules/security-group/aws"
version = "~> 3.0"
name = "bastion"
description = "Security group for bastion"
vpc_id = module.vpc.vpc_id
ingress_cidr_blocks = ["0.0.0.0/0"]
ingress_rules = ["ssh-tcp", "all-icmp"]
egress_rules = ["all-all"]
}
variable "public_key" {
default = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC87IclWXNLsicaYojXA2FXgVMjaZcZfXh8yf9ITFIaN313f7ZqJjNVyajf83qvg2YLZOGYOM6ETntuY9RBRAcLjE0nI+n+34AN1lka3grCtG3JPq//ALMj6lrc+Rnmakx6WwamAH48URP/HiXCRzaiQ2S6N7HmMc2Ak0e1L7HW0Y+qw41KXfw08lr/nyU+KxoUQ35TKGV+8FaUXQRRUQ++/ZcptvTH1dzjNqZHC5WvQfAXCeHCvdET9WZ+5YhvZLnL4ce0F8KSDSeq6EhRDbyHHiQAaIvXqT7VtyCQqIoitP84/253jmFr02oU37cqj/teQzw5GiT79lQ82p0vsA6fylKBiy0tzhSPjUYo6HVb4eI6jj+Qah/LXAtAQEkHHllQqr9bfxYJZwp+O0PULuA+x6fTJoz/h8sCDQicaUog8uXwtwNMypD++DUXV8k4ma05C/KxBMVLS6MEaocQLYfZOC/HBQiZSxqG7KmeOnde/v+sr7YiSN5l7R9+s42pAjMsUAzYvX55HGyIh8vXt6X4at+RFG+zzd2wpA58Oc7J0/71O+wwozc4D3MB8sUVgiFWtlor8ghVSFMzmCim/R1FhhjJ+cnwC+RC8FFqr0Lu7SDex6LMu8AxgtmW0QH2zwKvUqtE2hwio6kJn4bOsEggFdzJvCsExyLlFmABXJbx6Q== cardno:000604159224"
}
module "key_pair" {
source = "terraform-aws-modules/key-pair/aws"
key_name = "bastion_key"
public_key = var.public_key
}
module "bastion" {
source = "terraform-aws-modules/ec2-instance/aws"
instance_count = 1
name = "bastion"
ami = data.aws_ami.amazon_linux.id
subnet_id = tolist(data.aws_subnet_ids.all.ids)[0]
key_name = "bastion_key"
instance_type = "t2.nano"
vpc_security_group_ids = [module.aws_security_group.this_security_group_id]
associate_public_ip_address = true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment