Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added support for user defined filters #11

Merged
merged 5 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ While there are a few variables that can be configured through the module, the b
- ec2_attributes

By default, server sizes are automatically set but not AMIs and so you need to configure them
- image_filter_groups

The AMIs that are listed in the Turbo Deploy interface is configured through the use of filters that are used by the AWS API, you can look through the full list of filters in this [AWS documentation](https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html)

## Example

Expand All @@ -94,5 +97,35 @@ module "my_turbo_module" {
ServerSizes = ["t3.medium", "t3.large", "t3.xlarge"]
Amis = ["ami-0583d8c7a9c35822c", "ami-06338d230ffc3fc0c"]
}
image_filter_groups = {
"alma-ami" = [
{
name = "is-public"
values = ["true"]
},
{
name = "name"
values = ["AlmaLinux OS*"]
},
{
name = "state"
values = ["available"]
}
]
"redhat-ami" = [
{
name = "is-public"
values = ["true"]
},
{
name = "name"
values = ["RHEL-9.4.0*"]
},
{
name = "state"
values = ["available"]
}
]
}
}
```
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ resource "aws_lambda_function" "database_lambda" {
WEBSERVER_HOSTNAME = var.turbo_deploy_hostname
WEBSERVER_HTTP_PORT = var.turbo_deploy_http_port
WEBSERVER_HTTPS_PORT = var.turbo_deploy_https_port
AMI_FILTERS = base64gzip(jsonencode(var.image_filter_groups))
}
}
}
Expand Down
27 changes: 26 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,29 @@ variable "public_key" {
description = "The default public key to be added to all deployed instances"
type = string
default = null
}
}

# filter types can be found here https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_DescribeImages.html
variable "image_filter_groups" {
description = "Filter groups for different images"
type = map(list(object({
name = string
values = list(string)
})))
default = {
"alma-ami" = [
{
name = "is-public"
values = ["true"]
},
{
name = "name"
values = ["AlmaLinux OS*"]
},
{
name = "state"
values = ["available"]
}
]
}
}