Version: Terraform v0.6.16
Hi, i'm trying to read in the password from the file using the 'file' keyword, the problem is the content has a newline always appended when read (definitely no newline in the file), causing the rds declaration to break. Is there any way I can drop the newline? ...
#
## PostgreSQL Database for Kong
#
resource "aws_db_instance" "postgres" {
allocated_storage = "${var.kong_database_size}"
db_subnet_group_name = "${aws_db_subnet_group.proxy.name}"
engine = "postgres"
engine_version = "9.5.2"
instance_class = "db.t2.large"
multi_az = false
storage_encrypted = true
vpc_security_group_ids = [ "${aws_security_group.database.id}" ]
name = "kong"
username = "kong"
password = "${file(\"../secrets/db.credentials\")}"
tags {
Name = "${var.environment}-proxy-database"
Environment = "${var.environment}"
Role = "database"
}
}
@gambol99 , this could be a "not so beautiful" workaround. And there could be side effects depending on your password (if contain white spaces). But could fix the problem for the time being:
password = "${replace(file(\"../secrets/db.credentials\"), "\n", "")}"
cheers @jotacepea ... I'll give it a go
We also have an interpolation function trimspace, which removes leading and trailing whitespace, including newlines.
Why is this closed? I see that there are workarounds, but I can't see how this the intended behavior... is there a well-reasoned argument for adding a newline, or has this just "always been the case" here?
Indeed, the docs explicitly state that:
The contents of the file are read as-is.
I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Most helpful comment
We also have an interpolation function
trimspace, which removes leading and trailing whitespace, including newlines.