GithubHelp home page GithubHelp logo

test-mass-forker-org-1 / amazon-keyspaces-cql-to-cfn-converter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from aws/amazon-keyspaces-cql-to-cfn-converter

0.0 0.0 0.0 84 KB

Command-line tool for converting Apache Cassandra Query Language (CQL) scripts to AWS CloudFormation (CFN) templates, so Amazon Keyspaces (for Apache Cassandra) schema can be easily managed in AWS CloudFormation stacks.

Home Page: https://docs.aws.amazon.com/keyspaces/latest/devguide/what-is-keyspaces.html

License: Apache License 2.0

Kotlin 71.39% GAP 28.61%

amazon-keyspaces-cql-to-cfn-converter's Introduction

IMPORTANT: Latest Version

The current version is 1.0.0. Please see the changelog for details on version history.

Overview

This package implements a command-line tool for converting Apache Cassandra Query Language (CQL) scripts to AWS CloudFormation (CFN) templates, which allows Amazon Keyspaces (for Apache Cassandra) schema to be easily managed in AWS CloudFormation stacks.

The tool currently supports the following statements:

  • CREATE KEYSPACE
  • CREATE TABLE
  • USE

Example Usage

Given a CQL script named my_cql_script.cql

CREATE KEYSPACE my_keyspace WITH replication = {'class': 'SingleRegionStrategy'};
USE my_keyspace;
CREATE TABLE my_table (pk int PRIMARY KEY);

run the tool by executing

$ cql2cfn my_cql_script.cql my_cfn_template.json

this will produce a CFN template named my_cfn_template.json

{
  "Resources": {
    "Keyspace1": {
      "Type": "AWS::Cassandra::Keyspace",
      "Properties": {
        "KeyspaceName": "my_keyspace"
      }
    },
    "Table1": {
      "Type": "AWS::Cassandra::Table",
      "Properties": {
        "KeyspaceName": {
          "Ref": "Keyspace1"
        },
        "PartitionKeyColumns": [
          {
            "ColumnName": "pk",
            "ColumnType": "int"
          }
        ],
        "ClusteringKeyColumns": [],
        "RegularColumns": [],
        "TableName": "my_table"
      }
    }
  }
}

The tool requires one argument, the path to the CQL script to be converted. An optional second argument can be supplied to specify the path to the generated CFN template; otherwise, the generated CFN template is printed out to the standard output.

By default, the tool operates in relaxed mode, in which case it only gives warnings about the following issues:

  • A property specified for a keyspace/table is not applicable to or supported by Keyspaces
  • A keyspace/table is created a second time without IF NOT EXISTS
  • A keyspace is referenced without being created before

These warnings can be turned into errors by supplying the --strict option to the tool.

A help message can be printed out by using the --help option.

How to build the tool

The tool needs to be built from source by running the following on Linux/MacOS...

./gradlew installDist

on Microsoft Windows, run...

gradlew.bat installDist

JDK 11 or later is required for building the tool.

After it is built successfully, the executable can be found in ./build/install/cql2cfn/bin/cql2cfn.

Testing

To execute tests on Linux/MacOS use...

./gradlew test

On Microsoft Windows use...

gradlew.bat test

amazon-keyspaces-cql-to-cfn-converter's People

Contributors

bhouse99 avatar amazon-auto avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.