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
- Host: GitHub
- URL: https://github.com/nnichols/terraform-spotify
- Owner: nnichols
- Archived: true
- Created: 2021-07-16T13:14:51.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2025-01-03T22:11:17.000Z (5 months ago)
- Last Synced: 2025-02-28T23:57:48.442Z (4 months ago)
- Topics: spotify, terraform
- Language: HCL
- Homepage: https://open.spotify.com/playlist/5LZFjKNIaQ3yqTzc1V2hjS?si=34f30f5643884769
- Size: 20.5 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
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 applyTerraform used the selected providers to generate the following execution plan. Resource actions
are indicated with the following symbols:
+ createTerraform 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"
```