Git Product home page Git Product logo

jgillenwater / terraform-provider-astra Goto Github PK

View Code? Open in Web Editor NEW

This project forked from datastax/terraform-provider-astra

0.0 0.0 0.0 351 KB

A project that allows DataStax Astra users to manage their full database lifecycle for Astra Serverless databases (built on Apache Cassandra(TM)) using Terraform

Home Page: https://registry.terraform.io/providers/datastax/astra

License: Mozilla Public License 2.0

Shell 0.97% Go 98.72% Makefile 0.31%

terraform-provider-astra's Introduction

Terraform Provider for Astra

Astra is DataStax's (serverless) service platform for Apache Cassandra and Apache Pulsar.

Prerequisites

Astra

Before using this provider, you will need an existing or new Astra account. You will also need an Astra token which is used for authentication. You can generate a new token using the Token Management section on the Astra Dashboard.

Terraform

You will need Terraform version 1.0 or higher.

Getting Started

Reference documentation can be found in the terraform registry

Create a new Astra database using terraform

  1. Create a file called main.tf in a new directory:

    terraform {
      required_providers {
        astra = {
          source = "datastax/astra"
          version = "2.1.15"
        }
      }
    }
    
    variable "token" {}
    
    provider "astra" {
      // This can also be set via ASTRA_API_TOKEN environment variable.
      token = var.token
    }
    
    resource "astra_database" "example" {
      name           = "mydb1"
      keyspace       = "ks1"
      cloud_provider = "gcp"
      regions        = ["us-east1"]
    }
  2. Initialize terraform

    terraform init
    
  3. Preview the changes

    terraform plan
    
  4. Create resources

    terraform apply
    

    If the changes look ok, then approve the changes with yes.

  5. Wait for the resources to be created. The new database should be visible in the Astra Dashboard .

Examples

The examples diretory contains example configuration for the various resources.

Local Development

Build the provider from source

The build requires Go >= 1.15

In order to develop and test this provider, you'll need to configure your local environment with a custom Terraform config file. This allows provider plugins to be retrieved from the local file system instead of from the public servers.

  1. Edit or create a .terraformrc file in your $HOME directory which includes custom provider_installation settings. Note that you will need to manually expand $HOME to your actual home directory.

    provider_installation {
      # This disables the version and checksum verifications for locally installed astra providers.
      # See: https://developer.hashicorp.com/terraform/cli/config/config-file#development-overrides-for-provider-developers
      dev_overrides {
        "datastax/astra" = "$HOME/go/src/github.com/datastax/terraform-provider-astra/bin"
      }
      direct {
      }
    }
    
  2. Build the provider binary

    cd $HOME/go/src/github.com/datastax/terraform-provider-astra
    make
    
  3. Create a new Terraform config file or run an existing one and the locally built provider will be used. You may see a warning about using an unverified binary.

    โ”‚ Warning: Provider development overrides are in effect
    

    Note: terraform init should be skipped when developing locally.

Running the tests

The tests require several environment variables to be set in order to successfully run. By default any tests which are missing the required environment variables will be skipped.

```sh
export ASTRA_TEST_DATABASE_ID="<Astra database UUID>"
export ASTRA_TEST_DATACENTER_ID="<Astra datacenter id>"
export ASTRA_TEST_ENDPOINT_ID="<Astra endpoint ID>"
```

An example of these variables can be found in the file test/example-test.env. If a file called test/test.env is created it will be automatically loaded by the test script.

The tests can be run via Make.

make test

A single test can be run using golang test args.

```sh
export TESTARGS="-run TestStreamingTenant"
make test
```

Documentation Updates

When modifying plugin services, updates to documentation may be required. Once you have changed a service description, or added or deleted a service, you need to regenerate the docs and commit them with your changes.

Generating docs

The tool used to generate documentation is tfplugindocs. See the installation section for installing the tool. Once installed, generate the docs by running tfplugindocs from the root of the project:

tfplugindocs

The tool will build the plugin and generate the docs based on the implementation. Make sure to add the docs folder to your commit to include any changes in the docs.

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.