Skip to content

Commit

Permalink
no clean way to lookup portfolio or product ids
Browse files Browse the repository at this point in the history
  • Loading branch information
morga471 committed Feb 12, 2026
1 parent eee325c commit be4eed4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 46 deletions.
14 changes: 6 additions & 8 deletions common/defaults.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
locals {
# Get portfolio ID from lookup or variable
portfolio_id = var.portfolio_id != null ? var.portfolio_id : try(
[for p in data.aws_servicecatalog_portfolios.all[0].details :
p.id if can(regex(var.portfolio_name_pattern, p.name))
][0],
null
)
# Portfolio ID is required - must be provided via var.portfolio_id
portfolio_id = var.portfolio_id

# Get product ID from variable or portfolio lookup
# Product ID is required - must be provided via var.product_id
product_id = var.product_id

# Get the latest provisioning artifact ID
Expand Down Expand Up @@ -36,4 +31,7 @@ locals {
value = tostring(value)
}
]

# Module name for tagging
module_name = "aws-servicecatalog/ec2"
}
39 changes: 1 addition & 38 deletions common/locals.tf
Original file line number Diff line number Diff line change
@@ -1,39 +1,2 @@
# Intentionally empty file for consistency with aws-s3 pattern
# Module-specific locals should be defined in each submodule

locals {
# Portfolio ID must be specified
portfolio_id = var.portfolio_id

# Product ID must be specified
product_id = var.product_id

# Get the latest provisioning artifact ID
latest_artifact_id = try(
[for artifact in data.aws_servicecatalog_provisioning_artifacts.this.provisioning_artifact_details :
artifact.id if artifact.active
][0],
null
)

# Use provided path_id or default to latest
provisioning_artifact_id = var.path_id != null ? var.path_id : local.latest_artifact_id

# Merge default parameters with user-provided parameters
default_parameters = {}

parameters = merge(
local.default_parameters,
var.parameters
)

# Convert parameters map to the format expected by aws_servicecatalog_provisioned_product
provisioning_parameters = [
for key, value in local.parameters : {
key = key
value = tostring(value)
}
]

module_name = try(data.aws_servicecatalog_product.by_id[0].name, "Unknown")
}
# Module-specific locals should be defined in each submodule

0 comments on commit be4eed4

Please sign in to comment.