Skip to content

Commit

Permalink
added readme and output text
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerwelin committed Feb 10, 2020
1 parent ac5735f commit 9f69e39
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
15 changes: 14 additions & 1 deletion new-api.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"fmt"
"os"
"text/template"
"time"
Expand Down Expand Up @@ -140,10 +141,18 @@ func (tmpl *TmplData) bootstrapAPI() error {
// create top dir
createDir(tmpl.ApiProjectName)

// create readme
mg.Printf("\u2705 Writing out README\n")
time.Sleep(350 * time.Millisecond)
err := tmpl.createFileFromTemplate(reamdeFile, tmpl.ApiProjectName, "README.md")
if err != nil {
panic(err)
}

// create apigw sam/cf
mg.Printf("\u2705 Writing out CF/SAM config\n")
time.Sleep(350 * time.Millisecond)
err := tmpl.createFileFromTemplate(apiGWConf, tmpl.ApiProjectName, "apigw.yml")
err = tmpl.createFileFromTemplate(apiGWConf, tmpl.ApiProjectName, "apigw.yml")
if err != nil {
panic(err)
}
Expand All @@ -163,5 +172,9 @@ func (tmpl *TmplData) bootstrapAPI() error {
if err != nil {
return err
}

green := color.New(color.FgGreen).SprintFunc()
fmt.Printf("Success! Created API GW project at %s\nInside that directory, you can run several commands:\n\n\t%s\n\t\tcreates a zip of your code and dependencies and uploads it to S3\n\t%s\n\t\tdeploys the specified CloudFormation/SAM template by creating and then executing a change set\n\nHowever I recommend taking a look at the README file first\n\n", green(tmpl.ApiProjectName+"/"), green("sam package --template-file apigw.yml --output-template-file out.yaml --s3-bucket Your-S3-bucket"), green("sam deploy --template-file ./out.yaml --stack-name your-api-project --capabilities CAPABILITY_IAM"))

return nil
}
1 change: 0 additions & 1 deletion tmpl-languages.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

// node.js

const nodeFunction = `
'use strict'
const winston = require('winston')
Expand Down
29 changes: 29 additions & 0 deletions tmpl-readme.go
Original file line number Diff line number Diff line change
@@ -1 +1,30 @@
package main

const reamdeFile = `
## API GW Project
### Install Dependencies
You need the following dependencies to be able to build and deploy the api project:
* A working Pyhton installation
* awscli
* sam (serverless application model)
* create a new S3-bucket to store deployment files
**Install awscli and SAM**
` + "```" + `bash
$ pip install --user awscli
$ pip install --user aws-sam-cli
` + "```" + `
### Build the Project
` + "```" + `bash
$ sam package --template-file apigw.yml --output-template-file out.yaml --s3-bucket {Your-S3-bucket}
` + "```" + `
### Deploy the API
` + "```" + `bash
$ sam deploy --template-file ./out.yaml --stack-name your-api-project --capabilities CAPABILITY_IAM
` + "```" + `
`

0 comments on commit 9f69e39

Please sign in to comment.