Skip to content

Instantly share code, notes, and snippets.

@ardeshir
Forked from miguelmota/ssm_parameter.go
Created December 13, 2019 04:43
Show Gist options
  • Save ardeshir/3bbbe5d4a214fb33b31a21dca96aae26 to your computer and use it in GitHub Desktop.
Save ardeshir/3bbbe5d4a214fb33b31a21dca96aae26 to your computer and use it in GitHub Desktop.
AWS SSM Go SDK parameter store example
package main
import (
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ssm"
)
func main() {
sess, err := session.NewSessionWithOptions(session.Options{
Config: aws.Config{Region: aws.String("us-east-1")},
SharedConfigState: session.SharedConfigEnable,
})
if err != nil {
panic(err)
}
ssmsvc := ssm.New(sess, aws.NewConfig().WithRegion("us-west-2"))
keyname := "/MyService/MyApp/Dev/DATABASE_URI"
withDecryption := false
param, err := ssmsvc.GetParameter(&ssm.GetParameterInput{
Name: &keyname,
WithDecryption: &withDecryption,
})
value := *param.Parameter.Value
fmt.Println(value)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment