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 = "us-east-1" | |
shared_credentials_file = "~/.aws/credentials" | |
profile = "dev" | |
} |
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
# lookup for the "default" VPC | |
data "aws_vpc" "default_vpc" { | |
default = true | |
} | |
# subnet list in the "default" VPC | |
# The "default" VPC has all "public subnets" | |
data "aws_subnet_ids" "default_public" { | |
vpc_id = "${data.aws_vpc.default_vpc.id}" | |
} |
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
<powershell> | |
function Wait-For-Jenkins { | |
Write-Host "Waiting jenkins to launch on 8080..." | |
Do { | |
Write-Host "Waiting for Jenkins" | |
Nc -zv ${server_ip} 8080 |
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
# Setting Up Windows Slave | |
data "aws_ami" "jenkins_worker_windows" { | |
most_recent = true | |
owners = ["self"] | |
filter { | |
name = "name" | |
values = ["windows-slave-for-jenkins*"] | |
} | |
} |
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
resource "aws_security_group" "dev_jenkins_worker_windows" { | |
name = "dev_jenkins_worker_windows" | |
description = "Jenkins Server: created by Terraform for [dev]" | |
# legacy name of VPC ID | |
vpc_id = "${data.aws_vpc.default_vpc.id}" | |
tags { | |
Name = "dev_jenkins_worker_windows" | |
env = "dev" |
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
# Setting Up machine for Jenkins | |
#Jenkins root directory | |
$jenkins_slave_path = "C:\Jenkins" | |
If(!(test-path $jenkins_slave_path)) | |
{ | |
New-Item -ItemType Directory -Force -Path $jenkins_slave_path | |
} | |
# Install Chocolatey for managing installations |
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
<powershell> | |
write-output "Running User Data Script" | |
write-host "(host) Running User Data Script" | |
Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force -ErrorAction Ignore | |
# Don't set this before Set-ExecutionPolicy as it throws an error | |
$ErrorActionPreference = "stop" |
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
{ | |
"variables": { | |
"ami-description": "Windows Server for Jenkins Slave ({{isotime \"2006-01-02-15-04-05\"}})", | |
"ami-name": "windows-slave-for-jenkins-{{isotime \"2006-01-02-15-04-05\"}}", | |
"aws_access_key": "", | |
"aws_secret_key": "" | |
}, | |
"builders": [ | |
{ |
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 | |
set -x | |
function wait_for_jenkins () | |
{ | |
echo "Waiting jenkins to launch on 8080..." | |
while (( 1 )); do | |
echo "Waiting for Jenkins" |
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
data "aws_ami" "jenkins_worker_linux" { | |
most_recent = true | |
owners = ["self"] | |
filter { | |
name = "name" | |
values = ["amazon-linux-for-jenkins*"] | |
} | |
} |