Skip to content
This repository has been archived by the owner on Aug 17, 2020. It is now read-only.

Commit

Permalink
Detect outdated AWS roles and notify the user
Browse files Browse the repository at this point in the history
  • Loading branch information
cwaltken-edrans committed Jul 19, 2017
1 parent 2e9975a commit 8575526
Show file tree
Hide file tree
Showing 78 changed files with 15,891 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions infrastructure/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ import (
"encoding/json"
"fmt"
"io"
"os"
"path"
"time"

"github.com/Songmu/prompter"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
Expand All @@ -20,6 +23,10 @@ import (
uuid "github.com/satori/go.uuid"
)

var (
roleDate = time.Date(2017, 07, 13, 18, 40, 0, 0, time.UTC)
)

// AwsInfrastructure manages the resource creation and updates necessary to use
// Goad.
type AwsInfrastructure struct {
Expand Down Expand Up @@ -281,9 +288,18 @@ func (infra *AwsInfrastructure) createIAMLambdaRole(roleName string) (arn string
return "", err
}

CheckRoleDate(resp.Role)
return *resp.Role.Arn, nil
}

func CheckRoleDate(role *iam.Role) {
if role.CreateDate.Before(roleDate) {
if !prompter.YN("Your IAM role for goad might be outdated, continue anyways?", true) {
os.Exit(0)
}
}
}

func (infra *AwsInfrastructure) createIAMLambdaRolePolicy(roleName string) error {
svc := iam.New(session.New(), infra.config)

Expand Down
8 changes: 8 additions & 0 deletions vendor/github.com/Songmu/prompter/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions vendor/github.com/Songmu/prompter/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions vendor/github.com/Songmu/prompter/Makefile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions vendor/github.com/Songmu/prompter/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 71 additions & 0 deletions vendor/github.com/Songmu/prompter/exam_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions vendor/github.com/Songmu/prompter/funcs.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions vendor/github.com/Songmu/prompter/funcs_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 8575526

Please sign in to comment.