Skip to content

Commit

Permalink
remove resource list from the install command
Browse files Browse the repository at this point in the history
and uninstall command.

Before:
```
Mantil node org5 created:
	+ S3 bucket
	+ Lambda functions
	+ API Gateways
	+ IAM Roles
	+ DynamoDB tables
	+ Cloudwatch log groups
	+ Cloudformation stack
```

Now we have `mantil aws resources` command which will list exact
resource names, not just types.

```
Resources:
|    NAME    |         TYPE         |     AWS RESOURCE NAME      |               CLOUDWATCH LOG GROUP               |
|------------|----------------------|----------------------------|--------------------------------------------------|
| setup      | Lambda Function      | mantil-setup-3c2b1d2d      | /aws/lambda/mantil-setup-3c2b1d2d                |
| authorizer | Lambda Function      | mantil-authorizer-3c2b1d2d | /aws/lambda/mantil-authorizer-3c2b1d2d           |
| deploy     | Lambda Function      | mantil-deploy-3c2b1d2d     | /aws/lambda/mantil-deploy-3c2b1d2d               |
| destroy    | Lambda Function      | mantil-destroy-3c2b1d2d    | /aws/lambda/mantil-destroy-3c2b1d2d              |
| security   | Lambda Function      | mantil-security-3c2b1d2d   | /aws/lambda/mantil-security-3c2b1d2d             |
| setup      | CloudFormation Stack | mantil-setup-3c2b1d2d      |                                                  |
| http       | API Gateway          | mantil-http-3c2b1d2d       | /aws/vendedlogs/mantil-http-access-logs-3c2b1d2d |
|            | S3 Bucket            | mantil-3c2b1d2d            |                                                  |
Tags:
|       KEY        |         VALUE          |
|------------------|------------------------|
| MANTIL_KEY       | 3c2b1d2d               |
| MANTIL_WORKSPACE | NNq-UA4JS-Wsk8TYBwwoUw |
```
  • Loading branch information
ianic committed Dec 26, 2021
1 parent 5b160c2 commit 0007689
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions cli/controller/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (

"github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
"github.com/manifoldco/promptui"
"github.com/mantil-io/mantil/kit/aws"
"github.com/mantil-io/mantil/cli/controller/invoke"
"github.com/mantil-io/mantil/cli/log"
"github.com/mantil-io/mantil/cli/ui"
"github.com/mantil-io/mantil/domain"
"github.com/mantil-io/mantil/kit/aws"
"github.com/mantil-io/mantil/kit/progress"
"github.com/mantil-io/mantil/node/dto"
)
Expand Down Expand Up @@ -146,8 +146,7 @@ func (c *Setup) create(n *domain.Node) error {
AWSRegion: c.aws.Region(),
}})

ui.Title("\nMantil node %s created:\n", c.nodeName)
c.printNodeResources("+")
ui.Title("\nMantil node %s created.\n", c.nodeName)
return nil
}

Expand Down Expand Up @@ -271,7 +270,7 @@ func (c *Setup) Destroy() (bool, error) {
}
n := ws.Node(c.nodeName)
if n == nil {
return false, log.Wrap(&domain.NodeNotFoundError{c.nodeName})
return false, log.Wrap(&domain.NodeNotFoundError{Name: c.nodeName})
}
if !c.confirmDestroy(n) {
return false, nil
Expand Down Expand Up @@ -349,29 +348,14 @@ func (c *Setup) destroy(n *domain.Node) error {
InfrastructureDuration: infrastructureDuration,
}})
ui.Info("")
ui.Title("Mantil node %s destroyed:\n", c.nodeName)
c.printNodeResources("-")
ui.Title("Mantil node %s destroyed.\n", c.nodeName)
return nil
}

func (c *Setup) renderStackTemplate(data stackTemplateData) ([]byte, error) {
return renderTemplate(setupStackTemplate, data)
}

func (c *Setup) printNodeResources(sign string) {
resources := []string{
"S3 bucket",
"Lambda functions",
"API Gateways",
"IAM Roles",
"DynamoDB tables",
"Cloudwatch log groups",
"Cloudformation stack",
}
sep := fmt.Sprintf("\n\t%s ", sign)
ui.Info("\t%s %s ", sign, strings.Join(resources, sep))
}

type stackProgress struct {
prefix string
currentCnt int
Expand Down

0 comments on commit 0007689

Please sign in to comment.