Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dannybarrientos/1a59899e904aac2be7f5c1197bc38a87 to your computer and use it in GitHub Desktop.

Select an option

Save dannybarrientos/1a59899e904aac2be7f5c1197bc38a87 to your computer and use it in GitHub Desktop.

Revisions

  1. @jjruescas jjruescas revised this gist Jan 1, 2020. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion main.tf
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@ provider "aws" {
    }

    resource "aws_security_group" "instance" {
    name = "terraform-example-instance"
    name = "terraform-example-sg"

    ingress {
    from_port = 80
  2. @jjruescas jjruescas revised this gist Dec 31, 2019. No changes.
  3. @jjruescas jjruescas revised this gist Dec 31, 2019. No changes.
  4. @jjruescas jjruescas created this gist Dec 31, 2019.
    9 changes: 9 additions & 0 deletions install_choco_and_packages.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    #Install Chocolatey
    Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))

    #Install Packages
    choco install terraform -y
    choco install awscli -y

    #Refresh Environment Variables
    $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine")
    37 changes: 37 additions & 0 deletions main.tf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    provider "aws" {
    region = "us-west-2"
    }

    resource "aws_security_group" "instance" {
    name = "terraform-example-instance"

    ingress {
    from_port = 80
    to_port = 80
    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"]
    }
    }

    resource "aws_instance" "web" {
    ami = "ami-0c5204531f799e0c6"
    instance_type = "t2.micro"
    vpc_security_group_ids = [aws_security_group.instance.id]

    user_data = <<-EOF
    #!/bin/bash
    sudo amazon-linux-extras install nginx1.12 -y
    sudo service nginx start
    EOF

    tags = {
    Name = "HelloWorld"
    }
    }
    3 changes: 3 additions & 0 deletions output.tf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    output "public_ip" {
    value = "${aws_instance.web.public_ip}"
    }