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

feature/mandatory-UI-arn #3

Merged
merged 2 commits into from
Dec 1, 2023
Merged

Conversation

grumbling-tom
Copy link

@grumbling-tom grumbling-tom commented Nov 23, 2023

I would like to make the Metaflow UI a mandatory component for a Metaflow deployment.

The problem I am having is with the UI count:

  • this count value depends on the string value of the SSL certificate ARN
  • I am typically creating those SSL certificates in another module
  • the string value for the ARNs is not known at plan time if they do not yet exist (i.e. when the module has not been created before)
  • as such, the value of the count for the Metaflow UI cannot be determined, meaning the terraform plan fails with this error:
╷
│ Error: Invalid count argument
│ 
│   on .terraform/modules/ncr_metaflow.metaflow/main.tf line 44, in module "metaflow-ui":
│   44:   count  = var.ui_certificate_arn == "" ? 0 : 1
│ 
│ The "count" value depends on resource attributes that cannot be determined until apply, so Terraform cannot predict how many instances will be created. To work around this, use the -target
│ argument to first apply only the resources that the count depends on.
╵
╷

The workaround suggested requires that we run the terraform apply in two stages. This is not desirable because:

  • it is not compatible with our CI workflow
  • we want to be able to create both this module and the SSL modules at the same time, to speed up deployments of new infrastructure

Other things that I have tried:

  • Setting the default value to be null, rather than an empty string, with the hope that terraform would check the type for the input ui_certificate_arn variable. It did not.
  • Adding a lifecycle precondition that checks the ui_certificate_arn value, but these are not supported for modules

We could also add a second variable, create_ui, which we instead use as the conditional to count, rather than the string value of the ARN. This would be similar to how the terraform-eks module handles conditional resource creation.

The trade-off of this change is that we end up with a change in our terraform-aws fork that will almost certainly not be accepted into the upstream Outerbounds repo, which might make proposing changes later on harder.

@grumbling-tom grumbling-tom merged commit cbd1797 into natcap-main Dec 1, 2023
@grumbling-tom grumbling-tom deleted the feature/mandatory-ui-arn branch December 1, 2023 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants