[RFC] Allow use of profiles
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.
Codecov Report
Merging #57 into master will decrease coverage by
0.71%. The diff coverage is0%.
@@ 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
| Impacted Files | Coverage Δ | |
|---|---|---|
| config/config.go | 58.49% <0%> (-25.3%) |
:arrow_down: |
| sqs/client.go | 58.53% <0%> (-3.01%) |
:arrow_down: |
| cloudwatch/client.go | 18.75% <0%> (-5.25%) |
:arrow_down: |
| cloudwatch/request_type.go | 0% <0%> (ø) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing dataPowered by Codecov. Last update a8a27a0...dbaa8f5. Read the comment docs.
Coverage decreased (-0.2%) to 42.46% when pulling dbaa8f59428fe99bb07701320641a2a786abfd3b on DavidGamba:allow-use-of-profiles into 6ddcc8fd83b6bda66f5b1713b87d822444790f8e on evalphobia:master.
Coverage decreased (-0.2%) to 42.46% when pulling dbaa8f59428fe99bb07701320641a2a786abfd3b on DavidGamba:allow-use-of-profiles into 6ddcc8fd83b6bda66f5b1713b87d822444790f8e on evalphobia:master.
@DavidGamba Thank you for your patience and suggestion!
It's a good idea to use the session that you want.
What about Config struct directly have AWS session?
If it have the session, you don't have to change the constructor of each services. (e.g. sqs.New(conf))
/* 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
}
...
}
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.