diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 00000000..c24bb85f Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b47b2da0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.terraform/ +*terraform.tfstate \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..53a970ba --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +# TODO: Step 1 - Use an official Python runtime as a parent image. You can use `python:3.8-slim`. +FROM python:3.8-slim +# TODO: Step 2 - Set the working directory in the container +WORKDIR /app +# TODO: Step 3 Copy the application files in the container +COPY . . +# Install system dependencies and ODBC driver +RUN apt-get update && apt-get install -y \ + unixodbc unixodbc-dev odbcinst odbcinst1debian2 libpq-dev gcc && \ + apt-get install -y gnupg && \ + apt-get install -y wget && \ + wget -qO- https://packages.microsoft.com/keys/microsoft.asc | apt-key add - && \ + wget -qO- https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list && \ + apt-get update && \ + ACCEPT_EULA=Y apt-get install -y msodbcsql18 && \ + apt-get purge -y --auto-remove wget && \ + apt-get clean + +# Install pip and setuptools +RUN pip install --upgrade pip setuptools + +# TODO: Step 4 - Install Python packages specified in requirements.txt +RUN pip install --no-cache-dir -r requirements.txt +# TODO: Step 5 - Expose port +EXPOSE 5000 +# TODO: Step 6 - Define Startup Command +CMD ["python", "app.py"] \ No newline at end of file diff --git a/README.md b/README.md index 08407749..4487e829 100644 --- a/README.md +++ b/README.md @@ -13,15 +13,15 @@ Welcome to the Web App DevOps Project repo! This application allows you to effic ## Features - **Order List:** View a comprehensive list of orders including details like date UUID, user ID, card number, store code, product code, product quantity, order date, and shipping date. - + ![Screenshot 2023-08-31 at 15 48 48](https://github.com/maya-a-iuga/Web-App-DevOps-Project/assets/104773240/3a3bae88-9224-4755-bf62-567beb7bf692) - **Pagination:** Easily navigate through multiple pages of orders using the built-in pagination feature. - + ![Screenshot 2023-08-31 at 15 49 08](https://github.com/maya-a-iuga/Web-App-DevOps-Project/assets/104773240/d92a045d-b568-4695-b2b9-986874b4ed5a) - **Add New Order:** Fill out a user-friendly form to add new orders to the system with necessary information. - + ![Screenshot 2023-08-31 at 15 49 26](https://github.com/maya-a-iuga/Web-App-DevOps-Project/assets/104773240/83236d79-6212-4fc3-afa3-3cee88354b1a) - **Data Validation:** Ensure data accuracy and completeness with required fields, date restrictions, and card number validation. @@ -53,10 +53,72 @@ To run the application, you simply need to run the `app.py` script in this repos - **Database:** The application employs an Azure SQL Database as its database system to store order-related data. -## Contributors +## Contributors -- [Maya Iuga]([https://github.com/yourusername](https://github.com/maya-a-iuga)) +- [Maya Iuga](<[https://github.com/yourusername](https://github.com/maya-a-iuga)>) ## License This project is licensed under the MIT License. For more details, refer to the [LICENSE](LICENSE) file. + +## Robin Winters Azure End-to-End DevOps Pipeline Project + +1. _delivery-date column:_ delivery_date added to both backend (app.py) and frontend (order.html) files. +2. _removed delivery-date column:_ delivery_date removed from both backend (app.py) and frontend (order.html) files. + +### Containerization + +1. Dockerfile created based on python:3.8-slim +2. Docker image builded. + **imagename:** web-app-image + **imagetag:** 1.0 +3. Image pushed to Docker Hub + +- Image can be seen from the link below +- https://hub.docker.com/repository/docker/robinwinters/web-app-image/general + +### Networking Services Deployment with Terraform + +#### Overview + +This repository contains Terraform configurations for deploying networking resources in Azure, including a Virtual Network (VNet), subnets, and Network Security Groups (NSGs). This README provides an overview of the networking services deployed using Infrastructure as Code (IaC) with Terraform. + +#### Prerequisites + +Before running the Terraform configurations, ensure you have the following prerequisites set up: + +Azure subscription +Azure CLI installed and configured +Terraform CLI installed + +#### Terraform Configuration + +1. Input Variables + + - resource_group_name: The name of the Azure resource group where networking resources will be created. + - location: The Azure region where networking resources will be deployed. + - vnet_address_space: The address space for the Virtual Network (VNet). + +2. Networking Resources + + - Azure Resource Group + - Virtual Network (VNet) + - Subnets + - Network Security Group (NSG) + +3. Output Variables + - vnet_id: ID of the Virtual Network (VNet). + - control_plane_subnet_id: ID of the control plane subnet. + - worker_node_subnet_id: ID of the worker node subnet. + - resource_group_name: Name of the Azure Resource Group for networking resources. + - aks_nsg_id: ID of the Network Security Group (NSG) for AKS. + +#### Usage + +1. Clone Repository: Clone this repository to your local machine. +2. Set Terraform Variables: Update the variables.tf file with your desired values for input variables. +3. Initialize Terraform: Run terraform init to initialize the Terraform configuration. +4. Review Execution Plan: Run terraform plan to review the execution plan and ensure it matches your expectations. +5. Apply Terraform Changes: Run terraform apply to apply the Terraform changes and deploy networking resources to Azure. + +- \*\*git can only support files of a certain size & that the .terraform is larger so has to be avoided diff --git a/aks-terraform/.DS_Store b/aks-terraform/.DS_Store new file mode 100644 index 00000000..696c0e84 Binary files /dev/null and b/aks-terraform/.DS_Store differ diff --git a/aks-terraform/networking-module/.terraform.lock.hcl b/aks-terraform/networking-module/.terraform.lock.hcl new file mode 100644 index 00000000..49223d74 --- /dev/null +++ b/aks-terraform/networking-module/.terraform.lock.hcl @@ -0,0 +1,21 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/azurerm" { + version = "3.90.0" + hashes = [ + "h1:8exKO4IgZ9qLImDCAig+cKgONFUV/gW6pIlXc9CnPVk=", + "zh:194a4342620958403beabf4d57d552133ca6ac18eef3027d6d1a98846b52f8ab", + "zh:1d8ee378aaa793e3288c9328e056763c98d0f2e8560357296bc3446fbd3b1b9d", + "zh:24aba7903e912570e36edb03f79c68028d3e254175947b588c96521f09f89df4", + "zh:27f91fbeef9d04c6382014b6c32883a96dbe91cf7a4fa07a97be5d6b03991f95", + "zh:59eeaa2f50f698bab6f36ada0e865d6b624625ff5d76309334b3c3aa366cb692", + "zh:732af42d18fa222ee88f7f97c0898d4955ae48fde5456e22af3b8f5d324c6b41", + "zh:766034eac5e6a66cf3631580956dd584b1c2e6134167302fc8b95d6b42ebf08b", + "zh:a5b2ec52abfc3fb154047af45ea692c98c646c2b5c336b12b6341a49be95025c", + "zh:bdd72f85d770fa4a2e6ebf542858341d3df7e858a4d70c0f94df758721bcd811", + "zh:e9f15f2399c667c24b3daf8a843f1cadd13bc619becf6362b46c3216b17009b1", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + "zh:f73b1ec8b372bc1480ca0d93e78914f1c9cebe81395f20273d7bc99579b84809", + ] +} diff --git a/aks-terraform/networking-module/main.tf b/aks-terraform/networking-module/main.tf new file mode 100644 index 00000000..cd8b42ba --- /dev/null +++ b/aks-terraform/networking-module/main.tf @@ -0,0 +1,65 @@ +# Create the Azure Resource Group for networking resources +resource "azurerm_resource_group" "networking" { + name = var.resource_group_name + location = var.location +} + +# Define the Virtual Network (VNet) for the AKS cluster +resource "azurerm_virtual_network" "aks_vnet" { + name = "aks-vnet" + address_space = var.vnet_address_space + location = azurerm_resource_group.networking.location + resource_group_name = azurerm_resource_group.networking.name +} + +# Define subnets within the VNet for control plane and worker nodes +resource "azurerm_subnet" "control_plane_subnet" { + name = "aks-subnet-control-plane" + resource_group_name = azurerm_resource_group.networking.name + virtual_network_name = azurerm_virtual_network.aks_vnet.name + address_prefixes = ["10.0.1.0/24"] +} + +resource "azurerm_subnet" "worker_node_subnet" { + name = "aks-node-subnet" + resource_group_name = azurerm_resource_group.networking.name + virtual_network_name = azurerm_virtual_network.aks_vnet.name + address_prefixes = ["10.0.2.0/24"] +} + +# Define Network Security Group (NSG) for the AKS subnet +resource "azurerm_network_security_group" "aks_nsg" { + name = "aks-nsg" + location = azurerm_resource_group.networking.location + resource_group_name = azurerm_resource_group.networking.name +} + +# Allow inbound traffic to kube-apiserver (TCP/443) from your public IP address +resource "azurerm_network_security_rule" "kube_apiserver" { + name = "aks-kubi-api-server" + priority = 1001 + direction = "Inbound" + access = "Allow" + protocol = "Tcp" + source_port_range = "*" + destination_port_range = "443" + source_address_prefix = "150.143.254.11" + destination_address_prefix = "*" + resource_group_name = azurerm_resource_group.networking.name + network_security_group_name = azurerm_network_security_group.aks_nsg.name +} + +# Allow inbound traffic for SSH (TCP/22) - Optional +resource "azurerm_network_security_rule" "ssh" { + name = "aks-ssh" + priority = 1002 + direction = "Inbound" + access = "Allow" + protocol = "Tcp" + source_port_range = "*" + destination_port_range = "22" + source_address_prefix = "150.143.254.11" + destination_address_prefix = "*" + resource_group_name = azurerm_resource_group.networking.name + network_security_group_name = azurerm_network_security_group.aks_nsg.name +} diff --git a/aks-terraform/networking-module/output.tf b/aks-terraform/networking-module/output.tf new file mode 100644 index 00000000..14d2da4b --- /dev/null +++ b/aks-terraform/networking-module/output.tf @@ -0,0 +1,25 @@ +output "vnet_id" { + description = "ID of the Virtual Network (VNet)." + value = azurerm_virtual_network.aks_vnet.id +} + +output "control_plane_subnet_id" { + description = "ID of the control plane subnet." + value = azurerm_subnet.control_plane_subnet.id +} + +output "worker_node_subnet_id" { + description = "ID of the worker node subnet." + value = azurerm_subnet.worker_node_subnet.id +} + +output "resource_group_name" { + description = "Name of the Azure Resource Group for networking resources." + value = azurerm_resource_group.networking.name +} + +# Define more output variables as needed... +output "aks_nsg_id" { + description = "ID of the Network Security Group (NSG) for AKS." + value = azurerm_network_security_group.aks_nsg.id +} diff --git a/aks-terraform/networking-module/variables.tf b/aks-terraform/networking-module/variables.tf new file mode 100644 index 00000000..d26938e1 --- /dev/null +++ b/aks-terraform/networking-module/variables.tf @@ -0,0 +1,18 @@ +variable "resource_group_name" { + description = "The Azure resource group where the networking resources will be created in" + type = string + default = "azure-devops-project-resource-group" + +} + +variable "location" { + description = "The Azure region where the networking resources will be deployed." + type = string + default = "UK South" +} + +variable "vnet_address_space" { + description = "Address space for the Virtual Network (VNet)." + type = list(string) + default = ["10.0.0.0/16"] +}