Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage Fastly service configuration via Terraform #2510

Closed
ewdurbin opened this issue Aug 21, 2024 · 2 comments
Closed

Manage Fastly service configuration via Terraform #2510

ewdurbin opened this issue Aug 21, 2024 · 2 comments
Assignees

Comments

@ewdurbin
Copy link
Member

Describe the solution you'd like

Our current Fastly configuration is managed manually. This isn't ideal.

PSF Infrastructure currently manages PyPI's suite of Fastly services with Terraform via https://github.com/pypi/infra, and peps.python.org via https://github.com/python/peps/tree/main/infra. I'd like to see us do the same for www.python.org.

We have options, either a new Fastly service built from scratch to match the current service, or a Terraform import of the existing service (to be clear I don't think that constructs a terraform config, just imports the state).

This will enable us to have better safety and visibility in changes to that portion of the infrastructure.

@humitos
Copy link

humitos commented Aug 22, 2024

Hi 👋🏼 -- I'm not really related to this project, but I'm taking the liberty to comment here with my experience on Terraform + Cloudflare for Read the Docs since I had to do similar work there and I think it could save you some time. You can just ignore it, tho 😄

or a Terraform import of the existing service (to be clear I don't think that constructs a terraform config, just imports the state).

Cloudflare has a cf-terraforming tool that helps you importing these configs. I suppose that Fastly could have something similar. It helped me with 50-70% of the job here. It's not perfect, but it saved me a good amount of time.

Apart from that, for the rest of the work that I had to do manually, I followed these steps for any resource:

  1. declare the resource I want to import almost empty, by only defining the required attributes
  2. use terraform import <resource> to import the state
  3. run terraform plan -target <resource> to see the diff between the empty resource and the one that's in production
  4. copy and paste that diff output into the resource code and adapt it from there
  5. run terraform plan -target <resource> until there are no diff anymore 😄

Depending on the resource itself, it could be a pretty tedious work or super simple. Good luck 😸

@JacobCoffee
Copy link
Member

This was helpful, @humitos - thanks! :)

Completed in #2519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants