Skip to content

Instantly share code, notes, and snippets.

@mlabouardy
Created January 5, 2019 13:33
Show Gist options
  • Select an option

  • Save mlabouardy/a496ff0e389b3d38e73985ade0e38991 to your computer and use it in GitHub Desktop.

Select an option

Save mlabouardy/a496ff0e389b3d38e73985ade0e38991 to your computer and use it in GitHub Desktop.
Deploy Nexus repository on GCP with Terraform
provider "google" {
credentials = "${file("${var.credentials}")}"
project = "${var.project}"
region = "${var.region}"
}
resource "google_compute_firewall" "nexus" {
name = "nexus-firewall"
network = "${google_compute_network.nexus.name}"
allow {
protocol = "tcp"
ports = ["22", "8081"]
}
source_ranges = ["0.0.0.0/0"]
}
resource "google_compute_network" "nexus" {
name = "nexus-network"
}
resource "google_compute_instance" "nexus" {
name = "nexus"
machine_type = "${var.instance_type}"
zone = "${var.zone}"
boot_disk {
initialize_params {
image = "${var.image_name}"
size = 100
}
}
metadata {
sshKeys = "${var.ssh_user}:${file(var.ssh_pub_key_file)}"
}
network_interface {
network = "${google_compute_network.nexus.name}"
access_config = {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment