Terraform AWS submodule path in Terrafile?

I was attempting to pull just the AWS VPC Endpoint submodule from the standard VPC endpoint like so in the Terrafile, but it doesn’t really work:

+mod "sg", source: "https://github.com/terraform-aws-modules/terraform-aws-security-group"
+mod "vpc", source: "https://github.com/terraform-aws-modules/terraform-aws-vpc"
+mod "vpce", source: "https://github.com/terraform-aws-modules/terraform-aws-vpc//modules/vpc-endpoints"

I have sg and vpc there just to mess around with… ofc that vpce github url is not valid.

So I’m confused as to how you can/should reference the github urls like this withough a full https url and if you support something like this which I have in the main.tf in some stack right now:

128 module "vpce" {
129   source = "terraform-aws-modules/vpc/aws//modules/vpc-endpoints"

I guess I’m confused what the “standard” way is to reference a github terraform module in a Terrfafile and also how I can use the vpc-endpoints submoudle. Just pull the vpc module and do some extra path magic? I need some guidance. I’ve read docs and looked a bunch of things but it’s not clear so I just gave up on using the Terrafile for now. and have standard references in the .tf files like above. I do like the idea of letting terraspace manage things in the Terrafile though. I just need some help.

Well I just ran it again and not it pulled all 3 modules in the Terrafile…doh!!!

Bundling with Terrafile...
Exporting sg
Exporting vpc
Exporting vpce
Modules saved to vendor/modules
dbaber@atlas:~/src/infra/lx-infra$  [master|✚ 1…7⚑ 2]
11:37 $ ll vendor/modules/
total 0
drwxr-xr-x@ 18 dbaber  staff  576 Feb  3 11:37 sg/
drwxr-xr-x@ 20 dbaber  staff  640 Feb  3 11:37 vpc/
drwxr-xr-x@  7 dbaber  staff  224 Feb  3 11:37 vpce/

I guess this question still stands:

Can I make the github urls shorter or do I need the full url?

Oh and do you typically check vendor/modules into git or you ignore it with .gitignore ?

ok, I realized I can just do this to shorten the github urls up:

#mod "sg", source: "https://github.com/terraform-aws-modules/terraform-aws-security-group"
#mod "vpc", source: "https://github.com/terraform-aws-modules/terraform-aws-vpc"
#mod "vpce", source: "https://github.com/terraform-aws-modules/terraform-aws-vpc//modules/vpc-endpoints"

mod "sg", source: "terraform-aws-modules/terraform-aws-security-group"
mod "vpc", source: "terraform-aws-modules/terraform-aws-vpc"
mod "vpce", source: "terraform-aws-modules/terraform-aws-vpc//modules/vpc-endpoints"

I guess you would probably also check in vendor/modules as well since your code will/can reference them. Well, I guess you guys can close this issues since I was just having a dumb brain day. Sorry about that.

I am experiencing the same issue via this Terrafile:

mod "vpc", source: "terraform-aws-modules/vpc/aws", version: "5.5.1"
mod "vpc_endpoints", source: "https://github.com/terraform-aws-modules/terraform-aws-vpc//modules/vpc-endpoints", version: "5.5.1"
# mod "vpc_endpoints", source: "terraform-aws-modules/terraform-aws-vpc//modules/vpc-endpoints", version: "5.5.1"

line 3 fails on fresh terraspace bundle (when vendor/modules is empty):

ERROR: Unauthorized. Unable to lookup up module in Terraform Registry:


Try logging in with:

    terraform login