Skip to content

Commit

Permalink
Cleaning useless comments and debug comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DrumSlayers committed Jun 30, 2023
1 parent 02b410e commit 43b2bbe
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 361 deletions.
23 changes: 0 additions & 23 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
101 changes: 1 addition & 100 deletions modules/deploy-ec2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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
Expand All @@ -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
}
*/
}
10 changes: 0 additions & 10 deletions modules/deploy-ec2/output.tf
Original file line number Diff line number Diff line change
@@ -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
}
Expand All @@ -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)
} */
94 changes: 0 additions & 94 deletions modules/deploy-ec2/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion modules/deploy-s3-scaleway/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
10 changes: 1 addition & 9 deletions output.tf
Original file line number Diff line number Diff line change
@@ -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}"
} */
}
Loading

0 comments on commit 43b2bbe

Please sign in to comment.