Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
carlssonk committed Sep 26, 2024
1 parent f1d5e09 commit 6a2d36f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
4 changes: 2 additions & 2 deletions common/services/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ module "service_discovery_namespace" {
namespace_name = module.globals.var.organization
}

module "ec2_instance_nginx_proxy" {
module "ec2_instance_nginx" {
count = var.reverse_proxy_type == "nginx" ? 1 : 0
name = "nginx-reverse-proxy"
source = "../../modules/ec2-instance/default"
Expand Down Expand Up @@ -70,7 +70,7 @@ module "ec2_instance_nginx_proxy" {
module "ec2_instance_nginx_eip" {
count = var.reverse_proxy_type == "nginx" ? 1 : 0
source = "../../modules/elastic-ip/default"
instance_id = module.ec2_instance_nginx_proxy[0].id
instance_id = module.ec2_instance_nginx[0].id
}

module "main_alb_access_logs_bucket" {
Expand Down
19 changes: 7 additions & 12 deletions common/services/nginx_reverse_proxy.tpl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

#!/bin/bash

yum update -y
yum install -y nginx certbot python3-certbot-nginx
sudo yum update -y
sudo yum install -y nginx certbot python3-certbot-nginx

# Create nginx config
tee /etc/nginx/nginx.conf <<EOF
sudo tee /etc/nginx/nginx.conf <<EOF
events {
worker_connections 1024;
}
Expand Down Expand Up @@ -52,16 +52,11 @@ http {
EOF

# Obtain SSL certificate
certbot --nginx -d ${certbot_domains} --non-interactive --agree-tos -m [email protected]
sudo certbot --nginx -d ${certbot_domains} --non-interactive --agree-tos -m [email protected]

# Ensure Certbot auto-renewal is enabled
systemctl enable certbot.timer
systemctl start certbot.timer
sudo systemctl enable certbot.timer
sudo systemctl start certbot.timer

# Restart NGINX to apply changes
if systemctl is-active --quiet nginx; then
systemctl reload nginx
else
systemctl start nginx
systemctl enable nginx
fi
sudo systemctl restart nginx
2 changes: 1 addition & 1 deletion common/services/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
output "policy_documents" {
value = [
try(module.service_discovery_namespace[0].policy_document, null),
try(module.ec2_instance_nginx_proxy[0].policy_document, null),
try(module.ec2_instance_nginx[0].policy_document, null),
try(module.ec2_instance_nginx_eip[0].policy_document, null),
try(module.main_alb[0].policy_document, null),
try(module.main_alb_access_logs_bucket[0].policy_document, null),
Expand Down

0 comments on commit 6a2d36f

Please sign in to comment.