Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
Add firewall example
Browse files Browse the repository at this point in the history
  • Loading branch information
thojkooi committed Oct 7, 2017
1 parent 10a4701 commit 06edc1a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/extra-droplets/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ This example shows how to add other droplets that are not provisioned by this mo

## Running it

You can try out this example by providing a digitalocean access token and running `terraform apply`. Note that you may need to run `terraform get` first.
You can try out this example by providing a digitalocean access token and running `terraform apply`. Note that you may need to run `terraform init` first.
7 changes: 7 additions & 0 deletions examples/firewall/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Example: cluster with firewall

This example shows how to set up firewall rules for a DigitalOcean swarm mode cluster.

## Running it

You can try out this example by providing a digitalocean access token and running `terraform apply`. Note that you may need to run `terraform init` first.
43 changes: 43 additions & 0 deletions examples/firewall/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
variable "do_token" {}

provider "digitalocean" {
token = "${var.do_token}"
}

variable "ssh_keys" {
type = "list"
}

resource "digitalocean_tag" "cluster" {
name = "swarm-mode-cluster"
}

resource "digitalocean_tag" "manager" {
name = "manager"
}

resource "digitalocean_tag" "worker" {
name = "worker"
}

module "swarm-firewall" {
source = "github.com/thojkooi/terraform-digitalocean-swarm-firewall"
do_token = "${var.do_token}"
prefix = "example-com"
cluster_tags = ["${digitalocean_tag.cluster.id}", "${digitalocean_tag.manager.id}", "${digitalocean_tag.worker.id}"]
cluster_droplet_ids = []
allowed_outbound_addresses = ["0.0.0.0/0", "::/0"]
}

module "swarm-cluster" {
source = "github.com/thojkooi/terraform-digitalocean-docker-swarm-mode"
total_managers = 3
total_workers = 5
region = "ams3"
do_token = "${var.do_token}"
manager_ssh_keys = "${var.ssh_keys}"
worker_ssh_keys = "${var.ssh_keys}"
manager_tags = ["${digitalocean_tag.cluster.id}", "${digitalocean_tag.manager.id}"]
worker_tags = ["${digitalocean_tag.cluster.id}", "${digitalocean_tag.worker.id}"]
domain = "do.example.com"
}
2 changes: 1 addition & 1 deletion examples/user-data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ This example uses the Centos 7 image from DigitalOcean and uses user data to ins

## Running it

You can try out this example by providing a digitalocean access token and running `terraform apply`. Note that you may need to run `terraform get` first.
You can try out this example by providing a digitalocean access token and running `terraform apply`. Note that you may need to run `terraform init` first.

This example takes a while to complete, since Terraform is waiting until Docker is available on the provisioned droplets. This may take roughly 4 minutes.
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module "managers" {
region = "${var.region}"
domain = "${var.domain}"

total_instances = "${var.total_managers + 1}"
total_instances = "${var.total_managers}"
user_data = "${var.manager_user_data}"
tags = "${var.manager_tags}"

Expand Down

0 comments on commit 06edc1a

Please sign in to comment.