# Web Server Stack Template

This template creates an isolated network, security group, Ubuntu Instance with Nginx and a floating IP. Defaults are pre-filled for NeevCloud so you only need to select your SSH key pair.

Save as `webserver-stack.yaml` and upload via Orchestration or Past Direct.

```
heat_template_version: 2021-04-16

description: Isolated web server with network, security group and floating IP.

parameters:
  image:
    type: string
    description: Operating system image
    default: Ubuntu 22.04 Updated
  flavor:
    type: string
    description: VM size (Nano is 2 vCPU, 2 GB RAM)
    default: Nano
  volume_size:
    type: number
    description: Boot volume size in GB
    default: 30
  public_network:
    type: string
    description: Public network for floating IP
    default: Public
  key_name:
    type: string
    description: Your SSH key pair name

resources:
  app_network:
    type: OS::Neutron::Net
    properties:
      name: my-stack-network

  app_subnet:
    type: OS::Neutron::Subnet
    properties:
      network: { get_resource: app_network }
      cidr: 10.100.0.0/24
      dns_nameservers: [8.8.8.8, 8.8.4.4]

  app_router:
    type: OS::Neutron::Router
    properties:
      external_gateway_info:
        network: { get_param: public_network }

  router_interface:
    type: OS::Neutron::RouterInterface
    properties:
      router: { get_resource: app_router }
      subnet: { get_resource: app_subnet }

  web_sg:
    type: OS::Neutron::SecurityGroup
    properties:
      name: my-stack-sg
      rules:
        - { direction: ingress, protocol: tcp, port_range_min: 22, port_range_max: 22, remote_ip_prefix: 0.0.0.0/0 }
        - { direction: ingress, protocol: tcp, port_range_min: 80, port_range_max: 80, remote_ip_prefix: 0.0.0.0/0 }
        - { direction: ingress, protocol: tcp, port_range_min: 443, port_range_max: 443, remote_ip_prefix: 0.0.0.0/0 }
        - { direction: ingress, protocol: icmp, remote_ip_prefix: 0.0.0.0/0 }

  web_server:
    type: OS::Nova::Server
    properties:
      name: my-stack-webserver
      flavor: { get_param: flavor }
      key_name: { get_param: key_name }
      networks:
        - network: { get_resource: app_network }
      security_groups:
        - { get_resource: web_sg }
      block_device_mapping_v2:
        - boot_index: 0
          delete_on_termination: true
          image: { get_param: image }
          volume_size: { get_param: volume_size }
      user_data_format: RAW
      user_data: |
        #!/bin/bash
        apt-get update -y && apt-get install -y nginx
        echo "<h1>NeevCloud Orchestration</h1>" > /var/www/html/index.html
        systemctl enable nginx && systemctl start nginx

  floating_ip:
    type: OS::Neutron::FloatingIP
    properties:
      floating_network: { get_param: public_network }

  floating_ip_assoc:
    type: OS::Neutron::FloatingIPAssociation
    properties:
      floatingip_id: { get_resource: floating_ip }
      port_id: { get_attr: [web_server, addresses, { get_resource: app_network }, 0, port] }

outputs:
  web_url:
    description: Web server URL
    value:
      str_replace:
        template: http://HOST
        params:
          HOST: { get_attr: [floating_ip, floating_ip_address] }
```

### What it creates

A private network on 10.100.0.0/24 with a router connected to the internet. A security group allowing SSH, HTTP, HTTPS and ping. An Ubuntu Instance booted from a 30 GB volume with Nginx installed automatically. A [floating IP](/neevcloud-products/networking/floating-ips.md) attached to the Instance for public access.

When you delete the stack everything is removed together.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.neevcloud.com/neevcloud-products/orchestration-infrastructure-as-code/web-server-stack-template.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
