Open
Conversation
This will enable separation of session creation from new resource instantiation. It also allows callers with custom session needs to bring their own session.
Codecov Report
@@ Coverage Diff @@
## master #57 +/- ##
==========================================
- Coverage 42.2% 41.48% -0.72%
==========================================
Files 59 59
Lines 4109 4180 +71
==========================================
Hits 1734 1734
- Misses 2264 2335 +71
Partials 111 111
Continue to review full report at Codecov.
|
1 similar comment
Owner
|
@DavidGamba Thank you for your patience and suggestion! It's a good idea to use the session that you want. /* config.go */
type Config struct {
Session *session.Session
AccessKey string
...
}
// Session creates AWS session from the Config values.
func (c Config) Session() (*session.Session, error) {
if c.Session != nil {
return c.Session, nil
}
return session.NewSession(c.AWSConfig())
}/* sqs.go */
// New returns initialized *SQS.
func New(conf config.Config) (*SQS, error) {
sess, err := conf.Session()
if err != nil {
return nil, err
}
...
} |
Contributor
Author
|
Hi @evalphobia sorry for the long delay in answering. It looks good, I need to give it a try but I wont be able to get to that in a couple of weeks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This one is to just get your eyes on it.
The way you are doing your session creation doesn't allow for many options.
Our setup is a multi account setup where we use access keys defined in the root account and assume roles to access multiple other accounts.
In other cases we use ec2 instances with instance profiles to run our automation from.
Splitting the session creation from the resource creation allows the caller to bring custom session needs.