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

deveops load aws creds from session for deploy

This commit is contained in:
Lee Brown
2019-07-13 23:12:07 -08:00
parent 79e81aa7e8
commit aeeb51fc0f
4 changed files with 35 additions and 7 deletions

View File

@ -170,13 +170,22 @@ func (r *serviceDeployRequest) awsSession() *session.Session {
// AwsCredentials defines AWS credentials used for deployment. Unable to use roles when deploying
// using gitlab CI/CD pipeline.
type awsCredentials struct {
AccessKeyID string `validate:"required"`
SecretAccessKey string `validate:"required"`
Region string `validate:"required"`
AccessKeyID string `validate:"required_without=UseRole"`
SecretAccessKey string `validate:"required_without=UseRole"`
Region string `validate:"required_without=UseRole"`
UseRole bool
}
// Session returns a new AWS Session used to access AWS services.
func (creds awsCredentials) Session() *session.Session {
if creds.UseRole {
// 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())
}
return session.New(
&aws.Config{
Region: aws.String(creds.Region),