add manual credentials
This commit is contained in:
parent
4103f10502
commit
e31a66a59d
@ -3,4 +3,4 @@ aws:
|
||||
- us-east-1
|
||||
- us-east-2
|
||||
- us-west-1
|
||||
|
||||
credentials_path: ./mtd_aws/.credentials
|
2
main.go
2
main.go
@ -27,7 +27,7 @@ func main() {
|
||||
|
||||
for _, region := range config.AWS.Regions {
|
||||
fmt.Println("Listing instances in region:", region)
|
||||
aws_config := mtd_aws.New_config(region)
|
||||
aws_config := mtd_aws.New_config(region, config.AWS.Credentials_path)
|
||||
instances, err := mtd_aws.Instances(aws_config)
|
||||
if err != nil {
|
||||
fmt.Println("Error listing instances:", err)
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
"github.com/aws/aws-sdk-go-v2/service/ec2"
|
||||
"github.com/aws/aws-sdk-go-v2/service/ec2/types"
|
||||
)
|
||||
func New_config(region string) aws.Config {
|
||||
func New_config(region string, credentials string) aws.Config {
|
||||
// Create a new AWS config
|
||||
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithRegion(region))
|
||||
cfg, err := config.LoadDefaultConfig(context.TODO(), config.WithSharedConfigFiles([]string{credentials}), config.WithRegion(region))
|
||||
if err != nil {
|
||||
fmt.Println("Error creating config:", err)
|
||||
fmt.Println("Configure Credentials in line with the documentation found here: https://aws.github.io/aws-sdk-go-v2/docs/configuring-sdk/#specifying-credentials")
|
||||
|
@ -9,7 +9,8 @@ import (
|
||||
|
||||
type Config struct {
|
||||
AWS struct {
|
||||
Regions []string `yaml:"regions"`
|
||||
Regions []string `yaml:"regions"`
|
||||
Credentials_path string `yaml:"credentials_path"`
|
||||
} `yaml:"aws"`
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user