Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stremovskyy/go-aws-config
go-aws-config is a very simple wrapper around the AWS SDK for Go
https://github.com/stremovskyy/go-aws-config
app-config aws aws-appconfig go golang golang-library golang-package
Last synced: 4 days ago
JSON representation
go-aws-config is a very simple wrapper around the AWS SDK for Go
- Host: GitHub
- URL: https://github.com/stremovskyy/go-aws-config
- Owner: stremovskyy
- License: apache-2.0
- Created: 2023-02-06T11:45:06.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-06T11:47:36.000Z (over 1 year ago)
- Last Synced: 2024-06-20T22:35:30.062Z (5 months ago)
- Topics: app-config, aws, aws-appconfig, go, golang, golang-library, golang-package
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# GO AWS Config
[![GoDoc](https://godoc.org/github.com/stremovskyy/go_aws_config?status.svg)](https://godoc.org/github.com/stremovskyy/go_aws_config)
**go-aws-config** is a very simple wrapper around the AWS SDK for Go. It provides a simple way to get configuration values from AWS App Config.
### Jump to
* [Installation](#Installation)
* [Usage](#Usage)
* [License](#License)
* [Contributing](#Contributing)
* [Authors](#Authors)
* [Acknowledgments](#Acknowledgments)
* [TODO](#TODO)### Installation
```bash
go get github.com/stremovskyy/go-aws-config
```### Usage
#### With environment variables
```go
package mainimport (
"fmt"
"github.com/stremovskyy/go-aws-config"
)type Configuration struct {
// DB configuration
DBHost string `yaml:"db_host" json:"db_host"`
DBPort string `yaml:"db_port" json:"db_port"`
}func main() {
// Create new options for client
opts := &go_aws_config.Options{
Region: "eu-central-1",
ApplicationID: "test",
EnvironmentID: "TestEnvironment",
Profile: "test-config",
PollingInterval: 60,
CredentialsInEnv: true,
}// Create new client
configurator := go_aws_config.NewClient(opts)// Prepare client
err := configurator.Prepare()
if err != nil {
fmt.Printf("failed to prepare client, %v", err)
return
}// create a struct to load configuration into
dbConfiguration := &Configuration{}// load configuration into struct
err = configurator.LoadIntoYaml(dbConfiguration)
if err != nil {
fmt.Printf("failed to load configuration into struct, %v", err)
return
}// PROFIT!
fmt.Printf("db host: %s", dbConfiguration.DBHost)
}
```#### With credentials in code
```go
package mainimport (
"fmt"
"github.com/stremovskyy/go-aws-config"
)type Configuration struct {
// DB configuration
DBHost string `yaml:"db_host" json:"db_host"`
DBPort string `yaml:"db_port" json:"db_port"`
}func main() {
awsKey := "AKIAIOSFODNN7EXAMPLE"
awsSecret := "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
// Create new options for client
opts := &go_aws_config.Options{
Region: "eu-central-1",
ApplicationID: "test",
EnvironmentID: "TestEnvironment",
Profile: "test-config",
PollingInterval: 60,
CredentialsInEnv: false,
AccessKeyID: awsKey,
SecretAccessKey: awsSecret,
}// Create new client
configurator := go_aws_config.NewClient(opts)// Prepare client
err := configurator.Prepare()
if err != nil {
fmt.Printf("failed to prepare client, %v", err)
return
}// create a struct to load configuration into
dbConfiguration := &Configuration{}// load configuration into struct
err = configurator.LoadIntoYaml(dbConfiguration)
if err != nil {
fmt.Printf("failed to load configuration into struct, %v", err)
return
}// PROFIT!
fmt.Printf("db host: %s", dbConfiguration.DBHost)
}
```### License
This library is licensed under the Apache 2.0 License.
### Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.### Authors
* **Anton Stremovskyy** - *Initial work* - [stremovskyy](https://github.com/stremovskyy)
### Acknowledgments
* [AWS SDK for Go](https://github.com/aws/aws-sdk-go/)
* [AWS AppConfig](https://aws.amazon.com/appconfig/)
* [AWS AppConfig Go SDK](https://docs.aws.amazon.com/sdk-for-go/api/service/appconfig/)### TODO
* [ ] Add support for more configuration formats
* [ ] Add support for subscribing to configuration changes