Last active
October 6, 2020 15:43
-
-
Save kluu1/e30b577bdb8cb5846f5f2552860b4b74 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| provider "aws" { | |
| profile = "default" | |
| region = "us-east-1" | |
| } | |
| variable "ingressrules" { | |
| type = list(number) | |
| default = [80, 443, 22] | |
| } | |
| resource "aws_security_group" "web_traffic" { | |
| name = "Allow web traffic" | |
| description = "Allow ssh and standard http/https ports inbound and everything outbound" | |
| dynamic "ingress" { | |
| iterator = port | |
| for_each = var.ingressrules | |
| content { | |
| from_port = port.value | |
| to_port = port.value | |
| protocol = "TCP" | |
| cidr_blocks = ["0.0.0.0/0"] | |
| } | |
| } | |
| egress { | |
| from_port = 0 | |
| to_port = 0 | |
| protocol = "-1" | |
| cidr_blocks = ["0.0.0.0/0"] | |
| } | |
| tags = { | |
| "Terraform" = "true" | |
| } | |
| } | |
| data "aws_ami" "ubuntu" { | |
| ... | |
| } | |
| resource "aws_instance" "jenkins" { | |
| ami = data.aws_ami.ubuntu.id | |
| instance_type = "t2.micro" | |
| security_groups = [aws_security_group.web_traffic.name] | |
| key_name = "kluu" | |
| tags = { | |
| "Name" = "Jenkins_Server" | |
| "Terraform" = "true" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment