From 3823b1bf4465b243bda4beb3e3236f9d7243d570 Mon Sep 17 00:00:00 2001 From: Andrew Woodlee Date: Sat, 1 Mar 2025 01:57:05 -0600 Subject: [PATCH] get S3 profile using env AWS_PROFILE --- cmd/version.go | 2 +- docs/content/config/remote-resources.md | 4 ++++ pkg/remotefetcher/s3.go | 5 ++--- release | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/version.go b/cmd/version.go index 6af41ad..b511a2e 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -7,7 +7,7 @@ import ( "github.com/spf13/cobra" ) -const versionStr = "0.9.0" +const versionStr = "0.9.1" var ( versionCmd = &cobra.Command{ diff --git a/docs/content/config/remote-resources.md b/docs/content/config/remote-resources.md index 54bd918..ebdc956 100644 --- a/docs/content/config/remote-resources.md +++ b/docs/content/config/remote-resources.md @@ -12,6 +12,10 @@ For the main config file to be fetched remotely, pass the URL using `-f [url]`. If using S3, you should use the s3 protocol URI: `s3://bucketName/key/path`. You will also need to set the env variable `S3_ENDPOINT` to the appropriate value. The flag `--s3-endpoint` can be used to override this value or to set this value, if not already set. +## Authentication + +Currently, only the AWS authentication credentials file `~/.aws/credentials` is supported. For now, the environment variable `AWS_PROFILE` is used to lookup the profile. + ## Scripts Remote script support is currently limited to http/https endpoints. \ No newline at end of file diff --git a/pkg/remotefetcher/s3.go b/pkg/remotefetcher/s3.go index 04b43ee..f954581 100644 --- a/pkg/remotefetcher/s3.go +++ b/pkg/remotefetcher/s3.go @@ -44,9 +44,8 @@ func NewS3Fetcher(endpoint string, options ...FetcherOption) (*S3Fetcher, error) */ s3Endpoint := os.Getenv("S3_ENDPOINT") - creds, err := getS3Credentials("default", s3Endpoint, cfg.HTTPClient) + creds, err := getS3Credentials(os.Getenv("AWS_PROFILE"), s3Endpoint, cfg.HTTPClient) if err != nil { - println(err.Error()) return nil, err } @@ -133,7 +132,7 @@ func getS3Credentials(profile, host string, httpClient *http.Client) (*credentia if hdirErr != nil { return nil, hdirErr } - s3Creds := credentials.NewFileAWSCredentials(path.Join(homeDir, ".aws", "credentials"), "default") + s3Creds := credentials.NewFileAWSCredentials(path.Join(homeDir, ".aws", "credentials"), profile) credVals, credErr := s3Creds.GetWithContext(&credentials.CredContext{Endpoint: host, Client: httpClient}) if credErr != nil { return nil, credErr diff --git a/release b/release index 9165ca4..d6a203e 100755 --- a/release +++ b/release @@ -1,7 +1,7 @@ #!/bin/bash set -eou pipefail go generate ./... -export CURRENT_TAG="$(go run backy.go version -V)" +CURRENT_TAG="$(go run backy.go version -V)" goreleaser -f .goreleaser/github.yml check goreleaser -f .goreleaser/gitea.yml check changie batch $CURRENT_TAG