{"id":22878132,"url":"https://github.com/sporestudio/terraform-spotify","last_synced_at":"2025-03-31T14:18:43.708Z","repository":{"id":255360701,"uuid":"846139934","full_name":"sporestudio/terraform-spotify","owner":"sporestudio","description":"A Spotify Playlist made with Terraform.","archived":false,"fork":false,"pushed_at":"2024-08-29T13:43:44.000Z","size":1036,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-06T20:25:33.496Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sporestudio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-22T15:56:07.000Z","updated_at":"2024-08-29T13:43:48.000Z","dependencies_parsed_at":"2024-08-29T14:44:05.016Z","dependency_job_id":null,"html_url":"https://github.com/sporestudio/terraform-spotify","commit_stats":null,"previous_names":["sporestudio/terraform-spotify"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fterraform-spotify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fterraform-spotify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fterraform-spotify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sporestudio%2Fterraform-spotify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sporestudio","download_url":"https://codeload.github.com/sporestudio/terraform-spotify/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246481005,"owners_count":20784458,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-13T16:18:38.017Z","updated_at":"2025-03-31T14:18:43.688Z","avatar_url":"https://github.com/sporestudio.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Create a Spotify Playlist with Terraform\nI used Terraform data source to search Spotify tracks and use that data to build a playlist.\n\n## Prerequisites\nYou will need:\n\n- **Terraform:** version 1.0+\n- **Docker**\n- **Spotify account with developer access**\n\n\n## Create Spotify developer app\nBefore you can use Terraform with Spotify, you need to create a Spotify developer app.\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"assets/images/spotify-dashboard.png\" alt=\"Spotify Dashboard\" /\u003e\n\u003c/div\u003e\n\n\nClick on Create App and Fill out the name and the description according to your needs.\n\nOnce Spotify creates the app click on *Edit Settings*.\n\nCopy the URI below into the *Redirect URI* field and click Add so that Spotify can find its authorization app on port 27228 at the correct path\n\n\n```sh\nhttp://localhost:27228/spotify_callback\n```\n\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"assets/images/redirect-uri.png\" alt=\"Redirect URI\" /\u003e\n\u003c/div\u003e\n\n\n## Run authorization server\nNow that oyu created the Spotify app, we have to configure and start the athorization server proxy, which allows Terraform to interact with Spotify.\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"assets/images/proxy.png\" alt=\"Athorization sever\" /\u003e\n\u003c/div\u003e\n\nIn you terminal, you will need to set the redirect URI as an eviroment variable:\n\n```sh\n$ export SPOTIFY_CLIENT_REDIRECT_URI=http://localhost:27228/spotify_callback\n```\n\nThen we need to create the .env with the following contents to store your Spotify application's client ID and secret. You can find your credentials in the playlist's settings in your spotify developer account.\n\n```sh\nSPOTIFY_CLIENT_ID=\nSPOTIFY_CLIENT_SECRET=\n```\n\nMake sure that you have Docker running, you can check it (if your distro have systemd service) with:\n\n```sh\n$ sudo systemctl status docker\n```\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"assets/images/docker-status.png\" alt=\"docker-status\" /\u003e\n\u003c/div\u003e\n\nIn the sad case that you are using Windows, I guess you will have to make sure that Docker Desktop is running.\n\n\nThen you need to run the container:\n\n```sh\n$ docker run --rm -it -p 27228:27228 --env-file ./.env ghcr.io/conradludgate/spotify-auth-proxy\n```\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"assets/images/docker-run3.png\" alt=\"docker-run\" /\u003e\n\u003c/div\u003e\n\nVisit the AUTH url link and the server will redirect you to Spotify to autheticate. After authenticate, teh server will display **Authorization successful**, indicating that the Terraform provider can use the server.\n\nWe have to leave the server running.\n\n## Clone the repository\n\nThe next step is to clone the repository with the example configuration and then test and experiment with it.\n\n\n```sh\n$ git clone https://github.com/hashicorp/learn-terraform-spotify.git\n```\n\n## Configuration\n\nThe **main.tf** contains the Terraform configuration that searches Spotify and creates the playlist. \n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"assets/images/maintf.png\" alt=\"maintf\" /\u003e\n\u003c/div\u003e\n\nThe two first blocks configure Terraform itself and specify the community provider that Terraform uses to comunicate with Spotify and configure the Spotify provider with the key you set as a variable.\n\nThe resource block creates a playlist with the name and description provided and the track in the list with the *track id*.\n\n\u003e[!NOTE]\n\u003e This version of **main.tf** is a modified version by me, not the default version that you will see when you clone the repo for first time.\n\n## Set the API key\n\nWe have to rename the file **terraform.tfvars.example** to **terraform.tfvars** so that Terraform can detect the file.\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"assets/images/rename.png\" alt=\"rename-tfvars\" /\u003e\n\u003c/div\u003e\n\nThe **.gitignore** file in this repository excludes files with the **.tfvars** extension from version control to prevent you from accidentally committing your credentials.\n\n\u003e[!CAUTION]\n\u003e Never commit sensitive values to version control.\n\nYou will have to take the **APIKey** in the Spotify authorization proxy and replace the ... with it in the **terraform.tfvars**, so that Terraform can authenticate with Spotify.\n\n### Install the Spotify provider\n\nIn the terminal, we have to initialize Terraform, which will install the Spotify provider.\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"assets/images/terraform-init.png\" alt=\"terraform-init\" /\u003e\n\u003c/div\u003e\n\n## Create the playlist\n\nNow to create the playlist we have to apply our Terrform configuration. Terraform will show the changes and prompt for your approval.\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"assets/images/terraform-apply.png\" alt=\"terraform-apply\" /\u003e\n\u003c/div\u003e\n\n*In the image we can see how I already had the playlist made, and what I am doing is applying some changes.*\n\nNow we have our playlist in Spotify!\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"assets/images/playlist.png\" alt=\"playlist-image\" /\u003e\n\u003c/div\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsporestudio%2Fterraform-spotify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsporestudio%2Fterraform-spotify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsporestudio%2Fterraform-spotify/lists"}