An open API service indexing awesome lists of open source software.

https://github.com/nnichols/terraform-spotify

An example of Terraform's Spotify provider
https://github.com/nnichols/terraform-spotify

spotify terraform

Last synced: about 2 months ago
JSON representation

An example of Terraform's Spotify provider

Awesome Lists containing this project

README

        

# Terraform Spotify

An example of Terraform's Spotify provider, from [the Spotify tutorial.](https://learn.hashicorp.com/tutorials/terraform/spotify-playlist)
This repository was made as part of a promotional contest, which has since ended- therefore, this code is archived.

## Listen

The generated playlist is available on [Spotify.](https://open.spotify.com/playlist/5LZFjKNIaQ3yqTzc1V2hjS)

## Usage

First, load a fine named `.env` with a `SPOTIFY_CLIENT_ID` and a `SPOTIFY_CLIENT_SECRET`:

```txt
SPOTIFY_CLIENT_ID=some_long_secret
SPOTIFY_CLIENT_SECRET=dont_commit_me
```

These can be generated by creating a new app in the [Spotify Developer Dashboard](https://developer.spotify.com/dashboard/applications).

Prior to execution, run the Spotify Auth Proxy image:

```bash
docker run --rm -it -p 27228:27228 --env-file ./.env ghcr.io/conradludgate/spotify-auth-proxy
```

Follow the `Auth:` link to authorize Terraform against Spotify, and then copy the `APIKey` into a `terraform.tfvars` file:

```hcl
spotify_api_key = "SOME LONG SECRET KEY"
```

After that, apply the terraform and rock out.

```bash
$ terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions
are indicated with the following symbols:
+ create

Terraform will perform the following actions:

# spotify_playlist.playlist will be created
+ resource "spotify_playlist" "playlist" {
+ description = "This playlist is managed by Terraform via https://github.com/nnichols/terraform-spotify"
+ id = (known after apply)
+ name = "Songs to Terraform to"
+ public = true
+ snapshot_id = (known after apply)
+ tracks = [
+ "3VoIGEd6KW2whXqHQWCbWS",
+ "6B1PfbxffDXLyyDTBIE5cp",
+ "6P3eymlVtitV31GqV8usDO",
]
}

Plan: 1 to add, 0 to change, 0 to destroy.

Changes to Outputs:
+ playlist_url = (known after apply)

Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.

Enter a value: yes

spotify_playlist.playlist: Creating...
spotify_playlist.playlist: Creation complete after 1s [id=5LZFjKNIaQ3yqTzc1V2hjS]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

Outputs:

playlist_url = "https://open.spotify.com/playlist/5LZFjKNIaQ3yqTzc1V2hjS"
```