Last active
March 23, 2021 00:08
-
-
Save ohrafaelmartins/aedaac78405f3d2c626e62134903b678 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
sudo apt update -y | |
sudo apt install docker docker-compose -y | |
sudo groupadd docker | |
sudo usermod -aG docker $USER | |
newgrp docker | |
docker run -d -p 3000:3000 --name grafana grafana/grafana |
This file contains 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
#!/bin/bash | |
sudo apt update -y | |
sudo apt install docker docker-compose -y | |
sudo groupadd docker | |
sudo usermod -aG docker $USER | |
newgrp docker | |
docker run -d -v jenkins_home:/var/jenkins_home -p 8080:8080 -p 50000:50000 --name jenkins jenkins/jenkins:lts |
This file contains 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" { | |
region = "sa-east-1" | |
} | |
terraform { | |
backend "s3" { | |
bucket = "bucket-name" | |
key = "terraform-test.tfstate" | |
region = "sa-east-1" | |
} | |
required_providers { | |
aws = { | |
version = "~> 2.0" | |
source = "hashicorp/aws" | |
} | |
} | |
} | |
data "aws_ami" "ubuntu" { | |
most_recent = true | |
filter { | |
name = "name" | |
values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] | |
} | |
owners = ["099720109477"] # Ubuntu | |
} | |
resource "aws_instance" "web" { | |
ami = data.aws_ami.ubuntu.id | |
instance_type = "t2.micro" | |
count = length(var.instance_names) | |
associate_public_ip_address = true | |
key_name = "key_name" | |
user_data = file(var.instance_names[count.index]) ## The magic happens here | |
tags = { | |
Name = var.instance_names[count.index] | |
} | |
} | |
output "dns_name" { | |
value = aws_instance.web.*.public_dns | |
} | |
variable "instance_names" { | |
type = list(any) | |
default = ["jenkins", "grafana"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment