Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provision a big trusted-agent in Azure #39

Merged
merged 1 commit into from
Nov 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions plans/ci.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#
# Resources related to our CI infrastructure for ci.jenkins.io or trusted.ci
#


resource "azurerm_resource_group" "ci" {
name = "${var.prefix}jenkinsci"
location = "${var.location}"
tags {
env = "${var.prefix}"
}
}

resource "azurerm_storage_account" "ci_storage" {
name = "${var.prefix}jenkinscistore"
resource_group_name = "${azurerm_resource_group.ci.name}"
location = "${var.location}"
account_tier = "Standard"
account_replication_type = "LRS"

tags {
environment = "${var.prefix}"
}
}

resource "azurerm_storage_container" "ci_container" {
name = "vhds"
resource_group_name = "${azurerm_resource_group.ci.name}"
storage_account_name = "${azurerm_storage_account.ci_storage.name}"
container_access_type = "private"
}

resource "azurerm_public_ip" "ci_trusted_agent_1" {
name = "trusted-agent-1"
location = "${azurerm_resource_group.ci.location}"
resource_group_name = "${azurerm_resource_group.ci.name}"
public_ip_address_allocation = "dynamic"

tags {
environment = "${var.prefix}"
}
}

resource "azurerm_network_interface" "ci_trusted_agent_1_nic" {
name = "trusted-agent-1-nic"
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.ci.name}"

ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.public_dmz.id}"
private_ip_address_allocation = "dynamic"
public_ip_address_id = "${azurerm_public_ip.ci_trusted_agent_1.id}"
}
}

resource "azurerm_virtual_machine" "ci_trusted_agent_1" {
name = "trusted-agent-1"
location = "${var.location}"
resource_group_name = "${azurerm_resource_group.ci.name}"
network_interface_ids = ["${azurerm_network_interface.ci_trusted_agent_1_nic.id}"]
vm_size = "Standard_DS4_v2"

delete_os_disk_on_termination = true
delete_data_disks_on_termination = true

storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}

storage_os_disk {
name = "trusted-agent-1-disk"
vhd_uri = "${azurerm_storage_account.ci_storage.primary_blob_endpoint}${azurerm_storage_container.ci_container.name}/trustedagent1os.vhd"
caching = "ReadWrite"
create_option = "FromImage"
}


os_profile {
computer_name = "trusted-agent-1"
admin_username = "azureuser"
admin_password = "${random_id.prefix.hex}"
}

os_profile_linux_config {
disable_password_authentication = true
ssh_keys = [
{
path = "/home/azureuser/.ssh/authorized_keys"
key_data = "${file("${var.ssh_pubkey_path}")}"
},
]
}

tags {
environment = "${var.prefix}"
}
}


resource "random_id" "prefix" {
keepers {
prefix = "${var.prefix}"
}
byte_length = 16
}
27 changes: 17 additions & 10 deletions plans/vnets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,26 @@ resource "azurerm_virtual_network" "public_prod" {
address_prefix = "10.0.2.0/24"
security_group = "${azurerm_network_security_group.public_data_tier.id}"
}
}

# The "dmz-tier" subnet is intended for resources which need to be
# provisioned in the Public Production network but don't need to be
# accessible from the public internet. Such as dynamically provisioned VMs for
# Jenkins masters, or other untrusted workloads which should be in the Public
# Production VNet
subnet {
name = "dmz-tier"
address_prefix = "10.0.99.0/24"
security_group = "${azurerm_network_security_group.public_dmz_tier.id}"
}
# The "dmz-tier" subnet is intended for resources which need to be
# provisioned in the Public Production network but don't need to be
# accessible from the public internet. Such as dynamically provisioned VMs for
# Jenkins masters, or other untrusted workloads which should be in the Public
# Production VNet
#
# Defining as a separate resource so it can eaisly be referred to in the
# Terraform resource graph
resource "azurerm_subnet" "public_dmz" {
name = "dmz-tier"
resource_group_name = "${azurerm_resource_group.public_prod.name}"

virtual_network_name = "${azurerm_virtual_network.public_prod.name}"
network_security_group_id = "${azurerm_network_security_group.public_dmz_tier.id}"
address_prefix = "10.0.99.0/24"
}


# The Private Production VNet is where all management and highly classified
# resources should be provisioned. It should never have its resources exposed
# to the public internet but is peered with Public Production
Expand Down