Skip to content

Instantly share code, notes, and snippets.

@chahatd
Forked from miguelmota/ssm_parameter.go
Created November 24, 2021 13:38
Show Gist options
  • Save chahatd/095a7928207f9556b14d9d67fc944923 to your computer and use it in GitHub Desktop.
Save chahatd/095a7928207f9556b14d9d67fc944923 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"))
param, err := ssmsvc.GetParameter(&ssm.GetParameterInput{
Name: aws.String("/MyService/MyApp/Dev/DATABASE_URI"),
WithDecryption: aws.Bool(false),
})
if err != nil {
panic(err)
}
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