0

I'm using the AWS SDK for Go to get parameters from SSM. In order to instantiate an SSM client, I have to pass a session struct with params such as region, credentials and endpoint.

&aws.Config{
    Region:      aws.String("us-east-1"),
    Credentials: credentials.NewStaticCredentials("foo", "var", ""),
    Endpoint:    aws.String(os.Getenv("SSM_ENDPOINT")),
}

These credentials are optional, and have their standard values be overridden when user input is provided. I've been trying to create a flexible solution for receiving those inputs, such as:

  • Mapping inputs through a variadic function: Inputs would have to follow a specified order, can't really tell what each value's key is.
  • Instantiating specific values of a larger struct: Other values get instantiated on their zero values.

A possible solution would be Marshaling and Unmarshaling a JSON with json:",omitempty", but it doesn't really seem like the best way to do it.

Caio B
  • 25
  • 1
  • 3
  • Sounds like you want a helper function(s) to generate `&aws.Config`. Define you most common use cases first and then work backwards from there. – colm.anseo Aug 01 '20 at 00:26
  • I could have multiple structs for each case, but that's not very generic and hopefully not the best way to implement it. Is there no way to assign those params as they are received on input? – Caio B Aug 01 '20 at 02:20

0 Answers0