diff --git a/app.py b/app.py index fad18cf8a257300fb2fa7ef96015cb77d2dab564..2b10302955c9180b6eddec58b01ed8bb454bf0f7 100644 --- a/app.py +++ b/app.py @@ -48,7 +48,7 @@ app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False db = SQLAlchemy(app) -#Modèle utilisateur +#Modèle utilisateur -- USELESS class User(db.Model): id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) @@ -61,6 +61,18 @@ class Article(db.Model): description = db.Column(db.Text, nullable=False) price = db.Column(db.Float, nullable=False) + +# Modèle pour enregistrer les achats +class Purchase(db.Model): + id = db.Column(db.Integer, primary_key=True) + user_email = db.Column(db.String(120), nullable=False) + product_name = db.Column(db.String(120), nullable=False) + price = db.Column(db.Float, nullable=False) + + def __repr__(self): + return f"<Purchase {self.product_name} - {self.user_email}>" + + # Créer les tables dans la base de données with app.app_context(): db.create_all() @@ -81,42 +93,66 @@ def ePhone16ProMax(): # return "Hello, world" - +# Route d'administration @app.route('/admin', methods=['GET', 'POST']) def admin(): if request.method == 'POST': + # Récupère les données du formulaire title = request.form['title'] description = request.form['description'] price = request.form['price'] - - new_article = Article(title=title, description=description, price=price) + + # Crée et enregistre un nouvel article en base + new_article = Article( + title=title, + description=description, + price=float(price) + ) db.session.add(new_article) db.session.commit() - + + # Redirige vers la même page pour rafraîchir la liste return redirect(url_for('admin')) - - articles = Article.query.all() - return render_template('admin.html', articles=articles) -@app.route('/articles') -def articles(): + # En GET, on récupère la liste des articles en base articles = Article.query.all() - return render_template('articles.html', articles=articles) - -@app.route('/articles/<int:article_id>') -def article_details(article_id): - article = Article.query.get_or_404(article_id) - return render_template('article_details.html', article=article) + # On passe ces articles au template + return render_template('admin.html', articles=articles) -@app.route('/buy/<int:article_id>', methods=['POST']) -def buy(article_id): - article = Article.query.get_or_404(article_id) - user_email = request.form['email'] # Récupère l'email de l'utilisateur - # Simulation d'envoi de confirmation (ajoutez Flask-Mail pour le rendre réel) - print(f"Email de confirmation envoyé à {user_email} pour l'article {article.title} au prix de {article.price}€.") +# Route de suppression d'un article +@app.route('/admin/delete/<int:article_id>', methods=['GET']) +def delete_article(article_id): + # On récupère l'article à supprimer, ou 404 si introuvable + article_to_delete = Article.query.get_or_404(article_id) + db.session.delete(article_to_delete) + db.session.commit() + # On retourne sur la page admin + return redirect(url_for('admin')) + +@app.route('/purchase', methods=['POST']) +def purchase_ephone(): + # Récupère les données du formulaire + user_email = request.form.get('user_email') + product_name = request.form.get('product_name') + price_str = request.form.get('price') # Récupéré en chaîne + try: + price = float(price_str) + except (ValueError, TypeError): + price = 0.0 # ou gérer l'erreur autrement + + # Crée un enregistrement dans la table Purchase + new_purchase = Purchase( + user_email=user_email, + product_name=product_name, + price=price + ) + db.session.add(new_purchase) + db.session.commit() - return jsonify({"message": f"Confirmation envoyée à {user_email} pour l'achat de {article.title}."}) + # Ici, on peut renvoyer une page de confirmation, + # ou rediriger vers une autre page + return f"Achat enregistré pour {product_name} au prix de {price} €. Un email sera envoyé à {user_email}." if __name__ == '__main__': diff --git a/mydb.dump b/mydb.dump new file mode 100644 index 0000000000000000000000000000000000000000..5905c426a89b1227d34453fdf6b9e17ede88f09f --- /dev/null +++ b/mydb.dump @@ -0,0 +1,268 @@ +-- +-- PostgreSQL database dump +-- + +-- Dumped from database version 14.15 (Ubuntu 14.15-0ubuntu0.22.04.1) +-- Dumped by pg_dump version 14.15 (Ubuntu 14.15-0ubuntu0.22.04.1) + +-- Started on 2025-01-30 12:06:00 CET + +SET statement_timeout = 0; +SET lock_timeout = 0; +SET idle_in_transaction_session_timeout = 0; +SET client_encoding = 'UTF8'; +SET standard_conforming_strings = on; +SELECT pg_catalog.set_config('search_path', '', false); +SET check_function_bodies = false; +SET xmloption = content; +SET client_min_messages = warning; +SET row_security = off; + +SET default_tablespace = ''; + +SET default_table_access_method = heap; + +-- +-- TOC entry 212 (class 1259 OID 16395) +-- Name: article; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.article ( + id integer NOT NULL, + title character varying(120) NOT NULL, + description text NOT NULL, + price double precision NOT NULL +); + + +ALTER TABLE public.article OWNER TO postgres; + +-- +-- TOC entry 211 (class 1259 OID 16394) +-- Name: article_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.article_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.article_id_seq OWNER TO postgres; + +-- +-- TOC entry 3340 (class 0 OID 0) +-- Dependencies: 211 +-- Name: article_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.article_id_seq OWNED BY public.article.id; + + +-- +-- TOC entry 214 (class 1259 OID 16404) +-- Name: purchase; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public.purchase ( + id integer NOT NULL, + user_email character varying(120) NOT NULL, + product_name character varying(120) NOT NULL, + price double precision NOT NULL +); + + +ALTER TABLE public.purchase OWNER TO postgres; + +-- +-- TOC entry 213 (class 1259 OID 16403) +-- Name: purchase_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.purchase_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.purchase_id_seq OWNER TO postgres; + +-- +-- TOC entry 3341 (class 0 OID 0) +-- Dependencies: 213 +-- Name: purchase_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.purchase_id_seq OWNED BY public.purchase.id; + + +-- +-- TOC entry 210 (class 1259 OID 16386) +-- Name: user; Type: TABLE; Schema: public; Owner: postgres +-- + +CREATE TABLE public."user" ( + id integer NOT NULL, + name character varying(80) NOT NULL, + email character varying(120) NOT NULL +); + + +ALTER TABLE public."user" OWNER TO postgres; + +-- +-- TOC entry 209 (class 1259 OID 16385) +-- Name: user_id_seq; Type: SEQUENCE; Schema: public; Owner: postgres +-- + +CREATE SEQUENCE public.user_id_seq + AS integer + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +ALTER TABLE public.user_id_seq OWNER TO postgres; + +-- +-- TOC entry 3342 (class 0 OID 0) +-- Dependencies: 209 +-- Name: user_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: postgres +-- + +ALTER SEQUENCE public.user_id_seq OWNED BY public."user".id; + + +-- +-- TOC entry 3180 (class 2604 OID 16398) +-- Name: article id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.article ALTER COLUMN id SET DEFAULT nextval('public.article_id_seq'::regclass); + + +-- +-- TOC entry 3181 (class 2604 OID 16407) +-- Name: purchase id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.purchase ALTER COLUMN id SET DEFAULT nextval('public.purchase_id_seq'::regclass); + + +-- +-- TOC entry 3179 (class 2604 OID 16389) +-- Name: user id; Type: DEFAULT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public."user" ALTER COLUMN id SET DEFAULT nextval('public.user_id_seq'::regclass); + + +-- +-- TOC entry 3332 (class 0 OID 16395) +-- Dependencies: 212 +-- Data for Name: article; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.article (id, title, description, price) FROM stdin; +2 ePad9 Ipad9 800 +\. + + +-- +-- TOC entry 3334 (class 0 OID 16404) +-- Dependencies: 214 +-- Data for Name: purchase; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public.purchase (id, user_email, product_name, price) FROM stdin; +1 hugo.donneger@univ-lille.fr ePhone 16 Pro Max 900 +\. + + +-- +-- TOC entry 3330 (class 0 OID 16386) +-- Dependencies: 210 +-- Data for Name: user; Type: TABLE DATA; Schema: public; Owner: postgres +-- + +COPY public."user" (id, name, email) FROM stdin; +\. + + +-- +-- TOC entry 3343 (class 0 OID 0) +-- Dependencies: 211 +-- Name: article_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.article_id_seq', 2, true); + + +-- +-- TOC entry 3344 (class 0 OID 0) +-- Dependencies: 213 +-- Name: purchase_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.purchase_id_seq', 1, true); + + +-- +-- TOC entry 3345 (class 0 OID 0) +-- Dependencies: 209 +-- Name: user_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres +-- + +SELECT pg_catalog.setval('public.user_id_seq', 1, false); + + +-- +-- TOC entry 3187 (class 2606 OID 16402) +-- Name: article article_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.article + ADD CONSTRAINT article_pkey PRIMARY KEY (id); + + +-- +-- TOC entry 3189 (class 2606 OID 16409) +-- Name: purchase purchase_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public.purchase + ADD CONSTRAINT purchase_pkey PRIMARY KEY (id); + + +-- +-- TOC entry 3183 (class 2606 OID 16393) +-- Name: user user_email_key; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public."user" + ADD CONSTRAINT user_email_key UNIQUE (email); + + +-- +-- TOC entry 3185 (class 2606 OID 16391) +-- Name: user user_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres +-- + +ALTER TABLE ONLY public."user" + ADD CONSTRAINT user_pkey PRIMARY KEY (id); + + +-- Completed on 2025-01-30 12:06:04 CET + +-- +-- PostgreSQL database dump complete +-- + diff --git a/old/00-provider.tf b/old/00-provider.tf new file mode 100644 index 0000000000000000000000000000000000000000..29104fbb5e3b4b2fc8830c07beea321275b36dbc --- /dev/null +++ b/old/00-provider.tf @@ -0,0 +1,16 @@ +######################################## +# Fournisseur et configuration +######################################## +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.0" + } + } + required_version = ">= 1.0" +} + +provider "aws" { + region = var.region +} \ No newline at end of file diff --git a/old/output.tf.old b/old/output.tf.old new file mode 100644 index 0000000000000000000000000000000000000000..a9de7b0f52e63386d979aaf3707d9ba118948ce6 --- /dev/null +++ b/old/output.tf.old @@ -0,0 +1,19 @@ +output "bastion_public_ip" { + description = "Adresse IP publique de la bastion" + value = aws_instance.bastion.public_ip +} + +output "db_endpoint" { + description = "Endpoint RDS pour la base PostgreSQL" + value = aws_db_instance.this.endpoint +} + +output "api_private_ip" { + description = "Adresse privée de l'API EC2" + value = aws_instance.api_ec2.private_ip +} + +output "client_private_ip" { + description = "Adresse privée de l'EC2 client" + value = aws_instance.client_ec2.private_ip +} diff --git a/old/variables.tf b/old/variables.tf new file mode 100644 index 0000000000000000000000000000000000000000..e0b3423e0adfeec1e5239605d37a4c2e0af6040e --- /dev/null +++ b/old/variables.tf @@ -0,0 +1,12 @@ +###################################################### +# Variables +###################################################### +variable "identifiant" { + description = "Kenneth & Hugo" + default = "Kenneth & Hugo" +} + +variable "region" { + type = string + default = "eu-west-3" +} diff --git a/templates/admin.html b/templates/admin.html index f227d3cdefdbc8f4a8eec22703f9936c1373a71e..fe3014a1a69a823396f93fa8679063b506733a68 100644 --- a/templates/admin.html +++ b/templates/admin.html @@ -1,8 +1,8 @@ <!DOCTYPE html> <html lang="fr"> <head> - <meta charset="UTF-8" /> - <meta name="viewport" content="width=device-width, initial-scale=1" /> + <meta charset="UTF-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Administration - Gestion des Articles</title> <style> /* Réinitialisation des styles */ @@ -18,14 +18,14 @@ /* Bandeau en fond blanc */ header { - background: white; - width: 100%; + background: white; /* Fond blanc */ + width: 100%; /* S'étend sur toute la largeur */ border-bottom: 1px solid #eaeaea; - padding: 10px 0; + padding: 10px 0; /* Espacement vertical */ display: flex; - justify-content: space-between; + justify-content: space-between; /* Espacement entre le logo et le menu */ align-items: center; - padding-left: 20px; + padding-left: 20px; /* Espacement à gauche pour le logo */ } .logo { @@ -41,10 +41,10 @@ nav { display: flex; - justify-content: center; - gap: 20px; - flex-grow: 1; - text-align: center; + justify-content: center; /* Centre le contenu horizontalement */ + gap: 20px; /* Espace entre les liens */ + flex-grow: 1; /* Permet au nav de prendre toute la largeur restante */ + text-align: center; /* Centre le texte des liens */ } nav a { @@ -75,7 +75,7 @@ margin-bottom: 20px; } - /* Styles du formulaire */ + /* Style pour le formulaire */ form { margin-bottom: 30px; display: flex; @@ -91,7 +91,6 @@ form input, form textarea { border: 1px solid #ccc; border-radius: 5px; - width: 100%; } form button { @@ -101,14 +100,13 @@ border-radius: 5px; cursor: pointer; width: 150px; - align-self: flex-start; } form button:hover { background: #005bb5; } - /* Styles de la liste */ + /* Liste des articles */ .article-list { list-style: none; padding: 0; @@ -126,22 +124,22 @@ border-bottom: none; } - .article-list button { + .delete-link { background: #d9534f; color: white; border: none; border-radius: 5px; padding: 5px 10px; + text-decoration: none; cursor: pointer; } - .article-list button:hover { + .delete-link:hover { background: #c9302c; } </style> </head> <body> - <header> <div class="logo"> <!-- Remplacez l'URL ci-dessous par celle de votre logo --> @@ -156,84 +154,27 @@ <main> <h1>Gestion des Articles</h1> - <!-- Formulaire pour ajouter un nouvel article --> - <!-- (en front uniquement, pas d'envoi réel à un back-end dans cet exemple) --> - <form id="add-article-form"> - <input type="text" id="article-title" placeholder="Titre de l'article" required /> - <textarea id="article-description" placeholder="Description de l'article" required></textarea> - <input type="number" step="0.01" id="article-price" placeholder="Prix de l'article (€)" required /> + <!-- Formulaire pour ajouter un nouvel article (envoyé en POST) --> + <form method="POST" action="{{ url_for('admin') }}"> + <input type="text" name="title" placeholder="Titre de l'article" required> + <textarea name="description" placeholder="Description de l'article" required></textarea> + <input type="number" step="0.01" name="price" placeholder="Prix de l'article (€)" required> <button type="submit">Ajouter</button> </form> - <!-- Liste des articles ajoutés --> - <ul class="article-list" id="article-list"></ul> + <!-- Liste des articles --> + <ul class="article-list"> + {% for article in articles %} + <li> + <div> + <strong>{{ article.title }}</strong> – {{ article.price }} €<br> + {{ article.description }} + </div> + <!-- Lien de suppression --> + <a class="delete-link" href="{{ url_for('delete_article', article_id=article.id) }}">Supprimer</a> + </li> + {% endfor %} + </ul> </main> - - <script> - // Tableau qui stocke nos articles temporairement - const articles = []; - - // Fonction pour réafficher la liste complète - function renderArticles() { - const articleList = document.getElementById('article-list'); - // On vide la liste avant de la reconstruire - articleList.innerHTML = ''; - - // Pour chaque article du tableau, on crée un <li> et on l'ajoute - articles.forEach((article, index) => { - const li = document.createElement('li'); - li.innerHTML = ` - <div> - <strong>${article.title}</strong> - ${article.price} €<br> - ${article.description} - </div> - <button onclick="deleteArticle(${index})">Supprimer</button> - `; - articleList.appendChild(li); - }); - } - - // Supprimer un article en cliquant sur "Supprimer" - function deleteArticle(index) { - if (confirm('Voulez-vous vraiment supprimer cet article ?')) { - articles.splice(index, 1); // Retire l'article du tableau - renderArticles(); // Mets à jour l'affichage - } - } - - // Gestionnaire du formulaire : ajouter un nouvel article - document.getElementById('add-article-form').addEventListener('submit', function (e) { - e.preventDefault(); - - const titleField = document.getElementById('article-title'); - const descField = document.getElementById('article-description'); - const priceField = document.getElementById('article-price'); - - const title = titleField.value.trim(); - const description = descField.value.trim(); - const price = parseFloat(priceField.value); - - // Petite vérification - if (!title || !description || isNaN(price)) { - alert('Veuillez remplir tous les champs correctement.'); - return; - } - - // Ajout dans le tableau - articles.push({ title, description, price }); - - // Réaffiche la liste mise à jour - renderArticles(); - - // Réinitialise les champs - titleField.value = ''; - descField.value = ''; - priceField.value = ''; - }); - - // Initialisation : on affiche la liste (vide) au chargement - renderArticles(); - </script> - </body> </html> diff --git a/templates/ePhone16ProMax.html b/templates/ePhone16ProMax.html index e9530828f21e9f4bb51245794d96ccd79f9bf22f..0927552924a06a9e2507267dbc04dd2968da64d9 100644 --- a/templates/ePhone16ProMax.html +++ b/templates/ePhone16ProMax.html @@ -105,7 +105,8 @@ <h1>ePhone 16 Pro Max</h1> <div class="details"> <img src="https://store.storeimages.cdn-apple.com/4668/as-images.apple.com/is/iphone16pro-digitalmat-gallery-3-202409?wid=728&hei=666&fmt=p-jpg&qlt=95&.v=1723843057832" alt="ePhone 16 Pro Max"> - <p>Découvrez l'ePhone 16 Pro Max, un smartphone révolutionnaire avec des fonctionnalités haut de gamme : un écran OLED 6,7 pouces, un processeur A15 Bionic, un appareil photo de 108 MP, et bien plus encore.</p> + <p>Découvrez l'ePhone 16 Pro Max, un smartphone révolutionnaire avec des fonctionnalités haut de gamme : + écran OLED 6,7 pouces, processeur A15 Bionic, appareil photo de 108 MP, et plus encore.</p> </div> <div class="price"> @@ -114,27 +115,20 @@ <div class="form-container"> <h2>Acheter maintenant</h2> - <form id="purchase-form"> - <input type="email" id="user-email" placeholder="Votre adresse email" required> + + <!-- Formulaire POST vers une route "purchase_ephone" (à adapter) --> + <form method="POST" action="{{ url_for('purchase_ephone') }}"> + <!-- Email de l'utilisateur --> + <input type="email" name="user_email" placeholder="Votre adresse email" required> + + <!-- Champ caché pour le prix, ou éventuellement un identifiant de produit --> + <input type="hidden" name="price" value="900"> + <input type="hidden" name="product_name" value="ePhone 16 Pro Max"> + <button type="submit">Acheter</button> </form> </div> </main> - <script> - document.getElementById('purchase-form').addEventListener('submit', function (e) { - e.preventDefault(); - const email = document.getElementById('user-email').value; - const price = '900 €'; - - // Vérification de l'email - if (email) { - // Envoi d'une confirmation (simulé) - alert(`Confirmation d'achat envoyée à ${email}.\nPrix : ${price}`); - } else { - alert('Veuillez saisir une adresse email valide.'); - } - }); - </script> </body> </html> diff --git a/terraform_VPC/.terraform.lock.hcl b/terraform_VPC/.terraform.lock.hcl new file mode 100644 index 0000000000000000000000000000000000000000..b3226c1f2df567f98c49e85072b352d18f265567 --- /dev/null +++ b/terraform_VPC/.terraform.lock.hcl @@ -0,0 +1,25 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.84.0" + constraints = "~> 5.0" + hashes = [ + "h1:dwpeFUdcxgXVAc0JSqO57xf0/r2qOBLPloombCQWFz8=", + "zh:078f77438aba6ec8bf9154b7d223e5c71c48d805d6cd3bcf9db0cc1e82668ac3", + "zh:1f6591ff96be00501e71b792ed3a5a14b21ff03afec9a1c4a3fd9300e6e5b674", + "zh:2ab694e022e81dd74485351c5836148a842ed71cf640664c9d871cb517b09602", + "zh:33c8ccb6e3dc496e828a7572dd981366c6271075c1189f249b9b5236361d7eff", + "zh:6f31068ebad1d627e421c72ccdaafe678c53600ca73714e977bf45ff43ae5d17", + "zh:7488623dccfb639347cae66f9001d39cf06b92e8081975235a1ac3a0ac3f44aa", + "zh:7f042b78b9690a8725c95b91a70fc8e264011b836605bcc342ac297b9ea3937d", + "zh:88b56ac6c7209dc0a775b79975a371918f3aed8f015c37d5899f31deff37c61a", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:a1979ba840d704af0932f8de5f541cbb4caa9b6bbd25ed552a24e6772175ba07", + "zh:b058c0533dae580e69d1adbc1f69e6a80632374abfc10e8634d06187a108e87b", + "zh:c88610af9cf957f8dcf4382e0c9ca566ef10e3290f5de01d4d90b2d81b078aa8", + "zh:e9562c055a2247d0c287772b55abef468c79f8d66a74780fe1c5e5dae1a284a9", + "zh:f7a7c71d28441d925a25c08c4485c015b2d9f0338bc9707443e91ff8e161d3d9", + "zh:fee533e81976d0900aa6fa443dc54ef171cbd901847f28a6e8edb1d161fa6fde", + ] +} diff --git a/terraform_VPC/.terraform/environment b/terraform_VPC/.terraform/environment new file mode 100644 index 0000000000000000000000000000000000000000..4a90a52a175b3933cf230ad3564e259f64c99a0c --- /dev/null +++ b/terraform_VPC/.terraform/environment @@ -0,0 +1 @@ +DEV \ No newline at end of file diff --git a/terraform_VPC/.terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/linux_amd64/LICENSE.txt b/terraform_VPC/.terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/linux_amd64/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..b9ac071eb6387e85c6e4d5df995839696db0e513 --- /dev/null +++ b/terraform_VPC/.terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/linux_amd64/LICENSE.txt @@ -0,0 +1,375 @@ +Copyright (c) 2017 HashiCorp, Inc. + +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/terraform_VPC/.terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/linux_amd64/terraform-provider-aws_v5.84.0_x5 b/terraform_VPC/.terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/linux_amd64/terraform-provider-aws_v5.84.0_x5 new file mode 100755 index 0000000000000000000000000000000000000000..a23e6eb8203a0cb13136e969b4cbd731e7291a2f Binary files /dev/null and b/terraform_VPC/.terraform/providers/registry.terraform.io/hashicorp/aws/5.84.0/linux_amd64/terraform-provider-aws_v5.84.0_x5 differ diff --git a/terraform_VPC/hugo_kenneth.tfplan b/terraform_VPC/hugo_kenneth.tfplan new file mode 100644 index 0000000000000000000000000000000000000000..4fca9ceac0fe911cade72d946a1e4ac31edc00ca Binary files /dev/null and b/terraform_VPC/hugo_kenneth.tfplan differ diff --git a/terraform_VPC/main.tf b/terraform_VPC/main.tf new file mode 100644 index 0000000000000000000000000000000000000000..05bba4145ca93c94f82c2e597095d6cc1b7cbbe3 --- /dev/null +++ b/terraform_VPC/main.tf @@ -0,0 +1,234 @@ +#################################### +# Provider +#################################### +provider "aws" { + region = "eu-west-3" +} + +#################################### +# Variables et Locals +#################################### +variable "identifiant" { + description = "Votre identifiant" + default = "KENNETHHUGO" +} + +# Pour autoriser l'accès depuis votre IP locale (facultatif) +variable "my_ip" { + description = "Votre IP publique pour test (CIDR)" + default = "0.0.0.0/0" +} + +data "aws_availability_zones" "available" { + state = "available" +} + +# On utilise les Workspaces (DEV, PRD) et on associe chaque env à une plage CIDR +locals { + address_spaces = { + DEV = "10.0.35.0/24" + PRD = "10.0.36.0/24" + } + # Sélectionne la plage CIDR en fonction du workspace actif (DEV ou PRD) + address_space = local.address_spaces[terraform.workspace] +} + +#################################### +# VPC existante +#################################### +data "aws_vpc" "this" { + filter { + name = "tag:Name" + values = ["VPC"] + } +} + +#################################### +# Subnets (A et B) - 2 AZ différentes +#################################### +resource "aws_subnet" "private_subnet_a" { + vpc_id = data.aws_vpc.this.id + cidr_block = "10.0.35.0/24" # 1er bloc + availability_zone = data.aws_availability_zones.available.names[0] + map_public_ip_on_launch = true + + tags = { + Name = upper("${var.identifiant}_${terraform.workspace}_PRIVATE_SUBNET_A") + } +} + +resource "aws_subnet" "private_subnet_b" { + vpc_id = data.aws_vpc.this.id + cidr_block = "10.0.36.0/24" # 2e bloc + availability_zone = data.aws_availability_zones.available.names[1] + map_public_ip_on_launch = true + + tags = { + Name = upper("${var.identifiant}_${terraform.workspace}_PRIVATE_SUBNET_B") + } +} + +#################################### +# Security Groups +#################################### + +# SG Client : autorise HTTP (port 80) depuis Internet +resource "aws_security_group" "sg_client" { + name = upper("${var.identifiant}_${terraform.workspace}_SG_CLIENT") + vpc_id = data.aws_vpc.this.id + + ingress { + description = "Allow HTTP from anywhere" + from_port = 80 + to_port = 80 + protocol = "tcp" + cidr_blocks = [var.my_ip] + # var.my_ip = "0.0.0.0/0" par défaut, ou votre IP + } + + # Autorise tout en sortie + egress { + from_port = 0 + to_port = 0 + protocol = -1 + cidr_blocks = ["0.0.0.0/0"] + } + + tags = { + Name = upper("${var.identifiant}_${terraform.workspace}_SG_CLIENT") + } +} + +# SG API : autorise le port 5000 depuis SG_CLIENT +resource "aws_security_group" "sg_api" { + name = upper("${var.identifiant}_${terraform.workspace}_SG_API") + vpc_id = data.aws_vpc.this.id + + ingress { + description = "Allow API requests from client" + from_port = 5000 + to_port = 5000 + protocol = "tcp" + security_groups = [aws_security_group.sg_client.id] + } + + egress { + from_port = 0 + to_port = 0 + protocol = -1 + cidr_blocks = ["0.0.0.0/0"] + } + + tags = { + Name = upper("${var.identifiant}_${terraform.workspace}_SG_API") + } +} + +# SG RDS : autorise le port 5432 depuis SG_API +resource "aws_security_group" "sg_rds" { + name = upper("${var.identifiant}_${terraform.workspace}_SG_RDS") + vpc_id = data.aws_vpc.this.id + + ingress { + description = "Allow Postgres from API" + from_port = 5432 + to_port = 5432 + protocol = "tcp" + security_groups = [aws_security_group.sg_api.id] + } + + egress { + from_port = 0 + to_port = 0 + protocol = -1 + cidr_blocks = ["0.0.0.0/0"] + } + + tags = { + Name = upper("${var.identifiant}_${terraform.workspace}_SG_RDS") + } +} + +#################################### +# Instances EC2 : Client et API +#################################### + +# AMI Amazon Linux 2 (la plus récente) +data "aws_ami" "amazon_linux_2" { + most_recent = true + + filter { + name = "owner-alias" + values = ["amazon"] + } + + filter { + name = "name" + values = ["amzn2-ami-hvm*"] + } +} + +# Instance "Client" +resource "aws_instance" "client" { + ami = data.aws_ami.amazon_linux_2.id + instance_type = "t2.micro" + + # On la met, par exemple, dans le subnet A + subnet_id = aws_subnet.private_subnet_a.id + vpc_security_group_ids = [aws_security_group.sg_client.id] + + tags = { + Name = upper("${var.identifiant}_${terraform.workspace}_CLIENT_VM") + } +} + +# Instance "API" +resource "aws_instance" "api" { + ami = data.aws_ami.amazon_linux_2.id + instance_type = "t2.micro" + + # On peut la mettre aussi dans le subnet A (ou B, au choix) + subnet_id = aws_subnet.private_subnet_a.id + vpc_security_group_ids = [aws_security_group.sg_api.id] + + tags = { + Name = upper("${var.identifiant}_${terraform.workspace}_API_VM") + } +} + +#################################### +# RDS : Subnet Group + Instance +#################################### + +resource "aws_db_subnet_group" "this" { + name = lower("${var.identifiant}_${terraform.workspace}_rds_subnet_group") + # RDS exige au moins 2 subnets dans 2 AZ différentes + subnet_ids = [ + aws_subnet.private_subnet_a.id, + aws_subnet.private_subnet_b.id + ] + + tags = { + Name = upper("${var.identifiant}_${terraform.workspace}_RDS_SUBNET_GROUP") + } +} + +/* +resource "aws_db_instance" "mydb" { + allocated_storage = 5 + engine = "postgres" + engine_version = "14.15" + instance_class = "db.t2.micro" + username = "postgres" + password = "mysecretpassword" + skip_final_snapshot = true + db_subnet_group_name = aws_db_subnet_group.this.name + + # Attache la DB au SG RDS (port 5432) + vpc_security_group_ids = [aws_security_group.sg_rds.id] + + tags = { + Name = upper("${var.identifiant}_${terraform.workspace}_RDS_INSTANCE") + } +} +*/ \ No newline at end of file diff --git a/terraform_VPC/terraform.tfstate.d/DEV/terraform.tfstate b/terraform_VPC/terraform.tfstate.d/DEV/terraform.tfstate new file mode 100644 index 0000000000000000000000000000000000000000..ecd8bea64ef5afe5cc3a2b3c2902ea9241550c10 --- /dev/null +++ b/terraform_VPC/terraform.tfstate.d/DEV/terraform.tfstate @@ -0,0 +1,780 @@ +{ + "version": 4, + "terraform_version": "1.10.5", + "serial": 49, + "lineage": "eded4345-a67f-9a4a-9ad8-c68c205f47c2", + "outputs": {}, + "resources": [ + { + "mode": "data", + "type": "aws_ami", + "name": "amazon_linux_2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "architecture": "x86_64", + "arn": "arn:aws:ec2:eu-west-3::image/ami-03f3bb80e24b71cd8", + "block_device_mappings": [ + { + "device_name": "/dev/xvda", + "ebs": { + "delete_on_termination": "true", + "encrypted": "false", + "iops": "0", + "snapshot_id": "snap-07655f7a65903bcc5", + "throughput": "0", + "volume_size": "8", + "volume_type": "gp2" + }, + "no_device": "", + "virtual_name": "" + } + ], + "boot_mode": "", + "creation_date": "2025-01-23T03:26:36.000Z", + "deprecation_time": "2025-07-01T00:00:00.000Z", + "description": "Amazon Linux 2 AMI 2.0.20250123.4 x86_64 HVM gp2", + "ena_support": true, + "executable_users": null, + "filter": [ + { + "name": "name", + "values": [ + "amzn2-ami-hvm*" + ] + }, + { + "name": "owner-alias", + "values": [ + "amazon" + ] + } + ], + "hypervisor": "xen", + "id": "ami-03f3bb80e24b71cd8", + "image_id": "ami-03f3bb80e24b71cd8", + "image_location": "amazon/amzn2-ami-hvm-2.0.20250123.4-x86_64-gp2", + "image_owner_alias": "amazon", + "image_type": "machine", + "imds_support": "", + "include_deprecated": false, + "kernel_id": "", + "most_recent": true, + "name": "amzn2-ami-hvm-2.0.20250123.4-x86_64-gp2", + "name_regex": null, + "owner_id": "137112412989", + "owners": null, + "platform": "", + "platform_details": "Linux/UNIX", + "product_codes": [], + "public": true, + "ramdisk_id": "", + "root_device_name": "/dev/xvda", + "root_device_type": "ebs", + "root_snapshot_id": "snap-07655f7a65903bcc5", + "sriov_net_support": "simple", + "state": "available", + "state_reason": { + "code": "UNSET", + "message": "UNSET" + }, + "tags": {}, + "timeouts": null, + "tpm_support": "", + "uefi_data": null, + "usage_operation": "RunInstances", + "virtualization_type": "hvm" + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "data", + "type": "aws_availability_zones", + "name": "available", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "all_availability_zones": null, + "exclude_names": null, + "exclude_zone_ids": null, + "filter": null, + "group_names": [ + "eu-west-3-zg-1" + ], + "id": "eu-west-3", + "names": [ + "eu-west-3a", + "eu-west-3b", + "eu-west-3c" + ], + "state": "available", + "timeouts": null, + "zone_ids": [ + "euw3-az1", + "euw3-az2", + "euw3-az3" + ] + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "data", + "type": "aws_vpc", + "name": "this", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ec2:eu-west-3:920373009484:vpc/vpc-08da87242304c9723", + "cidr_block": "10.0.0.0/16", + "cidr_block_associations": [ + { + "association_id": "vpc-cidr-assoc-0fd519069ef9f4ba9", + "cidr_block": "10.0.0.0/16", + "state": "associated" + } + ], + "default": false, + "dhcp_options_id": "dopt-06fac3b0fae017c99", + "enable_dns_hostnames": false, + "enable_dns_support": true, + "enable_network_address_usage_metrics": false, + "filter": [ + { + "name": "tag:Name", + "values": [ + "VPC" + ] + } + ], + "id": "vpc-08da87242304c9723", + "instance_tenancy": "default", + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "main_route_table_id": "rtb-06b8cc99d46258d59", + "owner_id": "920373009484", + "state": null, + "tags": { + "Name": "VPC" + }, + "timeouts": null + }, + "sensitive_attributes": [] + } + ] + }, + { + "mode": "managed", + "type": "aws_db_subnet_group", + "name": "this", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:rds:eu-west-3:920373009484:subgrp:kennethhugo_dev_rds_subnet_group", + "description": "Managed by Terraform", + "id": "kennethhugo_dev_rds_subnet_group", + "name": "kennethhugo_dev_rds_subnet_group", + "name_prefix": "", + "subnet_ids": [ + "subnet-0957b7b385c51777e", + "subnet-0c577eaec9d03cdd1" + ], + "supported_network_types": [ + "IPV4" + ], + "tags": { + "Name": "KENNETHHUGO_DEV_RDS_SUBNET_GROUP" + }, + "tags_all": { + "Name": "KENNETHHUGO_DEV_RDS_SUBNET_GROUP" + }, + "vpc_id": "vpc-08da87242304c9723" + }, + "sensitive_attributes": [], + "private": "bnVsbA==", + "dependencies": [ + "aws_subnet.private_subnet_a", + "aws_subnet.private_subnet_b", + "data.aws_availability_zones.available", + "data.aws_vpc.this" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "api", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-03f3bb80e24b71cd8", + "arn": "arn:aws:ec2:eu-west-3:920373009484:instance/i-07e4e3764075819d1", + "associate_public_ip_address": true, + "availability_zone": "eu-west-3a", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 1 + } + ], + "cpu_threads_per_core": 1, + "credit_specification": [ + { + "cpu_credits": "standard" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enable_primary_ipv6": null, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-07e4e3764075819d1", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t2.micro", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-001db229f5297a2b7", + "private_dns": "ip-10-0-35-13.eu-west-3.compute.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "10.0.35.13", + "public_dns": "", + "public_ip": "51.44.12.205", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/xvda", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "tags_all": {}, + "throughput": 0, + "volume_id": "vol-02352fdccdee278c6", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-0957b7b385c51777e", + "tags": { + "Name": "KENNETHHUGO_DEV_API_VM" + }, + "tags_all": { + "Name": "KENNETHHUGO_DEV_API_VM" + }, + "tenancy": "default", + "timeouts": null, + "user_data": null, + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-0f9191c45d7ffe841" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwicmVhZCI6OTAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_security_group.sg_api", + "aws_security_group.sg_client", + "aws_subnet.private_subnet_a", + "data.aws_ami.amazon_linux_2", + "data.aws_availability_zones.available", + "data.aws_vpc.this" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "client", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-03f3bb80e24b71cd8", + "arn": "arn:aws:ec2:eu-west-3:920373009484:instance/i-0714a2da363e2d1f4", + "associate_public_ip_address": true, + "availability_zone": "eu-west-3a", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 1 + } + ], + "cpu_threads_per_core": 1, + "credit_specification": [ + { + "cpu_credits": "standard" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enable_primary_ipv6": null, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-0714a2da363e2d1f4", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t2.micro", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-0dbed98fe271c8c56", + "private_dns": "ip-10-0-35-14.eu-west-3.compute.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "10.0.35.14", + "public_dns": "", + "public_ip": "15.237.217.243", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/xvda", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "tags_all": {}, + "throughput": 0, + "volume_id": "vol-03bb498cd1c279046", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-0957b7b385c51777e", + "tags": { + "Name": "KENNETHHUGO_DEV_CLIENT_VM" + }, + "tags_all": { + "Name": "KENNETHHUGO_DEV_CLIENT_VM" + }, + "tenancy": "default", + "timeouts": null, + "user_data": null, + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-0e112008f976bb487" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwicmVhZCI6OTAwMDAwMDAwMDAwLCJ1cGRhdGUiOjYwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_security_group.sg_client", + "aws_subnet.private_subnet_a", + "data.aws_ami.amazon_linux_2", + "data.aws_availability_zones.available", + "data.aws_vpc.this" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_security_group", + "name": "sg_api", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:eu-west-3:920373009484:security-group/sg-0f9191c45d7ffe841", + "description": "Managed by Terraform", + "egress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 0, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "-1", + "security_groups": [], + "self": false, + "to_port": 0 + } + ], + "id": "sg-0f9191c45d7ffe841", + "ingress": [ + { + "cidr_blocks": [], + "description": "Allow API requests from client", + "from_port": 5000, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [ + "sg-0e112008f976bb487" + ], + "self": false, + "to_port": 5000 + } + ], + "name": "KENNETHHUGO_DEV_SG_API", + "name_prefix": "", + "owner_id": "920373009484", + "revoke_rules_on_delete": false, + "tags": { + "Name": "KENNETHHUGO_DEV_SG_API" + }, + "tags_all": { + "Name": "KENNETHHUGO_DEV_SG_API" + }, + "timeouts": null, + "vpc_id": "vpc-08da87242304c9723" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", + "dependencies": [ + "aws_security_group.sg_client", + "data.aws_vpc.this" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_security_group", + "name": "sg_client", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:eu-west-3:920373009484:security-group/sg-0e112008f976bb487", + "description": "Managed by Terraform", + "egress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 0, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "-1", + "security_groups": [], + "self": false, + "to_port": 0 + } + ], + "id": "sg-0e112008f976bb487", + "ingress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "Allow HTTP from anywhere", + "from_port": 80, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 80 + } + ], + "name": "KENNETHHUGO_DEV_SG_CLIENT", + "name_prefix": "", + "owner_id": "920373009484", + "revoke_rules_on_delete": false, + "tags": { + "Name": "KENNETHHUGO_DEV_SG_CLIENT" + }, + "tags_all": { + "Name": "KENNETHHUGO_DEV_SG_CLIENT" + }, + "timeouts": null, + "vpc_id": "vpc-08da87242304c9723" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", + "dependencies": [ + "data.aws_vpc.this" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_security_group", + "name": "sg_rds", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:eu-west-3:920373009484:security-group/sg-0c35a964669183e38", + "description": "Managed by Terraform", + "egress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 0, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "-1", + "security_groups": [], + "self": false, + "to_port": 0 + } + ], + "id": "sg-0c35a964669183e38", + "ingress": [ + { + "cidr_blocks": [], + "description": "Allow Postgres from API", + "from_port": 5432, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [ + "sg-0f9191c45d7ffe841" + ], + "self": false, + "to_port": 5432 + } + ], + "name": "KENNETHHUGO_DEV_SG_RDS", + "name_prefix": "", + "owner_id": "920373009484", + "revoke_rules_on_delete": false, + "tags": { + "Name": "KENNETHHUGO_DEV_SG_RDS" + }, + "tags_all": { + "Name": "KENNETHHUGO_DEV_SG_RDS" + }, + "timeouts": null, + "vpc_id": "vpc-08da87242304c9723" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", + "dependencies": [ + "aws_security_group.sg_api", + "aws_security_group.sg_client", + "data.aws_vpc.this" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_subnet", + "name": "private_subnet_a", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:eu-west-3:920373009484:subnet/subnet-0957b7b385c51777e", + "assign_ipv6_address_on_creation": false, + "availability_zone": "eu-west-3a", + "availability_zone_id": "euw3-az1", + "cidr_block": "10.0.35.0/24", + "customer_owned_ipv4_pool": "", + "enable_dns64": false, + "enable_lni_at_device_index": 0, + "enable_resource_name_dns_a_record_on_launch": false, + "enable_resource_name_dns_aaaa_record_on_launch": false, + "id": "subnet-0957b7b385c51777e", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "ipv6_native": false, + "map_customer_owned_ip_on_launch": false, + "map_public_ip_on_launch": true, + "outpost_arn": "", + "owner_id": "920373009484", + "private_dns_hostname_type_on_launch": "ip-name", + "tags": { + "Name": "KENNETHHUGO_DEV_PRIVATE_SUBNET_A" + }, + "tags_all": { + "Name": "KENNETHHUGO_DEV_PRIVATE_SUBNET_A" + }, + "timeouts": null, + "vpc_id": "vpc-08da87242304c9723" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "data.aws_availability_zones.available", + "data.aws_vpc.this" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_subnet", + "name": "private_subnet_b", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"]", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:eu-west-3:920373009484:subnet/subnet-0c577eaec9d03cdd1", + "assign_ipv6_address_on_creation": false, + "availability_zone": "eu-west-3b", + "availability_zone_id": "euw3-az2", + "cidr_block": "10.0.36.0/24", + "customer_owned_ipv4_pool": "", + "enable_dns64": false, + "enable_lni_at_device_index": 0, + "enable_resource_name_dns_a_record_on_launch": false, + "enable_resource_name_dns_aaaa_record_on_launch": false, + "id": "subnet-0c577eaec9d03cdd1", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "ipv6_native": false, + "map_customer_owned_ip_on_launch": false, + "map_public_ip_on_launch": true, + "outpost_arn": "", + "owner_id": "920373009484", + "private_dns_hostname_type_on_launch": "ip-name", + "tags": { + "Name": "KENNETHHUGO_DEV_PRIVATE_SUBNET_B" + }, + "tags_all": { + "Name": "KENNETHHUGO_DEV_PRIVATE_SUBNET_B" + }, + "timeouts": null, + "vpc_id": "vpc-08da87242304c9723" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "data.aws_availability_zones.available", + "data.aws_vpc.this" + ] + } + ] + } + ], + "check_results": null +} diff --git a/terraform_VPC/terraform.tfstate.d/DEV/terraform.tfstate.backup b/terraform_VPC/terraform.tfstate.d/DEV/terraform.tfstate.backup new file mode 100644 index 0000000000000000000000000000000000000000..ae93bebbc545d427d8862dd02dab71116c61735f --- /dev/null +++ b/terraform_VPC/terraform.tfstate.d/DEV/terraform.tfstate.backup @@ -0,0 +1,9 @@ +{ + "version": 4, + "terraform_version": "1.10.5", + "serial": 40, + "lineage": "eded4345-a67f-9a4a-9ad8-c68c205f47c2", + "outputs": {}, + "resources": [], + "check_results": null +}