Skip to content

Commit

Permalink
Add more EC2 describe instances params
Browse files Browse the repository at this point in the history
  • Loading branch information
cbruno10 committed Oct 16, 2023
1 parent cdbbb5c commit ccd5a18
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions pipelines/ec2/describe_ec2_instances.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,25 @@ pipeline "describe_ec2_instances" {
}

param "instance_ids" {
type = list(string)
type = list(string)
# TODO: Should we use [] or optional = true?
#default = []
optional = true
}

param "instance_type" {
type = string
description = "The type of instance (for example, t2.micro)."
optional = true
}

param "ebs_optimized" {
type = bool
description = "A Boolean that indicates whether the instance is optimized for Amazon EBS I/O."
optional = true
}


param "filter" {
type = string
optional = true
Expand All @@ -30,12 +46,13 @@ pipeline "describe_ec2_instances" {
step "container" "container_run_aws" {
image = "amazon/aws-cli"

cmd = concat([
"ec2",
"describe-instances",
## TODO next step is to only include instance-ids if any are provided
"--instance-ids",
], param.instance_ids)
cmd = concat(
["ec2", "describe-instances"],
# TODO: Do I need to check for empty list to?
param.instance_ids != nil && length(param.instance_ids) > 0 ? concat(["--instance-ids"], param.instance_ids) : [],
param.instance_type != nil ? ["--filters", "Name=instance-type,Values=${param.instance_type}"]) : [],
param.instance_type != nil ? ["--filters", "Name=ebs-optimized,Values=${param.ebs_optimized}"]) : [],
)

env = {
AWS_REGION = param.aws_region
Expand Down

0 comments on commit ccd5a18

Please sign in to comment.