GithubHelp home page GithubHelp logo

tmeckel / terraform-provider-spacelift Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spacelift-io/terraform-provider-spacelift

0.0 0.0 0.0 1.29 MB

Terraform provider to interact with Spacelift

License: MIT License

Go 100.00%

terraform-provider-spacelift's Introduction

Spacelift Terraform Provider

The Spacelift Terraform provider is used to programmatically interact with its GraphQL API, allowing Spacelift to declaratively manage itself ๐Ÿคฏ

Documentation

You can browse documentation on the Terraform provider registry.

Using the Provider

Terraform 0.13 and Above

You can use the provider via the Terraform provider registry.

Terraform 0.12 or Manual Installation

You can download a pre-built binary from the releases page, these are built using goreleaser (the configuration is in the repo). You can verify the signature using this key.

If you want to build from source, you can simply use go build in the root of the repository.

Development

Tools

To develop the provider locally you need the following tools:

Generating the Documentation

To generate the documentation, run the following command:

cd tools
go generate ./...

Using a Local Build of the Provider

Sometimes as well as running unit tests, you want to be able to run a local build of the provider against Spacelift. This involves the following steps:

  1. Building a copy of the provider using GoReleaser.
  2. Updating your .terraformrc file to point at your local build.
  3. Generating an API key in Spacelift.
  4. Running Terraform locally.

Building the Provider Using GoReleaser

To build the provider, run the following command:

goreleaser build --clean --snapshot

This will produce a number of binaries in subfolders of the dist folder for each supported architecture and OS:

dist
|-- artifacts.json
|-- config.yaml
|-- metadata.json
|-- terraform-provider-spacelift_darwin_amd64_v1
|   `-- terraform-provider-spacelift_v0.1.11-SNAPSHOT-bb215e9
|-- terraform-provider-spacelift_darwin_arm64
|   `-- terraform-provider-spacelift_v0.1.11-SNAPSHOT-bb215e9
|-- terraform-provider-spacelift_linux_amd64_v1
|   `-- terraform-provider-spacelift_v0.1.11-SNAPSHOT-bb215e9
|-- terraform-provider-spacelift_linux_arm64
|   `-- terraform-provider-spacelift_v0.1.11-SNAPSHOT-bb215e9
|-- terraform-provider-spacelift_windows_amd64_v1
|   `-- terraform-provider-spacelift_v0.1.11-SNAPSHOT-bb215e9.exe
`-- terraform-provider-spacelift_windows_arm64
    `-- terraform-provider-spacelift_v0.1.11-SNAPSHOT-bb215e9.exe

Updating your .terraformrc file

The next step is telling Terraform to use your local build, rather than a copy from the Terraform registry. You can do this by specifying dev_overrides in your .terraformrc file.

To do this, edit or create a .terraformrc in your home folder, and add the following contents:

provider_installation {
  dev_overrides {
    "spacelift.io/spacelift-io/spacelift" = "<absolute-path-to-repo>/dist/terraform-provider-spacelift_<OS>_<arch>"
  }

  direct {}
}

Make sure to replace <absolute-path-to-repo>, <OS>, and <arch> with the correct values, for example:

"spacelift.io/spacelift-io/spacelift" = "/home/my-user/github.com/spacelift-io/terraform-provider-spacelift/dist/terraform-provider-spacelift_linux_amd64_v1"

Generating an API Key

Follow the information in our API documentation page to generate an API key. Please make sure to generate an admin key since admin permissions are required for most operations you will be using the provider for.

Running Spacelift Terraform Provider Locally

To test your local build, just create the relevant Terraform files needed to test your changes, and run terraform plan, terraform apply, etc as normal. The main difference when running the provider locally rather than within Spacelift is that you need to tell it how to authenticate with your Spacelift account. Here's a minimal example:

terraform {
  required_providers {
    spacelift = {
      source = "spacelift.io/spacelift-io/spacelift"
    }
  }
}

provider "spacelift" {
  api_key_endpoint = "https://<account-name>.app.spacelift.io"
  api_key_id       = "<api-key-id>"
  api_key_secret   = "<api-key-secret>"
}

data "spacelift_account" "this" {
}

output "account_name" {
  value = data.spacelift_account.this.name
}

Make sure to replace <account-name>, <api-key-id> and <api-key-secret> with the relevant values.

Releasing New Versions of the Provider

In order to release a new version of the provider one should follow those simple steps:

  • Create a new tag for the latest commit on tha main branch git tag vX.Y.Z -m "Release"
  • Push the tag git push origin vX.Y.Z
  • Refer to our internal wiki on publishing the release artifacts

terraform-provider-spacelift's People

Contributors

marcinwyszynski avatar adamconnelly avatar cube2222 avatar jmfontaine avatar michieldewilde avatar truszkowski avatar peterdeme avatar b4k3r avatar themacies avatar tomasmik avatar yantrio avatar michalg9 avatar kniepok avatar mwasilew2 avatar eliecharra avatar mbialon avatar wojciech12 avatar alexjurkiewicz avatar spitzzz avatar dobarx avatar gergu avatar spr-mweber3 avatar hoeg avatar clistoq avatar dependabot[bot] avatar elliott-weston-cko avatar github-actions[bot] 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.