From f69671bd86f03acad9ddf926911e739fdda99870 Mon Sep 17 00:00:00 2001 From: Roman Mazur Date: Wed, 25 Oct 2023 21:16:50 +0200 Subject: [PATCH] infra: Fix deployment issues --- infra/deployment/deploy.sh | 4 ++++ infra/deployment/infra.cue | 9 ++++++++- infra/deployment/requirements.cue | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/infra/deployment/deploy.sh b/infra/deployment/deploy.sh index f02f6d8..cae1437 100755 --- a/infra/deployment/deploy.sh +++ b/infra/deployment/deploy.sh @@ -4,4 +4,8 @@ set -e cd out +if [ "$1" == "destroy" ]; then + terraform destroy --auto-approve && exit 0 +fi + terraform apply deploy-plan diff --git a/infra/deployment/infra.cue b/infra/deployment/infra.cue index 4a81d2f..ef16f9c 100644 --- a/infra/deployment/infra.cue +++ b/infra/deployment/infra.cue @@ -13,6 +13,8 @@ terraform: { ami: "${data.aws_ami.poll_server_ami.id}" instance_type: awsInstanceType.name tags: Name: "pollsvc server" + associate_public_ip_address: false + user_data: """ #!/bin/bash @@ -38,6 +40,11 @@ terraform: { """ } + resource: aws_eip: poll_server_ip: { + instance: "${aws_instance.poll_server.id}" + domain: "vpc" + } + data: aws_ami: poll_server_ami: { most_recent: true @@ -53,7 +60,7 @@ terraform: { resource: cloudflare_record: poll_server: { zone_id: "d383a7704b48586d1bc8c2f949712e28" name: "poll" - value: "${aws_instance.poll_server.public_ip}" + value: "${aws_eip.poll_server_ip.public_ip}" type: "A" ttl: 1 proxied: true diff --git a/infra/deployment/requirements.cue b/infra/deployment/requirements.cue index ea9aeea..76ce0c5 100644 --- a/infra/deployment/requirements.cue +++ b/infra/deployment/requirements.cue @@ -24,7 +24,7 @@ pollSvc: { Restart=always RestartSec=1 User=root - ExecStart=\(installPath) --addr=:443 --tls=\(certPath) + ExecStart=\(installPath) --addr=:443 --tls=\(certPath) --admin-secret="\(inputs.admin.secret)" [Install] WantedBy=multi-user.target