-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathfloating_ip_address.tf
52 lines (45 loc) · 1.18 KB
/
floating_ip_address.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# set the provider version
terraform {
required_providers {
upcloud = {
source = "UpCloudLtd/upcloud"
version = "~> 2.0"
}
}
}
# configure the provider
provider "upcloud" {
# Your UpCloud credentials are read from the environment variables:
# export UPCLOUD_USERNAME="Username of your UpCloud API user"
# export UPCLOUD_PASSWORD="Password of your UpCloud API user"
}
# create a server
resource "upcloud_server" "loadbalancer" {
hostname = "lb.example.tld"
zone = "nl-ams1"
plan = "1xCPU-1GB"
# Declare a network interface for the floating IP
network_interface {
type = "public"
}
template {
storage = "Ubuntu Server 20.04 LTS (Focal Fossa)"
size = 25
}
login {
user = "terraform"
keys = [
"<YOUR PUBLIC SSH KEY HERE>",
]
create_password = false
}
}
# create a floating ip address
resource "upcloud_floating_ip_address" "my_floating_ip" {
# attach the floating IP address to the server's public interface MAC
mac_address = upcloud_server.loadbalancer.network_interface[0].mac_address
zone = "de-fra1"
}
output "Public_ip" {
value = upcloud_server.loadbalancer.network_interface[0].ip_address
}