Terraform Provider for Spotify
github.com
github.com
The repo uses a middleware server. I'm wondering what other approaches there are.
I wanted to try and get the terraform provider to handle the oauth flow but it's tricky because of the way terraform providers run
The example directive "spotify_search_track" runs a server-side search on Spotify and returns a list of results, which you can use to populate a playlist.
This is like … very cool, but also isn't it a little against the spirit of immutable infrastructure? Every time Spotify re-ranks their search results my terraform apply will populate different songs into my playlist, without anything changing in my main.tf in source control.
Very common scenario with lots of neat use cases around it. One of the more interesting ones - use a GitHub pull request listing data source to create an ephemeral environment for each PR.
Disclaimer: Software Engineer at Spacelift
https://open.spotify.com/playlist/6NO3v396w2tZc6MnXSKNPM
https://github.com/mherdeg/learn-terraform-spotify/blob/main...
For example - get AWS AMI where we can pin it or let it be latest.
> the spirit of immutable infrastructure
Immutable means changes recreate the resources. Not that that there won't be any changes. Mutable infra is where we keep patching the same resource and potentially end up in a state where we are not able to recreate it.
I could see one combining these into a nice evening.
> This is not a joke provider. Or, it kind of is a joke, but even though it's a joke it will still order you a pizza. You are going to get a pizza. You should be careful with this provider, if you don't want a pizza.
[0]: https://github.com/nat-henderson/terraform-provider-dominos/...
You can see an example of it here: https://open.spotify.com/playlist/1z3LtkicovnnGJ6hdcrzSi?si=...
Code is here: https://github.com/ecliptik/minidisc-playlist
This was originally part of "Build Your Summer Playlist" [1] promo Hashicorp ran last summer, which they still have yet to announce winners...
1. https://www.hashicorp.com/blog/build-your-summer-spotify-pla...
I wonder if there is a provider implemented for Deezer..
Does anyone have any interesting hacks / improvements to vanilla Spotify experience? Some must-have apps or such?
This one doesn’t seem to do anything in particular a Spotify app couldn’t do
2) the way you advertise your app and ask for feedback is welcoming. It feels honest.
I think the initial version took me a week?
I've made a service that scratches my own itch of wanting a way to sort a collection of playlists by the last time they were updated. I've got that running here, and I use it often.
Should work multiple times, just click „don’t add“ when it asks you if you want to add duplicate tracks.
Despite the incorrect labelling "Saving a spotify track" means liking it, not "downloading to your device". So you can add it to another Spotify playlist.
To get historical likes, cmd-a / ctrl-a (or equivalent) all Liked Songs tracks and drag them into the backup playlist.
Music apps like Spotify and Apple Music are about whimsical, serendipitous discovery independent of rational thought. At least, for me, anyway.
The two are wholly incompatible. I'm shocked that this exists. It calls into question how I think of music streaming platforms, what I think they provide, and how I interact with them.
It's basically an annoying version of curl that has a DAG that you can't even make good use of. I wouldn't call it whimsical, but getting anything to work in Terraform consistently definitely requires serendipity.
what do you mean by this? 'terraform apply' runs plan first, and tells me the diff from the expected state. Then it asks me if I want to reconcile it.
I agree with the rest tho
#!/bin/sh
curl -d '{"some key": "value here"}' -H "X-Some-Header: Foo-Bar" https://some-aws-domain/some/rest/api
Put that in Git; now you have Infrastructure as Code. IaC is not some holy scepter ordained to us by God. It's literally just a version-controlled list of commands that call SaaS APIs. It's not special or magical. And Terraform doesn't do it any better than a bunch of curls in a shell script.The only reason to use Terraform is it's a standard way for a large group of people to make changes to the same thing. But if an entire team standardized on a shell script full of curls, that would work just as well. (Better, actually, because you could actually have error handling, auto-healing, importing existing resources, checking if they exist before trying to apply changes... you know, things that are useful for IaC that Terraform does not do)
The Terraform provider isn't from Spotify. Some dude made it. Spotify offers an API that can be used for any integrations people come up with.
No. Terraform is for manipulating state on the other side of an API, including orchestrating the state behind multiple different APIs such that those APIs will be "harmonious" for your use case.
> Music apps like Spotify and Apple Music are about whimsical, serendipitous discovery independent of rational thought. At least, for me, anyway. The two are wholly incompatible.
I beg to differ. If something changes, Terraform makes those changes visible to you, because it keeps notes on what it thought the state was on the other side of the API. For the right use case, being notified of those changes, and possibly deciding to do something else instead, is important.
It’s not as reductive as that. Terraform can give you a consistent configuration experience. What exactly that configuration does is heavily context and provider dependent. As commenters elsewhere have pointed out there’s an especially common use case with pinning to an AWS AMI that meets a certain criteria. New AMI gets published and next time you apply it’ll get the new AMI. That’s not idempotent.
Similarly, this Spotify flow would let implement something like a playlist that was dynamic, but refreshed only on your terms. The plan phase of a run would let you assess any playlist changes, if they’re an improvement you can apply. If you don’t like the change you abandon it and leave things as they are. A provider for a different stream service starts to unlock the potential for playlist portability. It doesn’t magically happen. But if you were managing all your playlists this way it would significantly reduce the effort to switch platforms.
I have been considering swapping some python scripts over to terraform but I'm concerned about the time it will take to learn Go and Terraform.
Anyone got some perspective on that?
Why do you think you need to write your own provider? Most people use the large ecosystem of prebuilt providers, and never write a single line of code
They push out a mobile app update every week with either no changes, or changes to things I don't care about. They removed push-to-preview. They refuse to add custom song start and end times. They focus incessantly on podcasts. Their playlist management is a joke. They get the most embarrassing things wrong, like failing to understand that two artists with the same name are not the same artist, or that a song in my Discover Weekly is just a re-release of a song already in my library. Until recently, their random shuffle kept getting stuck in a loop of ~100 songs. There is no modification history, so if I accidentally remove a song from a playlist or my library, I get a snackbar saying "Removed from library" but it won't tell me what, and there's no way to find out. Their song queue system is utterly anemic. The "Home" button also serves as a kind of pseudo "back button" but with no obvious rules to understand exactly how navigation is going to occur.
The fact that so many third party Spotify integrations exists, each tackling a different deficiency in the Spotify app itself speaks volumes about what Spotify's priorities are. Spotify is lucky that their library is massive and that their recommendations are good (for me anyway. My friend and my mother separately have had astoundingly awful experiences with the recommendation system despite years of trying), or there's be no love lost in moving elsewhere.
A lot of people like just managing playlists with a simple graphical console.
This works fine if you just want a playlist now, but you risk things like forgetting why the songs were added to a playlist; or forgetting which songs were in a playlist if the playlist accidentally got deleted.
Sure, describing it with Terraform may be more effort up front, but it saves effort in the long run.
I wanted to add a way for it to get the song names in there, but I never got around to it
- George Bernard Shaw