mirror of
https://github.com/mr-vercetti/tf-aws-demo.git
synced 2025-07-01 12:35:33 +02:00
Initial commit
This commit is contained in:
46
prod/main.tf
Executable file
46
prod/main.tf
Executable file
@ -0,0 +1,46 @@
|
||||
provider "aws" {
|
||||
profile = "default"
|
||||
region = var.REGION
|
||||
}
|
||||
|
||||
# Create VPC with NAT Gateway and route tables
|
||||
module "vpc" {
|
||||
source = "terraform-aws-modules/vpc/aws"
|
||||
version = "3.14.2"
|
||||
|
||||
name = var.DEMO_VPC_NAME
|
||||
cidr = var.DEMO_VPC_CIDR
|
||||
|
||||
azs = var.DEMO_VPC_AVAILABILITY_ZONES
|
||||
private_subnets = var.DEMO_VPC_PRIVATE_SUBNET_CIDRS
|
||||
public_subnets = var.DEMO_VPC_PUBLIC_SUBNET_CIDRS
|
||||
|
||||
enable_nat_gateway = true
|
||||
single_nat_gateway = true
|
||||
one_nat_gateway_per_az = false
|
||||
|
||||
tags = {
|
||||
Terraform = "true"
|
||||
Project = var.PROJECT_TAG
|
||||
}
|
||||
}
|
||||
|
||||
# Get VPC data
|
||||
module "vpc_data" {
|
||||
depends_on = [module.vpc]
|
||||
source = "../modules/vpc_data"
|
||||
|
||||
VPC_NAME = var.DEMO_VPC_NAME
|
||||
BASTION_HOST_AZ = var.DEMO_BASTION_HOST_AZ
|
||||
}
|
||||
|
||||
# Create bastion host
|
||||
module "bastion_host" {
|
||||
source = "../modules/bastion_host"
|
||||
|
||||
VPC_ID = module.vpc_data.vpc.id
|
||||
SUBNET_ID = module.vpc_data.bastion_host_subnet.id
|
||||
INSTANCE_TYPE = var.DEMO_BASTION_HOST_TYPE
|
||||
INSTANCE_NAME = var.DEMO_BASTION_HOST_NAME
|
||||
KEY_NAME = var.DEMO_BASTION_HOST_KEY_NAME
|
||||
}
|
23
prod/outputs.tf
Executable file
23
prod/outputs.tf
Executable file
@ -0,0 +1,23 @@
|
||||
output "demo_vpc_id" {
|
||||
value = module.vpc_data.vpc.id
|
||||
}
|
||||
|
||||
output "public_subnets" {
|
||||
value = module.vpc_data.public_subnets.ids
|
||||
}
|
||||
|
||||
output "private_subnets" {
|
||||
value = module.vpc_data.private_subnets.ids
|
||||
}
|
||||
|
||||
output "demo_bastion_host_subnet_id" {
|
||||
value = module.vpc_data.bastion_host_subnet.id
|
||||
}
|
||||
|
||||
output "demo_bastion_host_private_ip" {
|
||||
value = module.bastion_host.bastion_host_private_ip
|
||||
}
|
||||
|
||||
output "demo_bastion_host_public_ip" {
|
||||
value = module.bastion_host.bastion_host_public_ip
|
||||
}
|
49
prod/variables.tf
Executable file
49
prod/variables.tf
Executable file
@ -0,0 +1,49 @@
|
||||
# General
|
||||
variable "REGION" {
|
||||
type = string
|
||||
default = "eu-west-3"
|
||||
}
|
||||
|
||||
variable "PROJECT_TAG" {
|
||||
type = string
|
||||
}
|
||||
|
||||
# DEMO_VPC (network, network_data)
|
||||
variable "DEMO_VPC_NAME" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "DEMO_VPC_CIDR" {
|
||||
type = string
|
||||
default = "10.0.0.0/24"
|
||||
}
|
||||
|
||||
variable "DEMO_VPC_AVAILABILITY_ZONES" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "DEMO_VPC_PRIVATE_SUBNET_CIDRS" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
variable "DEMO_VPC_PUBLIC_SUBNET_CIDRS" {
|
||||
type = list(string)
|
||||
}
|
||||
|
||||
# Bastion host (bastion_host)
|
||||
variable "DEMO_BASTION_HOST_TYPE" {
|
||||
type = string
|
||||
default = "t2.micro"
|
||||
}
|
||||
|
||||
variable "DEMO_BASTION_HOST_NAME" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "DEMO_BASTION_HOST_KEY_NAME" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "DEMO_BASTION_HOST_AZ" {
|
||||
type = string
|
||||
}
|
8
prod/versions.tf
Executable file
8
prod/versions.tf
Executable file
@ -0,0 +1,8 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
aws = {
|
||||
source = "hashicorp/aws"
|
||||
version = "~> 3"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user