Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
hello-nginx-from-ICG
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PIACERE
public
demos
hello-nginx-from-ICG
Commits
ac8fd0a2
Commit
ac8fd0a2
authored
2 years ago
by
debora.benedetto@hpe.com
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
750ccb71
No related branches found
Branches containing commit
Tags
6.0
6.0.0
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.tf
+123
-0
123 additions, 0 deletions
main.tf
with
123 additions
and
0 deletions
main.tf
0 → 100644
+
123
−
0
View file @
ac8fd0a2
terraform
{
required_version
=
">= 0.14.0"
required_providers
{
openstack
=
{
source
=
"terraform-provider-openstack/openstack"
version
=
"~> 1.35.0"
}
}
}
# Configure the OpenStack Provider
provider
"openstack"
{
user_name
=
var
.
username
tenant_name
=
"admin"
password
=
var
.
password
auth_url
=
var
.
auth_url
insecure
=
true
}
resource
"openstack_compute_keypair_v2"
"user_key"
{
name
=
"user1"
public_key
=
var
.
ssh_key
}
# Retrieve data
data
"openstack_networking_network_v2"
"external"
{
name
=
"external"
}
data
"openstack_identity_project_v3"
"test_tenant"
{
name
=
"admin"
}
data
"openstack_networking_secgroup_v2"
"default"
{
name
=
"default"
tenant_id
=
data
.
openstack_identity_project_v3
.
test_tenant
.
id
}
# Router creation. UUID external gateway
resource
"openstack_networking_router_v2"
"generic"
{
name
=
"router-generic"
external_network_id
=
data
.
openstack_networking_network_v2
.
external
.
id
#External network id
}
# Network creation
resource
"openstack_networking_network_v2"
"generic"
{
name
=
"ostack2"
}
#### HTTP SUBNET ####
# Subnet configuration
resource
"openstack_networking_subnet_v2"
"nginx"
{
name
=
"subnet-nginx"
network_id
=
openstack_networking_network_v2
.
generic
.
id
cidr
=
"16.0.0.0/24"
dns_nameservers
=
[
"8.8.8.8"
,
"8.8.8.4"
]
}
# Router interface configuration
resource
"openstack_networking_router_interface_v2"
"nginx"
{
router_id
=
openstack_networking_router_v2
.
generic
.
id
subnet_id
=
openstack_networking_subnet_v2
.
nginx
.
id
}
resource
"openstack_compute_secgroup_v2"
"http"
{
name
=
"http"
description
=
"Open input http port"
rule
{
from_port
=
80
to_port
=
80
ip_protocol
=
"tcp"
cidr
=
"0.0.0.0/0"
}
}
resource
"openstack_compute_secgroup_v2"
"ssh"
{
name
=
"ssh"
description
=
"Open input ssh port"
rule
{
from_port
=
22
to_port
=
22
ip_protocol
=
"tcp"
cidr
=
"0.0.0.0/0"
}
}
#
# Create instance
#
resource
"openstack_compute_instance_v2"
"nginx"
{
name
=
"nginx-host"
image_name
=
"cirros"
flavor_name
=
"m1.tiny"
key_pair
=
openstack_compute_keypair_v2
.
user_key
.
name
network
{
port
=
openstack_networking_port_v2
.
nginx
.
id
}
}
# Create network port
resource
"openstack_networking_port_v2"
"nginx"
{
name
=
"nginx"
network_id
=
openstack_networking_network_v2
.
generic
.
id
admin_state_up
=
true
security_group_ids
=
[
data
.
openstack_networking_secgroup_v2
.
default
.
id
#default flavour id
]
fixed_ip
{
subnet_id
=
openstack_networking_subnet_v2
.
nginx
.
id
}
}
# Create floating ip
resource
"openstack_networking_floatingip_v2"
"nginx"
{
pool
=
"external"
}
# Attach floating ip to instance
resource
"openstack_compute_floatingip_associate_v2"
"nginx"
{
floating_ip
=
openstack_networking_floatingip_v2
.
nginx
.
address
instance_id
=
openstack_compute_instance_v2
.
nginx
.
id
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment