seqeralabs / terraform-seqera-aws

Apache License 2.0
5 stars 3 forks source link

Add optional dump of Terraform outputs to a local file #23

Closed pditommaso closed 10 months ago

pditommaso commented 10 months ago

For the sake of the automation of the Ec2 deployment it would be usual to add in the terraform script the ability to dump the output params into a local file.

Ideally having this format:

export TOWER_HOSTNAME=<value>
export TOWER_DB_HOSTNAME=<value>
export TOWER_REDIS_HOSTNAME=<value>
enekui commented 10 months ago

This TOWER_HOSTNAME is a value that Terraform is not handling. I can send to the file the other stuff that is part of the Terraform code. On the other hand, instead of making Terraform handle this, you can just type terraform output > output.txt and you will get the same result.

image

Also, look at the format of terraform output:

database_url = "seqera-db.cedbg7vc0xjg.eu-west-2.rds.amazonaws.com"
redis_url = "seqera-terraform-aws-redis.gmzywf.ng.0001.euw2.cache.amazonaws.com"

Even if I create the file, you will still have to do grep and sed in your bash script.

pditommaso commented 10 months ago

This TOWER_HOSTNAME is a value that Terraform is not handling.

Why not, it's this

enekui commented 10 months ago

This TOWER_HOSTNAME is a value that Terraform is not handling.

Why not, it's this

Well, technically speaking this is the DNS name of the EC2 instance, which only exists if the instance is deployed in public subnet with public IP. According to Tower manifests naming convention TOWER_HOSTNAME is something like "tower.example.com"

But we are still in the same situation. It comes out with terraform output command and con be redirected to a file with > so we keep terraform code clean. It's my recommendation based on my experience, at the end of the day if this is what you want to do, I will do it. But it's a bad practice to decrease the quality of what we are doing with the module because of bash scripts limitations.

HLWiencko commented 10 months ago

I'd be curious to get this in front of customers before making this particular change, just to see if it's something that people ask for. We might be over-anticipating. Can we keep this suggestion in our back pockets for a future iteration if customers need it?

pditommaso commented 10 months ago

Well, technically speaking this is the DNS name of the EC2 instance

Not a useful comment

enekui commented 10 months ago

Done! https://github.com/seqeralabs/terraform-seqera-aws/pull/24

pditommaso commented 10 months ago

Solved