1
0
mirror of https://github.com/raseels-repos/golang-saas-starter-kit.git synced 2025-06-15 00:15:15 +02:00

Init aws session with region when using role

This commit is contained in:
Lee Brown
2019-07-14 00:54:51 -08:00
parent db07498192
commit 8f5ff1ec1e
7 changed files with 38 additions and 2 deletions

View File

@ -247,6 +247,9 @@ func main() {
// configuration is provided. This is useful for taking advantage of
// EC2/ECS instance roles.
awsSession = session.Must(session.NewSession())
if cfg.Aws.Region != "" {
awsSession.Config.WithRegion(cfg.Aws.Region)
}
log.Printf("main : AWS : Using role.\n")

View File

@ -238,6 +238,9 @@ func main() {
// configuration is provided. This is useful for taking advantage of
// EC2/ECS instance roles.
awsSession = session.Must(session.NewSession())
if cfg.Aws.Region != "" {
awsSession.Config.WithRegion(cfg.Aws.Region)
}
log.Printf("main : AWS : Using role.\n")

View File

@ -183,7 +183,12 @@ func (creds awsCredentials) Session() *session.Session {
// Get an AWS session from an implicit source if no explicit
// configuration is provided. This is useful for taking advantage of
// EC2/ECS instance roles.
return session.Must(session.NewSession())
sess := session.Must(session.NewSession())
if creds.Region != "" {
sess.Config.WithRegion(creds.Region)
}
return sess
}
return session.New(

View File

@ -726,7 +726,7 @@ func NewServiceDeployRequest(log *log.Logger, flags ServiceDeployFlags) (*servic
// RDS settings for a Postgres database Instance. Could defined different settings by env.
req.DBInstance = &rds.CreateDBInstanceInput{
DBInstanceIdentifier: aws.String(req.ProjectName + "-" + req.Env + "-01"),
DBInstanceIdentifier: aws.String(req.ProjectName + "-" + req.Env),
DBName: aws.String("shared"),
Engine: aws.String("postgres"),
MasterUsername: aws.String("god"),

View File

@ -0,0 +1 @@
package cmd

View File

@ -0,0 +1,12 @@
package cmd
// DB mimics the general info needed for services used to define placeholders.
type DB struct {
Host string
User string
Pass string
Database string
Driver string
DisableTLS bool
}

View File

@ -57,6 +57,18 @@ func main() {
return // We displayed help.
}
/*
//
DBInstanceIdentifier: aws.String(req.ProjectName + "-" + req.Env),
Secret ID used to store the DB username and password across deploys.
dbSecretId := filepath.Join(req.ProjectName, req.Env, *req.DBInstance.DBInstanceIdentifier)
*/
// =========================================================================
// Log App Info