geronimo-iia / terraform-aws-tf-registry

Terraform module for creating a simple private serverless Terraform registry in AWS
https://registry.terraform.io/modules/geronimo-iia/tf-registry/aws/latest
MIT License
15 stars 1 forks source link

Feature s3 access with presigned url #1

Closed geronimo-iia closed 1 year ago

geronimo-iia commented 1 year ago

First Idea was to add a blob api to get terraforn module stored in the bucket using api gateway. The api gateway is used as a proxy to aws s3 bucket, and use JWT token as authentication method.

Using aws api gateay as a s3 proxy:

geronimo-iia commented 1 year ago

Testing terraform usage with this blob api

With blob api authentication, we had to configure a netrc file (https://everything.curl.dev/usingcurl/netrc).

see https://developer.hashicorp.com/terraform/language/modules/sources#http-urls

.netrc did not support JWT token (I find nothing about this)

With a netrc like this:

machine registry.my-domain.com login Bearer password My_JWT_Tokem

And adding support for Basic auth in lambda authorizer, things "work"....

But, we add to configure:

I did not like repeat myself... We will have to configure two file everywhere...

Rather than use API gateway as a s3 proxy, may we should use s3 presigned url in the "download response". With this solution, we should need a dedicated lambda to answer on this method, and confirm that we did not need public ACl on bucket.

geronimo-iia commented 1 year ago

By the way, gitlab api terraform registry, use "file" suffix to get module source.

geronimo-iia commented 1 year ago

Use presigned s3 URL

Terraform or terragunt client see just a public HTTPS URL.