Presently, the aws_directory_service_directory data source can retrieve all the relevant data about an AWS Directory service, but it can only do so when provided with a directory_id. This becomes a chicken/egg issue and couples code more tightly. For instance, I need to know the directory_id in order to join an MSSQL RDS database to the AD domain, but I cannot use this data source to retrieve this information. So I have the options of either statically setting the directory_id in configuration, doing a remote state lookup, or running an AWS CLI command to retrieve the ID. None of these are as loosely coupled or as robust as I'd like.
There is "describe-directories" action in the directory services API available. It seems that if a specific directory_id isn't provided to it, it returns all directories, which would allow terraform to implement the filtering on its side.
If the aws_directory_service_directory was enhanced (or another data source created) which allowed filter-based selection of the correct directory similar to other data sources such as aws_subnets or aws_db_instances or aws_ami, then we could then simply use that filtering to pick a directory based on the name or any other attribute and get the id back.
Affected Resource(s) and/or Data Source(s)
aws_directory_service_directory
Potential Terraform Configuration
data "aws_directory_service_directory" "my_corp_ad" {
filter {
name = "name"
values = ["mycorpad.mycompany.com"]
}
}
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Volunteering to Work on This Issue
If you are interested in working on this issue, please leave a comment.
If this would be your first contribution, please review the contribution guide.
Description
Presently, the aws_directory_service_directory data source can retrieve all the relevant data about an AWS Directory service, but it can only do so when provided with a directory_id. This becomes a chicken/egg issue and couples code more tightly. For instance, I need to know the directory_id in order to join an MSSQL RDS database to the AD domain, but I cannot use this data source to retrieve this information. So I have the options of either statically setting the directory_id in configuration, doing a remote state lookup, or running an AWS CLI command to retrieve the ID. None of these are as loosely coupled or as robust as I'd like.
There is "describe-directories" action in the directory services API available. It seems that if a specific directory_id isn't provided to it, it returns all directories, which would allow terraform to implement the filtering on its side.
If the aws_directory_service_directory was enhanced (or another data source created) which allowed filter-based selection of the correct directory similar to other data sources such as
aws_subnets
oraws_db_instances
oraws_ami
, then we could then simply use that filtering to pick a directory based on the name or any other attribute and get the id back.Affected Resource(s) and/or Data Source(s)
aws_directory_service_directory
Potential Terraform Configuration
References
https://docs.aws.amazon.com/directoryservice/latest/devguide/API_DescribeDirectories.html
Would you like to implement a fix?
No