Skip to content

Commit

Permalink
fix: s3 source handling (#3146)
Browse files Browse the repository at this point in the history
  • Loading branch information
levkohimins authored May 20, 2024
1 parent 7e283d7 commit 44d4083
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions terraform/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,14 @@ func ToSourceUrl(source string, workingDir string) (*url.URL, error) {
func normalizeSourceURL(source string, workingDir string) (string, error) {
newSource := httpSchemeRegexp.ReplaceAllString(source, "")

// We can't use `the getter.Detectors` global variable because we need to exclude `getter.FileDetector` from checking since it is not a URL detector.
// We can't use `the getter.Detectors` global variable because we need to exclude from checking:
// * `getter.FileDetector` is not a host detector
// * `getter.S3Detector` we should not remove `https` from s3 link since this is a public link, and if we remove `https` scheme, `getter.S3Detector` adds `s3::https` which in turn requires credentials.
detectors := []getter.Detector{
new(getter.GitHubDetector),
new(getter.GitLabDetector),
new(getter.GitDetector),
new(getter.BitBucketDetector),
new(getter.S3Detector),
new(getter.GCSDetector),
}

Expand Down
2 changes: 1 addition & 1 deletion terraform/source_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestToSourceUrl(t *testing.T) {
{"https://gitlab.com/catamphetamine/libphonenumber-js", "git::https://gitlab.com/catamphetamine/libphonenumber-js.git"},
{"https://bitbucket.org/atlassian/aws-ecr-push-image", "git::https://bitbucket.org/atlassian/aws-ecr-push-image.git"},
{"http://bitbucket.org/atlassian/aws-ecr-push-image", "git::https://bitbucket.org/atlassian/aws-ecr-push-image.git"},
{"https://s3-eu-west-1.amazonaws.com/modules/vpc.zip", "s3::https://s3-eu-west-1.amazonaws.com/modules/vpc.zip"},
{"https://s3-eu-west-1.amazonaws.com/modules/vpc.zip", "https://s3-eu-west-1.amazonaws.com/modules/vpc.zip"},
{"https://www.googleapis.com/storage/v1/modules/foomodule.zip", "gcs::https://www.googleapis.com/storage/v1/modules/foomodule.zip"},
{"https://www.googleapis.com/storage/v1/modules/foomodule.zip", "gcs::https://www.googleapis.com/storage/v1/modules/foomodule.zip"},
{"git::https://[email protected]/name/project-name/_git/repo-name", "git::https://[email protected]/name/project-name/_git/repo-name"},
Expand Down

0 comments on commit 44d4083

Please sign in to comment.