Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow IAM roam role per AWS account. #3

Merged
merged 1 commit into from
Mar 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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