From 43b2bbe03eb6e807524e86ba4a522ef038aac57f Mon Sep 17 00:00:00 2001 From: Pierre SARRET Date: Fri, 30 Jun 2023 22:24:02 +0200 Subject: [PATCH] Cleaning useless comments and debug comments --- main.tf | 23 ------ modules/deploy-ec2/main.tf | 101 +---------------------- modules/deploy-ec2/output.tf | 10 --- modules/deploy-ec2/variables.tf | 94 ---------------------- modules/deploy-s3-scaleway/main.tf | 2 +- output.tf | 10 +-- variables.tf | 124 ----------------------------- 7 files changed, 3 insertions(+), 361 deletions(-) diff --git a/main.tf b/main.tf index e9156fc..956b458 100644 --- a/main.tf +++ b/main.tf @@ -5,30 +5,7 @@ module "deploy-ec2" { ] source = "./modules/deploy-ec2" ssh_public_keys = var.ssh_public_keys - /* sg_name = var.sg_name - cidr_blocks_ingress = var.cidr_blocks_ingress - from_port_ingress = var.from_port_ingress - ipv6_cidr_blocks_ingress = var.ipv6_cidr_blocks_ingress - prefix_list_ids_ingress = var.prefix_list_ids_ingress - protocol_ingress = var.protocol_ingress - security_groups_ingress = var.security_groups_ingress - self_ingress = var.self_ingress - to_port_ingress = var.to_port_ingress - from_port_egress = var.from_port_egress - to_port_egress = var.to_port_egress - sg_egress_protocol = var.sg_egress_protocol - cidr_blocks_egress = var.cidr_blocks_egress - self_egress = var.self_egress - ipv6_cidr_blocks_egress = var.ipv6_cidr_blocks_egress - prefix_list_ids_egress = var.prefix_list_ids_egress - security_groups_egress = var.security_groups_egress */ ec2-config = var.ec2-config -# ami_id = var.ami_id - # ec2_instance_type = var.ec2_instance_type - # ec2_name = var.ec2_name - # ec2_name_storage = var.ec2_name_storage - # ec2_volume_size = var.ec2_volume_size - # ec2_volume_type = var.ec2_volume_type aws_session_token = var.aws_session_token aws_secret_access_key = var.aws_secret_access_key aws_access_key_id = var.aws_access_key_id diff --git a/modules/deploy-ec2/main.tf b/modules/deploy-ec2/main.tf index c93232b..42de13e 100644 --- a/modules/deploy-ec2/main.tf +++ b/modules/deploy-ec2/main.tf @@ -79,40 +79,6 @@ resource "aws_security_group" "ec2_sg" { } } - -/* resource "aws_security_group" "public-sg" { - - #description = "security group to allow incoming SSH connection to ec2 instance" - name = var.sg_name - vpc_id = aws_vpc.vpc.id - - ingress = [{ - cidr_blocks = var.cidr_blocks_ingress - description = "Allow SSH" - from_port = var.from_port_ingress - ipv6_cidr_blocks = var.ipv6_cidr_blocks_ingress - prefix_list_ids = var.prefix_list_ids_ingress - protocol = var.protocol_ingress - security_groups = var.security_groups_ingress - self = var.self_ingress - to_port = var.to_port_ingress - }] - - egress = [{ - description = "Allow connection to any internet service" - from_port = var.from_port_egress - to_port = var.to_port_egress - protocol = var.sg_egress_protocol - cidr_blocks = var.cidr_blocks_egress - self = var.self_egress - ipv6_cidr_blocks = var.ipv6_cidr_blocks_egress - prefix_list_ids = var.prefix_list_ids_egress - security_groups = var.security_groups_egress - - }] - -} */ - # EC2 locals { vars = { @@ -159,53 +125,8 @@ resource "aws_instance" "vm" { "Name" = each.key "DNS" = each.value.dns_name } - -// provisioner "local-exec" { -// command = "ansible-playbook -i \"${aws_instance.example.public_ip},\" -u ubuntu --private-key=~/.ssh/id_rsa playbook.yml --extra-vars '{\"variable1\":\"value1\", \"variable2\":\"value2\"}'" -// } -} - -## Dolibarr -/* resource "aws_instance" "ec2-dolibarr" { - ami = var.ami_id - name = "vm-${each.key}" - instance_type = var.ec2_instance_type - key_name = aws_key_pair.ssh-keys[0].key_name - subnet_id = aws_subnet.subnet.id - vpc_security_group_ids = [aws_security_group.ec2_sg["vm-dolibarr"].id] - user_data_replace_on_change = true # Destroy & Recreate on user_data change - associate_public_ip_address = true - root_block_device { - volume_size = var.ec2_volume_size - volume_type = var.ec2_volume_type - } - user_data = base64encode(templatefile("${path.module}/deploy-scripts/dolibarr.tftpl", local.vars)) - tags = { - "Name" = var.ec2_name - } - } -## Nextcloud -resource "aws_instance" "ec2-nextcloud" { - ami = var.ami_id - instance_type = var.ec2_instance_type - key_name = aws_key_pair.ssh-keys[0].key_name - subnet_id = aws_subnet.subnet.id - vpc_security_group_ids = [aws_security_group.ec2_sg["vm-nextcloud"].id] - user_data_replace_on_change = true # Destroy & Recreate on user_data change - associate_public_ip_address = true - root_block_device { - volume_size = var.ec2_volume_size - volume_type = var.ec2_volume_type - } - user_data = base64encode(templatefile("${path.module}/deploy-scripts/nextcloud.tftpl", local.vars)) - tags = { - "Name" = var.ec2_name_storage - } - -} */ - # EC2 DNS Entries resource "cloudflare_record" "cname" { for_each = aws_instance.vm @@ -216,24 +137,4 @@ resource "cloudflare_record" "cname" { type = "CNAME" ttl = 120 proxied = false -} - -/* -resource "cloudflare_record" "cname-dolibarr" { - zone_id = var.cloudflare_zone_id - name = "crm.transexpress.ovh" - value = "${aws_instance.ec2-dolibarr.public_dns}" - type = "CNAME" - ttl = 120 - proxied = false -} - -resource "cloudflare_record" "cname-nextcloud" { - zone_id = var.cloudflare_zone_id - name = "cloud.transexpress.ovh" - value = "${aws_instance.ec2-nextcloud.public_dns}" - type = "CNAME" - ttl = 120 - proxied = false -} -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/modules/deploy-ec2/output.tf b/modules/deploy-ec2/output.tf index 4b91019..412d4e8 100644 --- a/modules/deploy-ec2/output.tf +++ b/modules/deploy-ec2/output.tf @@ -1,6 +1,5 @@ output "vm-dns" { description = "Nom DNS public de nos EC2" - //value = aws_instance.ec2-nextcloud.public_dns value = { for instance in aws_instance.vm : instance.tags["Name"] => instance.public_dns } @@ -9,12 +8,3 @@ output "vm-dns" { output "ec2_instance_ids" { value = { for key, instance in aws_instance.vm : key => instance.id } } -# debug template -/* -output "rendered-tpl1" { - value = templatefile("${path.module}/deploy-scripts/dolibarr.sh", local.vars) -} - -output "rendered-tpl2" { - value = templatefile("${path.module}/deploy-scripts/nextcloud.sh", local.vars) -} */ diff --git a/modules/deploy-ec2/variables.tf b/modules/deploy-ec2/variables.tf index dc34335..684fddc 100644 --- a/modules/deploy-ec2/variables.tf +++ b/modules/deploy-ec2/variables.tf @@ -37,100 +37,6 @@ variable "ssh_public_keys" { type = list(string) } -# Security Group -/* -variable "sg_name" { - type = string - description = "name of security group" -} - - -# egress - -variable "sg_egress_protocol" { - - description = "Public ssh key to add on aws account" - type = string - -} - -variable "from_port_ingress" { - type = number -} - -variable "to_port_ingress" { - type = number -} - -variable "protocol_ingress" { - type = string -} - -variable "cidr_blocks_ingress" { - type = list(string) -} - -variable "ipv6_cidr_blocks_ingress" { - type = list(string) -} - -variable "prefix_list_ids_ingress" { - type = list(string) -} - -variable "security_groups_ingress" { - type = list(string) -} - -variable "self_ingress" { - type = bool -} - -# egress - -variable "from_port_egress" { - type = number -} - -variable "to_port_egress" { - type = number -} - -variable "ipv6_cidr_blocks_egress" { - type = list(string) -} - -variable "prefix_list_ids_egress" { - type = list(string) -} - -variable "cidr_blocks_egress" { - type = list(string) -} - -variable "self_egress" { - type = bool -} - -variable "security_groups_egress" { - type = list(string) -} - -variable "ami_id" {} -variable "ec2_instance_type" {} -variable "ec2_name" {} -variable "ec2_name_storage" {} - -variable "ec2_volume_size" { - description = "Volume size for EC2" - type = number -} -variable "ec2_volume_type" { - description = "Volume type for EC2" - type = string -} - -*/ variable "bucket_name" { description = "Name of Bucket S3" diff --git a/modules/deploy-s3-scaleway/main.tf b/modules/deploy-s3-scaleway/main.tf index 74f2959..39eea06 100644 --- a/modules/deploy-s3-scaleway/main.tf +++ b/modules/deploy-s3-scaleway/main.tf @@ -20,7 +20,7 @@ resource "scaleway_object_bucket" "main" { key = "bucket S3 - Projet" } } -#create me a output that show the bucket name for each bucket created + output "bucket_names" { value = scaleway_object_bucket.main } diff --git a/output.tf b/output.tf index dc32edf..283ecd3 100644 --- a/output.tf +++ b/output.tf @@ -1,12 +1,4 @@ output "vm-dns" { description = "Nom DNS public de nos EC2" value = "${module.deploy-ec2.vm-dns}" -} -# debug template -/* output "rendered-tpl1" { - value = "${module.deploy-ec2.rendered-tpl1}" -} - -output "rendered-tpl2" { - value = "${module.deploy-ec2.rendered-tpl2}" -} */ +} \ No newline at end of file diff --git a/variables.tf b/variables.tf index 55269a8..a37f3fe 100644 --- a/variables.tf +++ b/variables.tf @@ -36,130 +36,6 @@ variable "ssh_public_keys" { description = "List of public SSH keys to associate with the instance" type = list(string) } -/* -# Security Group - -variable "sg_name" { - type = string - description = "name of security group" -} - - -# egress - -variable "sg_egress_protocol" { - - description = "Public ssh key to add on aws account" - type = string - -} - -variable "from_port_ingress" { - description = "From port of ingress" - type = number -} - -variable "to_port_ingress" { - description = "To port of ingress" - type = number -} - -variable "protocol_ingress" { - description = "Protocol of ingress" - type = string -} - -variable "cidr_blocks_ingress" { - description = "CIDR blocks of ingress" - type = list(string) -} - -variable "ipv6_cidr_blocks_ingress" { - description = "IPv6 CIDR blocks of ingress" - type = list(string) -} - -variable "prefix_list_ids_ingress" { - description = "Prefix list IDs of ingress" - type = list(string) -} - -variable "security_groups_ingress" { - description = "Security groups of ingress" - type = list(string) -} - -variable "self_ingress" { - description = "Self of ingress" - type = bool -} - -# egress - -variable "from_port_egress" { - description = "From port of egress" - type = number -} - -variable "to_port_egress" { - description = "To port of egress" - type = number -} - -variable "ipv6_cidr_blocks_egress" { - description = "IPv6 CIDR blocks of egress" - type = list(string) -} - -variable "prefix_list_ids_egress" { - description = "Prefix list IDs of egress" - type = list(string) -} - -variable "cidr_blocks_egress" { - description = "CIDR blocks of egress" - type = list(string) -} - -variable "self_egress" { - description = "Self of egress" - type = bool -} - -variable "security_groups_egress" { - description = "Security groups of egress" - type = list(string) -} - -variable "ami_id" { - description = "AMI ID of the EC2 instance" - type = string -} -variable "ec2_instance_type" { - description = "Type of EC2 instance" - type = string -} -variable "ec2_name" { - description = "Name of EC2 instance" - type = string -} - -variable "ec2_name_storage" { - description = "Name of EC2 instance" - type = string -} - - -variable "ec2_volume_size" { - description = "Volume size for EC2" - type = number -} - -variable "ec2_volume_type" { - description = "Volume type for EC2" - type = string -} -*/ variable "mount_point" { description = "Mount point of Bucket S3 in EC2"