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

docs: add instance example #2575

Merged
merged 2 commits into from
May 22, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ test.tf
*.test
*.iml
.vscode
.terraform.tfstate.lock.info
.terraform.lock.hcl

# generated for examples tests
examples/**/provider.tf

website/vendor

Expand Down
3 changes: 3 additions & 0 deletions examples/instance-servers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Example: Instance Servers

This example provisions a customizable number of servers in a private network.
18 changes: 18 additions & 0 deletions examples/instance-servers/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
provider "scaleway" {}

resource "scaleway_vpc" "vpc" {}

resource "scaleway_vpc_private_network" "pn" {
vpc_id = scaleway_vpc.vpc.id
}

resource "scaleway_instance_ip" "ip" {
count = var.server_count
}

resource "scaleway_instance_server" "server" {
count = var.server_count
type = "PLAY2-MICRO"
image = "ubuntu_jammy"
ip_ids = [scaleway_instance_ip.ip[count.index].id]
}
4 changes: 4 additions & 0 deletions examples/instance-servers/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "ips_v4" {
description = "The public IPv4 addresses of the created instance servers"
value = scaleway_instance_server.server[*].public_ip
}
5 changes: 5 additions & 0 deletions examples/instance-servers/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
variable "server_count" {
description = "The number of servers and IPs to provision"
type = number
default = 3
}