Skip to content

Latest commit

 

History

History
114 lines (73 loc) · 5.83 KB

README.md

File metadata and controls

114 lines (73 loc) · 5.83 KB

Billing Dashboard & Alert System

Billing Dashboard Service to Provide Billing API Interfaces and Generate Billing Alert For Over Charges.

This creates a Redshift cluster where Billing report data is exported whenever the report is created.

aws-services

How To Setup a CodePipeline

Launch Stack

Input Parameter Values

  • CloudformationLambdaExecutionRoleArn:

    Enter ARN of IAM Role for Cloudformation to create changesets and target stack. If you already created one or more CodePipeline that uses Cloudformation, this role should have been created already, so you can use the same role, 'cloudformation-lambda-execution-role'. If not, please create a role with the same name with Trust Relationships and Policy Document defined here.

  • CodePipelineServiceRoleArn:

    Enter ARN of IAM Role for CodePipeline to be executed. If you already created one or more CodePipeline, this role should have been created already, so you can use the same role, 'AWS-CodePipeline-Service'. If not, please create a role with the same name with Trust Relationships and Policy Document defined here.

  • CustomAuthorizerIAMRoleName:

    Enter the NAME (not ARN) of IAM Role that has the permission for API Gateway to invoke custom authorizer Lambda Function. (See here for Trust Relationships and Policy Document).

  • CustomAuthorizerLambdaName:

    Enter the NAME (not ARN) of custom authorizer Lambda Function. (See here for the Lambda Function Project for Custom Authorizer using SSO Server).

  • EncryptionLambdaName:

    Enter the NAME (not ARN) of the encryption Lambda Function. If you didn't already deployed the Encryption Lambda Function, see here to deploy the Lambda Function to Encrypt Environment Variables.

  • GitHubPersonalAccessToken:

    Access Token for CodeBuild to access to the this Github repository. (See here to find how to generate the access token).

  • GitHubSourceRepositoryBranch: master

  • GitHubSourceRepositoryName: aws-services-billing

  • GitHubSourceRepositoryOwner: SungardAS

  • ParameterOverrides: { "VPCCidrBlock": "ip_range", "SubnetCidrBlock1": "ip_range", "SubnetCidrBlock2": "ip_range", "NameTag": "redshift", "RedshiftUser": "redshift_user", "RedshiftPass": "redshift_pass", "RedshiftDatabase": "redshift_db", "RedshiftSnapshotIdentifier": "snapshot_id_to_restore_from", "RedshiftSnapshotClusterIdentifier": "cluster_of_source_snapshot", "AlarmThresholdNumber": "10", "AllowedAverageCost": "2", "PlotlyUsername": "plotly_user_name", "PlotlyAPIKey": "plotly_api_key", "SlackWebHookUrl": "slack_web_hook_url", "SlackChannel": "slack_channel" }

  • ProjectImage: aws/codebuild/nodejs:4.3.2

How to Setup a Billing Report to Upload Billing Data to S3 Bucket & Redshift

The creation of this project stack will be started automatically once its Codepipline is successfully setup.

Follow steps in here.

  • Specify 'BillingDataUploadBucketName' value in the Output of the newly created this project stack for the S3 Bucket Name
  • Choose 'BucketServiceIAMRoleNameForRedshift' value in the Output of the newly created this project stack during "Manage IAM Roles"

Once the billing report is created in the S3 bucket, the billing data will be automatically imported to the Redshift.

How To Send Requests To API

  • Find the API url from the 'Output' tab of the "SungardAS-aws-services-billing" stack in the Cloudformation console

To get the charge differences for all accounts

path: /billing
method : GET
headers: {
  "Authorization": <refresh_token_from_SSO_server>
}

To get the charge differences for all services in a specific account

path: /billing?account=<<account_id>>
method : GET
headers: {
  "Authorization": <refresh_token_from_SSO_server>
}

To run a specific SQL against the Redshift database

path: /sql
method : POST
headers: {
  "Authorization": <refresh_token_from_SSO_server>
}
data:
{
  "sql": "<<SQL>>"
}

How To Test Lambda Functions

  • $ cd tests
  • Export necessary environment variables and fill the necessary input values
  • $ node test_xxx.js

Sungard Availability Services | Labs

This project is maintained by the Labs group at Sungard Availability Services

GitHub: https://sungardas.github.io

Blog: http://blog.sungardas.com/CTOLabs/