Skip to content

Instantly share code, notes, and snippets.

@Gunisalvo
Created June 7, 2018 15:17
Show Gist options
  • Select an option

  • Save Gunisalvo/8806ab0d8c34e709af551946aa79d224 to your computer and use it in GitHub Desktop.

Select an option

Save Gunisalvo/8806ab0d8c34e709af551946aa79d224 to your computer and use it in GitHub Desktop.

Revisions

  1. Gunisalvo created this gist Jun 7, 2018.
    46 changes: 46 additions & 0 deletions week_02.tf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    provider "aws" {
    region = "us-east-2"
    }


    resource "aws_security_group" "uol_security" {
    name = "CKIT523-Group-[REPLACE WITH YOUR NAME]" #fixme!
    description = "Uol Security"

    ingress {
    from_port = 22
    to_port = 22
    protocol = "TCP"
    cidr_blocks = ["0.0.0.0/0"]
    }

    }


    data "aws_ami" "ubuntu" {
    most_recent = true

    filter {
    name = "name"
    values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"]
    }

    filter {
    name = "virtualization-type"
    values = ["hvm"]
    }

    owners = ["099720109477"] # Canonical
    }

    resource "aws_instance" "uol_ec2" {
    ami = "${data.aws_ami.ubuntu.id}"
    instance_type = "t2.medium" # As described on the assignment
    key_name = "CKIT523Key-[REPLACE WITH YOUR NAME]" #fixme!
    security_groups = [
    "${aws_security_group.uol_security.name}"
    ]
    tags {
    Name = "CKIT523-[REPLACE WITH YOUR NAME]" #fixme!
    }
    }