I have the following terraform script which creates Elastic Beanstalk with rds:
resource "aws_elastic_beanstalk_application" "elb_app" {
name = "my-app"
}
resource "aws_elastic_beanstalk_environment" "elb_env" {
name = "my-env"
application = aws_elastic_beanstalk_application.elb_app.name
solution_stack_name = data.aws_elastic_beanstalk_solution_stack.net_latest.name
setting {
namespace = "aws:elasticbeanstalk:application:environment"
name = "RDS_HOSTNAME"
value = # How can I set here the RDS endpoint ???
}
setting {
namespace = "aws:rds:dbinstance"
name = "HasCoupledDatabase"
value = "true"
}
setting {
namespace = "aws:rds:dbinstance"
name = "DBEngine"
value = var.db_engine
}
setting {
namespace = "aws:rds:dbinstance"
name = "DBEngineVersion"
value = var.db_engine_version
}
setting {
namespace = "aws:rds:dbinstance"
name = "DBInstanceClass"
value = var.db_instance_type
}
setting {
namespace = "aws:rds:dbinstance"
name = "DBPassword"
value = var.db_password
}
setting {
namespace = "aws:rds:dbinstance"
name = "DBUser"
value = var.db_user
}
}
The question is: how can I set the RDS_HOSTNAME
?
As far as I know, it is possible to get the endpoint from an RDS created as a separate resource, but I didn’t find any documentation how to get this from RDS created as part of an Elastic Beanstalk.
I spent many days and didn’t find any example however it should be a typical case for developers.