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"))
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)
}
@danielpsf

This comment has been minimized.

Copy link

@danielpsf danielpsf commented Feb 21, 2019

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

@jyotianeja99

This comment has been minimized.

Copy link

@jyotianeja99 jyotianeja99 commented May 2, 2019

I also liked this example. :)

@olafur-palsson

This comment has been minimized.

Copy link

@olafur-palsson olafur-palsson commented Feb 7, 2020

@jayakumar-v
This is completely unrelated to the topic. (The function you are using in lambda.Start is nil

@gopaldevalla

This comment has been minimized.

Copy link

@gopaldevalla gopaldevalla commented Apr 15, 2020

Mee too liked it... Thanks much...

@Pitasi

This comment has been minimized.

Copy link

@Pitasi Pitasi commented May 8, 2020

Watch out to check for errors returned at line 23 :)

@yuvrajsingh79

This comment has been minimized.

Copy link

@yuvrajsingh79 yuvrajsingh79 commented Jul 30, 2020

Is there a way to load a json file as a parameter ?

@Pitasi

This comment has been minimized.

Copy link

@Pitasi Pitasi commented Jul 30, 2020

@yuvrajsingh79 AWS SDK returns parameter as a string, you can then json unmarshal that string into a struct.

@yuvrajsingh79

This comment has been minimized.

Copy link

@yuvrajsingh79 yuvrajsingh79 commented Jul 30, 2020

@Pitasi thanks, you mean to say that we can store in a json file as a parameter and then fetch it -> unmarshal that string ?

@andreleoni

This comment has been minimized.

Copy link

@andreleoni andreleoni commented Jul 31, 2020

thank you for share this example!

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.