Skip to content

Instantly share code, notes, and snippets.

@lawliet89
Created September 3, 2018 04:42
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 lawliet89/6293525a06cc85e48372b1cb10f0186d to your computer and use it in GitHub Desktop.
Save lawliet89/6293525a06cc85e48372b1cb10f0186d to your computer and use it in GitHub Desktop.
Terraform Demo Snippet
resource "aws_security_group" "client" {
name_prefix = "${var.client_asg_name}"
description = "Security Group for ${var.client_asg_name}"
vpc_id = "${var.vpc_id}"
tags = "${merge(var.tags, map("Name", "${var.client_asg_name}"))}"
# aws_launch_configuration.launch_configuration in this module sets create_before_destroy to true, which means
# everything it depends on, including this resource, must set it as well, or you'll get cyclic dependency errors
# when you try to do a terraform destroy.
lifecycle {
create_before_destroy = true
}
}
resource "aws_security_group_rule" "client_ssh_inbound" {
type = "ingress"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["${var.ssh_cidr}"]
security_group_id = "${aws_security_group.client.id}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment