paddlehq / go-aws-ssm Goto Github PK
View Code? Open in Web Editor NEWGo package that interfaces with AWS System Manager
License: Apache License 2.0
Go package that interfaces with AWS System Manager
License: Apache License 2.0
Add licenses, speak with @paddledave
Could you please make method getKeyValueMap exported (GetKeyValueMap)?
Whe i am testing this from my local machine , i should be able to specify Access Key and Sevcret Key , how do i do that
tempConfig, _ := awsConfigV2.LoadDefaultConfig(context.TODO())
paramStore, _ := awsParamStore.NewParameterStore(&tempConfig)
cannot use &tempConfig (value of type *"github.com/aws/aws-sdk-go-v2/aws".Config) as *"github.com/aws/aws-sdk-go/aws".Config value in argument to awsParamStore.NewParameterStore
How i can use default config like from ~/.aws/credentials or like v2 LoadDefaultConfig(context.TODO()) for setup keys without store in code?
GetAllParametersByPath
callMake sure the constructors are abstract enough with AWS Session and add some good defaults.
Hi,
I'm storing a relatively large value in AWS Param Store that is greater than 512 bytes. What I'm seeing is that when I try to fetch that value from Param Store, it gets the full value, but when I try to feed that value into viper using viper.ReadConfig(params)
it only feeds the first 512 bytes of the param value.
Code:
params, err = ssm.GetAllParametersByPath(ssmPath, true)
if err != nil {
return
}
// inspecting the individual params here shows that the full value has been captured
err = viper.ReadConfig(params)
// err returned: While parsing config: unexpected end of JSON input
I've pinpointed where the error is coming from:
In buffer.go
, the minimum size of the buffer initialized in buffer.ReadFrom(r io.Reader)
is 512 bytes. It is suppose to automatically increase the size of the buffer when it gets to that predefined size and doesn't find an EOF char during r.Read(...)
:
// Buffer.ReadFrom. As long as the Buffer has at least MinRead bytes beyond
// what is required to hold the contents of r, ReadFrom will not grow the
// underlying buffer.
const MinRead = 512
// ReadFrom reads data from r until EOF and appends it to the buffer, growing
// the buffer as needed. The return value n is the number of bytes read. Any
// error except io.EOF encountered during the read is also returned. If the
// buffer becomes too large, ReadFrom will panic with ErrTooLarge.
func (b *Buffer) ReadFrom(r io.Reader) (n int64, err error) {
b.lastRead = opInvalid
for {
i := b.grow(MinRead)
b.buf = b.buf[:i]
m, e := r.Read(b.buf[i:cap(b.buf)])
if m < 0 {
panic(errNegativeRead)
}
b.buf = b.buf[:i+m]
n += int64(m)
if e == io.EOF {
return n, nil // e is EOF, so return nil explicitly
}
if e != nil {
return n, e
}
}
}
parameter.go
implements the io.Reader
's Read
like so:
func (p *Parameters) Read(des []byte) (n int, err error) {
bytesJSON, err := json.Marshal(p.getKeyValueMap())
if err != nil {
return 0, err
}
return copy(des, bytesJSON), io.EOF
}
This means that we are returning an io.EOF
regardless of if we've read the full param value.
So we return the first 512 bytes back to buffer.ReadFrom(...)
along with the io.EOF, which buffer.ReadFrom(..)
interprets as being finished with the full message, so it doesn't try to enlarge the buffer and read more of the value, thus chopping off the end of the value (including the end JSON }
), which is why we end up with the unexpected end of JSON content
error.
The limit on the value as described by AWS for Param Store entries is 8Kb for advanced keys or 4Kb for normal keys, so I felt I should bring this issue to the repo's owners attention.
Hope you are having a good day!
Hi, i tried the basic usage, but it does not get the default region unfortunately. So, i added the region as;
pmstore, err := awsssm.NewParameterStore(aws.NewConfig().WithRegion("eu-west-1"))
Like this, it works. But i don't want to pass region in code. And way to do it, we need create NewSessionWithOptions and enable the SharedConfig, as;
func NewParameterStore(ssmConfig ...*aws.Config) (*ParameterStore, error) {
sessionAWS, err := session.NewSessionWithOptions(session.Options{
SharedConfigState: session.SharedConfigEnable,
})
if err != nil {
return nil, err
}
svc := ssm.New(sessionAWS)
return &ParameterStore{ssm: svc}, nil
}
Is there any way to do it without manipulating this function ?
improve Readme, typos, documentation and add go examples
Add the option to fetch a single Parameter and not ByPath only
Move the build to travis, @dmonteiro-paddle can give you access
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.