Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Added credential provider example - #1438

Closed
siennathesane wants to merge 1 commit into
localstack:mainfrom
siennathesane:docs/update-go-examples
Closed

Added credential provider example#1438
siennathesane wants to merge 1 commit into
localstack:mainfrom
siennathesane:docs/update-go-examples

Conversation

@siennathesane

Copy link
Copy Markdown

Added a credential provider example for the AWS for Go SDK v2. There is a matching PR with the complete code at localstack/localstack-aws-sdk-examples#9.

Signed-off-by: Sienna Satterwhite <sienna.satterwhite@jamf.com>
@github-actions

Copy link
Copy Markdown

⚡️ Deploying PR Preview...

@gregfurman
gregfurman self-requested a review August 21, 2024 07:56
@gregfurman

Copy link
Copy Markdown
Contributor

Hey. Thanks for this! I'm always a fan of Golang + LocalStack getting more love 😄

Couple of remarks on this. First, the CI is failing becase of linting issues (see failed job here). Also maybe give the best practices a lookthrough which could help diagnose/fix this.

In addition, I think for the purposes of documentation, it would probably be a better idea to provide users' with a simpler minimum-viable-solution. While what this PR proposes would obviously work, I'm concerned perhaps the scope is a bit large.

What about something like this?

const (
	AwsLocalEndpoint        = "http://localhost:4566"
	AwsLocalCredentialsName = "AwsLocalCredentials"
	AwsLocalDefaultRegion   = "us-east-1"
	AwsLocalAccountId       = "000000000000"
	AwsLocalAccessKey       = "test"
	AwsLocalSecret          = "test"
)

func main() {
	// build an aws.Credential-compliant configuration
	localstackCredentials := aws.Credentials{
		AccessKeyID:     AwsLocalAccessKey,
		SecretAccessKey: AwsLocalSecret,
		SessionToken:    "SESSION",
		Source:          "LocalStack hardcoded credentials.",
	}

	awsCfg, err := config.LoadDefaultConfig(context.TODO(),
		config.WithCredentialsProvider(credentials.StaticCredentialsProvider{
			Value: localstackCredentials,
		}),
		config.WithDefaultRegion(AwsLocalDefaultRegion),
		// Optionally, add more LoadOptions...
	)

	// ...

}

It could probably be slimmed down even further to just focus on the credential provider.

What are your thoughts?

@siennathesane

Copy link
Copy Markdown
Author

The matching PR in the examples repo contains all the necessary code, so I don't think this update is required. I included it since it's a common use case, but I don't feel strongly about this PR. Feel free to update or close it, I'm fine with either

@HarshCasper HarshCasper added the wontfix This will not be worked on label Feb 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

wontfix This will not be worked on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants