0.0.43 • Published 12 months ago

@talkncloud/tnc-cup v0.0.43

Weekly downloads
253
License
MIT
Repository
github
Last release
12 months ago

tcup

GitHub license npm version Known Vulnerabilities

Note: This is currently in PREVIEW. There will be bugs, we will fix the bugs.

talkncloud checkup (tcup) has been developed by talkncloud and is a client for AWS price estimation. This cli client will parse cloudformation templates and post revelvant sections to the tcup backend api to provide a price estimate.

Some key features:

  • Parse cloudformation & CDK (transpiled CF out)
  • Minimize post data by configuring client to remove key sections
  • Convert the estimate into your local currency
  • Support for multiple regions
  • Set a budget threshold
  • CI/CD friendly with error 0, 1, 2
  • Cli output with tabular display

How to Install

npm install -g @talkncloud/tcup

tcup can now be used from the terminal simply by running "tcup"

Configuration

The local configuration contains common configuration parameters required to use tcup. The configuration file is located in the $HOME directory named ".config.json".

Install the sample config file by running the following command

tcup config

a new file will be created in $HOME/.config/tcup.json

Configuration Parameters

KeyTypePossible valuesDescription
apiobjectRequired
api.baseUrlstringhttps://api.talkncloud.comRequired, fixed
api.versionstringclientRequired, fixed
api.headerobjectRequired
api.header.x-api-keystringsome api keyRequired
templateEndpointstringtemplateRequired, where data is posted to - /template
servicesEndpointstringservicesRequired, list of supported services - /services
findobject
find.includearray["AWS::CDK::Metadata"]if include empty or undefined, it will show all resources
find.excludearray["AWS::CDK::Metadata"]exclude will override include
currencystringUSDthree letter country code to convery currency
budgetstring50.00budget allocated for this template
regionstringap-southeast-2AWS compatible region code

API KEY

Go to tcup to register, once registered use the dashboard to generate an API KEY. Use this key to update your config.json.

Cli usage

USAGE
  $ tcup [COMMAND]

COMMANDS
  config  configure the local config file
  cost    perform cloud cost estimation
  help    display help for tcup

cost usage

USAGE
  $ tcup cost [OPTS]

OPTIONS
  -h, --help               show CLI help
  -j, --json               prepend json api response to stdout
  -o, --output             output results to plain text
  -t, --template=template  (required) template to read

Example

  1. Navigate to your directory with the cloudformation template
  2. tcup -t mytemplate.json || yaml
  [ DynamoDB ]                                                                                              
  |> tncdb38B2E622                                                                                          
  |- rcu        $0.00013 per hour for units of read capacity beyond the free tier                 $2.6    
  |-- units     20000 RCU                                                                                 
  |- storage    $0.25 per GB-Month of storage used beyond first 25 free GB-Months                 $166.5  
  |-- units     666 GB                                                                                    
  |- wcu        $0.00065 per hour for units of write capacity beyond the free tier                $13     
  |-- units     20000 WCU                                                                                 
  [ Cognito ]                                                                                               
  |> tncup                                                                                                  
  |- pool       Cognito User Pools us-east-1 tier 1 pricing                                       $27.5   
  |-- units     5000 USER                                                                                 
  [ AppSync ]                                                                                               
  |> api                                                                                                    
  |- api        $4 per million query and data modification operations in US East (N. Virginia)    $40     
  |-- units     10000000 REQ                                                                              
  [ WAFv2 ]                                                                                                 
  |> waf                                                                                                    
  |- req        $0.60 per million requests processed                                              $0.06   
  |-- units     100000 REQ                                                                                
  |- rule       $1.00 per rule created (prorated hourly)                                          $3      
  |-- units     3 RULE                                                                                    
  |- acl        $5.00 per web ACL created (prorated hourly)                                       $5      
  |-- units     1 COUNT                                                                                   
                                                                                                          
                                                                                   DAILY (USD)    $9      
                                                                                  WEEKLY (USD)    $64     
                                                                                 MONTHLY (USD)    $258    
Budget: over monthly budget by $157 (USD)

SUPPORTED SERVICES

At this time we only support AWS. A list of supported AWS services can be found here: services

API

tcup consists of a client that interfaces with the backend api. The backend api exposes a few endpoints and can be queried using typical curl tools.

Authorization

In general, to use the API you'll need an API key, the keys have typical rate limiting etc enabled. To use the endpoints below add the following to the header:

x-api-key: 'YOUR AWESOME KEY HERE'

Endpoints

Post body to api

POST /template

Body

[{"file":[{"WebInstance":{"Type":"AWS::EC2::Instance","Properties":{"BlockDeviceMappings":[{"DeviceName":"/dev/sda1","Ebs":{"VolumeSize":24000,"VolumeType":"gp3"}}],"InstanceType":"t2.nano","ImageId":"ami-80861296","KeyName":"my-key","Monitoring":true,"SecurityGroupIds":[{"class":"Ref","name":"Ref","data":"WebSecurityGroup"}],"SubnetId":"subnet-abc01234","Tags":[{"Key":"Name","Value":"webserver"}],"Volumes":[{"Device":"/dev/sdf","VolumeId":{"class":"Ref","name":"Ref","data":"LogVolume"}}]}}}],"currency":{"code":"USD"},"budget":10, "region": "us-east-1"}]

Response

[
    {
        "EC2": {
            "Compute": {
                "description": "$0.0058 per On Demand Linux t2.nano Instance Hour - ami: Canonical, Ubuntu, 16.04 LTS, amd64 xenial image build on 2017-04-14",
                "price": 4.0
            },
            "Storage-AMI": {
                "description": "$0.10 per GB-month of General Purpose SSD (gp2) provisioned storage - US East (Northern Virginia) size: 8GB",
                "price": 0.8
            },
            "Storage": {
                "description": "$0.005 per provisioned IOPS-month of gp3 - US East (N. Virginia) size: 24000GB",
                "price": 120.0
            }
        }
    },
    {
        "TOTAL (USD)": {
            "description": "Total estimated price (USD)",
            "price": 125
        }
    },
    {
        "budget": {
            "status": 1,
            "message": "over budget by $114 (USD)"
        }
    }
]

List current supported services

GET /services

Response

{
    "AppSync:GraphQLApi": "AWS::AppSync::GraphQLApi",
    "Cognito:UserPool": "AWS::Cognito::UserPool",
    "EC2:Instance": "AWS::EC2::Instance",
    "EC2:Volume": "AWS::EC2::Volume",
    "RDS:DBInstance": "AWS::RDS::DBInstance",
    "S3:Bucket": "AWS::S3::Bucket",
    "WAFv2:WebACL": "AWS::WAFv2::WebACL"
}

List supported currencies for conversion

GET /currency

Response

{
    "results": {
        "ALL": {
            "currencyName": "Albanian Lek",
            "currencySymbol": "Lek",
            "id": "ALL"
        },
        "XCD": {
            "currencyName": "East Caribbean Dollar",
            "currencySymbol": "$",
            "id": "XCD"
        },
        "EUR": {
            "currencyName": "Euro",
            "currencySymbol": "€",
            "id": "EUR"
        }...

API response codes

Status CodeDescription
200OK
400BAD REQUEST
403ACCESS DENIED
429TOO MANY REQUESTS / LIMIT
500INTERNAL SERVER ERROR
502BAD GATEWAY
503UNAVAILABLE
504TIMEOUT

Contributing

Yes please! Check out our contribution guide.

0.0.43

12 months ago

0.0.41

12 months ago

0.0.42

12 months ago

0.0.38

12 months ago

0.0.37

12 months ago

0.0.36

1 year ago

0.0.35

1 year ago

0.0.34

1 year ago

0.0.33

1 year ago

0.0.32

1 year ago

0.0.31

1 year ago

0.0.30

1 year ago

0.0.28

1 year ago

0.0.29

1 year ago

0.0.27

1 year ago

0.0.26

1 year ago

0.0.25

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.20

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.10

1 year ago

0.0.11

1 year ago

0.0.12

1 year ago

0.0.13

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago