Skip to content

Commit

Permalink
Allow IAM roam role per AWS account.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhlias committed Mar 16, 2017
1 parent f000f3c commit f0b1f29
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ From the files mentioned above here are some examples of what their contents nee
```
project: name_of_your_project
region: eu-west-1
roam-role: roam-role
roam-roles:
project-dev: roam-role-dev
project-prd: roam-role-prd
use-sts: true
encrypt-s3-state: true
accounts-mapping:
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
type conf struct {
Project string
Region string
Roam_role string `yaml:"roam-role"`
Roam_roles map[string]string `yaml:"roam-roles"`
Accounts_mapping map[string]string `yaml:"accounts-mapping"`
Use_sts bool `yaml:"use-sts"`
Encrypt_s3_state bool `yaml:"encrypt-s3-state"`
Expand Down Expand Up @@ -126,7 +126,7 @@ func main() {
awsconf := &aws_helper.Config{
Region: project_config.Region,
Profile: profile,
Role: project_config.Roam_role,
Role: project_config.Roam_roles[project_config.account],
Account_id: project_config.Accounts_mapping[project_config.account],
Use_mfa: use_mfa,
Use_sts: project_config.Use_sts,
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ func TestProjectConfig(t *testing.T) {

project_config := load_config(fmt.Sprintf("%s/project.yaml", fixtures_dir))

if project_config.Project != "test" || project_config.Region != "eu-west-1" || !project_config.Use_sts || !project_config.Encrypt_s3_state || project_config.Roam_role != "roam-role" || len(project_config.Accounts_mapping[fmt.Sprintf("%s-dev", project_config.Project)]) <= 0 || len(project_config.Accounts_mapping[fmt.Sprintf("%s-prd", project_config.Project)]) <= 0 {
if project_config.Project != "test" || project_config.Region != "eu-west-1" || !project_config.Use_sts || !project_config.Encrypt_s3_state || len(project_config.Roam_roles[fmt.Sprintf("%s-dev", project_config.Project)]) <= 0 || len(project_config.Accounts_mapping[fmt.Sprintf("%s-dev", project_config.Project)]) <= 0 || len(project_config.Accounts_mapping[fmt.Sprintf("%s-prd", project_config.Project)]) <= 0 {
t.Fatal("Project configuration parameters in fixtures don't match expected values when parsed.")
}

Expand Down
4 changes: 3 additions & 1 deletion test-fixtures/project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

project: test
region: eu-west-1
roam-role: roam-role
roam-roles:
test-dev: roam-role-dev
test-prd: roam-role-prd
use-sts: true
encrypt-s3-state: true
accounts-mapping:
Expand Down

0 comments on commit f0b1f29

Please sign in to comment.