Skip to content

Chore: module-version fails when using tf-module-promise with git repo #189

@abangser

Description

@abangser

using version 0.11.0 and 0.11.2 the following command does not work:

$ kratix init tf-module-promise bucket \
  --group syntasso.io --kind bucket \
  --module-source git::https://github.com/thoughtbot/terraform-s3-bucket \
  --module-version v0.4.0 \
  --dir bucket
Fetching terraform module variables, this might take up to a minute...
Error: failed to download and convert terraform module to CRD: failed to initialize terraform: terraform init failed: exit status 1: Initializing modules...
╷
│ Error: Invalid registry module source address
│
│   on main.tf line 2, in module "kratix_target":
│    2:   source = "git::https://github.com/thoughtbot/terraform-s3-bucket"
│
│ Failed to parse module registry address: a module registry source address
│ must have either three or four slash-separated components.
│
│ Terraform assumed that you intended a module registry source address
│ because you also set the argument "version", which applies only to registry
│ modules.

but moving the module version to a git reference does:

kratix init tf-module-promise bucket \
  --group syntasso.io --kind bucket \
  --module-source "git::https://github.com/thoughtbot/terraform-s3-bucket?ref=v0.4.0" \
  --dir bucket
Fetching terraform module variables, this might take up to a minute...
Promise generated successfully. It is set to schedule to Destinations with the label `environment: terraform` by default. To modify this behavior, update the `.spec.destinationSelectors` field in `promise.yaml`

The help output from the command correctly states that this only works with the Terraform Registry style (as also stated in TF docs):

Flags:
  -h, --help                    help for tf-module-promise
  -s, --module-source source    Source of the terraform module.
                                This can be a Git URL, Terraform registry path, or a local directory path.
                                It follows the same format as the source argument in the Terraform module block.
  -m, --module-version string   (Optional) version of the terraform module; only use when pulling modules from Terraform registry

But we actually error on this when we may want to just ignore with a warning?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions