Terraform module: Fastly with S3 backend

Levent Yalcin
LevOps
Published in
2 min readJul 6, 2017

I don’t know what’s wrong me today but I can’t put into words what I have in my mind. So, I’ll try to write down a quick post.

To me, Fastly is the CDN solution. You don’t need to wait for hours and hours your configuration change has been deployed and activated across POPs. Same with purging objects from cache. You can group your cached content by Surrogate Keys and purge them with a single API call. All these are happening in seconds.

On the other hand, you don’t need to lock-in yourself to a solution you never used before by signing a contract for a year or more, or you don’t need to wait for someone comes up with a contract and the other sets up your account and the configuration. All you need to do is visiting their website, create an account and start to use the service immediately.

For all these, Fastly fits into definition of the “Cloud Service”.

As I tended to have all the infrastructure as code, I provision Fastly services by Terraform. Actually, there is that open source project from GDS but never used it before.

I’m not sure what else I could do, but, at least, I thought it is a good idea to share the Terraform module I’m using for provisioning a Fastly service with an S3 backend.

What module does is;

  • Creates a bucket with website hosting option enabled and a policy which only allows connections from Fastly POPs and given whitelist CIDR(s).
  • You can either use your own custom VCL or the default one.
  • Cleans up Amazon’s response headers unless Fastly-Debug header is set to 1
  • You can choose if you’d like force connections to use TLS.
  • You also have control over gzip settings and bucket versioning.

Please check the repository and the README file if you’d like use; https://github.com/opsgang/terraform_s3_hosting_fastly/

--

--

Levent Yalcin
LevOps
Editor for

DevOps, Cyclist, tea consumer, coffee lover, good experience with accidents and injuries