Skip to content
This repository has been archived by the owner on Mar 16, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from ibuildthecloud/main
Browse files Browse the repository at this point in the history
Improve messages and metadata for serverless acorn
  • Loading branch information
ibuildthecloud authored Aug 14, 2023
2 parents 7fca888 + 81792aa commit dc8d200
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 5 deletions.
33 changes: 33 additions & 0 deletions rds/serverless/Acornfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
name: "AWS Aurora Serverless Database"
description: "AWS managed on-demand, autoscaling database"
icon: "icon.png"
info: localData.info

args: {
// Name of the root/admin user. Default is admin.
adminUsername: "admin"
Expand All @@ -23,13 +28,15 @@ args: {
}

services: rds: {
name: "Database Instance"
default: true
generated: job: "apply"
}

services: "cdk-context": build: "../../utils/cdk"

jobs: apply: {
name: "CloudFormation Provisioner"
build: {
context: ".."
buildArgs: MAIN: "serverless"
Expand Down Expand Up @@ -93,6 +100,7 @@ jobs: apply: {

if args.username != "" {
jobs: "create-user": {
name: "Create Additional User"
build: images.user.containerBuild
dependsOn: ["apply"]
env: {
Expand All @@ -106,6 +114,7 @@ if args.username != "" {
}

secrets: user: {
name: "User Credential"
type: "basic"
data: username: args.username
}
Expand All @@ -117,6 +126,30 @@ images: user: containerBuild: {
}

secrets: admin: {
name: "Admin Credential"
type: "generated"
params: job: "apply"
}

localData: info: """
## Connection Information

**Address**: @{services.rds.address}:@{services.rds.port.3306} \\
**Admin User Name**: \(args.adminUsername) \\
**Admin User Secret**: @{acorn.name}.admin

## Sample Usage
```typescript
containers: app: {
image: "app-image"
env: {
DB_HOST: "@{@{service.}@{acorn.name}.address}"
DB_PORT: "@{@{service.}@{acorn.name}.port.3306}"
DB_NAME: "@{@{service.}@{acorn.name}.data.dbName}"
DB_USER: "@{@{service.}@{acorn.name}.secrets.admin.username}"
DB_PASS: "@{@{service.}@{acorn.name}.secrets.admin.password}"
}
}

```
"""
Binary file added rds/serverless/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions utils/cdk/Acornfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
name: "CloudFormation Framework"
services: context: {
default: true
generated: job: "context-generator"
Expand Down
13 changes: 8 additions & 5 deletions utils/cfn-events/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,16 @@ func getEventPhrase(t bool) string {
}

func (s *Stack) message() string {
action := "provisioning"
key := "(ready/failed/total)"
action := "Provisioning"
suffix := ""
if s.FailedResources > 0 {
suffix = fmt.Sprintf(" (%d failed, stack: %s)", s.FailedResources, s.Name)
}

value := s.ReadyCount
if os.Getenv(acornEventKey) == "delete" {
action = "deleting"
key = "(deleted/failed/total)"
action = "Deleting"
value = s.DeletedCount
}
return fmt.Sprintf("CFN Stack: %s %s, %d/%d/%d %s\n", s.Name, action, value, s.FailedResources, s.TotalCount, key)
return fmt.Sprintf("CloudFormation: %s resources (%d/%d ready)%s\n", action, value, s.TotalCount, suffix)
}

0 comments on commit dc8d200

Please sign in to comment.