Skip to content

Commit

Permalink
Modularized terraform code, added cognito admin user controls, added …
Browse files Browse the repository at this point in the history
…support for route53
  • Loading branch information
seanturner026 committed May 22, 2021
1 parent 1348439 commit 287a0ce
Show file tree
Hide file tree
Showing 39 changed files with 556 additions and 277 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### Serverless Release Dashboard
### Moot - A Serverless Release Dashboard

AWS Serverless solution deployed with Terraform which implements a single-page-application dashboard. This dashboard creates releases that are intended to trigger continuous integration (CI) production deploy pipelines. All that is needed to kick off a release is a version number.

Expand All @@ -19,11 +19,11 @@ This solution utilises the following services:

#### Repositories View

![alt text](https://github.com/seanturner026/serverless-release-dashboard/blob/main/assets/repositories.png?raw=true)
![alt text](https://github.com/seanturner026/moot/blob/main/assets/repositories.png?raw=true)

#### Add Repository View
![alt text](https://github.com/seanturner026/serverless-release-dashboard/blob/main/assets/repositories-add.png?raw=true)
![alt text](https://github.com/seanturner026/moot/blob/main/assets/repositories-add.png?raw=true)

#### Users View

![alt text](https://github.com/seanturner026/serverless-release-dashboard/blob/main/assets/users.png?raw=true)
![alt text](https://github.com/seanturner026/moot/blob/main/assets/users.png?raw=true)
2 changes: 1 addition & 1 deletion cmd/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider"
"github.com/seanturner026/serverless-release-dashboard/internal/util"
"github.com/seanturner026/moot/internal/util"
log "github.com/sirupsen/logrus"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/auth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider/cognitoidentityprovideriface"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
"github.com/seanturner026/serverless-release-dashboard/internal/util"
"github.com/seanturner026/moot/internal/util"
log "github.com/sirupsen/logrus"
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/auth/reset_password.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider"
"github.com/seanturner026/serverless-release-dashboard/internal/util"
"github.com/seanturner026/moot/internal/util"
log "github.com/sirupsen/logrus"
)

Expand Down
96 changes: 0 additions & 96 deletions cmd/post_confirmation/main.go

This file was deleted.

12 changes: 7 additions & 5 deletions cmd/releases/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
"github.com/aws/aws-sdk-go/service/ssm"
"github.com/aws/aws-sdk-go/service/ssm/ssmiface"
"github.com/seanturner026/serverless-release-dashboard/internal/util"
"github.com/seanturner026/moot/internal/util"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -46,16 +46,17 @@ type awsController struct {
}

type configuration struct {
DashboardName string
SlackWebhookURL string
}

func (app awsController) getProviderToken(e releaseEvent) (string, error) {
func (app application) getProviderToken(e releaseEvent) (string, error) {
input := &ssm.GetParameterInput{
Name: aws.String(fmt.Sprintf("/dev_release_dashboard/%s_token", e.RepoProvider)),
Name: aws.String(fmt.Sprintf("/%s/%s_token", app.Config.DashboardName, e.RepoProvider)),
WithDecryption: aws.Bool(true),
}

resp, err := app.SSM.GetParameter(input)
resp, err := app.AWS.SSM.GetParameter(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
log.Error(fmt.Sprintf("%v", aerr.Error()))
Expand Down Expand Up @@ -111,7 +112,7 @@ func (app application) handler(event events.APIGatewayV2HTTPRequest) (events.API
log.Error(fmt.Sprintf("%v", err))
}

token, err := app.AWS.getProviderToken(e)
token, err := app.getProviderToken(e)
if err != nil {
message := fmt.Sprintf("Unable to release %s version %s, please double check the %s token", e.RepoName, e.ReleaseVersion, e.RepoProvider)
statusCode := 400
Expand Down Expand Up @@ -167,6 +168,7 @@ func main() {
SSM: ssm.New(session.Must(session.NewSession())),
},
Config: configuration{
DashboardName: os.Getenv("DASHBOARD_NAME"),
SlackWebhookURL: os.Getenv("SLACK_WEBHOOK_URL"),
},
}
Expand Down
12 changes: 6 additions & 6 deletions cmd/repositories/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ type createRepoEvent struct {
GitlabProjectID string `dynamodbav:"GitlabProjectID,omitempty" json:"gitlab_repo_id,omitempty"`
}

func (app awsController) getProviderToken(e createRepoEvent) (string, error) {
func (app application) getProviderToken(e createRepoEvent) (string, error) {
input := &ssm.GetParameterInput{
Name: aws.String(fmt.Sprintf("/dev_release_dashboard/%s_token", e.RepoProvider)),
Name: aws.String(fmt.Sprintf("/%s/%s_token", app.Config.DashboardName, e.RepoProvider)),
WithDecryption: aws.Bool(true),
}

resp, err := app.SSM.GetParameter(input)
resp, err := app.AWS.SSM.GetParameter(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
log.Error(fmt.Sprintf("%v", aerr.Error()))
Expand Down Expand Up @@ -87,7 +87,7 @@ func (app awsController) writeRepoToDB(e createRepoEvent, itemInput map[string]*
}
return err
}
log.Info(fmt.Sprintf("wrote ID %s successfully", e.RepoName))
log.Info(fmt.Sprintf("wroterepository %s successfully", e.RepoName))
return nil
}

Expand All @@ -98,9 +98,9 @@ func (app application) repositoriesCreateHandler(event events.APIGatewayV2HTTPRe
log.Error(fmt.Sprintf("%v", err))
}
e.PK = "repo"
token, err := app.AWS.getProviderToken(e)
token, err := app.getProviderToken(e)
if err != nil {
message := fmt.Sprintf("Unable to onboard %s, please double check that the token has read/write access to this repository", e.RepoName)
message := fmt.Sprintf("Unable to onboard %s, please double check that a token has been provided for %s", e.RepoName, e.RepoProvider)
statusCode := 400
return message, statusCode
}
Expand Down
16 changes: 12 additions & 4 deletions cmd/repositories/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ import (
"github.com/aws/aws-sdk-go/service/ssm"
"github.com/aws/aws-sdk-go/service/ssm/ssmiface"
"github.com/google/go-github/github"
util "github.com/seanturner026/serverless-release-dashboard/internal/util"
util "github.com/seanturner026/moot/internal/util"
log "github.com/sirupsen/logrus"
"github.com/xanzy/go-gitlab"
)

type application struct {
AWS awsController
GH githubController
GL gitlabController
AWS awsController
GH githubController
GL gitlabController
Config configuration
}

type awsController struct {
Expand All @@ -41,6 +42,10 @@ type gitlabController struct {
Client *gitlab.Client
}

type configuration struct {
DashboardName string
}

type repository struct {
RepoName string `json:"repo_name,omitempty"`
RepoProvider string `dynamodbav:"SK" json:"repo_provider,omitempty"`
Expand Down Expand Up @@ -85,6 +90,9 @@ func main() {
DB: dynamodb.New(session.Must(session.NewSession())),
SSM: ssm.New(session.Must(session.NewSession())),
},
Config: configuration{
DashboardName: os.Getenv("DASHBOARD_NAME"),
},
}

lambda.Start(app.handler)
Expand Down
2 changes: 1 addition & 1 deletion cmd/users/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider/cognitoidentityprovideriface"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbiface"
"github.com/seanturner026/serverless-release-dashboard/internal/util"
"github.com/seanturner026/moot/internal/util"
log "github.com/sirupsen/logrus"
)

Expand Down
Loading

0 comments on commit 287a0ce

Please sign in to comment.