GithubHelp home page GithubHelp logo

yakdriver / terraform-provider-spotify Goto Github PK

View Code? Open in Web Editor NEW

This project forked from conradludgate/terraform-provider-spotify

0.0 1.0 0.0 1.64 MB

Terraform provider for spotify

Home Page: https://registry.terraform.io/providers/conradludgate/spotify/latest

License: MIT License

Go 99.21% Dockerfile 0.79%

terraform-provider-spotify's Introduction

terraform-provider-spotify

docs downloads latest version code coverage

This is a terraform provider for managing your spotify playlists.

Featured tutorial - https://learn.hashicorp.com/tutorials/terraform/spotify-playlist

Featured interview - https://www.hashicorp.com/blog/build-your-summer-spotify-playlist-with-terraform

I am not affiliated with Hashicorp or Terraform.

If you are having trouble with the provider, try updating to the latest version before submitting a bug report

Example

resource "spotify_playlist" "playlist" {
  name        = "My playlist"
  description = "My playlist is so awesome"
  public      = false

  tracks = flatten([
    data.spotify_track.overkill.id,
    data.spotify_track.blackwater.id,
    data.spotify_track.overkill.id,
    data.spotify_search_track.search.tracks[*].id,
  ])
}

data "spotify_track" "overkill" {
  url = "https://open.spotify.com/track/4XdaaDFE881SlIaz31pTAG"
}
data "spotify_track" "blackwater" {
  spotify_id = "4lE6N1E0L8CssgKEUCgdbA"
}

data "spotify_search_track" "search" {
  name   = "Somebody Told Me"
  artist = "The Killers"
  album  = "Hot Fuss"
}

output "test" {
  value = data.spotify_search_track.search.tracks
}

Installation

Add the following to your terraform configuration

terraform {
  required_providers {
    spotify = {
      source  = "conradludgate/spotify"
      version = "~> 0.2.0"
    }
  }
}

How to use

First, you need an instance of a spotify oauth2 server running. This acts as a middleware between terraform and spotify to allow easy access to access tokens.

Public proxy

For a simple way to manage your spotify oauth2 tokens is to use https://oauth2.conrad.cafe. (source code)

Register a new account, create a spotify token with the following scopes

  • user-read-email
  • user-read-private
  • playlist-read-private
  • playlist-modify-private
  • playlist-modify-public
  • user-library-read
  • user-library-modify

Then take note of the token id in the URL and the API key that is shown on the page

Configure the terraform provider like so

provider "spotify" {
  auth_server = "https://oauth2.conrad.cafe"
  api_key     = var.spotify_api_key
  username    = "your username"
  token_id    = "your token id"
}

variable "spotify_api_key" {
  type = string
}

Self hosted

If you want a bit more control over your tokens, you can self host a simple instance of the oauth2 proxy designed specifically for this terraform provider

See spotify_auth_proxy to get started.

Once you have the server running, make note of the API Key it gives you.

Configure the terraform provider like so

variable "spotify_api_key" {
  type = string
}

provider "spotify" {
  api_key = var.spotify_api_key
}

terraform-provider-spotify's People

Contributors

conradludgate avatar tdeknecht avatar karl-cardenas-coding avatar topfunky avatar im2nguyen avatar sirhc avatar jfryy avatar prozsolt avatar

Watchers

James Cloos 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.