Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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)
}
@danielpsf

This comment has been minimized.

Copy link

danielpsf commented Feb 21, 2019

Loved your example... Pretty simple and solid. Thank you man! 😍

@jyotianeja99

This comment has been minimized.

Copy link

jyotianeja99 commented May 2, 2019

I also liked this example. :)

@jayakumar-v

This comment has been minimized.

Copy link

jayakumar-v commented Dec 18, 2019

Hi @miguelmota - Followed exactly the same code base - Got an error as
"errorMessage": "runtime error: invalid memory address or nil pointer dereference",
"errorType": "errorString",
"stackTrace": [
{
"path": "github.com/aws/aws-lambda-go@v1.13.2/lambda/function.go",
"line": 31,
"label": "(*Function).Invoke.func1"
}

thrown at line calling ssmsvc.GetParameter method. I am testing method by calling from lambda

Can you help on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.