From 06367914c7b897f13a3463a04ae10058c0782560 Mon Sep 17 00:00:00 2001 From: Magnus Andersson Date: Mon, 29 Apr 2024 14:49:34 +0200 Subject: [PATCH] Initial version --- .tfvars | 2 ++ dtca.tf | 28 ++++++++++++++++++++++++++++ main.tf | 22 ++++++++++++++++++++++ network.tf | 3 +++ securitygroups.tf | 8 ++++++++ vars.tf | 7 +++++++ 6 files changed, 70 insertions(+) create mode 100644 .tfvars create mode 100644 dtca.tf create mode 100644 main.tf create mode 100644 network.tf create mode 100644 securitygroups.tf create mode 100644 vars.tf diff --git a/.tfvars b/.tfvars new file mode 100644 index 0000000..47955e4 --- /dev/null +++ b/.tfvars @@ -0,0 +1,2 @@ +caname = "dtca-test" +cadbname = "dtcadb-test" diff --git a/dtca.tf b/dtca.tf new file mode 100644 index 0000000..dae3756 --- /dev/null +++ b/dtca.tf @@ -0,0 +1,28 @@ +resource "openstack_networking_port_v2" "dtcaport" { + name = "${dtcaname}-sunet-se-port" + network_id = data.openstack_networking_network_v2.public.id + # A list of security group ID + security_group_ids = [ + data.openstack_networking_secgroup_v2.sshfromjumphosts.id, + data.openstack_networking_secgroup_v2.allegress.id + ] + admin_state_up = "true" + lifecycle { + prevent_destroy = true + } +} + + +resource "openstack_networking_port_v2" "dtcadbport" { + name = "${dtcadbname}-sunet-se-port" + network_id = data.openstack_networking_network_v2.public.id + # A list of security group ID + security_group_ids = [ + data.openstack_networking_secgroup_v2.sshfromjumphosts.id, + data.openstack_networking_secgroup_v2.allegress.id + ] + admin_state_up = "true" + lifecycle { + prevent_destroy = true + } +} diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..499c59d --- /dev/null +++ b/main.tf @@ -0,0 +1,22 @@ +# Define required providers +terraform { +required_version = ">= 0.14.0" + required_providers { + openstack = { + source = "terraform-provider-openstack/openstack" + version = "~> 1.53.0" + } + local = { + source = "hashicorp/local" + version = "2.4.1" + } + } +} + +provider "openstack" { + # Source application credentials to use environemnt variables to provide auth +} + +provider "local" { + # Configuration options +} diff --git a/network.tf b/network.tf new file mode 100644 index 0000000..1b99e2b --- /dev/null +++ b/network.tf @@ -0,0 +1,3 @@ +data "openstack_networking_network_v2" "public" { + name = "sunet.se-public" +} diff --git a/securitygroups.tf b/securitygroups.tf new file mode 100644 index 0000000..27f8629 --- /dev/null +++ b/securitygroups.tf @@ -0,0 +1,8 @@ +# Datasource of sunet ssh-from-jumphost security group. +data "openstack_networking_secgroup_v2" "sshfromjumphosts" { + name = "ssh-from-jumphost" +} + +data "openstack_networking_secgroup_v2" "allegress" { + name = "Allow all outgoing" +} diff --git a/vars.tf b/vars.tf new file mode 100644 index 0000000..7592b0b --- /dev/null +++ b/vars.tf @@ -0,0 +1,7 @@ +variable "caname" { + type = string +} + +variable "cadbname" { + type = string +}